Class: Bibliothecary::MultiParsers::DependenciesCSV

Inherits:
Object
  • Object
show all
Extended by:
Analyser::TryCache
Includes:
Analyser
Defined in:
lib/bibliothecary/multi_parsers/dependencies_csv.rb

Defined Under Namespace

Classes: CSVFile

Class Method Summary collapse

Methods included from Analyser::TryCache

try_cache

Methods included from Analyser

create_analysis, create_error_analysis, included

Class Method Details

.mappingObject



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

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

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



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/bibliothecary/multi_parsers/dependencies_csv.rb', line 139

def self.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

  dependencies = csv_file
    .result
    .map do |dep_kvs|
      Dependency.new(
        **dep_kvs, source: options.fetch(:filename, nil)
      )
    end

  ParserResult.new(dependencies: dependencies)
end

.platform_nameObject



21
22
23
# File 'lib/bibliothecary/multi_parsers/dependencies_csv.rb', line 21

def self.platform_name
  raise "DependenciesCSV is a multi-parser and does not have a platform name."
end