module Sprockets::Paths
Public Instance Methods
Append a ‘path` to the `paths` list.
Paths
at the beginning of the ‘Array` have a higher priority.
# File lib/sprockets/paths.rb, line 47 def append_path(path) self.config = hash_reassoc(config, :paths) do |paths| path = File.expand_path(path, config[:root]).freeze paths.push(path) end end
Clear all paths and start fresh.
There is no mechanism for reordering paths, so its best to completely wipe the paths list and reappend them in the order you want.
# File lib/sprockets/paths.rb, line 59 def clear_paths self.config = hash_reassoc(config, :paths) do |paths| paths.clear end end
Public: Iterate over every file under all load paths.
Returns Enumerator if no block is given.
# File lib/sprockets/paths.rb, line 68 def each_file return to_enum(__method__) unless block_given? paths.each do |root| stat_tree(root).each do |filename, stat| if stat.file? yield filename end end end nil end
Returns an ‘Array` of path `String`s.
These paths will be used for asset logical path lookups.
# File lib/sprockets/paths.rb, line 30 def paths config[:paths] end
Prepend a ‘path` to the `paths` list.
Paths
at the end of the ‘Array` have the least priority.
# File lib/sprockets/paths.rb, line 37 def prepend_path(path) self.config = hash_reassoc(config, :paths) do |paths| path = File.expand_path(path, config[:root]).freeze paths.unshift(path) end end
Returns ‘Environment` root.
All relative paths are expanded with root as its base. To be useful set this to your applications root directory. (‘Rails.root`)
# File lib/sprockets/paths.rb, line 13 def root config[:root] end
Private Instance Methods
Internal: Change Environment
root.
Only the initializer should change the root.
# File lib/sprockets/paths.rb, line 20 def root=(path) self.config = hash_reassoc(config, :root) do File.expand_path(path) end end