Class: Bibliothecary::Runner::MultiManifestFilter
- Inherits:
-
Object
- Object
- Bibliothecary::Runner::MultiManifestFilter
- Defined in:
- lib/bibliothecary/runner/multi_manifest_filter.rb
Instance Method Summary collapse
-
#files_to_check ⇒ Object
Standalone multi manifest files should always be treated as lockfiles, since there’s no human-written manifest file to go with them.
-
#initialize(path:, related_files_info_entries:, runner:) ⇒ MultiManifestFilter
constructor
A new instance of MultiManifestFilter.
- #multiple_file_results ⇒ Object
- #no_lockfile_results ⇒ Object
- #partition_file_entries! ⇒ Object
- #results ⇒ Object
- #single_file_results ⇒ Object
Constructor Details
#initialize(path:, related_files_info_entries:, runner:) ⇒ MultiManifestFilter
Returns a new instance of MultiManifestFilter.
4 5 6 7 8 |
# File 'lib/bibliothecary/runner/multi_manifest_filter.rb', line 4 def initialize(path:, related_files_info_entries:, runner:) @path = path = @runner = runner end |
Instance Method Details
#files_to_check ⇒ Object
Standalone multi manifest files should always be treated as lockfiles, since there’s no human-written manifest file to go with them.
12 13 14 15 16 17 18 19 |
# File 'lib/bibliothecary/runner/multi_manifest_filter.rb', line 12 def files_to_check @files_to_check ||= .each_with_object({}) do |files_info, all| files_info.lockfiles.each do |file| all[file] ||= 0 all[file] += 1 end end end |
#multiple_file_results ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/bibliothecary/runner/multi_manifest_filter.rb', line 37 def multiple_file_results return @multiple_file_results if @multiple_file_results @multiple_file_results = [] @multiple_file_entries.each do |file| analysis = @runner.analyse_file(file, File.read(File.join(@path, file))) rfis_for_file = .find_all { |rfi| rfi.lockfiles.include?(file) } rfis_for_file.each do |rfi| file_analysis = analysis.find { |a| a[:platform] == rfi.platform } next unless file_analysis next if file_analysis[:dependencies].empty? @multiple_file_results << rfi end end @multiple_file_results end |
#no_lockfile_results ⇒ Object
27 28 29 |
# File 'lib/bibliothecary/runner/multi_manifest_filter.rb', line 27 def no_lockfile_results @no_lockfile_results ||= .find_all { |rfi| rfi.lockfiles.empty? } end |
#partition_file_entries! ⇒ Object
58 59 60 61 62 63 |
# File 'lib/bibliothecary/runner/multi_manifest_filter.rb', line 58 def partition_file_entries! @single_file_entries, @multiple_file_entries = files_to_check.partition { |file, count| count == 1 } @single_file_entries = @single_file_entries.map(&:first) @multiple_file_entries = @multiple_file_entries.map(&:first) end |
#results ⇒ Object
21 22 23 24 25 |
# File 'lib/bibliothecary/runner/multi_manifest_filter.rb', line 21 def results partition_file_entries! (no_lockfile_results + single_file_results + multiple_file_results).uniq end |
#single_file_results ⇒ Object
31 32 33 34 35 |
# File 'lib/bibliothecary/runner/multi_manifest_filter.rb', line 31 def single_file_results @single_file_results ||= @single_file_entries.map do |file| .find { |rfi| rfi.lockfiles.include?(file) } end end |