Module: Sparrowhawk::FileEntryMapper
- Includes:
- Enumerable
- Included in:
- ApplicationFilesMapper, PublicDirMapper
- Defined in:
- lib/sparrowhawk/file_entry_mapper.rb
Instance Method Summary collapse
- #each ⇒ Object
- #excluded?(file_path) ⇒ Boolean
- #excluded_path_patterns ⇒ Object
- #expand_path(file_name) ⇒ Object
- #file_entry_tuples ⇒ Object
Instance Method Details
#each ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/sparrowhawk/file_entry_mapper.rb', line 5 def each file_entry_tuples.each do |entry_name, file_path| next if File.directory? file_path next if excluded? file_path yield FileEntry.new entry_name, file_path end end |
#excluded?(file_path) ⇒ Boolean
23 24 25 |
# File 'lib/sparrowhawk/file_entry_mapper.rb', line 23 def excluded? file_path excluded_path_patterns.any? { |pattern| pattern =~ file_path } end |
#excluded_path_patterns ⇒ Object
27 28 29 |
# File 'lib/sparrowhawk/file_entry_mapper.rb', line 27 def excluded_path_patterns @excluded_path_patterns ||= [] end |
#expand_path(file_name) ⇒ Object
19 20 21 |
# File 'lib/sparrowhawk/file_entry_mapper.rb', line 19 def file_name File. file_name end |
#file_entry_tuples ⇒ Object
13 14 15 16 17 |
# File 'lib/sparrowhawk/file_entry_mapper.rb', line 13 def file_entry_tuples Dir.glob(file_pattern).uniq.map do |f| [entry_name(f), (f)] end end |