licensee 6.1.1 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +2 -2
  3. data/bin/licensee +7 -4
  4. data/lib/licensee.rb +25 -22
  5. data/lib/licensee/content_helper.rb +5 -4
  6. data/lib/licensee/license.rb +56 -45
  7. data/lib/licensee/matchers/copyright_matcher.rb +2 -2
  8. data/lib/licensee/matchers/dice_matcher.rb +7 -4
  9. data/lib/licensee/matchers/exact_matcher.rb +2 -2
  10. data/lib/licensee/matchers/gemspec_matcher.rb +5 -2
  11. data/lib/licensee/matchers/npm_bower_matcher.rb +5 -2
  12. data/lib/licensee/matchers/package_matcher.rb +2 -2
  13. data/lib/licensee/project.rb +21 -96
  14. data/lib/licensee/project_file.rb +6 -7
  15. data/lib/licensee/project_files/license_file.rb +3 -3
  16. data/lib/licensee/project_files/package_info.rb +7 -7
  17. data/lib/licensee/project_files/readme.rb +24 -0
  18. data/lib/licensee/projects/fs_project.rb +32 -0
  19. data/lib/licensee/projects/git_project.rb +55 -0
  20. data/lib/licensee/version.rb +2 -2
  21. data/test/fixtures/bower-with-readme/README.md +1 -0
  22. data/test/fixtures/bower-with-readme/bower.json +3 -0
  23. data/test/functions.rb +23 -12
  24. data/test/helper.rb +5 -0
  25. data/test/test_licensee.rb +9 -8
  26. data/test/test_licensee_bin.rb +11 -5
  27. data/test/test_licensee_copyright_matcher.rb +23 -23
  28. data/test/test_licensee_dice_matcher.rb +5 -5
  29. data/test/test_licensee_exact_matcher.rb +4 -4
  30. data/test/test_licensee_gemspec_matcher.rb +4 -4
  31. data/test/test_licensee_license.rb +82 -70
  32. data/test/test_licensee_license_file.rb +30 -28
  33. data/test/test_licensee_npm_bower_matcher.rb +11 -11
  34. data/test/test_licensee_package_info.rb +8 -7
  35. data/test/test_licensee_project.rb +45 -37
  36. data/test/test_licensee_project_file.rb +9 -9
  37. data/test/test_licensee_readme.rb +47 -0
  38. data/test/test_licensee_vendor.rb +10 -7
  39. data/vendor/choosealicense.com/_licenses/afl-3.0.txt +0 -3
  40. data/vendor/choosealicense.com/_licenses/agpl-3.0.txt +5 -5
  41. data/vendor/choosealicense.com/_licenses/apache-2.0.txt +1 -2
  42. data/vendor/choosealicense.com/_licenses/artistic-2.0.txt +14 -13
  43. data/vendor/choosealicense.com/_licenses/bsd-2-clause.txt +2 -3
  44. data/vendor/choosealicense.com/_licenses/bsd-3-clause-clear.txt +0 -6
  45. data/vendor/choosealicense.com/_licenses/bsd-3-clause.txt +2 -4
  46. data/vendor/choosealicense.com/_licenses/cc0-1.0.txt +2 -1
  47. data/vendor/choosealicense.com/_licenses/epl-1.0.txt +2 -1
  48. data/vendor/choosealicense.com/_licenses/eupl-1.1.txt +345 -0
  49. data/vendor/choosealicense.com/_licenses/gpl-2.0.txt +5 -5
  50. data/vendor/choosealicense.com/_licenses/gpl-3.0.txt +5 -4
  51. data/vendor/choosealicense.com/_licenses/isc.txt +1 -2
  52. data/vendor/choosealicense.com/_licenses/lgpl-2.1.txt +5 -6
  53. data/vendor/choosealicense.com/_licenses/lgpl-3.0.txt +8 -8
  54. data/vendor/choosealicense.com/_licenses/lppl-1.3c.txt +445 -0
  55. data/vendor/choosealicense.com/_licenses/mit.txt +1 -1
  56. data/vendor/choosealicense.com/_licenses/mpl-2.0.txt +2 -1
  57. data/vendor/choosealicense.com/_licenses/ms-pl.txt +0 -1
  58. data/vendor/choosealicense.com/_licenses/ms-rl.txt +1 -1
  59. data/vendor/choosealicense.com/_licenses/ofl-1.1.txt +1 -2
  60. data/vendor/choosealicense.com/_licenses/osl-3.0.txt +1 -3
  61. data/vendor/choosealicense.com/_licenses/unlicense.txt +1 -2
  62. data/vendor/choosealicense.com/_licenses/wtfpl.txt +0 -2
  63. metadata +33 -11
  64. data/vendor/choosealicense.com/_licenses/no-license.txt +0 -25
