lib/licensee/matchers/copyright_matcher.rb in licensee-5.0.0 vs lib/licensee/matchers/copyright_matcher.rb in licensee-6.0.0b1
- old
+ new
@@ -1,24 +1,25 @@
# encoding=utf-8
class Licensee
- class CopyrightMatcher < Matcher
+ module Matchers
+ class Copyright
+ REGEX = /\s*Copyright (©|\(c\)|\xC2\xA9)? ?(\d{4}|\[year\])(.*)?\s*/i
- REGEX = /\s*Copyright (©|\(c\)|\xC2\xA9)? ?(\d{4}|\[year\])(.*)?\s*/i
+ def initialize(file)
+ @file = file
+ end
- def match
- # Note: must use content, and not content_normalized here
- no_license if file.content.strip =~ /\A#{REGEX}\z/i
- rescue
- nil
- end
+ 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
- def confidence
- 100
- end
-
- private
-
- def no_license
- @no_license ||= Licensee::License.find("no-license")
+ def confidence
+ 100
+ end
end
end
end