lib/spandx/php/parsers/composer.rb in spandx-0.13.3 vs lib/spandx/php/parsers/composer.rb in spandx-0.13.4
- old
+ new
@@ -2,27 +2,27 @@
module Spandx
module Php
module Parsers
class Composer < ::Spandx::Core::Parser
- def matches?(filename)
- File.basename(filename) == 'composer.lock'
+ def match?(path)
+ path.basename.fnmatch? 'composer.lock'
end
- def parse(file_path)
+ def parse(path)
items = Set.new
- composer_lock = JSON.parse(IO.read(file_path))
+ composer_lock = JSON.parse(path.read)
composer_lock['packages'].concat(composer_lock['packages-dev']).each do |dependency|
- items.add(map_from(dependency))
+ items.add(map_from(path, dependency))
end
items
end
private
- def map_from(dependency)
+ def map_from(path, dependency)
Spandx::Core::Dependency.new(
- package_manager: :composer,
+ path: path,
name: dependency['name'],
version: dependency['version'],
meta: dependency
)
end