data/test/helper.rb CHANGED
@@ -5,3 +5,8 @@ require 'shoulda'
5
5
  require 'open3'
6
6
  require_relative 'functions'
7
7
  require_relative '../lib/licensee'
8
+
9
+ def assert_license_content(expected, readme)
10
+ content = Licensee::Project::Readme.license_content(readme)
11
+ assert_equal expected, content
12
+ end
@@ -1,27 +1,28 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestLicensee < Minitest::Test
4
- should "know the licenses" do
4
+ should 'know the licenses' do
5
5
  assert_equal Array, Licensee.licenses.class
6
6
  assert_equal 15, Licensee.licenses.size
7
- assert_equal 24, Licensee.licenses(:hidden => true).size
7
+ assert_equal 26, Licensee.licenses(hidden: true).size
8
8
  assert_equal Licensee::License, Licensee.licenses.first.class
9
9
  end
10
10
 
11
11
  should "detect a project's license" do
12
- assert_equal "mit", Licensee.license(fixture_path("licenses.git")).key
12
+ assert_equal 'mit', Licensee.license(fixture_path('licenses.git')).key
13
13
  end
14
14
 
15
- should "init a project" do
16
- assert_equal Licensee::GitProject, Licensee.project(fixture_path("licenses.git")).class
15
+ should 'init a project' do
16
+ project = Licensee.project(fixture_path('licenses.git'))
17
+ assert_equal Licensee::GitProject, project.class
17
18
  end
18
19
 
19
- context "confidence threshold" do
20
- should "return the confidence threshold" do
20
+ context 'confidence threshold' do
21
+ should 'return the confidence threshold' do
21
22
  assert_equal 90, Licensee.confidence_threshold
22
23
  end
23
24
 
24
- should "let the user override the confidence threshold" do
25
+ should 'let the user override the confidence threshold' do
25
26
  Licensee.confidence_threshold = 50
26
27
  assert_equal 50, Licensee.confidence_threshold
27
28
  Licensee.confidence_threshold = 90
@@ -1,12 +1,18 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestLicenseeBin < Minitest::Test
4
- should "work via commandline" do
5
- root = File.expand_path "..", File.dirname(__FILE__)
4
+ should 'work via commandline' do
5
+ root = File.expand_path '..', File.dirname(__FILE__)
6
6
  Dir.chdir root
7
- stdout,stderr,status = Open3.capture3("#{root}/bin/licensee")
8
- assert stdout.include?("License: MIT"), "expected #{stdout} to include `License: MIT`"
9
- assert stdout.include?("License file: LICENSE.md"), "expected #{stdout} to include `Matched file: LICENSE.md`"
7
+ stdout, stderr, status = Open3.capture3("#{root}/bin/licensee")
8
+
9
+ msg = "expected #{stdout} to include `License: MIT`"
10
+ assert stdout.include?('License: MIT'), msg
11
+
12
+ msg = "expected #{stdout} to include `Matched file: LICENSE.md`"
13
+ assert stdout.include?('License file: LICENSE.md'), msg
14
+
10
15
  assert_equal 0, status
16
+ assert stderr.empty?
11
17
  end
12
18
  end
@@ -2,51 +2,51 @@
2
2
  require 'helper'
3
3
 
4
4
  class TestLicenseeCopyrightMatchers < Minitest::Test
5
- should "match the license" do
6
- text = "Copyright 2015 Ben Balter"
5
+ should 'match the license' do
6
+ text = 'Copyright 2015 Ben Balter'
7
7
  file = Licensee::Project::LicenseFile.new(text)
