Class: Licensee::Matchers::Copyright

Inherits:
Object
  • Object
show all
Defined in:
lib/licensee/matchers/copyright_matcher.rb

Constant Summary collapse

REGEX =
/\s*Copyright (©|\(c\)|\xC2\xA9)? ?(\d{4}|\[year\])(.*)?\s*/i

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Copyright

Returns a new instance of Copyright.



7
8
9
# File 'lib/licensee/matchers/copyright_matcher.rb', line 7

def initialize(file)
  @file = file
end

Instance Method Details

#confidenceObject



20
21
22
# File 'lib/licensee/matchers/copyright_matcher.rb', line 20

def confidence
  100
end

#matchObject



11
12
13
14
15
16
17
18
# File 'lib/licensee/matchers/copyright_matcher.rb', line 11

def match
  # Note: must use content, and not content_normalized here
  if @file.content.strip =~ /\A#{REGEX}\z/i
    Licensee::License.find("no-license") 
  end
rescue
  nil
end