Class: Bibliothecary::Parsers::Dub
- Inherits:
-
Object
- Object
- Bibliothecary::Parsers::Dub
- Includes:
- Analyser
- Defined in:
- lib/bibliothecary/parsers/dub.rb
Class Method Summary collapse
- .map_dependencies(hash, key, type) ⇒ Object
- .parse(filename, path) ⇒ Object
- .parse_manifest(manifest) ⇒ Object
- .parse_sdl_manifest(manifest) ⇒ Object
Methods included from Analyser
Class Method Details
.map_dependencies(hash, key, type) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/bibliothecary/parsers/dub.rb', line 30 def self.map_dependencies(hash, key, type) hash.fetch(key,[]).map do |name, requirement| { name: name, requirement: requirement, type: type } end end |
.parse(filename, path) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/bibliothecary/parsers/dub.rb', line 9 def self.parse(filename, path) if filename.match(/^dub\.json$/) file_contents = File.open(path).read json = JSON.parse(file_contents) parse_manifest(json) elsif filename.match(/^dub\.sdl$/) file_contents = File.open(path).read parse_sdl_manifest(file_contents) else [] end end |
.parse_manifest(manifest) ⇒ Object
22 23 24 |
# File 'lib/bibliothecary/parsers/dub.rb', line 22 def self.parse_manifest(manifest) map_dependencies(manifest, 'dependencies', 'runtime') end |
.parse_sdl_manifest(manifest) ⇒ Object
26 27 28 |
# File 'lib/bibliothecary/parsers/dub.rb', line 26 def self.parse_sdl_manifest(manifest) SdlParser.new(:runtime, manifest).dependencies end |