Module: Sprockets::Paths
Constant Summary
Constants included from PathUtils
Sprockets::PathUtils::SEPARATOR_PATTERN
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_matching_path_for_extensions, #find_upwards, #join, #match_path_extname, #path_extnames, #path_parents, #paths_split, #relative_path?, #relative_path_from, #set_pipeline, #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, #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.
47 48 49 50 51 52 |
# File 'lib/sprockets/paths.rb', line 47 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.
59 60 61 62 63 |
# File 'lib/sprockets/paths.rb', line 59 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.
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# 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 |
#paths ⇒ Object
Returns an ‘Array` of path `String`s.
These paths will be used for asset logical path lookups.
30 31 32 |
# File 'lib/sprockets/paths.rb', line 30 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.
37 38 39 40 41 42 |
# File 'lib/sprockets/paths.rb', line 37 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`)
13 14 15 |
# File 'lib/sprockets/paths.rb', line 13 def root config[:root] end |