gems-license-finder 0.0.3 → 0.0.4

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: f98586f27c7d0fbd33dc870a4ec90e67d7dfcc13
4
- data.tar.gz: c2d415e82f4de573a6bf8c253a75f11ef28a0cc3
3
+ metadata.gz: f6d28fe96a76eaa967e76b832c1e40b5a3ed1b8c
4
+ data.tar.gz: 30241e403daf6db8fc7e412c0095a022d3ad121f
5
5
  SHA512:
6
- metadata.gz: 55ce3bc14c5e56d0f8101a9f67d6207bbec04468ada63ab4bf0363d5f67556ee4d7572d63d91a28bb674032acb91ea216fa919ef5ee170f48b3ca5a264d9b5a8
7
- data.tar.gz: 4955d84a89745a597e6ab1073ee0cdf24273aa8fe34251d2380c5c965a610c445c56209af4c24ed53d7f2895f1e66c9e421eb42840dae3af0edcc0a95b7c9321
6
+ metadata.gz: 901c6b74dd7ae99f75703696da7f6bb6851ac4ebd777fd88deb7b4f98cd0817d5a7e9acc6e16d960a7e6e9273d6e064fcc3668d7846449fc293ae2f95f1aa1b1
7
+ data.tar.gz: 6bb9c63ca23a31538265d1f58bd4f0aad980a439f5c174cc6e32be01e107a152f5a52c22429ac3245e58f62a2f5a74019f3c93b169c341612715494eb22ca20b
@@ -19,10 +19,11 @@ module GemsLicenseFinder
19
19
 
20
20
  class Client
21
21
  LICENSE_FILES = %w[LICENSE LICENSE.md LICENSE.markdown MIT-LICENSE
22
- LICENSE.txt MIT-LICENSE.txt MIT.LICENSE MIT-LICENSE.md
23
- COPYING COPYING.md GNU GNU.txt GNU.rdoc GNU.markdown]
22
+ LICENSE.txt MIT-LICENSE.txt MIT.LICENSE MIT_LICENSE
23
+ MIT-LICENSE.md LICENSE.rdoc License
24
+ COPYING License.txt COPYING.md GNU GNU.txt GNU.rdoc GNU.markdown]
24
25
 
25
- README_FILES = %w[README.md README.rdoc README.markdown README.txt README]
26
+ README_FILES = %w[README.md README.rdoc README.markdown README.txt README README.textile]
26
27
 
27
28
  LICENSES_STRINGS = {
28
29
  "mit" => "Permission is hereby granted",
@@ -66,7 +67,7 @@ module GemsLicenseFinder
66
67
 
67
68
  def github_info name, rubygems
68
69
  url = rubygems["Source Code"] || rubygems["Homepage"]
69
- if url.to_s =~ /github\.com/
70
+ if url.to_s =~ /\/\/github\.com/
70
71
  # Sometimes the homepage in rubygems.org is old, e.g:
71
72
  # carlhuda/bundler => bundler/bundler
72
73
  open(url.sub("http:","https:")) { |o| url = o.base_uri.to_s } # follow redirects
@@ -93,15 +94,22 @@ module GemsLicenseFinder
93
94
  end
94
95
 
95
96
  README_FILES.each do |file|
96
- break if license and type
97
+ break if license and type
97
98
  content = GitHub::Markup.render(file,fetch_github_file(user,repo,file)) rescue next
98
99
  type, lurl = normalize_licence(content) if type.nil?
99
100
 
100
- license ||= "https://github.com/#{user}/#{repo}/blob/master/#{file}#" +
101
- utf8_match(content,'<h\d+>.*?(license.*?)<\/h\d+>')[1].
101
+ rurl = "https://github.com/#{user}/#{repo}/blob/master/#{file}"
102
+
103
+ license ||= rurl + "#" + utf8_match(content,'<h\d+>[\s|\t]*(license.*?)<\/h\d+>')[1].
102
104
  to_s.downcase.gsub(/\s/,"-") rescue nil
103
105
 
106
+ if license.nil? and utf8_match(content,'licen[cs]e')
107
+ license = rurl
108
+ type, lurl = normalize_licence content
109
+ end
110
+
104
111
  type, lurl = type_from_license_text(content) if license and type.nil?
112
+ break if content
105
113
  end
106
114
 
107
115
  info = {license: license, github_url: url}
@@ -118,7 +126,8 @@ module GemsLicenseFinder
118
126
  end
119
127
 
120
128
  def find_github_url name
121
- @github.search.repos(q: "#{name} language:ruby").to_a[1][1][0].html_url
129
+ (@github.search.repos(q: "#{name} language:ruby").to_a[1][1][0] ||
130
+ @github.search.repos(q: "ruby #{name}").to_a[1][1][0]).html_url
122
131
  end
123
132
 
124
133
  def fetch_github_file user, repo, file
@@ -139,27 +148,27 @@ module GemsLicenseFinder
139
148
 
140
149
  def normalize_licence str
141
150
  case str.downcase
142
- when /(^|\W)mit(\W|$)/
151
+ when /(^|\W)mit(\W|$)/i
143
152
  ["MIT","http://choosealicense.com/licenses/mit/"]
144
- when /(^|\W)bsd\W.*?3/
153
+ when /(^|\W)bsd\W.*?3/i
145
154
  ["BSD-3","http://choosealicense.com/licenses/bsd-3-clause/"]
146
- when /(^|\W)bsd(\W|$)/
155
+ when /(^|\W)bsd(\W|$)/i
147
156
  ["BSD","http://choosealicense.com/licenses/bsd/"]
148
- when /(^|\W)apache(\W|$)/
157
+ when /(^|\W)apache(\W|$)/i
149
158
  ["Apache","http://choosealicense.com/licenses/apache/"]
150
- when /(^|\W)lgpl\W.*?3/
159
+ when /(^|\W)lgpl\W.*?3/i
151
160
  ["LGPL-3","http://choosealicense.com/licenses/lgpl-v3/"]
152
- when /(^|\W)lgpl(\W|$)/
161
+ when /(^|\W)lgpl(\W|$)/i
153
162
  ["LGPL","http://choosealicense.com/licenses/lgpl-v2.1/"]
154
- when /(affero)|(agpl)/
163
+ when /(affero)|(agpl)/i
155
164
  ["Affero-GPL","http://choosealicense.com/licenses/agpl/"]
156
- when /(^|\W)gpl\W.*?3/
165
+ when /(^|\W)gpl\W.*?3/i
157
166
  ["GPL-3","http://choosealicense.com/licenses/gpl-v3/"]
158
- when /(^|\W)gpl(\W|$)/
167
+ when /(^|\W)gpl(\W|$)/i
159
168
  ["GPL-2","http://choosealicense.com/licenses/gpl-v2/"]
160
- when /(^|\W)artistic(\W|$)/
169
+ when /(^|\W)artistic(\W|$)/i
161
170
  ["Artistic","http://choosealicense.com/licenses/artistic/"]
162
- when /(license.*?ruby)|(ruby.*?license)/
171
+ when /(licen[sc]e.*?ruby)|(ruby.*?licen[sc]e)/msi
163
172
  ["Ruby","https://www.ruby-lang.org/en/about/license.txt"]
164
173
  when "ruby"
165
174
  ["Ruby","https://www.ruby-lang.org/en/about/license.txt"]
@@ -1,3 +1,3 @@
1
1
  module GemsLicenseFinder
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gems-license-finder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eran Barak Levi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-26 00:00:00.000000000 Z
11
+ date: 2014-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest