Class: LicenseFinder::Dotnet

Inherits:
PackageManager show all
Defined in:
lib/license_finder/package_managers/dotnet.rb

Defined Under Namespace

Classes: AssetFile, PackageMetadata

Instance Method Summary collapse

Methods inherited from PackageManager

#active?, #command_exists?, #current_packages_with_relations, #detected_package_path, id, #initialize, #installed?, #prepare, #project_root?, takes_priority_over

Constructor Details

This class inherits a constructor from LicenseFinder::PackageManager

Instance Method Details

#asset_filesObject



71
72
73
# File 'lib/license_finder/package_managers/dotnet.rb', line 71

def asset_files
  Dir[project_path.join('**/project.assets.json')]
end

#current_packagesObject



60
61
62
63
64
65
66
67
68
69
# File 'lib/license_finder/package_managers/dotnet.rb', line 60

def current_packages
  package_metadatas = asset_files
                      .flat_map { |path| AssetFile.new(path).dependencies }
                      .uniq { |d| [d.name, d.version] }

  package_metadatas.map do |d|
    path = Dir.glob("#{Dir.home}/.nuget/packages/#{d.name.downcase}/#{d.version}").first
    NugetPackage.new(d.name, d.version, spec_licenses: d.read_license_urls, install_path: path)
  end
end

#package_management_commandObject



75
76
77
# File 'lib/license_finder/package_managers/dotnet.rb', line 75

def package_management_command
  'dotnet'
end

#possible_package_pathsObject



55
56
57
58
# File 'lib/license_finder/package_managers/dotnet.rb', line 55

def possible_package_paths
  paths = Dir[project_path.join('*.csproj')]
  paths.map { |p| Pathname(p) }
end

#prepare_commandObject



79
80
81
# File 'lib/license_finder/package_managers/dotnet.rb', line 79

def prepare_command
  "#{package_management_command} restore"
end