Class: Bibliothecary::Runner::MultiManifestFilter
- Inherits:
-
Object
- Object
- Bibliothecary::Runner::MultiManifestFilter
- Defined in:
- lib/bibliothecary/runner/multi_manifest_filter.rb
Defined Under Namespace
Classes: FileAnalysis
Instance Method Summary collapse
- #each_analysis_and_rfis ⇒ Object
-
#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.
19 20 21 22 23 |
# File 'lib/bibliothecary/runner/multi_manifest_filter.rb', line 19 def initialize(path:, related_files_info_entries:, runner:) @path = path @related_files_info_entries = @runner = runner end |
Instance Method Details
#each_analysis_and_rfis ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/bibliothecary/runner/multi_manifest_filter.rb', line 72 def each_analysis_and_rfis @multiple_file_entries.each do |file| contents = Bibliothecary.utf8_string(File.read(File.join(@path, file))) analysis = @runner.analyse_file(file, contents) rfis_for_file = @related_files_info_entries.find_all { |rfi| rfi.lockfiles.include?(file) } yield analysis, rfis_for_file end end |
#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.
27 28 29 30 31 32 33 34 |
# File 'lib/bibliothecary/runner/multi_manifest_filter.rb', line 27 def files_to_check @files_to_check ||= @related_files_info_entries.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
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/bibliothecary/runner/multi_manifest_filter.rb', line 52 def multiple_file_results return @multiple_file_results if @multiple_file_results @multiple_file_results = [] each_analysis_and_rfis do |analysis, rfis_for_file| rfis_for_file.each do |rfi| file_analysis = FileAnalysis.new( analysis.find { |a| a[:platform] == rfi.platform } ) next if file_analysis.skip? @multiple_file_results << rfi end end @multiple_file_results end |
#no_lockfile_results ⇒ Object
42 43 44 |
# File 'lib/bibliothecary/runner/multi_manifest_filter.rb', line 42 def no_lockfile_results @no_lockfile_results ||= @related_files_info_entries.find_all { |rfi| rfi.lockfiles.empty? } end |
#partition_file_entries! ⇒ Object
82 83 84 85 86 87 |
# File 'lib/bibliothecary/runner/multi_manifest_filter.rb', line 82 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
36 37 38 39 40 |
# File 'lib/bibliothecary/runner/multi_manifest_filter.rb', line 36 def results partition_file_entries! (no_lockfile_results + single_file_results + multiple_file_results).uniq end |
#single_file_results ⇒ Object
46 47 48 49 50 |
# File 'lib/bibliothecary/runner/multi_manifest_filter.rb', line 46 def single_file_results @single_file_results ||= @single_file_entries.map do |file| @related_files_info_entries.find { |rfi| rfi.lockfiles.include?(file) } end end |