class Licensed::Sources::Gradle::Dependency

Public Class Methods

new(name:, version:, path:, url:, metadata: {}) click to toggle source
Calls superclass method Licensed::Dependency::new
# File lib/licensed/sources/gradle.rb, line 23
def initialize(name:, version:, path:, url:, metadata: {})
  @url = url
  super(name: name, version: version, path: path, metadata: metadata)
end
retrieve_license(url) click to toggle source

Cache and return the results of getting the license content.

# File lib/licensed/sources/gradle.rb, line 18
def retrieve_license(url)
  (@licenses ||= {})[url] ||= Net::HTTP.get(URI(url))
end

Public Instance Methods

exist?() click to toggle source

Returns whether the dependency content exists

# File lib/licensed/sources/gradle.rb, line 29
def exist?
  # shouldn't force network connections just to check if content exists
  # only check that the path is not empty
  !path.to_s.empty?
end
project_files() click to toggle source

Returns a Licensee::ProjectFiles::LicenseFile for the dependency

# File lib/licensed/sources/gradle.rb, line 36
def project_files
  return [] if @url.nil?

  license_data = self.class.retrieve_license(@url)
  Array(Licensee::ProjectFiles::LicenseFile.new(license_data, { uri: @url }))
end