instance method
load_path!
Ruby on Rails edge
Since edgeSignature
load_path!(= @load_path = true)
No documentation comment.
Parameters
-
= @load_path = truereq
Source
# File railties/lib/rails/paths.rb, line 174
def load_path! = @load_path = true
def skip_load_path! = @load_path = false
def load_path? = @load_path
def each(&block)
@paths.each(&block)
end
def <<(path)
@paths << path
end
alias :push :<<
def concat(paths)
@paths.concat paths
end
def unshift(*paths)
@paths.unshift(*paths)
end
def to_ary
@paths
end
def paths
raise "You need to set a path root" unless @root.path
map do |p|
Pathname.new(@root.path).join(p)
end
end
def extensions # :nodoc:
$1.split(",") if @glob =~ /\{([\S]+)\}/
end
# Expands all paths against the root and return all unique values.
def expanded
raise "You need to set a path root" unless @root.path
result = []
each do |path|
path = File.expand_path(path, @root.path)
if @glob && File.directory?(path)
result.concat files_in(path)
else
result << path
end
end
result.uniq!
result
end
# Returns all expanded paths but only if they exist in the filesystem.
def existent
expanded.select do |f|
does_exist = File.exist?(f)
if !does_exist && File.symlink?(f)
raise "File #{f.inspect} is a symlink that does not point to a valid file"
end
does_exist
end
end
def existent_directories
expanded.select { |d| File.directory?(d) }
end
def expanded_files
expanded.select { |file| !File.extname(file).empty? }
end
alias to_a expanded
private
def files_in(path)
files = Dir.glob(@glob, base: path, sort: false)
files -= @exclude if @exclude
files.map! { |file| File.join(path, file) }
files.sort
end
end
end
end
Defined in railties/lib/rails/paths.rb line 174
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Rails::Paths::Path