class Licensee::Project

Attributes

detect_packages[R]
detect_packages?[R]
detect_readme[R]
detect_readme?[R]

Public Class Methods

new(detect_packages: false, detect_readme: false) click to toggle source
# File lib/licensee/project.rb, line 9
def initialize(detect_packages: false, detect_readme: false)
  @detect_packages = detect_packages
  @detect_readme = detect_readme
end

Public Instance Methods

license() click to toggle source

Returns the matching License instance if a license can be detected

# File lib/licensee/project.rb, line 15
def license
  @license ||= matched_file && matched_file.license
end
license_file() click to toggle source
# File lib/licensee/project.rb, line 23
def license_file
  return @license_file if defined? @license_file
  @license_file = begin
    content, name = find_file { |n| LicenseFile.name_score(n) }
    LicenseFile.new(content, name) if content && name
  end
end
matched_file() click to toggle source
# File lib/licensee/project.rb, line 19
def matched_file
  @matched_file ||= (license_file || readme || package_file)
end
package_file() click to toggle source
# File lib/licensee/project.rb, line 41
def package_file
  return unless detect_packages?
  return @package_file if defined? @package_file
  @package_file = begin
    content, name = find_file { |n| PackageInfo.name_score(n) }
    PackageInfo.new(content, name) if content && name
  end
end
readme() click to toggle source
# File lib/licensee/project.rb, line 31
def readme
  return unless detect_readme?
  return @readme if defined? @readme
  @readme = begin
    content, name = find_file { |n| Readme.name_score(n) }
    content = Readme.license_content(content)
    Readme.new(content, name) if content && name
  end
end