Class: Licensee::Project::Readme
- Inherits:
-
LicenseFile
- Object
- File
- LicenseFile
- Licensee::Project::Readme
- Defined in:
- lib/licensee/project_files/readme.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::PREFERRED_EXT, LicenseFile::PREFERRED_EXT_REGEX
Constants included from ContentHelper
ContentHelper::DIGEST, ContentHelper::END_OF_TERMS_REGEX
Constants inherited from File
File::ENCODING, File::ENCODING_OPTIONS
Instance Attribute Summary
Attributes inherited from File
Class Method Summary collapse
Methods inherited from LicenseFile
#attribution, lesser_gpl_score, #possible_matchers, #potential_false_positive?
Methods included from ContentHelper
#content_normalized, #hash, #length, #length_delta, #max_delta, #similarity, #wordset
Methods inherited from File
#confidence, #initialize, #license, #matcher
Constructor Details
This class inherits a constructor from Licensee::Project::File
Class Method Details
.license_content(content) ⇒ Object
28 29 30 31 |
# File 'lib/licensee/project_files/readme.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.rb', line 21 def self.name_score(filename) SCORES.each do |pattern, score| return score if pattern =~ filename end 0.0 end |