8
- assert_equal "no-license", Licensee::Matchers::Copyright.new(file).match.key
8
+ assert_equal 'no-license', Licensee::Matchers::Copyright.new(file).match.key
9
9
  end
10
10
 
11
- should "know the match confidence" do
12
- text = "Copyright 2015 Ben Balter"
11
+ should 'know the match confidence' do
12
+ text = 'Copyright 2015 Ben Balter'
13
13
  file = Licensee::Project::LicenseFile.new(text)
14
14
  assert_equal 100, Licensee::Matchers::Copyright.new(file).confidence
15
15
  end
16
16
 
17
- should "match Copyright (C) copyright notices" do
18
- text = "Copyright (C) 2015 Ben Balter"
17
+ should 'match Copyright (C) copyright notices' do
18
+ text = 'Copyright (C) 2015 Ben Balter'
19
19
  file = Licensee::Project::LicenseFile.new(text)
20
- assert_equal "no-license", Licensee::Matchers::Copyright.new(file).match.key
20
+ assert_equal 'no-license', Licensee::Matchers::Copyright.new(file).match.key
21
21
  end
22
22
 
23
- should "match Copyright © copyright notices" do
24
- text = "copyright © 2015 Ben Balter"
23
+ should 'match Copyright © copyright notices' do
24
+ text = 'copyright © 2015 Ben Balter'
25
25
  file = Licensee::Project::LicenseFile.new(text)
26
- assert_equal "no-license", Licensee::Matchers::Copyright.new(file).match.key
26
+ assert_equal 'no-license', Licensee::Matchers::Copyright.new(file).match.key
27
27
  end
28
28
 
29
- should "not false positive" do
30
- text = File.open(Licensee::License.find("mit").path).read.split("---").last
29
+ should 'not false positive' do
30
+ text = File.open(Licensee::License.find('mit').path).read.split('---').last
31
31
  file = Licensee::Project::LicenseFile.new(text)
32
32
  assert_equal nil, Licensee::Matchers::Copyright.new(file).match
33
33
  end
34
34
 
35
- should "handle UTF-8 encoded copyright notices" do
36
- text = "Copyright (c) 2010-2014 Simon Hürlimann"
35
+ should 'handle UTF-8 encoded copyright notices' do
36
+ text = 'Copyright (c) 2010-2014 Simon Hürlimann'
37
37
  file = Licensee::Project::LicenseFile.new(text)
38
- assert_equal "no-license", Licensee::Matchers::Copyright.new(file).match.key
38
+ assert_equal 'no-license', Licensee::Matchers::Copyright.new(file).match.key
39
39
  end
40
40
 
41
- should "handle ASCII-8BIT encoded copyright notices" do
42
- text = "Copyright \xC2\xA92015 Ben Balter`".force_encoding("ASCII-8BIT")
41
+ should 'handle ASCII-8BIT encoded copyright notices' do
42
+ text = "Copyright \xC2\xA92015 Ben Balter`".force_encoding('ASCII-8BIT')
43
43
  file = Licensee::Project::LicenseFile.new(text)
44
- assert_equal "no-license", Licensee::Matchers::Copyright.new(file).match.key
44
+ assert_equal 'no-license', Licensee::Matchers::Copyright.new(file).match.key
45
45
  end
46
46
 
47
- should "match comma, separated dates" do
48
- text = "Copyright (c) 2003, 2004 Ben Balter"
47
+ should 'match comma, separated dates' do
48
+ text = 'Copyright (c) 2003, 2004 Ben Balter'
49
49
  file = Licensee::Project::LicenseFile.new(text)
50
- assert_equal "no-license", Licensee::Matchers::Copyright.new(file).match.key
50
+ assert_equal 'no-license', Licensee::Matchers::Copyright.new(file).match.key
51
51
  end
52
- end
52
+ end
@@ -2,20 +2,20 @@ require 'helper'
2
2
 
3
3
  class TestLicenseeDiceMatchers < Minitest::Test
4
4
  def setup
5
- text = license_from_path(Licensee::License.find("mit").path)
5
+ text = license_from_path(Licensee::License.find('mit').path)
6
6
  @mit = Licensee::Project::LicenseFile.new(text)
