Class: Licensee::License
- Inherits:
-
Object
- Object
- Licensee::License
- Extended by:
- Forwardable, ClassMethods
- Includes:
- ContentHelper, HashHelper, ContentMethods, IdentityMethods
- Defined in:
- lib/licensee/license.rb,
lib/licensee/license/class_methods.rb,
lib/licensee/license/content_methods.rb,
lib/licensee/license/identity_methods.rb
Overview
Represents a known license (metadata + normalized content) from vendored data.
Defined Under Namespace
Modules: ClassMethods, ContentMethods, IdentityMethods
Constant Summary collapse
- YAML_DEFAULTS =
Preserved for backwards compatibility
Licensee::LicenseMeta.members
- PSEUDO_LICENSES =
Pseudo-license are license placeholders with no content
‘other` - The project had a license, but we were not able to detect it `no-license` - The project is not licensed (e.g., all rights reserved)
NOTE: A lack of detected license will be a nil license
%w[other no-license].freeze
- DEFAULT_OPTIONS =
Default options to use when retrieving licenses via #all
{ hidden: false, featured: nil, pseudo: true }.freeze
- SOURCE_PREFIX =
%r{https?://(?:www\.)?}i- SOURCE_SUFFIX =
%r{(?:\.html?|\.txt|/)(?:\?[^\s]*)?}i- HASH_METHODS =
%i[ key spdx_id meta url rules fields other? gpl? lgpl? cc? ].freeze
Constants included from ContentHelper::Constants
ContentHelper::Constants::DIGEST, ContentHelper::Constants::END_OF_TERMS_REGEX, ContentHelper::Constants::NORMALIZATIONS, ContentHelper::Constants::REGEXES, ContentHelper::Constants::START_REGEX, ContentHelper::Constants::STRIP_METHODS, ContentHelper::Constants::VARIETAL_WORDS
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
-
#initialize(key) ⇒ License
constructor
A new instance of License.
- #inspect ⇒ Object
-
#meta ⇒ Object
License metadata from YAML front matter with defaults merged in.
- #rules ⇒ Object
Methods included from ClassMethods
all, find, find_by_title, keys, license_dir, license_files, spdx_dir
Methods included from IdentityMethods
#==, #creative_commons?, #gpl?, #key_title_regex, #lgpl?, #name, #name_without_version, #nickname_title_regex, #normalize_version_capture, #normalized_title_regex, #other?, #pseudo_license?, #simple_title_regex, #source_regex, #spdx_id, #title_regex, #title_regex_parts, #url, #version_substitution
Methods included from ContentMethods
#content, #content_for_mustache, #fields, #path
Methods included from HashHelper
Methods included from ContentHelper
#bigrams, const_missing, #content_hash, format_percent, #length, #length_delta, normalize_for_wrapping, title_regex, #wordset, wrap, wrap_line, wrap_lines
Methods included from ContentHelper::SimilarityMethods
#bigram_similarity, #similarity
Methods included from ContentHelper::NormalizationMethods
#content_normalized, #content_without_title_and_version, #normalize_content
Constructor Details
#initialize(key) ⇒ License
Returns a new instance of License.
77 78 79 |
# File 'lib/licensee/license.rb', line 77 def initialize(key) @key = key.downcase end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
42 43 44 |
# File 'lib/licensee/license.rb', line 42 def key @key end |
Instance Method Details
#inspect ⇒ Object
90 91 92 |
# File 'lib/licensee/license.rb', line 90 def inspect "#<Licensee::License key=#{key}>" end |
#meta ⇒ Object
License metadata from YAML front matter with defaults merged in
82 83 84 |
# File 'lib/licensee/license.rb', line 82 def @meta ||= LicenseMeta.from_yaml(yaml) end |
#rules ⇒ Object
86 87 88 |
# File 'lib/licensee/license.rb', line 86 def rules @rules ||= LicenseRules.() end |