Class: Licensee::Project::LicenseFile

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

Instance Attribute Summary

Attributes inherited from File

#content, #filename

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ContentHelper

#create_word_set

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



48
49
50
51
52
53
54
55
# File 'lib/licensee/project_file.rb', line 48

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
  return 0.0
end

Instance Method Details

#attributionObject



43
44
45
46
# File 'lib/licensee/project_file.rb', line 43

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

#possible_matchersObject



35
36
37
# File 'lib/licensee/project_file.rb', line 35

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

#wordsetObject



39
40
41
# File 'lib/licensee/project_file.rb', line 39

def wordset
  @wordset ||= create_word_set(content)
end