licensee 5.0.0 → 6.0.0b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +15 -50
  3. data/bin/licensee +7 -8
  4. data/lib/licensee.rb +9 -33
  5. data/lib/licensee/content_helper.rb +7 -8
  6. data/lib/licensee/license.rb +5 -28
  7. data/lib/licensee/matchers/copyright_matcher.rb +17 -16
  8. data/lib/licensee/matchers/dice_matcher.rb +65 -0
  9. data/lib/licensee/matchers/exact_matcher.rb +12 -6
  10. data/lib/licensee/matchers/gemspec_matcher.rb +11 -11
  11. data/lib/licensee/matchers/npm_bower_matcher.rb +10 -10
  12. data/lib/licensee/matchers/package_matcher.rb +11 -10
  13. data/lib/licensee/project.rb +96 -30
  14. data/lib/licensee/project_file.rb +57 -77
  15. data/lib/licensee/version.rb +1 -1
  16. data/licensee.gemspec +26 -0
  17. data/test/fixtures/npm.git/HEAD +1 -0
  18. data/test/fixtures/npm.git/config +4 -0
  19. data/test/fixtures/npm.git/objects/info/packs +2 -0
  20. data/test/fixtures/npm.git/objects/pack/pack-03c0879445cabcc37f91d97c7955465adef26f4a.idx +0 -0
  21. data/test/fixtures/npm.git/objects/pack/pack-03c0879445cabcc37f91d97c7955465adef26f4a.pack +0 -0
  22. data/test/fixtures/npm.git/packed-refs +2 -0
  23. data/test/functions.rb +4 -15
  24. data/test/test_licensee.rb +1 -13
  25. data/test/test_licensee_copyright_matcher.rb +19 -28
  26. data/test/test_licensee_dice_matcher.rb +21 -0
  27. data/test/test_licensee_exact_matcher.rb +4 -6
  28. data/test/test_licensee_gemspec_matcher.rb +3 -11
  29. data/test/test_licensee_license.rb +2 -12
  30. data/test/test_licensee_npm_bower_matcher.rb +10 -16
  31. data/test/test_licensee_project.rb +24 -35
  32. data/test/test_licensee_project_file.rb +5 -10
  33. data/vendor/choosealicense.com/_licenses/afl-3.0.txt +69 -0
  34. data/vendor/choosealicense.com/_licenses/isc.txt +2 -2
  35. metadata +14 -26
  36. data/lib/licensee/filesystem_repository.rb +0 -38
  37. data/lib/licensee/matcher.rb +0 -32
  38. data/lib/licensee/matchers/git_matcher.rb +0 -27
  39. data/lib/licensee/matchers/levenshtein_matcher.rb +0 -75
  40. data/test/test_licensee_content_helper.rb +0 -40
  41. data/test/test_licensee_git_matcher.rb +0 -19
  42. data/test/test_licensee_levenshtein_matcher.rb +0 -34
  43. data/test/test_licensee_matcher.rb +0 -7
@@ -0,0 +1,69 @@
1
+ ---
2
+ title: Academic Free License v3.0
3
+ source: http://opensource.org/licenses/afl-3.0
4
+
5
+ description: The Academic Free License is a variant of the Open Source License that does not require that the source code of derivative works be disclosed. It contains explicit copyright and patent grants and reserves trademark rights in the author.
6
+
7
+ hidden: true
8
+
9
+ how: Create a text file (typically named LICENSE or LICENSE.txt) in the root of your source code and copy the text of the license into the file. Files licensed under OSL 3.0 must also include the notice "Licensed under the Academic Free License version 3.0" adjacent to the copyright notice.
10
+
11
+ required:
12
+ - include-copyright
13
+
14
+ permitted:
15
+ - commercial-use
16
+ - modifications
17
+ - distribution
18
+ - sublicense
19
+ - private-use
20
+ - patent-grant
21
+
22
+ forbidden:
23
+ - trademark-use
24
+ - no-liability
25
+
26
+ ---
27
+ Academic Free License (“AFL”) v. 3.0
28
+
29
+ This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work:
30
+
31
+ Licensed under the Academic Free License version 3.0
32
+
33
+ 1) Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
34
+
35
+ a) to reproduce the Original Work in copies, either alone or as part of a collective work;
36
+ b) to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
37
+ c) to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor’s reserved rights and remedies, in this Academic Free License;
38
+ d) to perform the Original Work publicly; and
39
+ e) to display the Original Work publicly.
40
+
41
+ 2) Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
42
+
43
+ 3) Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
44
+
45
+ 4) Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor’s trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
46
+
47
+ 5) External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
48
+
49
+ 6) Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
50
+
51
+ 7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
52
+
53
+ 8) Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
54
+
55
+ 9) Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including “fair use” or “fair dealing”). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
56
+
57
+ 10) Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
58
+
59
+ 11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
60
+
61
+ 12) Attorneys’ Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
62
+
63
+ 13) Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
64
+
65
+ 14) Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
66
+
67
+ 15) Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
68
+
69
+ 16) Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
@@ -6,7 +6,7 @@ source: http://opensource.org/licenses/isc-license
6
6
 