7
7
  end
8
8
 
9
- should "match the license" do
10
- assert_equal "mit", Licensee::Matchers::Dice.new(@mit).match.key
9
+ should 'match the license' do
10
+ assert_equal 'mit', Licensee::Matchers::Dice.new(@mit).match.key
11
11
  end
12
12
 
13
- should "know the match confidence" do
13
+ should 'know the match confidence' do
14
14
  matcher = Licensee::Matchers::Dice.new(@mit)
15
15
  assert matcher.confidence > 95, "#{matcher.confidence} < 95"
16
16
  end
17
17
 
18
- should "calculate max delta" do
18
+ should 'calculate max delta' do
19
19
  assert_equal 83.7, Licensee::Matchers::Dice.new(@mit).max_delta
20
20
  end
21
21
  end
@@ -2,15 +2,15 @@ require 'helper'
2
2
 
3
3
  class TestLicenseeExactMatchers < Minitest::Test
4
4
  def setup
5
- text = File.open(Licensee::License.find("mit").path).read.split("---").last
5
+ text = File.open(Licensee::License.find('mit').path).read.split('---').last
6
6
  @mit = Licensee::Project::LicenseFile.new(text)
7
7
  end
8
8
 
9
- should "match the license" do
10
- assert_equal "mit", Licensee::Matchers::Exact.new(@mit).match.key
9
+ should 'match the license' do
10
+ assert_equal 'mit', Licensee::Matchers::Exact.new(@mit).match.key
11
11
  end
12
12
 
13
- should "know the match confidence" do
13
+ should 'know the match confidence' do
14
14
  assert_equal 100, Licensee::Matchers::Exact.new(@mit).confidence
15
15
  end
16
16
  end
@@ -1,11 +1,11 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestLicenseeGemspecMatchers < Minitest::Test
4
- should "detect its own license" do
5
- root = File.expand_path "../", File.dirname(__FILE__)
4
+ should 'detect its own license' do
5
+ root = File.expand_path '../', File.dirname(__FILE__)
6
6
  project = Licensee::GitProject.new(root, detect_packages: true)
7
7
  matcher = Licensee::Matchers::Gemspec.new(project.package_file)
8
- assert_equal "mit", matcher.send(:license_property)
9
- assert_equal "mit", matcher.match.key
8
+ assert_equal 'mit', matcher.send(:license_property)
9
+ assert_equal 'mit', matcher.match.key
10
10
  end
11
11
  end
@@ -1,119 +1,127 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestLicenseeLicense < Minitest::Test
4
-
5
4
  def setup
6
- @license = Licensee::License.new "MIT"
5
+ @license = Licensee::License.new 'MIT'
7
6
  end
8
7
 
9
- should "read the license body" do
8
+ should 'read the license body' do
10
9
  assert @license.body
11
- assert @license.text =~ /MIT/, "Expected the following license body to contain MIT:\n#{@license.body}"
10
+ msg = "Expected the following to contain MIT:\n#{@license.body}"
11
+ assert @license.text =~ /MIT/, msg
12
12
  end
13
13
 
14
- should "read the license body if it contains `---`" do
15
- license = Licensee::License.new "MIT"
14
+ should 'read the license body if it contains `---`' do
15
+ license = Licensee::License.new 'MIT'
16
16
  content = "---\nfoo: bar\n---\nSome license\n---------\nsome text\n"
17
17
  license.instance_variable_set(:@raw_content, content)
18
18
  assert_equal "Some license\n---------\nsome text\n", license.body
19
19
  end
20
20
 
21
- should "read the license meta" do
22
- assert_equal "MIT License", @license.meta["title"]
21
+ should 'read the license meta' do
22
+ assert_equal 'MIT License', @license.meta['title']
23
23
  end
24
24
 
25
- should "know the license path" do
26
- assert_equal File.expand_path("./vendor/choosealicense.com/_licenses/mit.txt"), @license.path
25
+ should 'know the license path' do
26
+ path = File.expand_path('./vendor/choosealicense.com/_licenses/mit.txt')
27
+ assert_equal path, @license.path
27
28
  end
