Class: Bibliothecary::Parsers::Shard
- Inherits:
-
Object
- Object
- Bibliothecary::Parsers::Shard
- Includes:
- Analyser
- Defined in:
- lib/bibliothecary/parsers/shard.rb
Class Method Summary collapse
- .map_dependencies(hash, key, type) ⇒ Object
- .mapping ⇒ Object
- .parse_yaml_lockfile(file_contents) ⇒ Object
- .parse_yaml_manifest(file_contents) ⇒ Object
Methods included from Analyser
Class Method Details
.map_dependencies(hash, key, type) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/bibliothecary/parsers/shard.rb', line 32 def self.map_dependencies(hash, key, type) hash.fetch(key,[]).map do |name, requirement| { name: name, requirement: requirement['version'] || '*', type: type } end end |
.mapping ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/bibliothecary/parsers/shard.rb', line 8 def self.mapping { /^shard\.yml$/i => { kind: 'manifest', parser: :parse_yaml_manifest }, /^shard\.lock$/i => { kind: 'lockfile', parser: :parse_yaml_lockfile } } end |
.parse_yaml_lockfile(file_contents) ⇒ Object
21 22 23 24 |
# File 'lib/bibliothecary/parsers/shard.rb', line 21 def self.parse_yaml_lockfile(file_contents) manifest = YAML.load file_contents map_dependencies(manifest, 'shards', 'runtime') end |
.parse_yaml_manifest(file_contents) ⇒ Object
26 27 28 29 30 |
# File 'lib/bibliothecary/parsers/shard.rb', line 26 def self.parse_yaml_manifest(file_contents) manifest = YAML.load file_contents map_dependencies(manifest, 'dependencies', 'runtime') + map_dependencies(manifest, 'development_dependencies', 'runtime') end |