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::ANY_EXT_REGEX, LicenseFile::CC_FALSE_POSITIVE_REGEX, LicenseFile::COPYING_REGEX, LicenseFile::FILENAME_REGEXES, LicenseFile::LICENSE_REGEX, LicenseFile::OFL_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::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
Methods inherited from LicenseFile
#attribution, #gpl?, lesser_gpl_score, #lgpl?, #license, #possible_matchers, #potential_false_positive?
Methods included from ContentHelper
#content_hash, #content_normalized, #content_without_title_and_version, format_percent, #length, #length_delta, #max_delta, #similarity, #wordset, wrap
Methods inherited from ProjectFile
#confidence, #filename, #initialize, #license, #matcher, #possible_matchers
Constructor Details
This class inherits a constructor from Licensee::ProjectFiles::ProjectFile
Class Method Details
.license_content(content) ⇒ Object
28 29 30 31 |
# File 'lib/licensee/project_files/readme_file.rb', line 28 def self.license_content(content) match = CONTENT_REGEX.match(content) match[1].strip if match end |
.name_score(filename) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/licensee/project_files/readme_file.rb', line 21 def self.name_score(filename) SCORES.each do |pattern, score| return score if pattern =~ filename end 0.0 end |