licensee 3.0.0 → 4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 839782ad5361d8938500dd5938eb33e38a821d9a
4
- data.tar.gz: a688eb2acdf6a1da457cdcf4037a346e4b20691c
3
+ metadata.gz: 6d766a47dd9215350c16975d59ac9053d2e1b2e7
4
+ data.tar.gz: df2aed7e4d51620490bc20737beddf11c3f4ffca
5
5
  SHA512:
6
- metadata.gz: 61151787e52a75c131b53b6ffdc38e8e8c7140546837e39bc3586bf87928d43b12505ee5f983b853520c6f65d1c742c0b3c381200df95b824a8a957bb031576a
7
- data.tar.gz: 9bfe7533e62e998eb1406c663ba93bf2db81f85a92d274f1efb5f2d389f6e6e029e88b64ba94955d4dc322545254506287734d767b37ae70b40840238083cf7d
6
+ metadata.gz: ea10fa6deca9df416c8977d1577be155ed13a12d8750c593ed9da4d034ac052f4043800a8c06d7fc86bed1c3bb153850fad1abd4cebefede831754f1534feb03
7
+ data.tar.gz: 5dd629e1f02dba2d815eb052d3ae99be780196fbecd53c512002afdf28703ad4a8ad9cbfeac52fa39fd3b7dd1032b72f8f6fb314c26589b72c5c23349323ca19
data/README.md CHANGED
@@ -34,7 +34,10 @@ Licensee will even diff the distributed license with the original, so you can se
34
34
  license = Licensee.license "/path/to/a/project"
35
35
  => #<Licensee::License name="MIT" match=0.9842154131847726>
36
36
 
37
- license.meta["title"]
37
+ license.key
38
+ => "mit"
39
+
40
+ license.name
38
41
  => "MIT License"
39
42
 
40
43
  license.meta["source"]
@@ -1,14 +1,14 @@
1
1
  class Licensee
2
2
  class License
3
- attr_reader :name
3
+ attr_reader :key
4
4
 
5
- def initialize(name)
6
- @name=name.downcase
5
+ def initialize(key)
6
+ @key=key.downcase
7
7
  end
8
8
 
9
9
  # Path to vendored license file on disk
10
10
  def path
11
- @path ||= File.expand_path "#{@name}.txt", Licensee::Licenses.base
11
+ @path ||= File.expand_path "#{@key}.txt", Licensee::Licenses.base
12
12
  end
13
13
 
14
14
  # Raw content of license file, including YAML front matter
@@ -18,11 +18,20 @@ class Licensee
18
18
 
19
19
  # License metadata from YAML front matter
20
20
  def meta
21
- @meta ||= front_matter = YAML.load(parts[1]) if parts[1]
21
+ @meta ||= YAML.load(parts[1]) if parts[1]
22
22
  rescue
23
23
  nil
24
24
  end
25
25
 
26
+ def name
27
+ meta["title"] if meta
28
+ end
29
+
30
+ def featured?
31
+ meta["featured"] if meta
32
+ end
33
+ alias_method :featured, :featured?
34
+
26
35
  # The license body (e.g., contents - frontmatter)
27
36
  def body
28
37
  @body ||= parts[2]
@@ -42,7 +51,7 @@ class Licensee
42
51
  end
43
52
 
44
53
  def inspect
45
- "#<Licensee::License name=\"#{name}\">"
54
+ "#<Licensee::License key= \"#{key}\" name=\"#{name}\">"
46
55
  end
47
56
 
48
57
  private
@@ -6,14 +6,14 @@ class Licensee
6
6
  def list
7
7
  @licenses ||= begin
8
8
  licenses = []
9
- names.each { |name| licenses.push License.new(name) }
9
+ keys.each { |key| licenses.push License.new(key) }
10
10
  licenses
11
11
  end
12
12
  end
13
13
 
14
- # Given a license name, attempt to return a matching Licensee::License instance
15
- def find(name)
16
- list.find { |l| l.name.downcase == name.downcase }
14
+ # Given a license key, attempt to return a matching Licensee::License instance
15
+ def find(key)
16
+ list.find { |l| l.key.downcase == key.downcase }
17
17
  end
18
18
 
19
19
  # Path to vendored licenses
@@ -23,13 +23,13 @@ class Licensee
23
23
 
24
24
  private
25
25
 
26
- # Returns a list of potential license names, as vendored
27
- def names
28
- @names ||= begin
29
- names = Dir.entries(base)
30
- names.map! { |l| File.basename(l, ".txt").downcase }
31
- names.reject! { |l| l =~ /^\./ || l.nil? }
32
- names
26
+ # Returns a list of potential license keys, as vendored
27
+ def keys
28
+ @keys ||= begin
29
+ keyes = Dir.entries(base)
30
+ keyes.map! { |l| File.basename(l, ".txt").downcase }
31
+ keyes.reject! { |l| l =~ /^\./ || l.nil? }
32
+ keyes
33
33
  end
34
34
  end
35
35
 
@@ -1,3 +1,3 @@
1
1
  class Licensee
