Class: Licensee::ProjectFiles::ReadmeFile
- Inherits:
-
LicenseFile
- Object
- ProjectFile
- LicenseFile
- Licensee::ProjectFiles::ReadmeFile
- Defined in:
- lib/licensee/project_files/readme_file.rb
Constant Summary collapse
- EXTENSIONS =
%w[md markdown mdown txt rdoc].freeze
- SCORES =
{ /\AREADME\z/i => 1.0, /\AREADME\.(#{Regexp.union(EXTENSIONS).source})\z/i => 0.9 }.freeze
- TITLE_REGEX =
/licen[sc]e:?/i
- UNDERLINE_REGEX =
/\n[-=]+/m
- CONTENT_REGEX =
/^ (?: # Header lookbehind [\#=]+\s#{TITLE_REGEX} # Start of hashes or rdoc header | #{TITLE_REGEX}#{UNDERLINE_REGEX} # Start of underlined header )$ (.*?) # License content (?=^ # Header or end of file lookahead (?: [\#=]+ # Next hash or rdoc header | [^\n]+#{UNDERLINE_REGEX} # 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
41 42 43 44 |
# File 'lib/licensee/project_files/readme_file.rb', line 41 def self.license_content(content) match = CONTENT_REGEX.match(content) match[1].strip if match end |
.name_score(filename) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/licensee/project_files/readme_file.rb', line 34 def self.name_score(filename) SCORES.each do |pattern, score| return score if pattern =~ filename end 0.0 end |