gems-license-finder 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +34 -16
- data/README.md +52 -1
- data/bin/gems-license-finder +6 -1
- data/lib/gems-license-finder/version.rb +1 -1
- data/lib/gems-license-finder.rb +30 -4
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc20743bac6f1311273501d69701f197bd2c144d267ed21271c4bad421c6920a
|
4
|
+
data.tar.gz: 7a26d48a3954b1e8ce2a3e5671353d0652150cc657dc47ca77963f288115faf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da3ee54712e560cd04b57b8699b2b4e72cf824230a5683f3c6509452ae809ca6cbd5b36aa9bf5296132cc87a29cac0458b84a8218b11618d2ccaa9a68e376258
|
7
|
+
data.tar.gz: fd132288f005d7c5ff528a4dd98abe8e243b4e53a28aa119d9204a480ff30c44149b1ba7e2dabcc0d0b1dc0bca600233a247ba7e244d69416549ce320573f9b0
|
data/Gemfile.lock
CHANGED
@@ -3,29 +3,47 @@ PATH
|
|
3
3
|
specs:
|
4
4
|
gems-license-finder (0.0.10)
|
5
5
|
bluecloth (~> 2.2.0)
|
6
|
-
faraday (~> 1
|
6
|
+
faraday (~> 1)
|
7
7
|
github-markup (~> 3.0.5)
|
8
8
|
github_api (~> 0.19.0)
|
9
9
|
kramdown (~> 2.3.0)
|
10
10
|
maruku (~> 0.7.3)
|
11
11
|
posix-spawn (~> 0.3.15)
|
12
|
-
rack (~> 2.2.
|
12
|
+
rack (~> 2.2.4)
|
13
13
|
rdiscount (~> 2.2.0)
|
14
14
|
redcarpet (~> 3.5.1)
|
15
15
|
|
16
16
|
GEM
|
17
17
|
remote: http://rubygems.org/
|
18
18
|
specs:
|
19
|
-
addressable (2.
|
19
|
+
addressable (2.8.0)
|
20
20
|
public_suffix (>= 2.0.2, < 5.0)
|
21
21
|
bluecloth (2.2.0)
|
22
22
|
descendants_tracker (0.0.4)
|
23
23
|
thread_safe (~> 0.3, >= 0.3.1)
|
24
|
-
faraday (1.
|
24
|
+
faraday (1.10.0)
|
25
|
+
faraday-em_http (~> 1.0)
|
26
|
+
faraday-em_synchrony (~> 1.0)
|
27
|
+
faraday-excon (~> 1.1)
|
28
|
+
faraday-httpclient (~> 1.0)
|
29
|
+
faraday-multipart (~> 1.0)
|
25
30
|
faraday-net_http (~> 1.0)
|
26
|
-
|
27
|
-
|
28
|
-
|
31
|
+
faraday-net_http_persistent (~> 1.0)
|
32
|
+
faraday-patron (~> 1.0)
|
33
|
+
faraday-rack (~> 1.0)
|
34
|
+
faraday-retry (~> 1.0)
|
35
|
+
ruby2_keywords (>= 0.0.4)
|
36
|
+
faraday-em_http (1.0.0)
|
37
|
+
faraday-em_synchrony (1.0.0)
|
38
|
+
faraday-excon (1.1.0)
|
39
|
+
faraday-httpclient (1.0.1)
|
40
|
+
faraday-multipart (1.0.4)
|
41
|
+
multipart-post (~> 2)
|
42
|
+
faraday-net_http (1.0.1)
|
43
|
+
faraday-net_http_persistent (1.2.0)
|
44
|
+
faraday-patron (1.0.0)
|
45
|
+
faraday-rack (1.0.0)
|
46
|
+
faraday-retry (1.0.3)
|
29
47
|
github-markup (3.0.5)
|
30
48
|
github_api (0.19.0)
|
31
49
|
addressable (~> 2.4)
|
@@ -34,8 +52,8 @@ GEM
|
|
34
52
|
hashie (~> 3.5, >= 3.5.2)
|
35
53
|
oauth2 (~> 1.0)
|
36
54
|
hashie (3.6.0)
|
37
|
-
jwt (2.
|
38
|
-
kramdown (2.3.
|
55
|
+
jwt (2.4.1)
|
56
|
+
kramdown (2.3.2)
|
39
57
|
rexml
|
40
58
|
maruku (0.7.3)
|
41
59
|
metaclass (0.0.4)
|
@@ -44,20 +62,20 @@ GEM
|
|
44
62
|
metaclass (~> 0.0.1)
|
45
63
|
multi_json (1.15.0)
|
46
64
|
multi_xml (0.6.0)
|
47
|
-
multipart-post (2.
|
48
|
-
oauth2 (1.4.
|
49
|
-
faraday (>= 0.
|
65
|
+
multipart-post (2.2.3)
|
66
|
+
oauth2 (1.4.10)
|
67
|
+
faraday (>= 0.17.3, < 3.0)
|
50
68
|
jwt (>= 1.0, < 3.0)
|
51
69
|
multi_json (~> 1.3)
|
52
70
|
multi_xml (~> 0.5)
|
53
71
|
rack (>= 1.2, < 3)
|
54
72
|
posix-spawn (0.3.15)
|
55
|
-
public_suffix (4.0.
|
56
|
-
rack (2.2.
|
73
|
+
public_suffix (4.0.7)
|
74
|
+
rack (2.2.4)
|
57
75
|
rdiscount (2.2.0.2)
|
58
76
|
redcarpet (3.5.1)
|
59
|
-
rexml (3.2.
|
60
|
-
ruby2_keywords (0.0.
|
77
|
+
rexml (3.2.5)
|
78
|
+
ruby2_keywords (0.0.5)
|
61
79
|
thread_safe (0.3.6)
|
62
80
|
|
63
81
|
PLATFORMS
|
data/README.md
CHANGED
@@ -18,10 +18,11 @@ or add this to your `Gemfile` and bundle
|
|
18
18
|
via command line
|
19
19
|
```
|
20
20
|
$ gems-license-finder --help
|
21
|
-
Usage: gems-license-finder gem-name [options]
|
21
|
+
Usage: gems-license-finder [gem-name | Gemfile.lock] [options]
|
22
22
|
|
23
23
|
-o, --output FORMAT output format [json, yaml]
|
24
24
|
-t, --token TOKEN github token string ( or by GITHUB_TOKEN environment variable )
|
25
|
+
-p, --parallel X number of threads to use
|
25
26
|
-v, --version Print version and exit
|
26
27
|
|
27
28
|
For more information about how to generate the github token please look at:
|
@@ -43,6 +44,56 @@ $ gems-license-finder bundler
|
|
43
44
|
"license": "https://github.com/bundler/bundler//blob/master/LICENSE.md",
|
44
45
|
"github_url": "https://github.com/bundler/bundler/"
|
45
46
|
}
|
47
|
+
```
|
48
|
+
|
49
|
+
finding licenses for gems listed in Gemfile.lock
|
50
|
+
```
|
51
|
+
$ cat /your/project/path/Gemfile.lock
|
52
|
+
GEM
|
53
|
+
remote: https://rubygems.org/
|
54
|
+
specs:
|
55
|
+
eventmachine (1.2.7)
|
56
|
+
zscheduler (0.0.8)
|
57
|
+
eventmachine
|
58
|
+
|
59
|
+
PLATFORMS
|
60
|
+
ruby
|
61
|
+
|
62
|
+
DEPENDENCIES
|
63
|
+
zscheduler!
|
64
|
+
|
65
|
+
BUNDLED WITH
|
66
|
+
1.17.3
|
67
|
+
|
68
|
+
$ gems-license-finder /your/project/path/Gemfile.lock
|
69
|
+
|
70
|
+
{
|
71
|
+
"eventmachine": {
|
72
|
+
"homepage": "http://rubyeventmachine.com",
|
73
|
+
"source_code": "https://github.com/eventmachine/eventmachine",
|
74
|
+
"documentation": "https://www.rubydoc.info/gems/eventmachine/1.2.7",
|
75
|
+
"bug_tracker": "https://github.com/eventmachine/eventmachine/issues",
|
76
|
+
"download": "/downloads/eventmachine-1.2.7.gem",
|
77
|
+
"reverse_dependencies": "/gems/eventmachine/reverse_dependencies",
|
78
|
+
"license_type": "Ruby",
|
79
|
+
"license_url": "https://www.ruby-lang.org/en/about/license.txt",
|
80
|
+
"description": "EventMachine implements a fast, single-threaded engine for arbitrary networkcommunications. It's extremely easy to use in Ruby. EventMachine wraps allinteractions with IP sockets, allowing programs to concentrate on theimplementation of network protocols. It can be used to create both networkservers and clients. To create a server or client, a Ruby program only needsto specify the IP address and port, and provide a Module that implements thecommunications protocol. Implementations of several standard network protocolsare provided with the package, primarily to serve as examples. The real goalof EventMachine is to enable programs to easily interface with other programsusing TCP/IP, especially if custom protocols are required.",
|
81
|
+
"license": "https://github.com/eventmachine/eventmachine/blob/master/LICENSE",
|
82
|
+
"github_url": "https://github.com/eventmachine/eventmachine"
|
83
|
+
},
|
84
|
+
"zscheduler": {
|
85
|
+
"homepage": "http://github.com/eranb/zscheduler",
|
86
|
+
"source_code": "https://github.com/eranb/zscheduler",
|
87
|
+
"documentation": "https://www.rubydoc.info/gems/zscheduler/0.0.8",
|
88
|
+
"download": "/downloads/zscheduler-0.0.8.gem",
|
89
|
+
"reverse_dependencies": "/gems/zscheduler/reverse_dependencies",
|
90
|
+
"license_type": "LGPL",
|
91
|
+
"license_url": "http://choosealicense.com/licenses/lgpl-v2.1/",
|
92
|
+
"description": "minimalistic scheduler on top of event-machine",
|
93
|
+
"license": "https://github.com/eranb/zscheduler/blob/master/LICENSE",
|
94
|
+
"github_url": "https://github.com/eranb/zscheduler"
|
95
|
+
}
|
96
|
+
}
|
46
97
|
|
47
98
|
```
|
48
99
|
|
data/bin/gems-license-finder
CHANGED
@@ -8,7 +8,8 @@ require 'yaml'
|
|
8
8
|
require 'json'
|
9
9
|
require 'optparse'
|
10
10
|
|
11
|
-
options = {
|
11
|
+
options = {output: ->(h) { JSON.pretty_generate h }}
|
12
|
+
|
12
13
|
options[:oauth_token] = ENV["GITHUB_TOKEN"] if ENV["GITHUB_TOKEN"]
|
13
14
|
|
14
15
|
OptionParser.new do |opts|
|
@@ -23,6 +24,10 @@ OptionParser.new do |opts|
|
|
23
24
|
options[:oauth_token] = v
|
24
25
|
end
|
25
26
|
|
27
|
+
opts.on("-p", "--parallel X", "number of threads to use") do |v|
|
28
|
+
options[:parallel] = v.to_i.zero? ? 1 : v.to_i
|
29
|
+
end
|
30
|
+
|
26
31
|
opts.on("-v", "--version","print current version and exit") do
|
27
32
|
puts GemsLicenseFinder.version
|
28
33
|
exit
|
data/lib/gems-license-finder.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'github_api'
|
4
4
|
require 'open-uri'
|
5
5
|
require 'uri'
|
6
|
+
require 'bundler'
|
6
7
|
require 'github/markup'
|
7
8
|
require 'gems-license-finder/version'
|
8
9
|
require 'cgi'
|
@@ -20,7 +21,7 @@ module GemsLicenseFinder
|
|
20
21
|
|
21
22
|
class Client
|
22
23
|
LICENSE_FILES = %w[LICENSE LICENSE.md LICENSE.markdown MIT-LICENSE
|
23
|
-
LICENSE.txt MIT-LICENSE.txt MIT.LICENSE MIT_LICENSE
|
24
|
+
LICENSE.txt MIT-LICENSE.txt MIT.LICENSE MIT_LICENSE
|
24
25
|
MIT-LICENSE.md LICENSE.rdoc License
|
25
26
|
COPYING License.txt COPYING.md GNU GNU.txt GNU.rdoc GNU.markdown]
|
26
27
|
|
@@ -41,15 +42,40 @@ module GemsLicenseFinder
|
|
41
42
|
}
|
42
43
|
|
43
44
|
def initialize options = {}
|
45
|
+
@parallel = options.delete(:parallel) || 1
|
44
46
|
@github = Github.new options.clone
|
45
47
|
end
|
46
48
|
|
47
49
|
def find name
|
50
|
+
lockfile?(name) ? find_from_lockfile(name) : find_single(name)
|
51
|
+
end
|
52
|
+
|
53
|
+
def find_single name
|
48
54
|
normalize github_info(name , rubygems_info(name))
|
49
55
|
end
|
50
56
|
|
57
|
+
def find_from_lockfile lockfile
|
58
|
+
Bundler::LockfileParser.new(Bundler.read_file lockfile).
|
59
|
+
specs.
|
60
|
+
map(&:name).
|
61
|
+
each_slice(@parallel).
|
62
|
+
reduce({}) {|acc, slice|
|
63
|
+
acc.merge(
|
64
|
+
slice.
|
65
|
+
map {|x| [x, Thread.new {find_single(x) rescue {}}]}.
|
66
|
+
map {|x, t| [x, t.value]}.
|
67
|
+
to_h
|
68
|
+
)
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
51
72
|
private
|
52
73
|
|
74
|
+
def lockfile? str
|
75
|
+
File.exists?(str) &&
|
76
|
+
File.basename(str).eql?("Gemfile.lock")
|
77
|
+
end
|
78
|
+
|
53
79
|
def rubygems_info name
|
54
80
|
begin
|
55
81
|
content = open("https://rubygems.org/gems/#{name}").read
|
@@ -84,7 +110,7 @@ module GemsLicenseFinder
|
|
84
110
|
license = "#{url}/blob/master/#{file}" if content
|
85
111
|
|
86
112
|
if license
|
87
|
-
type, lurl = (file =~ /mit|gnu/i) ?
|
113
|
+
type, lurl = (file =~ /mit|gnu/i) ?
|
88
114
|
normalize_licence(file.split(".").first) : type_from_license_text(content)
|
89
115
|
break
|
90
116
|
end
|
@@ -95,7 +121,7 @@ module GemsLicenseFinder
|
|
95
121
|
end
|
96
122
|
|
97
123
|
README_FILES.each do |file|
|
98
|
-
break if license and type
|
124
|
+
break if license and type
|
99
125
|
content = GitHub::Markup.render(file,fetch_github_file(user,repo,file)) rescue next
|
100
126
|
type, lurl = normalize_licence(content) if type.nil?
|
101
127
|
|
@@ -105,7 +131,7 @@ module GemsLicenseFinder
|
|
105
131
|
to_s.downcase.gsub(/\s/,"-") rescue nil
|
106
132
|
|
107
133
|
if license.nil? and utf8_match(content,'licen[cs]e')
|
108
|
-
license = rurl
|
134
|
+
license = rurl
|
109
135
|
type, lurl = normalize_licence content
|
110
136
|
end
|
111
137
|
|
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.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eran
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.2.
|
61
|
+
version: 2.2.4
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.2.
|
68
|
+
version: 2.2.4
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: github-markup
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: 1
|
173
|
+
version: '1'
|
174
174
|
type: :runtime
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: 1
|
180
|
+
version: '1'
|
181
181
|
description: Poor man's license finder for rubygems, that might work
|
182
182
|
email: eran@kontera.com
|
183
183
|
executables:
|