7
7
  description: A permissive license lets people do anything with your code with proper attribution and without warranty. The ISC license is functionally equivalent to the <a href="/licenses/bsd">BSD 2-Clause</a> and <a href="/licenses/mit">MIT</a> licenses, removing some language that is no longer necessary.
8
8
 
9
- how: Create a text file (typically named LICENSE or LICENSE.txt) in the root of your source code and copy the text of the license into the file. Replace [year] with the current year and [fullname] with the name (or names) of the copyright holders. [email] is optional but recommended.
9
+ how: Create a text file (typically named LICENSE or LICENSE.txt) in the root of your source code and copy the text of the license into the file. Replace [year] with the current year and [fullname] with the name (or names) of the copyright holders.
10
10
 
11
11
  required:
12
12
  - include-copyright
@@ -23,7 +23,7 @@ forbidden:
23
23
 
24
24
  ---
25
25
 
26
- Copyright (c) [year], [fullname] <[email]>
26
+ Copyright (c) [year], [fullname]
27
27
 
28
28
  Permission to use, copy, modify, and/or distribute this software for any
29
29
  purpose with or without fee is hereby granted, provided that the above
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: licensee
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 6.0.0b1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Balter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-08 00:00:00.000000000 Z
11
+ date: 2015-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rugged
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.23'
27
- - !ruby/object:Gem::Dependency
28
- name: levenshtein-ffi
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.1'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.1'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: pry
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -108,19 +94,17 @@ files:
108
94
  - bin/licensee
109
95
  - lib/licensee.rb
110
96
  - lib/licensee/content_helper.rb
111
- - lib/licensee/filesystem_repository.rb
112
97
  - lib/licensee/license.rb
113
- - lib/licensee/matcher.rb
114
98
  - lib/licensee/matchers/copyright_matcher.rb
99
+ - lib/licensee/matchers/dice_matcher.rb
115
100
  - lib/licensee/matchers/exact_matcher.rb
116
101
  - lib/licensee/matchers/gemspec_matcher.rb
117
- - lib/licensee/matchers/git_matcher.rb
118
- - lib/licensee/matchers/levenshtein_matcher.rb
119
102
  - lib/licensee/matchers/npm_bower_matcher.rb
120
103
  - lib/licensee/matchers/package_matcher.rb
121
104
  - lib/licensee/project.rb
122
105
  - lib/licensee/project_file.rb
123
106
  - lib/licensee/version.rb
107
+ - licensee.gemspec
124
108
  - test/fixtures/bower/bower.json
125
109
  - test/fixtures/case-sensitive.git/HEAD
126
110
  - test/fixtures/case-sensitive.git/config
@@ -175,23 +159,27 @@ files:
175
159
  - test/fixtures/no-license.git/objects/ff/1592f44259635df9feda5e02853964b26f9e4d
176
160
  - test/fixtures/no-license.git/refs/heads/master
177
161
  - test/fixtures/npm-non-spdx/package.json
162
+ - test/fixtures/npm.git/HEAD
163
+ - test/fixtures/npm.git/config
164
+ - test/fixtures/npm.git/objects/info/packs
165
+ - test/fixtures/npm.git/objects/pack/pack-03c0879445cabcc37f91d97c7955465adef26f4a.idx
166
+ - test/fixtures/npm.git/objects/pack/pack-03c0879445cabcc37f91d97c7955465adef26f4a.pack
167
+ - test/fixtures/npm.git/packed-refs
178
168
  - test/fixtures/npm/package.json
179
169
  - test/functions.rb
180
170
  - test/helper.rb
181
171
  - test/test_licensee.rb
182
172
  - test/test_licensee_bin.rb
183
- - test/test_licensee_content_helper.rb
184
173
  - test/test_licensee_copyright_matcher.rb
174
+ - test/test_licensee_dice_matcher.rb
185
175
  - test/test_licensee_exact_matcher.rb
186
176
  - test/test_licensee_gemspec_matcher.rb
187
- - test/test_licensee_git_matcher.rb
188
- - test/test_licensee_levenshtein_matcher.rb
189
177
  - test/test_licensee_license.rb
190
- - test/test_licensee_matcher.rb
191
178
  - test/test_licensee_npm_bower_matcher.rb
192
179
  - test/test_licensee_project.rb
193
180
  - test/test_licensee_project_file.rb
