module Licensee
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
Filesystem-based project
Analyze a folder on the filesystem for license information
Project files for this project type will contain the following keys:
:name - the relative file name :dir - the directory path containing the file
Licensee::Project represents an open source project on disk It is not used directly, but rather is extended by FSProject and GitProject depending on the type of file system access available
Subclasses must implement the Files and LoadFile private methods
Constants
- CONFIDENCE_THRESHOLD
Over which percent is a match considered a match by default
- DOMAIN
Base domain from which to build license URLs
- VERSION
Public Class Methods
# File lib/licensee.rb, line 47 def confidence_threshold @confidence_threshold ||= CONFIDENCE_THRESHOLD end
# File lib/licensee.rb, line 51 def confidence_threshold=(value) @confidence_threshold = value @inverse_confidence_threshold = nil end
Inverse of the confidence threshold, represented as a float By default this will be 0.02
# File lib/licensee.rb, line 58 def inverse_confidence_threshold @inverse_confidence_threshold ||= (1 - (Licensee.confidence_threshold / 100.0)).round(2) end
Returns the license for a given path
# File lib/licensee.rb, line 33 def license(path) Licensee.project(path).license end
Returns an array of Licensee::License instances
# File lib/licensee.rb, line 28 def licenses(options = {}) Licensee::License.all(options) end
# 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