class Rails::Paths::Path
def <<(path)
def <<(path) @paths << path end
def absolute_current # :nodoc:
def absolute_current # :nodoc: File.expand_path(@current, @root.path) end
def children
def children keys = @root.keys.find_all { |k| k.start_with?(@current) && k != @current } @root.values_at(*keys.sort) end
def concat(paths)
def concat(paths) @paths.concat paths end
def each(&block)
def each(&block) @paths.each(&block) end
def existent
def existent expanded.select { |f| File.exist?(f) } end
def existent_directories
def existent_directories expanded.select { |d| File.directory?(d) } end
def expanded
def expanded raise "You need to set a path root" unless @root.path result = [] each do |p| path = File.expand_path(p, @root.path) if @glob && File.directory?(path) Dir.chdir(path) do result.concat(Dir.glob(@glob).map { |file| File.join path, file }.sort) end else result << path end end result.uniq! result end
def extensions # :nodoc:
def extensions # :nodoc: $1.split(',') if @glob =~ /\{([\S]+)\}/ end
def first
def first expanded.first end
def initialize(root, current, paths, options = {})
def initialize(root, current, paths, options = {}) @paths = paths @current = current @root = root @glob = options[:glob] options[:autoload_once] ? autoload_once! : skip_autoload_once! options[:eager_load] ? eager_load! : skip_eager_load! options[:autoload] ? autoload! : skip_autoload! options[:load_path] ? load_path! : skip_load_path! end
def last
def last expanded.last end
def to_ary
def to_ary @paths end
def unshift(*paths)
def unshift(*paths) @paths.unshift(*paths) end