2
- VERSION = "3.0.0"
2
+ VERSION = "4.0.0"
3
3
  end
@@ -57,7 +57,7 @@ def verify_license_file(license, chaos = false, wrap=false)
57
57
 
58
58
  actual = license_file.match
59
59
  assert actual, "No match for #{expected}."
60
- assert_equal expected, actual.name, "expeceted #{expected} but got #{actual.name} for .match. Confidence: #{license_file.confidence}. Method: #{license_file.matcher.class}"
60
+ assert_equal expected, actual.key, "expeceted #{expected} but got #{actual.key} for .match. Confidence: #{license_file.confidence}. Method: #{license_file.matcher.class}"
61
61
  end
62
62
 
63
63
  def wrap(text, line_width=80)
@@ -8,7 +8,7 @@ class TestLicensee < Minitest::Test
8
8
  end
9
9
 
10
10
  should "detect a project's license" do
11
- assert_equal "mit", Licensee.license(fixture_path("licenses.git")).name
11
+ assert_equal "mit", Licensee.license(fixture_path("licenses.git")).key
12
12
  end
13
13
 
14
14
  should "diff a license" do
@@ -9,7 +9,7 @@ class TestLicenseeExactMatcher < Minitest::Test
9
9
  end
10
10
 
11
11
  should "match the license" do
12
- assert_equal "mit", Licensee::ExactMatcher.match(@mit).name
12
+ assert_equal "mit", Licensee::ExactMatcher.match(@mit).key
13
13
  end
14
14
 
15
15
  should "know the match confidence" do
@@ -9,7 +9,7 @@ class TestLicenseeGitMatcher < Minitest::Test
9
9
  end
10
10
 
11
11
  should "match the license" do
12
- assert_equal "mit", Licensee::GitMatcher.match(@mit).name
12
+ assert_equal "mit", Licensee::GitMatcher.match(@mit).key
13
13
  end
14
14
 
15
15
  should "know the match confidence" do
@@ -9,7 +9,7 @@ class TestLicenseeLevenshteinMatcher < Minitest::Test
9
9
  end
10
10
 
11
11
  should "match the license" do
12
- assert_equal "mit", Licensee::LevenshteinMatcher.match(@mit).name
12
+ assert_equal "mit", Licensee::LevenshteinMatcher.match(@mit).key
13
13
  end
14
14
 
15
15
  should "know the match confidence" do
@@ -15,4 +15,24 @@ class TestLicenseeLicense < Minitest::Test
15
15
  assert_equal "MIT License", @license.meta["title"]
16
16
  end
17
17
 
18
+ should "know the license path" do
19
+ assert_equal File.expand_path("./vendor/choosealicense.com/_licenses/mit.txt"), @license.path
20
+ end
21
+
22
+ should "know the license name" do
23
+ assert_equal "MIT License", @license.name
24
+ end
25
+
26
+ should "know the license ID" do
27
+ assert_equal "mit", @license.key
28
+ end
29
+
30
+ should "know if the license is featured" do
31
+ assert @license.featured?
32
+ refute Licensee::License.new("cc0").featured?
33
+ end
34
+
35
+ should "parse the license parts" do
36
+ assert_equal 3, @license.send(:parts).size
37
+ end
18
38
  end
@@ -15,7 +15,7 @@ class TestLicenseeLicenseFile < Minitest::Test
15
15
  end
16
16
 
17
17
  should "match the license" do
18
- assert_equal "mit", @file.match.name
18
+ assert_equal "mit", @file.match.key
19
19
  end
20
20
 
21
21
  should "diff the file" do
@@ -3,8 +3,8 @@ require 'helper'
3
3
  class TestLicenseeLicenses < Minitest::Test
4
4
 
5
5
  should "know license names" do
6
- assert_equal Array, Licensee::Licenses.send(:names).class
7
- assert_equal 15, Licensee::Licenses.send(:names).size
6
+ assert_equal Array, Licensee::Licenses.send(:keys).class
7
+ assert_equal 15, Licensee::Licenses.send(:keys).size
8
8
  end
9
9
 
10
10
  should "load the licenses" do
@@ -14,8 +14,8 @@ class TestLicenseeLicenses < Minitest::Test
14
14
  end
15
15
 
16
16
  should "find a license" do
17
- assert_equal "mit", Licensee::Licenses.find("mit").name
18
- assert_equal "mit", Licensee::Licenses.find("MIT").name
17
+ assert_equal "mit", Licensee::Licenses.find("mit").key
18
+ assert_equal "mit", Licensee::Licenses.find("MIT").key
19
19
  end
20
20
 
21
21
  end
@@ -11,6 +11,6 @@ class TestLicenseeProject < Minitest::Test
11
11
  end
12
12
 
13
13
  should "detect the license" do
14
- assert_equal "mit", @project.license.name
14
+ assert_equal "mit", @project.license.key
15
15
  end
16
16
  end
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: 3.0.0
4
+ version: 4.0.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: 2014-10-10 00:00:00.000000000 Z
11
+ date: 2014-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rugged