Class: Licensee::ProjectFiles::ReadmeFile
- Inherits:
-
LicenseFile
- Object
- ProjectFile
- LicenseFile
- Licensee::ProjectFiles::ReadmeFile
- Defined in:
- lib/licensee/project_files/readme_file.rb
Constant Summary collapse
- SCORES =
{ /\AREADME\z/i => 1.0, /\AREADME\.(md|markdown|mdown|txt)\z/i => 0.9 }.freeze
- CONTENT_REGEX =
/^ (?:\#+\sLicen[sc]e # Start of hashes-based license header | Licen[sc]e\n[-=]+)$ # Start of underlined license header (.*?) # License content (?=^(?:\#+ # Next hashes-based header | [^\n]+\n[-=]+) # Next of underlined header | \z) # End of file /mix
Constants inherited from LicenseFile
LicenseFile::CC_FALSE_POSITIVE_REGEX, LicenseFile::COPYING_REGEX, LicenseFile::FILENAME_REGEXES, LicenseFile::LICENSE_REGEX, LicenseFile::OFL_REGEX, LicenseFile::OTHER_EXT_REGEX, LicenseFile::PATENTS_REGEX, LicenseFile::PREFERRED_EXT, LicenseFile::PREFERRED_EXT_REGEX
Constants included from ContentHelper
ContentHelper::ALL_RIGHTS_RESERVED_REGEX, ContentHelper::ALT_TITLE_REGEX, ContentHelper::DIGEST, ContentHelper::END_OF_TERMS_REGEX, ContentHelper::HR_REGEX, ContentHelper::MARKDOWN_HEADING_REGEX, ContentHelper::MARKUP_REGEX, ContentHelper::VERSION_REGEX, ContentHelper::WHITESPACE_REGEX
Constants inherited from ProjectFile
ProjectFile::ENCODING, ProjectFile::ENCODING_OPTIONS
Instance Attribute Summary
Attributes inherited from ProjectFile
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from LicenseFile
#attribution, #gpl?, lesser_gpl_score, #lgpl?, #license, #potential_false_positive?
Methods included from ContentHelper
#content_hash, #content_normalized, #content_without_title_and_version, format_percent, #length, #length_delta, #max_delta, #similarity, title_regex, #wordset, wrap
Methods inherited from ProjectFile
#confidence, #copyright?, #filename, #initialize, #license, #matcher
Constructor Details
This class inherits a constructor from Licensee::ProjectFiles::ProjectFile
Class Method Details
.license_content(content) ⇒ Object
32 33 34 35 |
# File 'lib/licensee/project_files/readme_file.rb', line 32 def self.license_content(content) match = CONTENT_REGEX.match(content) match[1].strip if match end |
.name_score(filename) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/licensee/project_files/readme_file.rb', line 25 def self.name_score(filename) SCORES.each do |pattern, score| return score if pattern =~ filename end 0.0 end |
Instance Method Details
#possible_matchers ⇒ Object
21 22 23 |
# File 'lib/licensee/project_files/readme_file.rb', line 21 def possible_matchers super.push(Matchers::Reference) end |