mirror of https://github.com/licensee/licensee.git
better regex
This commit is contained in:
parent
46d70aa17d
commit
8e6a9543a7
|
@ -1,10 +1,10 @@
|
|||
class Licensee
|
||||
class CopyrightMatcher < Matcher
|
||||
|
||||
REGEX = /\A(Copyright )?(©|\(c\)) \d{4}(.*)\n?\z/i
|
||||
REGEX = /\A(Copyright|Copyright ©|Copyright \(c\)) \d{4}.*?\n?\z/i
|
||||
|
||||
def match
|
||||
no_license if file.content_normalized =~ REGEX
|
||||
no_license if file.content.strip =~ REGEX
|
||||
end
|
||||
|
||||
def confidence
|
||||
|
|
|
@ -16,15 +16,15 @@ class TestLicenseeCopyrightMatcher < Minitest::Test
|
|||
assert_equal 100, Licensee::CopyrightMatcher.new(@file).confidence
|
||||
end
|
||||
|
||||
should "match (C) copyright notices" do
|
||||
text = "(C) 2015 Ben Balter"
|
||||
should "match Copyright (C) copyright notices" do
|
||||
text = "Copyright (C) 2015 Ben Balter"
|
||||
blob = FakeBlob.new(text)
|
||||
file = Licensee::LicenseFile.new(blob)
|
||||
assert_equal "no-license", Licensee::CopyrightMatcher.match(file).key
|
||||
end
|
||||
|
||||
should "match © copyright notices" do
|
||||
text = "© 2015 Ben Balter"
|
||||
should "match Copyright © copyright notices" do
|
||||
text = "copyright © 2015 Ben Balter"
|
||||
blob = FakeBlob.new(text)
|
||||
file = Licensee::LicenseFile.new(blob)
|
||||
assert_equal "no-license", Licensee::CopyrightMatcher.match(file).key
|
||||
|
|
Loading…
Reference in New Issue