Class: Spandx::Php::Parsers::Composer

Inherits:
Core::Parser show all
Defined in:
lib/spandx/php/parsers/composer.rb

Constant Summary

Constants inherited from Core::Parser

Core::Parser::UNKNOWN

Instance Method Summary collapse

Methods inherited from Core::Parser

for, parse

Methods included from Core::Registerable

#all, #each, #inherited, #registry

Instance Method Details

#match?(path) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/spandx/php/parsers/composer.rb', line 7

def match?(path)
  path.basename.fnmatch? 'composer.lock'
end

#parse(path) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/spandx/php/parsers/composer.rb', line 11

def parse(path)
  items = Set.new
  composer_lock = Oj.load(path.read)
  composer_lock['packages'].concat(composer_lock['packages-dev']).each do |dependency|
    items.add(map_from(path, dependency))
  end
  items
end