Sha256: 68a53c3a030ae0b44dd1275496ed101c412e77ee4cc1cc941078d73815fe19bf

Contents?: true

Size: 971 Bytes

Versions: 7

Compression:

Stored size: 971 Bytes

Contents

# frozen_string_literal: true

module Spandx
  module Dotnet
    module Parsers
      class Csproj < ::Spandx::Core::Parser
        def self.matches?(filename)
          ['.csproj', '.props'].include?(File.extname(filename))
        end

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

        private

        def map_from(package_reference)
          ::Spandx::Core::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 ||= NugetGateway.new(catalogue: catalogue)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
spandx-0.11.0 lib/spandx/dotnet/parsers/csproj.rb
spandx-0.10.1 lib/spandx/dotnet/parsers/csproj.rb
spandx-0.10.0 lib/spandx/dotnet/parsers/csproj.rb
spandx-0.9.0 lib/spandx/dotnet/parsers/csproj.rb
spandx-0.8.0 lib/spandx/dotnet/parsers/csproj.rb
spandx-0.7.0 lib/spandx/dotnet/parsers/csproj.rb
spandx-0.6.0 lib/spandx/dotnet/parsers/csproj.rb