Class: Licensee::Matchers::Copyright

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

Overview

Detects explicit copyright / reserved-rights notices.

Constant Summary collapse

Regexp.union([/copyright/i, /\(c\)/i, "\u00A9", "\xC2\xA9"])
MAIN_LINE_REGEX =
/[_*\-\s]*#{COPYRIGHT_SYMBOLS}.*$/i
CONTINUATION_LINE_REGEX =
/\n[ \t]+\d{4}[^\n]*/
OPTIONAL_LINE_REGEX =
/[_*\-\s]*with Reserved Font Name.*$/i
REGEX =
/#{ContentHelper::START_REGEX}(#{MAIN_LINE_REGEX}#{CONTINUATION_LINE_REGEX}*#{OPTIONAL_LINE_REGEX}*)+$/i

Constants inherited from Matcher

Matcher::HASH_METHODS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Matcher

#initialize, #name

Methods included from HashHelper

#serialize_hash_value, #to_h

Constructor Details

This class inherits a constructor from Licensee::Matchers::Matcher

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



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

def file
  @file
end

Instance Method Details

#confidenceObject



21
22
23
# File 'lib/licensee/matchers/copyright.rb', line 21

def confidence
  100
end

#matchObject



14
15
16
17
18
19
# File 'lib/licensee/matchers/copyright.rb', line 14

def match
  # NOTE: must use content, and not content_normalized here
  Licensee::License.find('no-license') if /#{REGEX}+\z/io.match?(file.content.strip)
rescue Encoding::CompatibilityError
  nil
end