licensee 4.7.2 → 4.7.3

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: 8ba75185c14cbfaa45edb5dc8fdb46744c10bcf0
4
- data.tar.gz: f4cf2d3c717c6e4f198d35e76eb3aa72451dd57d
3
+ metadata.gz: 3fab96ab59af3a4a833c477146b855cd1378e1b3
4
+ data.tar.gz: 02e9e05ef12c5692e9a863e7e98fd6c42074e6f6
5
5
  SHA512:
6
- metadata.gz: 82231c76c1ab2d6d77640420f3f850154b835703246a62ac71779f7609b348e2244f6be33b1321dd74944104cc3e01ce5add1e31735f318c3e4389a03b4bc9b8
7
- data.tar.gz: 03d1e3e669f55a1cf3e882a1859e130715a52e7368aaf3506b03917c79483943c850113830103212785400c9ee52d78a65dd8dfcf6f99a000cb4baa517e6cabe
6
+ metadata.gz: 9facdb5802dcc399d23dcd3cc9adcd317c740da3e276d6da8ffa0941a19bf1cad33417780b85be35fe349dd7ceb4a95fbde24b55ce0ff6a58b602741b1ed411c
7
+ data.tar.gz: 3bfed7331ecb9265253da64fd448a8892940692e5d13f0f3f63301d7e2604d2a76d0d019d27536f78cce82382b7e37cf7c9d47ddefaf9db117f3f1b1e5dae0cc
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  *A Ruby Gem to detect under what license a project is distributed.*
4
4
 
5
- [![Build Status](https://travis-ci.org/benbalter/licensee.svg)](https://travis-ci.org/benbalter/licensee) [![Gem Version](https://badge.fury.io/rb/licensee.svg)](http://badge.fury.io/rb/licensee)
5
+ [![Build Status](https://travis-ci.org/benbalter/licensee.svg?branch=master)](https://travis-ci.org/benbalter/licensee) [![Gem Version](https://badge.fury.io/rb/licensee.svg)](http://badge.fury.io/rb/licensee)
6
6
 
7
7
  ## The problem
8
8
 
data/lib/licensee.rb CHANGED
@@ -17,7 +17,7 @@ require_relative "licensee/matchers/levenshtein_matcher"
17
17
 
18
18
  class Licensee
19
19
 
20
- # Over watch percent is a match considered a match
20
+ # Over which percent is a match considered a match
21
21
  CONFIDENCE_THRESHOLD = 90
22
22
 
23
23
  # Base domain from which to build license URLs
@@ -17,7 +17,7 @@ class Licensee
17
17
  # Raw file contents
18
18
  def content
19
19
  @contents ||= begin
20
- blob.content
20
+ blob.content.force_encoding("UTF-8")
21
21
  end
22
22
  end
23
23
  alias_method :to_s, :content
@@ -1,10 +1,12 @@
1
1
  class Licensee
2
2
  class CopyrightMatcher < Matcher
3
3
 
4
- REGEX = /\A(Copyright|Copyright ©|Copyright \(c\)) \d{4}.*?\n?\z/i
4
+ REGEX = /\ACopyright (©|\(c\)|\xC2\xA9)? ?\d{4}.*?\n?\z/i
5
5
 
6
6
  def match
7
7
  no_license if file.content.strip =~ REGEX
8
+ rescue
9
+ nil
8
10
  end
9
11
 
10
12
  def confidence
@@ -38,10 +38,10 @@ class Licensee
38
38
  #
39
39
  # filename - (string) the name of the file to score
40
40
  #
41
- # Returns 1.0 if the file is definately a license file
41
+ # Returns 1.0 if the file is definitely a license file
42
42
  # Returns 0.75 if the file is probably a license file
43
43
  # Returns 0.5 if the file is likely a license file
44
- # Returns 0.0 if the file is definately not a license file
44
+ # Returns 0.0 if the file is definitely not a license file
45
45
  def self.match_license_file(filename)
46
46
  return 1.0 if filename =~ /\A(un)?licen[sc]e(\.[^.]+)?\z/i
47
47
  return 0.75 if filename =~ /\Acopy(ing|right)(\.[^.]+)?\z/i
@@ -1,3 +1,3 @@
1
1
  class Licensee
2
- VERSION = "4.7.2"
2
+ VERSION = "4.7.3"
3
3
  end
@@ -43,4 +43,11 @@ class TestLicenseeCopyrightMatcher < Minitest::Test
43
43
  file = Licensee::LicenseFile.new(blob)
44
44
  assert_equal "no-license", Licensee::CopyrightMatcher.match(file).key
45
45
  end
46
- end
46
+
47
+ should "handle ASCII-8BIT encoded copyright notices" do
48
+ text = "Copyright \xC2\xA92015 Ben Balter`".force_encoding("ASCII-8BIT")
49
+ blob = FakeBlob.new(text)
50
+ file = Licensee::LicenseFile.new(blob)
51
+ assert_equal "no-license", Licensee::CopyrightMatcher.match(file).key
52
+ end
53
+ 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: 4.7.2
4
+ version: 4.7.3
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-07-20 00:00:00.000000000 Z
11
+ date: 2015-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rugged