Class: Bibliothecary::Parsers::Packagist
- Inherits:
-
Object
- Object
- Bibliothecary::Parsers::Packagist
- Includes:
- Analyser
- Defined in:
- lib/bibliothecary/parsers/packagist.rb
Class Method Summary collapse
- .mapping ⇒ Object
-
.parse_lockfile(file_contents, options: {}) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
-
.parse_manifest(file_contents, options: {}) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
Methods included from Analyser
create_analysis, create_error_analysis, included
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 { match_filename("composer.json") => { kind: "manifest", parser: :parse_manifest, }, match_filename("composer.lock") => { kind: "lockfile", parser: :parse_lockfile, }, } end |
.parse_lockfile(file_contents, options: {}) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/bibliothecary/parsers/packagist.rb', line 25 def self.parse_lockfile(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument manifest = JSON.parse file_contents manifest.fetch("packages",[]).map do |dependency| { name: dependency["name"], requirement: dependency["version"], type: "runtime", }.tap do |result| # Store Drupal version if Drupal, but include the original manifest version for reference result[:original_requirement], result[:requirement] = result[:requirement], dependency.dig("source", "reference") if is_drupal_module(dependency) end end + manifest.fetch("packages-dev",[]).map do |dependency| { name: dependency["name"], requirement: dependency["version"], type: "development", }.tap do |result| # Store Drupal version if Drupal, but include the original manifest version for reference result[:original_requirement], result[:requirement] = result[:requirement], dependency.dig("source", "reference") if is_drupal_module(dependency) end end end |
.parse_manifest(file_contents, options: {}) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
48 49 50 51 52 |
# File 'lib/bibliothecary/parsers/packagist.rb', line 48 def self.parse_manifest(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument manifest = JSON.parse file_contents map_dependencies(manifest, "require", "runtime") + map_dependencies(manifest, "require-dev", "development") end |