Class: Bibliothecary::Parsers::CPAN

Inherits:
Object
  • Object
show all
Includes:
Analyser
Defined in:
lib/bibliothecary/parsers/cpan.rb

Class Method Summary collapse

Methods included from Analyser

create_analysis, create_error_analysis, included

Class Method Details

.mappingObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/bibliothecary/parsers/cpan.rb', line 11

def self.mapping
  {
    match_filename("META.json", case_insensitive: true) => {
      kind: "manifest",
      parser: :parse_json_manifest,
    },
    match_filename("META.yml", case_insensitive: true) => {
      kind: "manifest",
      parser: :parse_yaml_manifest,
    },
  }
end

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



26
27
28
29
30
31
# File 'lib/bibliothecary/parsers/cpan.rb', line 26

def self.parse_json_manifest(file_contents, options: {})
  manifest = JSON.parse file_contents
  manifest["prereqs"].map do |_group, deps|
    map_dependencies(deps, "requires", "runtime", options.fetch(:filename, nil))
  end.flatten
end

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



33
34
35
36
# File 'lib/bibliothecary/parsers/cpan.rb', line 33

def self.parse_yaml_manifest(file_contents, options: {})
  manifest = YAML.load file_contents
  map_dependencies(manifest, "requires", "runtime", options.fetch(:filename, nil))
end