Class: Bibliothecary::Parsers::Packagist
- Inherits:
-
Object
- Object
- Bibliothecary::Parsers::Packagist
- Includes:
- Analyser
- Defined in:
- lib/bibliothecary/parsers/packagist.rb
Class Method Summary collapse
Methods included from Analyser
Class Method Details
.mapping ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/bibliothecary/parsers/packagist.rb', line 8 def self.mapping { /^composer\.json$/ => { kind: 'manifest', parser: :parse_manifest }, /^composer\.lock$/ => { kind: 'lockfile', parser: :parse_lockfile } } end |
.parse_lockfile(file_contents) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/bibliothecary/parsers/packagist.rb', line 21 def self.parse_lockfile(file_contents) manifest = JSON.parse file_contents manifest.fetch('packages',[]).map do |dependency| { name: dependency["name"], requirement: dependency["version"], type: 'runtime' } end + manifest.fetch('packages-dev',[]).map do |dependency| { name: dependency["name"], requirement: dependency["version"], type: 'development' } end end |
.parse_manifest(file_contents) ⇒ Object
38 39 40 41 42 |
# File 'lib/bibliothecary/parsers/packagist.rb', line 38 def self.parse_manifest(file_contents) manifest = JSON.parse file_contents map_dependencies(manifest, 'require', 'runtime') + map_dependencies(manifest, 'require-dev', 'development') end |