Method: Munge::Core::Source#initialize

Defined in:
lib/munge/core/source.rb

#initialize(source_abspath, binary_extensions = []) ⇒ Source

Returns a new instance of Source.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/munge/core/source.rb', line 8

def initialize(source_abspath, binary_extensions = [])
  item_factory = ItemFactory.new(source_abspath, binary_extensions)
  pattern      = File.join(source_abspath, "**", "*")

  @items =
    Dir.glob(pattern)
      .reject { |item_path| File.directory?(item_path) }
      .map    { |item_path| item_factory.create(item_path) }
      .map    { |item| [item.id, item] }
      .to_h
end