28
29
 
29
- should "know the license name" do
30
- assert_equal "MIT License", @license.name
30
+ should 'know the license name' do
31
+ assert_equal 'MIT License', @license.name
31
32
  end
32
33
 
33
- should "know the license nickname" do
34
- expected = "GNU Affero GPL v3.0"
35
- assert_equal expected, Licensee::License.find("agpl-3.0").nickname
34
+ should 'know the license nickname' do
35
+ expected = 'GNU AGPLv3'
36
+ assert_equal expected, Licensee::License.find('agpl-3.0').nickname
36
37
  end
37
38
 
38
- should "know the license ID" do
39
- assert_equal "mit", @license.key
39
+ should 'know the license ID' do
40
+ assert_equal 'mit', @license.key
40
41
  end
41
42
 
42
- should "know the other license" do
43
- assert_equal "other", Licensee::License.find_by_key("other").key
43
+ should 'know the other license' do
44
+ assert_equal 'other', Licensee::License.find_by_key('other').key
44
45
  end
45
46
 
46
- should "know license equality" do
47
- assert @license == Licensee::License.new("MIT")
48
- refute @license == Licensee::License.new("ISC")
49
- refute @license == nil
47
+ should 'know license equality' do
48
+ assert @license == Licensee::License.new('MIT')
49
+ refute @license == Licensee::License.new('ISC')
50
+ refute @license.nil?
50
51
  end
51
52
 
52
- should "know if the license is featured" do
53
+ should 'know if the license is featured' do
53
54
  assert @license.featured?
54
55
  assert_equal TrueClass, @license.featured?.class
55
- refute Licensee::License.new("cc0-1.0").featured?
56
- assert_equal FalseClass, Licensee::License.new("cc0-1.0").featured?.class
56
+ refute Licensee::License.new('cc0-1.0').featured?
57
+ assert_equal FalseClass, Licensee::License.new('cc0-1.0').featured?.class
57
58
  end
58
59
 
59
- should "inject default meta without overriding" do
60
- license = Licensee::License.new("cc0-1.0")
60
+ should 'inject default meta without overriding' do
61
+ license = Licensee::License.new('cc0-1.0')
61
62
 
62
- assert license.meta.has_key? "featured"
63
- assert_equal false, license.meta["featured"]
63
+ assert license.meta.key? 'featured'
64
+ assert_equal false, license.meta['featured']
64
65
 
65
- assert license.meta.has_key? "hidden"
66
- assert_equal false, license.meta["hidden"]
66
+ assert license.meta.key? 'hidden'
67
+ assert_equal false, license.meta['hidden']
67
68
 
68
- assert license.meta.has_key? "variant"
69
- assert_equal true, license.meta["variant"]
69
+ assert license.meta.key? 'variant'
70
+ assert_equal true, license.meta['variant']
70
71
  end
71
72
 
72
- should "know when the license is hidden" do
73
+ should 'know when the license is hidden' do
73
74
  refute @license.hidden?
74
- assert Licensee::License.new("ofl-1.1").hidden?
75
- assert Licensee::License.new("no-license").hidden?
75
+ assert Licensee::License.new('ofl-1.1').hidden?
76
+ assert Licensee::License.new('no-license').hidden?
76
77
  end
77
78
 
78
- should "parse the license parts" do
79
+ should 'parse the license parts' do
79
80
  assert_equal 3, @license.send(:parts).size
80
81
  end
81
82
 
82
- should "build the license URL" do
83
- assert_equal "http://choosealicense.com/licenses/mit/", @license.url
83
+ should 'build the license URL' do
84
+ assert_equal 'http://choosealicense.com/licenses/mit/', @license.url
84
85
  end
85
86
 
86
- should "return all licenses" do
87
+ should 'return all licenses' do
87
88
  assert_equal Array, Licensee::License.all.class
88
89
  assert Licensee::License.all.size > 3
89
90
  end
90
91
 
91
- should "strip leading newlines from the license" do
92
- assert_equal "T", @license.body[0]
92
+ should 'strip leading newlines from the license' do
93
+ assert_equal 'T', @license.body[0]
93
94
  end
94
95
 
