Class: Bibliothecary::Parsers::Dub

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

Class Method Summary collapse

Methods included from Analyser

included

Class Method Details

.map_dependencies(hash, key, type) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/bibliothecary/parsers/dub.rb', line 31

def self.map_dependencies(hash, key, type)
  hash.fetch(key,[]).map do |name, requirement|
    {
      name: name,
      requirement: requirement,
      type: type
    }
  end
end

.mappingObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/bibliothecary/parsers/dub.rb', line 9

def self.mapping
  {
    /^dub\.json$/ => {
      kind: 'manifest',
      parser: :parse_manifest
    },
    /^dub\.sdl$/ => {
      kind: 'manifest',
      parser: :parse_sdl_manifest
    }
  }
end

.parse_manifest(file_contents) ⇒ Object



22
23
24
25
# File 'lib/bibliothecary/parsers/dub.rb', line 22

def self.parse_manifest(file_contents)
  manifest = JSON.parse(file_contents)
  map_dependencies(manifest, 'dependencies', 'runtime')
end

.parse_sdl_manifest(manifest) ⇒ Object



27
28
29
# File 'lib/bibliothecary/parsers/dub.rb', line 27

def self.parse_sdl_manifest(manifest)
  SdlParser.new(:runtime, manifest).dependencies
end