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|txt)\z/i => 0.9 }.freeze
- CONTENT_REGEX =
/^#+ Licen[sc]e$(.*?)(?=#+|\z)/im
Constants included from ContentHelper
Instance Attribute Summary
Attributes inherited from File
Class Method Summary collapse
Methods inherited from LicenseFile
#attribution, #possible_matchers
Methods included from ContentHelper
#content_normalized, #hash, #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
18 19 20 21 |
# File 'lib/licensee/project_files/readme.rb', line 18 def self.license_content(content) match = CONTENT_REGEX.match(content) match[1].strip if match end |
.name_score(filename) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/licensee/project_files/readme.rb', line 11 def self.name_score(filename) SCORES.each do |pattern, score| return score if pattern =~ filename end 0.0 end |