Class: Licensee::Matchers::Copyright

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

Constant Summary collapse

Regexp.union([/copyright/i, /\(c\)/i, "\u00A9", "\xC2\xA9"])
REGEX =
/^\s*#{COPYRIGHT_SYMBOLS}.*$/i

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Copyright

rubocop:enable Metrics/LineLength



12
13
14
# File 'lib/licensee/matchers/copyright_matcher.rb', line 12

def initialize(file)
  @file = file
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



5
6
7
# File 'lib/licensee/matchers/copyright_matcher.rb', line 5

def file
  @file
end

Instance Method Details

#confidenceObject



25
26
27
# File 'lib/licensee/matchers/copyright_matcher.rb', line 25

def confidence
  100
end

#matchObject



16
17
18
19
20
21
22
23
# File 'lib/licensee/matchers/copyright_matcher.rb', line 16

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