Module: Licensee

Defined in:
lib/licensee/projects/project.rb,
lib/licensee.rb,
lib/licensee/rule.rb,
lib/licensee/license.rb,
lib/licensee/version.rb,
lib/licensee/matchers.rb,
lib/licensee/projects.rb,
lib/licensee/hash_helper.rb,
lib/licensee/license_meta.rb,
lib/licensee/license_field.rb,
lib/licensee/license_rules.rb,
lib/licensee/matchers/cran.rb,
lib/licensee/matchers/dice.rb,
lib/licensee/matchers/spdx.rb,
lib/licensee/project_files.rb,
lib/licensee/content_helper.rb,
lib/licensee/matchers/cabal.rb,
lib/licensee/matchers/cargo.rb,
lib/licensee/matchers/exact.rb,
lib/licensee/matchers/nuget.rb,
lib/licensee/matchers/gemspec.rb,
lib/licensee/matchers/matcher.rb,
lib/licensee/matchers/package.rb,
lib/licensee/matchers/copyright.rb,
lib/licensee/matchers/npm_bower.rb,
lib/licensee/matchers/reference.rb,
lib/licensee/matchers/dist_zilla.rb,
lib/licensee/projects/fs_project.rb,
lib/licensee/projects/git_project.rb,
lib/licensee/projects/github_project.rb,
lib/licensee/project_files/readme_file.rb,
lib/licensee/project_files/license_file.rb,
lib/licensee/project_files/project_file.rb,
lib/licensee/project_files/package_manager_file.rb

Overview

A project file is a file within a project that contains license information Currently extended by LicenseFile, PackageManagerFile, and ReadmeFile

Sublcasses should implement the possible_matchers method

Defined Under Namespace

Modules: ContentHelper, HashHelper, Matchers, ProjectFiles, Projects Classes: InvalidLicense, License, LicenseField, LicenseMeta, LicenseRules, Rule

Constant Summary collapse

CONFIDENCE_THRESHOLD =

Over which percent is a match considered a match by default

98
DOMAIN =

Base domain from which to build license URLs

'http://choosealicense.com'
VERSION =
'9.17.1'

Class Method Summary collapse

Class Method Details

.confidence_thresholdObject



47
48
49
# File 'lib/licensee.rb', line 47

def confidence_threshold
  @confidence_threshold ||= CONFIDENCE_THRESHOLD
end

.confidence_threshold=(value) ⇒ Object



51
52
53
54
# File 'lib/licensee.rb', line 51

def confidence_threshold=(value)
  @confidence_threshold = value
  @inverse_confidence_threshold = nil
end

.inverse_confidence_thresholdObject

Inverse of the confidence threshold, represented as a float By default this will be 0.02



58
59
60
61
# File 'lib/licensee.rb', line 58

def inverse_confidence_threshold
  @inverse_confidence_threshold ||=
    (1 - (Licensee.confidence_threshold / 100.0)).round(2)
end

.license(path) ⇒ Object

Returns the license for a given path



33
34
35
# File 'lib/licensee.rb', line 33

def license(path)
  Licensee.project(path).license
end

.licenses(options = {}) ⇒ Object

Returns an array of Licensee::License instances



28
29
30
# File 'lib/licensee.rb', line 28

def licenses(options = {})
  Licensee::License.all(options)
end

.project(path, **args) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/licensee.rb', line 37

def project(path, **args)
  if %r{\Ahttps://github.com}.match?(path)
    Licensee::Projects::GitHubProject.new(path, **args)
  else
    Licensee::Projects::GitProject.new(path, **args)
  end
rescue Licensee::Projects::GitProject::InvalidRepository
  Licensee::Projects::FSProject.new(path, **args)
end