Parent

Methods

Class/Module Index [+]

Quicksearch

Webgen::Source::FileSystem

This class is used to read source paths from a directory in the file system.

Attributes

glob[R]

The glob (see Dir.glob for details) that is used to specify which paths under the root path should be returned by paths.

root[R]

The root path from which paths read.

Public Class Methods

new(root, glob = '**/*') click to toggle source

Create a new file system source for the root path root using the provided glob.

# File lib/webgen/source/filesystem.rb, line 38
def initialize(root, glob = '**/*')
  if root =~ /^([a-zA-Z]:|\/)/
    @root = root
  else
    @root = File.join(WebsiteAccess.website.directory, root)
  end
  @glob = glob
end

Public Instance Methods

paths() click to toggle source

Return all paths under root which match glob.

# File lib/webgen/source/filesystem.rb, line 48
def paths
  @paths ||= Dir.glob(File.join(@root, @glob), File::FNM_DOTMATCH|File::FNM_CASEFOLD).to_set.collect do |f|
    next unless File.exists?(f) # handle invalid links
    temp = Pathname.new(f.sub(/^#{Regexp.escape(@root)}\/?/, '/')).cleanpath.to_s
    temp += '/' if File.directory?(f) && temp[-1] != //
    path = Path.new(temp, f)
    path
  end.compact
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.