95
- should "fail loudly for invalid licenses" do
96
- assert_raises(Licensee::InvalidLicense) { Licensee::License.new("foo").name }
96
+ should 'fail loudly for invalid licenses' do
97
+ assert_raises(Licensee::InvalidLicense) do
98
+ Licensee::License.new('foo').name
99
+ end
97
100
  end
98
101
 
99
102
  should "support 'other' licenses" do
100
- license = Licensee::License.new("other")
103
+ license = Licensee::License.new('other')
101
104
  assert_equal nil, license.content
102
- assert_equal "Other", license.name
105
+ assert_equal 'Other', license.name
103
106
  refute license.featured?
104
107
  end
105
108
 
106
- should "know the license hash" do
107
- assert_equal "fb278496ea4663dfcf41ed672eb7e56eb70de798", @license.hash
109
+ should 'know the license hash' do
110
+ assert_equal 'fb278496ea4663dfcf41ed672eb7e56eb70de798', @license.hash
108
111
  end
109
112
 
110
- describe "name without version" do
111
- should "strip the version from the license name" do
112
- expected = "GNU Affero General Public License"
113
- assert_equal expected, Licensee::License.find("agpl-3.0").name_without_version
114
- expected = "GNU General Public License"
115
- assert_equal expected, Licensee::License.find("gpl-2.0").name_without_version
116
- assert_equal expected, Licensee::License.find("gpl-3.0").name_without_version
113
+ describe 'name without version' do
114
+ should 'strip the version from the license name' do
115
+ expected = 'GNU Affero General Public License'
116
+ name = Licensee::License.find('agpl-3.0').name_without_version
117
+ assert_equal expected, name
118
+
119
+ expected = 'GNU General Public License'
120
+ name = Licensee::License.find('gpl-2.0').name_without_version
121
+ assert_equal expected, name
122
+
123
+ name = Licensee::License.find('gpl-3.0').name_without_version
124
+ assert_equal expected, name
117
125
  end
118
126
 
119
127
  Licensee.licenses.each do |license|
@@ -123,30 +131,34 @@ class TestLicenseeLicense < Minitest::Test
123
131
  end
124
132
  end
125
133
 
126
- describe "class methods" do
127
- should "know license names" do
134
+ describe 'class methods' do
135
+ should 'know license names' do
128
136
  assert_equal Array, Licensee::License.keys.class
129
- assert_equal 24, Licensee::License.keys.size
137
+ assert_equal 26, Licensee::License.keys.size
130
138
  end
131
139
 
132
- should "load the licenses" do
140
+ should 'load the licenses' do
133
141
  assert_equal Array, Licensee::License.all.class
134
142
  assert_equal 15, Licensee::License.all.size
135
143
  assert_equal Licensee::License, Licensee::License.all.first.class
136
144
  end
137
145
 
138
- should "find a license" do
139
- assert_equal "mit", Licensee::License.find("mit").key
140
- assert_equal "mit", Licensee::License.find("MIT").key
141
- assert_equal "mit", Licensee::License["mit"].key
146
+ should 'find a license' do
147
+ assert_equal 'mit', Licensee::License.find('mit').key
148
+ assert_equal 'mit', Licensee::License.find('MIT').key
149
+ assert_equal 'mit', Licensee::License['mit'].key
142
150
  end
143
151
 
144
- should "filter the licenses" do
145
- assert_equal 24, Licensee::License.all(:hidden => true).size
146
- assert_equal 3, Licensee::License.all(:featured => true).size
147
- assert_equal 12, Licensee::License.all(:featured => false).size
148
- assert_equal 21, Licensee::License.all(:featured => false, :hidden => true).size
149
- assert_equal 12, Licensee::License.all(:featured => false, :hidden => false).size
152
+ should 'filter the licenses' do
153
+ assert_equal 26, Licensee::License.all(hidden: true).size
154
+ assert_equal 3, Licensee::License.all(featured: true).size
155
+ assert_equal 12, Licensee::License.all(featured: false).size
156
+
157
+ licenses = Licensee::License.all(featured: false, hidden: true)
158
+ assert_equal 23, licenses.size
159
+
160
+ licenses = Licensee::License.all(featured: false, hidden: false)
161
+ assert_equal 12, licenses.size
150
162
  end
