Module: Bibliothecary::MultiParsers::DependenciesCSV

Includes:
Analyser, Analyser::TryCache
Defined in:
lib/bibliothecary/multi_parsers/dependencies_csv.rb

Defined Under Namespace

Classes: CSVFile

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Analyser::TryCache

#try_cache

Methods included from Analyser

create_analysis, create_error_analysis, included

Class Method Details

.mappingObject



9
10
11
12
13
14
15
16
17
# File 'lib/bibliothecary/multi_parsers/dependencies_csv.rb', line 9

def self.mapping
  {
    match_filename("dependencies.csv") => {
      kind: "lockfile",
      ungroupable: true,
      parser: :parse_dependencies_csv,
    },
  }
end

Instance Method Details

#parse_dependencies_csv(file_contents, options: {}) ⇒ Object



139
140
141
142
143
144
145
146
147
148
149
# File 'lib/bibliothecary/multi_parsers/dependencies_csv.rb', line 139

def parse_dependencies_csv(file_contents, options: {})
  csv_file = try_cache(options, options[:filename]) do
    raw_csv_file = CSVFile.new(file_contents)
    raw_csv_file.parse!
    raw_csv_file
  end

  csv_file.result.find_all do |dependency|
    dependency[:platform] == platform_name.to_s
  end
end