Class: Licensee::Matchers::Copyright

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

Constant Summary collapse

Regexp.union([/copyright/i, /\(c\)/i, "\u00A9", "\xC2\xA9"])
REGEX =
/#{ContentHelper::START_REGEX}(?:portions )?(\s*#{COPYRIGHT_SYMBOLS}.*$)+$/i.freeze

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

#to_h

Constructor Details

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

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



4
5
6
# File 'lib/licensee/matchers/copyright.rb', line 4

def file
  @file
end

Instance Method Details

#confidenceObject



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

def confidence
  100
end

#matchObject

rubocop:enable Metrics/LineLength



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

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