licensee 4.5.0 → 4.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d6d6862fe6acd66d17a577ac52357cb55352c355
4
- data.tar.gz: 1e52b8216cd0443e86bf2f6b4bdc67d3a12c6b3c
3
+ metadata.gz: 046dcbf68cab0fbba5bd8624102a73c11fbe2c4e
4
+ data.tar.gz: 2b569387243ebeed517c5b873b8f4529149ba62d
5
5
  SHA512:
6
- metadata.gz: 4afadc876117dca8dae492065fd0145086dafb195f50dd0314e42299f9d4345ab4fc124fce52b89812553fb2cc082037e2ce03807a9cb074c080eb6af5ba8fa6
7
- data.tar.gz: f0028b11795d26f8c23664ee7e010fc7c57eeead50b29c77dd2086dd8f5ee63da05a1459c564751d704e6da7b1fd3f79b753b18bff956691e077d2c7a2c5063a
6
+ metadata.gz: 0fe55bf7698ecc52aaa2de8dd77f85cb8ad9357e29abeeb8a3237a1b258fcb1ca172d7329027d0a6f045e2c869029af20fe342ac91011199e9ccdf5423c05af5
7
+ data.tar.gz: a4f92f1e13d453c7819c52dc591243edde132ec41c9f743c397b06902be2a40019776558ce03b935a3998682962e63af6f902bd4496032d8f79b740fb002d8fd
data/bin/licensee CHANGED
@@ -7,7 +7,7 @@ project = Licensee::Project.new(path)
7
7
  license = project.license_file
8
8
 
9
9
  if license
10
- puts "License file: #{project.send(:license_blob)[:name]}"
10
+ puts "License file: #{license.path}"
11
11
  puts "License: #{license.match ? license.match.meta['title'] : 'no license'}"
12
12
  puts "Confidence: #{license.confidence}%"
13
13
  puts "Method: #{license.matcher.class}"
@@ -1,9 +1,10 @@
1
1
  class Licensee
2
2
  class LicenseFile
3
- attr_reader :blob
3
+ attr_reader :blob, :path
4
4
 
5
- def initialize(blob)
5
+ def initialize(blob, options={})
6
6
  @blob = blob
7
+ @path = options[:path]
7
8
  end
8
9
 
9
10
  def similarity(other)
@@ -37,7 +37,7 @@ class Licensee
37
37
 
38
38
  # Returns an instance of Licensee::LicenseFile if there's a license file detected
39
39
  def license_file
40
- @license_file ||= LicenseFile.new(@repository.lookup(license_blob[:oid])) if license_blob
40
+ @license_file ||= LicenseFile.new(license_blob, :path => license_path) if license_blob
41
41
  end
42
42
 
43
43
  # Returns the matching Licensee::License instance if a license can be detected
@@ -57,12 +57,20 @@ class Licensee
57
57
 
58
58
  # Detects the license file, if any
59
59
  # Returns the blob hash as detected in the tree
60
- def license_blob
60
+ def license_hash
61
61
  # Prefer an exact match to one of our known file names
62
- license_blob = tree.find { |blob| LICENSE_FILENAMES.include? blob[:name].downcase }
62
+ license_hash = tree.find { |blob| LICENSE_FILENAMES.include? blob[:name].downcase }
63
63
 
64
64
  # Fall back to the first file in the project root that has the word license in it
65
- license_blob || tree.find { |blob| blob[:name] =~ /licen(s|c)e/i }
65
+ license_hash || tree.find { |blob| blob[:name] =~ /licen(s|c)e/i }
66
+ end
67
+
68
+ def license_blob
69
+ @repository.lookup(license_hash[:oid]) if license_hash
70
+ end
71
+
72
+ def license_path
73
+ license_hash[:name] if license_hash
66
74
  end
67
75
  end
68
76
  end
@@ -1,3 +1,3 @@
1
1
  class Licensee
2
- VERSION = "4.5.0"
2
+ VERSION = "4.6.0"
3
3
  end
@@ -6,6 +6,7 @@ class TestLicenseeBin < Minitest::Test
6
6
  Dir.chdir root
7
7
  stdout,stderr,status = Open3.capture3("#{root}/bin/licensee")
8
8
  assert stdout.include?("License: MIT"), "expected #{stdout} to include `License: MIT`"
9
+ assert stdout.include?("License file: LICENSE.md"), "expected #{stdout} to include `License file: LICENSE.md`"
9
10
  assert_equal 0, status
10
11
  end
11
12
  end
@@ -36,4 +36,11 @@ class TestLicenseeCopyrightMatcher < Minitest::Test
36
36
  file = Licensee::LicenseFile.new(blob)
37
37
  assert_equal nil, Licensee::CopyrightMatcher.match(file)
38
38
  end
39
+
40
+ should "handle UTF-8 encoded copyright notices" do
41
+ text = "Copyright (c) 2010-2014 Simon Hürlimann"
42
+ blob = FakeBlob.new(text)
43
+ file = Licensee::LicenseFile.new(blob)
44
+ assert_equal "no-license", Licensee::CopyrightMatcher.match(file).key
45
+ end
39
46
  end
@@ -5,7 +5,7 @@ class TestLicenseeLicenseFile < Minitest::Test
5
5
  def setup
6
6
  @repo = Rugged::Repository.new(fixture_path("licenses.git"))
7
7
  blob = 'bcb552d06d9cf1cd4c048a6d3bf716849c2216cc'
8
- @file = Licensee::LicenseFile.new(@repo.lookup(blob))
8
+ @file = Licensee::LicenseFile.new(@repo.lookup(blob), :path => "LICENSE")
9
9
  @gpl = Licensee::Licenses.find "GPL-3.0"
