Class: LicenseFinder::MavenPackage

Inherits:
Package
  • Object
show all
Defined in:
lib/license_finder/packages/maven_package.rb

Instance Attribute Summary

Attributes inherited from Package

#authors, #children, #description, #groups, #homepage, #install_path, #license_names_from_spec, #logger, #manual_approval, #name, #parents, #summary, #version

Instance Method Summary collapse

Methods inherited from Package

#<=>, #activations, #approved?, #approved_manually!, #approved_manually?, #decide_on_license, #eql?, #hash, license_names_from_standard_spec, #licenses, #licenses_from_spec, #licensing, #log_activation, #missing?, #permitted!, #permitted?, #restricted!, #restricted?

Constructor Details

#initialize(spec, options = {}) ⇒ MavenPackage

Returns a new instance of MavenPackage.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/license_finder/packages/maven_package.rb', line 5

def initialize(spec, options = {})
  name = spec['artifactId']
  name = "#{spec['groupId']}:#{name}" if options[:include_groups]
  @jar_file = spec['jarFile']

  super(
    name,
    spec['version'],
    options.merge(
      spec_licenses: Array(spec['licenses']).map { |l| l['name'] },
      groups: Array(spec['groupId']),
      summary: spec['summary'],
      description: spec['description'],
      homepage: spec['homepage']
    )
  )
end

Instance Method Details

#license_filesObject



31
32
33
# File 'lib/license_finder/packages/maven_package.rb', line 31

def license_files
  LicenseFiles.find(@jar_file, logger: logger)
end

#notice_filesObject



35
36
37
# File 'lib/license_finder/packages/maven_package.rb', line 35

def notice_files
  NoticeFiles.find(@jar_file, logger: logger)
end

#package_managerObject



23
24
25
# File 'lib/license_finder/packages/maven_package.rb', line 23

def package_manager
  'Maven'
end

#package_urlObject



27
28
29
# File 'lib/license_finder/packages/maven_package.rb', line 27

def package_url
  "https://search.maven.org/artifact/#{CGI.escape(groups.first)}/#{CGI.escape(name.split(':').last)}/#{CGI.escape(version)}/jar"
end