Sha256: ca0660ec543785f3d35b8a3c7bb2848bc17fd4acd13192244bcb6a52cb93cec9

Contents?: true

Size: 779 Bytes

Versions: 1

Compression:

Stored size: 779 Bytes

Contents

# frozen_string_literal: true

module Spandx
  module Php
    module Parsers
      class Composer < ::Spandx::Core::Parser
        def match?(path)
          path.basename.fnmatch? 'composer.lock'
        end

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

        private

        def map_from(path, dependency)
          Spandx::Core::Dependency.new(
            path: path,
            name: dependency['name'],
            version: dependency['version'],
            meta: dependency
          )
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spandx-0.13.4 lib/spandx/php/parsers/composer.rb