Class: Licensee::Project::LicenseFile

Inherits:
File
  • Object
show all
Includes:
ContentHelper
Defined in:
lib/licensee/project_files/license_file.rb

Direct Known Subclasses

Readme

Constant Summary

Constants included from ContentHelper

ContentHelper::DIGEST

Instance Attribute Summary

Attributes inherited from File

#content, #filename

Class Method Summary collapse

Instance Method Summary collapse

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

.name_score(filename) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/licensee/project_files/license_file.rb', line 15

def self.name_score(filename)
  return 1.0 if filename =~ /\A(un)?licen[sc]e\z/i
  return 0.9 if filename =~ /\A(un)?licen[sc]e\.(md|markdown|txt)\z/i
  return 0.8 if filename =~ /\Acopy(ing|right)(\.[^.]+)?\z/i
  return 0.7 if filename =~ /\A(un)?licen[sc]e\.[^.]+\z/i
  return 0.5 if filename =~ /licen[sc]e/i
  0.0
end

Instance Method Details

#attributionObject



10
11
12
13
# File 'lib/licensee/project_files/license_file.rb', line 10

def attribution
  matches = /^#{Matchers::Copyright::REGEX}$/i.match(content)
  matches[0].strip if matches
end

#possible_matchersObject



6
7
8
# File 'lib/licensee/project_files/license_file.rb', line 6

def possible_matchers
  [Matchers::Copyright, Matchers::Exact, Matchers::Dice]
end