This class is used to read source paths from a directory in the file system.
The glob (see Dir.glob for details) that is used to specify which paths under the root path should be returned by paths.
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
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
Generated with the Darkfish Rdoc Generator 2.