Module: Sprockets::Paths
Constant Summary
Constants included from PathUtils
Sprockets::PathUtils::SEPARATOR_PATTERN
Constants included from Utils
Utils::UNBOUND_METHODS_BIND_TO_ANY_OBJECT
Instance Method Summary collapse
-
#append_path(path) ⇒ Object
Append a ‘path` to the `paths` list.
-
#clear_paths ⇒ Object
Clear all paths and start fresh.
-
#each_file ⇒ Object
Public: Iterate over every file under all load paths.
-
#paths ⇒ Object
Returns an ‘Array` of path `String`s.
-
#prepend_path(path) ⇒ Object
Prepend a ‘path` to the `paths` list.
-
#root ⇒ Object
Returns ‘Environment` root.
Methods included from PathUtils
#absolute_path?, #atomic_write, #directory?, #entries, #file?, #find_upwards, #match_path_extname, #path_extnames, #path_parents, #paths_split, #relative_path?, #split_subpath, #stat, #stat_directory, #stat_sorted_tree, #stat_tree
Methods included from Utils
#concat_javascript_sources, #dfs, #dfs_paths, #duplicable?, #hash_reassoc, #hash_reassoc1, #module_include, #normalize_extension, #string_end_with_semicolon?
Instance Method Details
#append_path(path) ⇒ Object
Append a ‘path` to the `paths` list.
Paths at the beginning of the ‘Array` have a higher priority.
46 47 48 49 50 51 |
# File 'lib/sprockets/paths.rb', line 46 def append_path(path) self.config = hash_reassoc(config, :paths) do |paths| path = File.(path, config[:root]).freeze paths.push(path) end end |
#clear_paths ⇒ Object
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.
58 59 60 61 62 |
# File 'lib/sprockets/paths.rb', line 58 def clear_paths self.config = hash_reassoc(config, :paths) do |paths| paths.clear end end |
#each_file ⇒ Object
Public: Iterate over every file under all load paths.
Returns Enumerator if no block is given.
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/sprockets/paths.rb', line 67 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 |
#paths ⇒ Object
Returns an ‘Array` of path `String`s.
These paths will be used for asset logical path lookups.
29 30 31 |
# File 'lib/sprockets/paths.rb', line 29 def paths config[:paths] end |
#prepend_path(path) ⇒ Object
Prepend a ‘path` to the `paths` list.
Paths at the end of the ‘Array` have the least priority.
36 37 38 39 40 41 |
# File 'lib/sprockets/paths.rb', line 36 def prepend_path(path) self.config = hash_reassoc(config, :paths) do |paths| path = File.(path, config[:root]).freeze paths.unshift(path) end end |
#root ⇒ Object
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`)
12 13 14 |
# File 'lib/sprockets/paths.rb', line 12 def root config[:root] end |