Module: Licensee
- Defined in:
- 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/projects/project.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/license/class_methods.rb,
lib/licensee/commands/detect_helpers.rb,
lib/licensee/license/content_methods.rb,
lib/licensee/projects/github_project.rb,
lib/licensee/content_helper/constants.rb,
lib/licensee/license/identity_methods.rb,
lib/licensee/project_files/readme_file.rb,
lib/licensee/project_files/license_file.rb,
lib/licensee/project_files/project_file.rb,
lib/licensee/content_helper/similarity_methods.rb,
lib/licensee/project_files/package_manager_file.rb,
lib/licensee/content_helper/normalization_methods.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: Commands, ContentHelper, HashHelper, LicenseAllHelper, 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.19.0'
Class Method Summary collapse
- .confidence_threshold ⇒ Object
- .confidence_threshold=(value) ⇒ Object
-
.inverse_confidence_threshold ⇒ Object
Inverse of the confidence threshold, represented as a float By default this will be 0.02.
-
.license(path) ⇒ Object
Returns the license for a given path.
-
.licenses(options = {}) ⇒ Object
Returns an array of Licensee::License instances.
- .project(path, **args) ⇒ Object
- .project_for_path(path, **args) ⇒ Object
- .unsupported_remote_message(path) ⇒ Object
- .unsupported_remote_url?(path) ⇒ Boolean
Class Method Details
.confidence_threshold ⇒ Object
68 69 70 |
# File 'lib/licensee.rb', line 68 def confidence_threshold @confidence_threshold ||= CONFIDENCE_THRESHOLD end |
.confidence_threshold=(value) ⇒ Object
72 73 74 75 |
# File 'lib/licensee.rb', line 72 def confidence_threshold=(value) @confidence_threshold = value @inverse_confidence_threshold = nil end |
.inverse_confidence_threshold ⇒ Object
Inverse of the confidence threshold, represented as a float By default this will be 0.02
79 80 81 82 |
# File 'lib/licensee.rb', line 79 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
34 35 36 |
# File 'lib/licensee.rb', line 34 def license(path) Licensee.project(path).license end |
.licenses(options = {}) ⇒ Object
Returns an array of Licensee::License instances
29 30 31 |
# File 'lib/licensee.rb', line 29 def licenses( = {}) Licensee::License.all() end |
.project(path, **args) ⇒ Object
38 39 40 41 42 |
# File 'lib/licensee.rb', line 38 def project(path, **args) project_for_path(path, **args) rescue Licensee::Projects::GitProject::InvalidRepository Licensee::Projects::FSProject.new(path, **args) end |
.project_for_path(path, **args) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/licensee.rb', line 44 def project_for_path(path, **args) if %r{\Ahttps://github.com}.match?(path) Licensee::Projects::GitHubProject.new(path, **args) elsif unsupported_remote_url?(path) raise ArgumentError, (path) elsif args[:filesystem] Licensee::Projects::FSProject.new(path, **args) else Licensee::Projects::GitProject.new(path, **args) end end |
.unsupported_remote_message(path) ⇒ Object
62 63 64 65 |
# File 'lib/licensee.rb', line 62 def (path) "Unsupported remote URL: #{path} " \ 'Clone the repo and run licensee on the local path.' end |
.unsupported_remote_url?(path) ⇒ Boolean
57 58 59 |
# File 'lib/licensee.rb', line 57 def unsupported_remote_url?(path) %r{\Ahttps?://}.match?(path) end |