Class: Source::CompositeFilesProvider
- Inherits:
-
FilesProvider
- Object
- FilesProvider
- Source::CompositeFilesProvider
- Defined in:
- lib/gpm/source/files_providers/composite_files_provider.rb
Instance Method Summary collapse
- #file_contents ⇒ Object
-
#initialize(*file_providers) ⇒ CompositeFilesProvider
constructor
A new instance of CompositeFilesProvider.
Methods inherited from FilesProvider
Constructor Details
#initialize(*file_providers) ⇒ CompositeFilesProvider
Returns a new instance of CompositeFilesProvider.
3 4 5 |
# File 'lib/gpm/source/files_providers/composite_files_provider.rb', line 3 def initialize(*file_providers) @file_providers = file_providers end |
Instance Method Details
#file_contents ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/gpm/source/files_providers/composite_files_provider.rb', line 7 def file_contents @file_providers.inject({}) do |merged, file_provider| contents = file_provider.file_contents same_files_with_different_content = (merged.keys & contents.keys).find_all {|f| merged[f] != contents[f]} raise "duplicate filenames with different content found in different file providers: #{same_files_with_different_content}" unless same_files_with_different_content.empty? merged.merge contents end end |