194
181
  - test/test_licensee_vendor.rb
182
+ - vendor/choosealicense.com/_licenses/afl-3.0.txt
195
183
  - vendor/choosealicense.com/_licenses/agpl-3.0.txt
196
184
  - vendor/choosealicense.com/_licenses/apache-2.0.txt
197
185
  - vendor/choosealicense.com/_licenses/artistic-2.0.txt
@@ -229,9 +217,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
229
217
  version: '0'
230
218
  required_rubygems_version: !ruby/object:Gem::Requirement
231
219
  requirements:
232
- - - ">="
220
+ - - ">"
233
221
  - !ruby/object:Gem::Version
234
- version: '0'
222
+ version: 1.3.1
235
223
  requirements: []
236
224
  rubyforge_project:
237
225
  rubygems_version: 2.4.8
@@ -1,38 +0,0 @@
1
- class Licensee
2
- class FilesystemRepository
3
- def initialize(path)
4
- @path = path
5
- end
6
-
7
- def last_commit() self end
8
-
9
- def tree
10
- return to_enum(__method__) unless block_given?
11
- Dir.entries(@path).each do |name|
12
- filename = File.join @path, name
13
- next if File.directory? filename
14
- yield(:name => name, :type => :blob, :oid => filename)
15
- end
16
- end
17
-
18
- def lookup(filename)
19
- Blob.new File.read(filename)
20
- end
21
-
22
- Blob = Struct.new(:content) do
23
- def size
24
- content.size
25
- end
26
-
27
- def similarity(other)
28
- self.hashsig ? Rugged::Blob::HashSignature.compare(self.hashsig, other) : 0
29
- end
30
-
31
- def hashsig(options = 0)
32
- @hashsig ||= Rugged::Blob::HashSignature.new(content, options)
33
- rescue Rugged::InvalidError
34
- nil
35
- end
36
- end
37
- end
38
- end
@@ -1,32 +0,0 @@
1
- # Abstract class to describe different matching strategies
2
- # Must respond to:
3
- # - match
4
- # - confidence
5
- #
6
- # Can assume file will be a Licensee::LicenseFile instance
7
- class Licensee
8
- class Matcher
9
- attr_reader :file
10
-
11
- def self.match(file)
12
- self.new(file).match
13
- end
14
-
15
- def self.package_manager?
16
- false
17
- end
18
-
19
- def initialize(file)
20
- @file = file
21
- end
22
-
23
- def match
24
- nil
25
- end
26
-
27
- def confidence
28
- 0
29
- end
30
- alias_method :similarity, :confidence
31
- end
32
- end
@@ -1,27 +0,0 @@
1
- class Licensee
2
- class GitMatcher < Matcher
3
-
4
- def match
5
- match_info[0] if match_info && match_info[1] >= Licensee.confidence_threshold
6
- end
7
-
8
- def confidence
9
- match_info[1] unless match_info.nil?
10
- end
11
-
12
- private
13
-
14
- def matches
15
- @matches ||= Licensee.licenses(:hidden => true).map { |l| [l, file.similarity(l)] }.select { |l,sim| sim > 0 }
16
- end
17
-
18
- # Pulled out for easier testing
19
- def match_info
20
- return @match_info if defined? @match_info
21
- @match_info = begin
22
- match = matches.max_by { |license, similarity| similarity }
23
- match if match
24
- end
25
- end
26
- end
27
- end
@@ -1,75 +0,0 @@
1
- class Licensee
2
- class LevenshteinMatcher < Matcher
3
-
4
- # Return the first potential license that is more similar than the confidence threshold
5
- def match
6
- return @match if defined? @match
7
- @match = potential_licenses.find do |license|
8
-
9
- # If we know the license text contains the license name or nickname,
10
- # bail early unless the file we're checking contains it.
11
- # Guards against OSL & AFL confusion. See https://github.com/benbalter/licensee/issues/50
12
- next if license.body_includes_name? && !includes_license_name?(license)
13
- next if license.body_includes_nickname? && !includes_license_nickname?(license)
14
-
15
- similarity(license) >= Licensee.confidence_threshold
16
- end
17
- end
18
-
19
- # Sort all licenses, in decending order, by difference in length to the file
20
- # Difference in lengths cannot exceed the file's length * the confidence threshold / 100
21
- def potential_licenses
22
- @potential_licenses ||= begin
23
- licenses = Licensee.licenses(:hidden => true)
24
- licenses = licenses.select do |license|
25
- license.body_normalized && length_delta(license) <= max_delta
26
- end
27
- licenses.sort_by { |l| length_delta(l) }
28
- end
29
- end
30
-
31
- # Calculate the difference between the file length and a given license's length
32
- def length_delta(license)
33
- (file_length - license.body_normalized.length).abs
34
- end
35
-
36
- # Maximum possible difference between file length and license length
37
- # for a license to be a potential license to be matched
38
- def max_delta
39
- @max_delta ||= (file_length * (Licensee.confidence_threshold.to_f / 100.to_f ))
40
- end
41
-
42
- # Confidence that the matched license is a match
43
- def confidence
44
- @confidence ||= match ? similarity(match) : 0
45
- end
46
-
47
- private
48
-
49
- # Length of the file, normalized to strip whitespace
50
- def file_length
51
- @file_length ||= file.content_normalized.length.to_f
52
- end
53
-
54
- # Calculate percent changed between file and potential license
55
- def similarity(license)
56
- 100 * (file_length - distance(license)) / file_length
57
- end
58
-
59
- # Calculate the levenshtein distance between file and license
60
- # Note: We used content/body normalized because white space and capitalization
61
- # isn't legally significant in this context. Fewer characters lets levenshtein
62
- # work faster. As long as they both undergo the same transformation, should match.
63
- def distance(license)
64
- Levenshtein.distance(license.body_normalized, file.content_normalized).to_f
65
- end
66
-
67
- def includes_license_name?(license)
68
- file.content_normalized.include?(license.name_without_version.downcase)
69
- end
70
-
71
- def includes_license_nickname?(license)
72
- license.nickname && file.content_normalized.include?(license.nickname.downcase)
73
- end
74
- end
75
- end
@@ -1,40 +0,0 @@
1
- require 'helper'
2
-
3
- class TestHelper
4
- include Licensee::ContentHelper
5
- end
6
-
7
- class TestLicenseeContentHelper < Minitest::Test
8
-
9
- def setup
10
- @helper = TestHelper.new
11
- end
12
-
13
- def normalize(content)
14
- @helper.normalize_content(content)
15
- end
16
-
17
- should "downcase content" do
18
- assert_equal "foo", normalize("Foo")
19
- end
20
-
21
- should "strip leading whitespace" do
22
- assert_equal "foo", normalize("\n Foo")
23
- end
24
-
25
- should "strip trailing whitespace" do
26
- assert_equal "foo", normalize("Foo \n ")
27
- end
28
-
29
- should "strip double spaces" do
30
- assert_equal "foo bar", normalize("Foo bar")
31
- end
32
-
33
- should "strip copyrights" do
34
- assert_equal "foo", normalize("Copyright (c) 2015 Ben Balter\nFoo")
35
- end
36
-
37
- should "strip null bytes" do
38
- assert_equal "foo", normalize("\u0000Foo")
39
- end
40
- end
@@ -1,19 +0,0 @@
1
- require 'helper'
2
-
3
- class TestLicenseeGitMatcher < Minitest::Test
4
-
5
- def setup
6
- text = license_from_path( Licensee::License.find("mit").path )
7
- blob = FakeBlob.new(text)
8
- @mit = Licensee::ProjectFile.new(blob, "LICENSE")
9
- end
10
-
11
- should "match the license" do
12
- assert_equal "mit", Licensee::GitMatcher.match(@mit).key
13
- end
14
-
15
- should "know the match confidence" do
16
- assert_equal 94, Licensee::GitMatcher.new(@mit).confidence
17
- end
18
-
19
- end
@@ -1,34 +0,0 @@
1
- require 'helper'
2
-
3
- class TestLicenseeLevenshteinMatcher < Minitest::Test
4
-
5
- def setup
6
- text = license_from_path( Licensee::License.find("mit").path )
7
- blob = FakeBlob.new(text)
8
- @mit = Licensee::ProjectFile.new(blob, "LICENSE")
9
- end
10
-
11
- should "match the license" do
12
- assert_equal "mit", Licensee::LevenshteinMatcher.match(@mit).key
13
- end
14
-
15
- should "know the match confidence" do
16
- matcher = Licensee::LevenshteinMatcher.new(@mit)
17
- assert matcher.confidence > 98, "#{matcher.confidence} < 98"
18
- end
19
-
20
- should "calculate max delta" do
21
- assert_equal 937.8000000000001, Licensee::LevenshteinMatcher.new(@mit).max_delta
22
- end
23
-
24
- should "calculate length delta" do
25
- isc = Licensee::License.find("isc")
26
- assert_equal 0.0, Licensee::LevenshteinMatcher.new(@mit).length_delta(Licensee::License.find("mit"))
27
- assert_equal 347.0, Licensee::LevenshteinMatcher.new(@mit).length_delta(isc)
28
- end
29
-
30
- should "round up potential licenses" do
31
- assert_equal 7, Licensee::LevenshteinMatcher.new(@mit).potential_licenses.size
32
- end
33
-
34
- end