Sha256: f13d2b60e86aa4a95a14850d6256f506c068d2f6bea8967ec49c30afdaff3d81

Contents?: true

Size: 930 Bytes

Versions: 3

Compression:

Stored size: 930 Bytes

Contents

# frozen_string_literal: true

module Spandx
  module Parsers
    class Csproj < Base
      def self.matches?(filename)
        filename.match?(/.*\.csproj/)
      end

      def parse(lockfile)
        ProjectFile
          .new(lockfile)
          .package_references
          .map { |x| map_from(x) }
      end

      private

      def map_from(package_reference)
        Dependency.new(
          name: package_reference.name,
          version: package_reference.version,
          licenses: licenses_for(package_reference)
        )
      end

      def licenses_for(package_reference)
        nuget
          .licenses_for(package_reference.name, package_reference.version)
          .map { |x| catalogue[x] }
      end

      def nuget
        @nuget ||= Gateways::Nuget.new(catalogue: catalogue)
      end
    end
  end
end
require 'spandx/parsers/csproj/package_reference'
require 'spandx/parsers/csproj/project_file'

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spandx-0.2.0 lib/spandx/parsers/csproj.rb
spandx-0.1.7 lib/spandx/parsers/csproj.rb
spandx-0.1.6 lib/spandx/parsers/csproj.rb