verify MIT w/o title is detected

This commit is contained in:
Ben Balter 2015-09-02 12:00:39 -04:00
parent 86bc169ccf
commit 5f620e43ce
4 changed files with 26 additions and 2 deletions

View File

@ -2,7 +2,7 @@ class Licensee
class GitMatcher < Matcher
def match
match_info[0] unless match_info.nil?
match_info[0] if match_info && match_info[1] >= Licensee.confidence_threshold
end
def confidence
@ -19,7 +19,7 @@ class Licensee
def match_info
@match_info ||= begin
match = matches.max_by { |license, similarity| similarity }
match if match && match[1] > Licensee.confidence_threshold
match if match
end
end
end

19
test/fixtures/mit-without-title/mit.txt vendored Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2015 Ben Balter
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -15,4 +15,5 @@ class TestLicenseeGitMatcher < Minitest::Test
should "know the match confidence" do
assert_equal 94, Licensee::GitMatcher.new(@mit).confidence
end
end

View File

@ -68,6 +68,10 @@ class TestLicenseeProject < Minitest::Test
end
end
should "detect the MIT license even with the title removed" do
verify_license_file fixture_path("mit-without-title/mit.txt")
end
describe "packages" do
def setup