Module: StaticPaths::Finders
- Includes:
- Enumerable
- Defined in:
- lib/static_paths/finders.rb
Instance Method Summary
- - (Array<String>) all_static_dirs(path) Finds all occurrences of a given directory path, within all static directories.
- - (Array<String>) all_static_files(path) Finds all occurrences of a given file path, within all static directories.
- - (Array<String>) all_static_paths(path) Finds all occurrences of a given path, within all static directories.
- - (Array<String>) each_static_dir(path, &block) {|static_dir| ... } Finds all occurrences of a given directory path, within all static directories.
- - (Array<String>) each_static_file(path, &block) {|static_file| ... } Finds all occurrences of a given file path, within all static directories.
- - (Object) each_static_path(path, &block) {|potential_path| ... } Passes all existing static paths for the specified path, within the static directories, to the given block.
- - (String?) find_static_dir(path) Searches for a directory at the given path, within any static directory.
- - (String?) find_static_file(path) Searches for a file at the given path, within any static directory.
- - (String?) find_static_path(path) Searches for the given path within any static directory.
- - (Array<String>) static_glob(pattern) Finds all paths that match a given pattern, within all static directories.
Instance Method Details
- (Array<String>) all_static_dirs(path)
Finds all occurrences of a given directory path, within all static directories.
170 171 172 |
# File 'lib/static_paths/finders.rb', line 170 def all_static_dirs(path) Enumerator.new(self,:each_static_dir,path).to_a end |
- (Array<String>) all_static_files(path)
Finds all occurrences of a given file path, within all static directories.
132 133 134 |
# File 'lib/static_paths/finders.rb', line 132 def all_static_files(path) Enumerator.new(self,:each_static_file,path).to_a end |
- (Array<String>) all_static_paths(path)
Finds all occurrences of a given path, within all static directories.
93 94 95 |
# File 'lib/static_paths/finders.rb', line 93 def all_static_paths(path) Enumerator.new(self,:each_static_path,path).to_a end |
- (Array<String>) each_static_dir(path, &block) {|static_dir| ... }
Finds all occurrences of a given directory path, within all static directories.
153 154 155 156 157 |
# File 'lib/static_paths/finders.rb', line 153 def each_static_dir(path,&block) each_static_path(path) do |full_path| block.call(full_path) if File.directory?(full_path) end end |
- (Array<String>) each_static_file(path, &block) {|static_file| ... }
Finds all occurrences of a given file path, within all static directories.
114 115 116 117 118 |
# File 'lib/static_paths/finders.rb', line 114 def each_static_file(path,&block) each_static_path(path) do |full_path| block.call(full_path) if File.file?(full_path) end end |
- (Object) each_static_path(path, &block) {|potential_path| ... }
Passes all existing static paths for the specified path, within the static directories, to the given block.
21 22 23 24 25 26 27 |
# File 'lib/static_paths/finders.rb', line 21 def each_static_path(path,&block) StaticPaths.paths.each do |dir| full_path = File.join(dir,path) block.call(full_path) if File.exists?(full_path) end end |
- (String?) find_static_dir(path)
Searches for a directory at the given path, within any static directory.
75 76 77 78 79 80 81 |
# File 'lib/static_paths/finders.rb', line 75 def find_static_dir(path) each_static_path(path) do |full_path| return full_path if File.directory?(full_path) end return nil end |
- (String?) find_static_file(path)
Searches for a file at the given path, within any static directory.
55 56 57 58 59 60 61 |
# File 'lib/static_paths/finders.rb', line 55 def find_static_file(path) each_static_path(path) do |full_path| return full_path if File.file?(full_path) end return nil end |
- (String?) find_static_path(path)
Searches for the given path within any static directory.
40 41 42 |
# File 'lib/static_paths/finders.rb', line 40 def find_static_path(path) Enumerator.new(self,:each_static_path,path).first end |
- (Array<String>) static_glob(pattern)
Finds all paths that match a given pattern, within all static directories.
184 185 186 187 188 189 190 191 192 |
# File 'lib/static_paths/finders.rb', line 184 def static_glob(pattern) paths = [] StaticPaths.paths.each do |path| paths += Dir[File.join(path,pattern)] end return paths end |