Module: Sparrowhawk::FileEntryMapper

Includes:
Enumerable
Included in:
ApplicationFilesMapper, PublicDirMapper
Defined in:
lib/sparrowhawk/file_entry_mapper.rb

Instance Method Summary collapse

Instance Method Details

#eachObject


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

Returns:

  • (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_patternsObject


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 expand_path file_name
  File.expand_path file_name
end

#file_entry_tuplesObject


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), expand_path(f)]
  end
end