10
10
  @mit = Licensee::Licenses.find "MIT"
11
11
  end
@@ -18,6 +18,10 @@ class TestLicenseeLicenseFile < Minitest::Test
18
18
  assert_equal "mit", @file.match.key
19
19
  end
20
20
 
21
+ should "know the path" do
22
+ assert_equal "LICENSE", @file.path
23
+ end
24
+
21
25
  should "diff the file" do
22
26
  expected = "-Copyright (c) [year] [fullname]\n+Copyright (c) 2014 Ben Balter"
23
27
  assert @file.diff.include?(expected)
@@ -36,9 +36,19 @@ class TestLicenseeProject < Minitest::Test
36
36
  assert_equal "mit", project.license.key
37
37
  end
38
38
 
39
+ should "return the license hash" do
40
+ project = make_project "licenses.git", as_git
41
+ assert_equal "LICENSE", project.send(:license_hash)[:name]
42
+ end
43
+
39
44
  should "return the license blob" do
40
45
  project = make_project "licenses.git", as_git
41
- assert_equal "LICENSE", project.send(:license_blob)[:name]
46
+ assert_equal 1077, project.send(:license_blob).size
47
+ end
48
+
49
+ should "return the license path" do
50
+ project = make_project "licenses.git", as_git
51
+ assert_equal "LICENSE", project.send(:license_path)
42
52
  end
43
53
 
44
54
  should "detect an atypically cased license file" do
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  title: GNU Affero General Public License v3.0
3
+ nickname: GNU Affero GPL v3.0
3
4
  category: GPL
4
5
  tab-slug: agpl-v3
5
6
  hide-from-license-list: true
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  layout: license
3
3
  title: BSD 2-clause "Simplified" License
4
+ nickname: Simplified BSD
4
5
  category: BSD
5
6
  tab-slug: bsd
6
7
  hide-from-license-list: true
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  layout: license
3
3
  title: BSD 3-clause "New" or "Revised" License
4
+ nickname: New BSD
4
5
  category: BSD
5
6
  tab-slug: bsd-3
6
7
  hide-from-license-list: true
@@ -8,7 +9,7 @@ permalink: /licenses/bsd-3-clause/
8
9
 
9
10
  description: A permissive license that comes in two variants, the <a href="/licenses/bsd">BSD 2-Clause</a> and <a href="/licenses/bsd-3-clause">BSD 3-Clause</a>. Both have very minute differences to the MIT license. The three clause variant prohibits others from using the name of the project or its contributors to promote derivative works without written consent.
10
11
 
11
- 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. Replace {organization} with the organization, if any, that sponsors this work.
12
+ 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. Replace [project] with the project organization, if any, that sponsors this work.
12
13
 
13
14
  source: http://opensource.org/licenses/BSD-3-Clause
14
15
 
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  layout: license
3
3
  title: Creative Commons Zero v1.0 Universal
4
+ nickname: CC0 1.0 Universal
4
5
  category: Public Domain Dedication
5
6
  tab-slug: cc0
6
7
  permalink: /licenses/cc0/
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  title: GNU General Public License v2.0
3
+ nickname: GNU GPL v2.0
3
4
  category: GPL
4
5
  tab-slug: gpl-v2
5
6
  hide-from-license-list: false
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  title: GNU General Public License v3.0
3
+ nickname: GNU GPL v3.0
3
4
  category: GPL
4
5
  tab-slug: gpl-v3
5
6
  hide-from-license-list: true
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  layout: license
3
3
  title: GNU Lesser General Public License v2.1
4
+ nickname: GNU LGPL v2.1
4
5
  category: LGPL
5
6
  tab-slug: lgpl-v2_1
6
7
  redirect_from: /licenses/lgpl-v2.1/
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  layout: license
3
3
  title: GNU Lesser General Public License v3.0
4
+ nickname: GNU LGPL v3.0
4
5
  category: LGPL
5
6
  tab-slug: lgpl-v3
6
7
  hide-from-license-list: true
@@ -10,9 +11,9 @@ permalink: /licenses/lgpl-3.0/
10
11
 
11
12
  description: Version 3 of the LGPL is an additional set of permissions to the <a href="/licenses/GPL-3.0">GPL v3 license</a> that requires that derived works be licensed under the same license, but works that only link to it do not fall under this restriction.
12
13
 
13
- how: This license is an additional set of permissions to the <a href="/licenses/gpl-3.0">GPL v3</a> license. Follow the instructions to apply the GPL v3 license. Then either paste this text to the bottom of that file OR add a separate file (typically named COPYING.lesser or LICENSE.lesser) in the root of your source code and copy the text.
14
+ how: This license is an additional set of permissions to the <a href="/licenses/gpl-3.0">GPL v3</a> license. Follow the instructions to apply the GPL v3. Then either paste this text to the bottom of the created file OR add a separate file (typically named COPYING.lesser or LICENSE.lesser) in the root of your source code and copy the text.
14
15
 
15
- note: The Free Software Foundation recommends taking the additional step of adding a boilerplate notice to the top of each file. The boilerplate can be found at the end of the license.
16
+ note: The Free Software Foundation recommends taking the additional step of adding a boilerplate notice to the top of each file. The boilerplate can be found at the end of the <a href="/licenses/gpl-3.0">GPL v3 license</a>. Insert the word “Lesser” before “General” in all three places in the boilerplate notice to make sure that you refer to the LGPL v3 and not the GPL v3.
16
17
 
17
18
  required:
18
19
  - include-copyright
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: 4.5.0
4
+ version: 4.6.0
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-06-24 00:00:00.000000000 Z
11
+ date: 2015-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rugged