151
163
  end
152
164
  end
@@ -2,54 +2,56 @@ require 'helper'
2
2
 
3
3
  class TestLicenseeLicenseFile < Minitest::Test
4
4
  def setup
5
- @repo = Rugged::Repository.new(fixture_path("licenses.git"))
6
- blob, _ = Rugged::Blob.to_buffer(@repo, 'bcb552d06d9cf1cd4c048a6d3bf716849c2216cc')
5
+ @repo = Rugged::Repository.new(fixture_path('licenses.git'))
6
+ ref = 'bcb552d06d9cf1cd4c048a6d3bf716849c2216cc'
7
+ blob, = Rugged::Blob.to_buffer(@repo, ref)
7
8
  @file = Licensee::Project::LicenseFile.new(blob)
8
9
  end
9
10
 
10
- context "content" do
11
- should "parse the attribution" do
12
- assert_equal "Copyright (c) 2014 Ben Balter", @file.attribution
11
+ context 'content' do
12
+ should 'parse the attribution' do
13
+ assert_equal 'Copyright (c) 2014 Ben Balter', @file.attribution
13
14
  end
14
15
 
15
- should "not choke on non-UTF-8 licenses" do
16
+ should 'not choke on non-UTF-8 licenses' do
16
17
  text = "\x91License\x93".force_encoding('windows-1251')
17
18
  file = Licensee::Project::LicenseFile.new(text)
18
19
  assert_equal nil, file.attribution
19
20
  end
20
21
 
21
- should "create the wordset" do
22
+ should 'create the wordset' do
22
23
  assert_equal 93, @file.wordset.count
23
- assert_equal "the", @file.wordset.first
24
+ assert_equal 'the', @file.wordset.first
24
25
  end
25
26
 
26
- should "create the hash" do
27
- assert_equal "fb278496ea4663dfcf41ed672eb7e56eb70de798", @file.hash
27
+ should 'create the hash' do
28
+ assert_equal 'fb278496ea4663dfcf41ed672eb7e56eb70de798', @file.hash
28
29
  end
29
30
  end
30
31
 
31
- context "license filename scoring" do
32
+ context 'license filename scoring' do
32
33
  EXPECTATIONS = {
33
- "license" => 1.0,
34
- "LICENCE" => 1.0,
35
- "unLICENSE" => 1.0,
36
- "unlicence" => 1.0,
37
- "license.md" => 0.9,
38
- "LICENSE.md" => 0.9,
39
- "license.txt" => 0.9,
40
- "COPYING" => 0.8,
41
- "copyRIGHT" => 0.8,
42
- "COPYRIGHT.txt" => 0.8,
43
- "LICENSE.php" => 0.7,
44
- "LICENSE-MIT" => 0.5,
45
- "MIT-LICENSE.txt" => 0.5,
46
- "mit-license-foo.md" => 0.5,
47
- "README.txt" => 0.0
48
- }
34
+ 'license' => 1.0,
35
+ 'LICENCE' => 1.0,
36
+ 'unLICENSE' => 1.0,
37
+ 'unlicence' => 1.0,
38
+ 'license.md' => 0.9,
39
+ 'LICENSE.md' => 0.9,
40
+ 'license.txt' => 0.9,
41
+ 'COPYING' => 0.8,
42
+ 'copyRIGHT' => 0.8,
43
+ 'COPYRIGHT.txt' => 0.8,
44
+ 'LICENSE.php' => 0.7,
45
+ 'LICENSE-MIT' => 0.5,
46
+ 'MIT-LICENSE.txt' => 0.5,
47
+ 'mit-license-foo.md' => 0.5,
48
+ 'README.txt' => 0.0
49
+ }.freeze
49
50
 
50
51
  EXPECTATIONS.each do |filename, expected|
51
52
  should "score a license named `#{filename}` as `#{expected}`" do
52
- assert_equal expected, Licensee::Project::LicenseFile.name_score(filename)
53
+ score = Licensee::Project::LicenseFile.name_score(filename)
54
+ assert_equal expected, score
53
55
  end
54
56
  end
55
57
  end