gems_deplevel 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +2 -0
- data/lib/gems_deplevel.rb +115 -0
- data.tar.gz.sig +0 -0
- metadata +110 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d4b7f4086dad12b6185922496da34ef75aec713e6cc2c0faaf9ec74bb3457929
|
4
|
+
data.tar.gz: cb0155935157cec20a44011c952b07b318c9bbb619bcc9dbd238516c47ef2495
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4db2f35732d03288d12a7b524b9a8ba319dd685292dfae65f512eeb8b095b7dc8c067dd887e3625381e94087bdebfceba0693c6f2ad391e6e9d5fa33fceea383
|
7
|
+
data.tar.gz: 8d023123a7ebcfe1ed58a809f1fd786adfcf3212fc01f44a21e22d2e9bc306f68e1d8d1680fef3d400708207c7abd5e656fb1646e88c52ef5c06b2e038b0b796
|
checksums.yaml.gz.sig
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: gems_deplevel.rb
|
4
|
+
|
5
|
+
require 'gems'
|
6
|
+
require 'dir-to-xml'
|
7
|
+
|
8
|
+
|
9
|
+
class GemDepLevelErr < Exception
|
10
|
+
end
|
11
|
+
|
12
|
+
class GemsDepLevel
|
13
|
+
|
14
|
+
def initialize(dir=nil, debug: false)
|
15
|
+
@dir, @debug = dir, debug
|
16
|
+
end
|
17
|
+
|
18
|
+
# Returns the dependency depth level for a gem's transitive dependencies
|
19
|
+
#
|
20
|
+
# * gemlist contains the a list gem names, each containing the
|
21
|
+
# gem dependencies
|
22
|
+
#
|
23
|
+
# - use gem_deps() to make the gemlist or scan_gems() if using a
|
24
|
+
# local gem_src directory
|
25
|
+
#
|
26
|
+
#
|
27
|
+
def dep_level(name, gemlist=gem_deps(name))
|
28
|
+
|
29
|
+
raise GemDepLevelErr, 'supply the name of a gem' unless name
|
30
|
+
|
31
|
+
gemtally = Hash.new(0)
|
32
|
+
scan(name, gemlist, gemtally)
|
33
|
+
|
34
|
+
gemtally.sort_by(&:last).group_by(&:last).map do |key, value|
|
35
|
+
[key, value.map(&:first)]
|
36
|
+
end.to_h
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
# returns a Hash object of transitive gem dependencies for a specific gem
|
41
|
+
# [{gem name => [gem1, gem2, ...]}, {gem1 => [gem1.1, gem1.2]}]
|
42
|
+
#
|
43
|
+
def gem_deps(name)
|
44
|
+
|
45
|
+
return unless name
|
46
|
+
|
47
|
+
puts 'name: ' + name.inspect if @debug
|
48
|
+
gem = Gems.info name
|
49
|
+
|
50
|
+
a = gem['dependencies']['runtime'].map {|x| x['name']}
|
51
|
+
h = {name => a}
|
52
|
+
|
53
|
+
a.inject(h) do |r,x|
|
54
|
+
puts 'r.keys: ' + r.keys.inspect if @debug
|
55
|
+
r.keys.include?(x) ? r : r.merge!(gem_deps(x))
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
# Returns the dependencies for each gem as a Hash object
|
62
|
+
#
|
63
|
+
def scan_gems(dir=@dir)
|
64
|
+
|
65
|
+
raise GemDepLevelErr, 'please provde a directory path' unless dir
|
66
|
+
|
67
|
+
dtx = DirToXML.new dir
|
68
|
+
names = dtx.directories
|
69
|
+
|
70
|
+
gems = names.map do |name|
|
71
|
+
|
72
|
+
filename = "#{name}/#{name}.gemspec"
|
73
|
+
gemspec = File.join(dir, filename)
|
74
|
+
|
75
|
+
if File.exists? gemspec then
|
76
|
+
|
77
|
+
s = File.read gemspec
|
78
|
+
dependencies = s.scan(/add_runtime_dependency\(['"]([^'"]+)/)
|
79
|
+
.map(&:first)
|
80
|
+
|
81
|
+
[name, dependencies]
|
82
|
+
|
83
|
+
else
|
84
|
+
nil
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
return Hash[gems.compact]
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
private
|
94
|
+
|
95
|
+
def scan(gem, h, gemtally=Hash.new(0), level=0)
|
96
|
+
|
97
|
+
if @debug then
|
98
|
+
puts 'inside scan'
|
99
|
+
puts 'gem; ' + gem.inspect
|
100
|
+
puts 'h: ' + h.inspect
|
101
|
+
end
|
102
|
+
|
103
|
+
return unless h.include? gem
|
104
|
+
|
105
|
+
gemtally[gem] = level if gemtally[gem] <= level
|
106
|
+
|
107
|
+
h[gem].each do |x|
|
108
|
+
scan(x, h, gemtally, level+1)
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
end
|
115
|
+
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gems_deplevel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjIwMzA2MTYyMzUxWhcN
|
15
|
+
MjMwMzA2MTYyMzUxWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQC2sg7p
|
17
|
+
nkOs+rixKmf5Re9IflscLimiyDWKD8yrj3S8Mc2KlcBTYCSR0+9+V4UXnIUsine1
|
18
|
+
AYhvdWLVvz5lE1KqaM1aDotGnov4cOf3lFLGRc21ViCj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Poaslfg2cbKTVjIEYMPB/un0zDnBik3kkPdduWidsB3uYjetMg+ENVBhlRdK3
|
34
|
+
gpXaVgfSrhCsziv9lfVcb48W/fL6FgVD4kks0LKk4XUZqNR40XZRv/TvqaquiFhy
|
35
|
+
nKgF6Ie+ZheTbRhj8524w8BLfATiXyCpfv1kx/P0D+2ObCPBSUe8BEK6P2oyAAYm
|
36
|
+
ztLaT0+fn8qN1xLaamkdpzfU
|
37
|
+
-----END CERTIFICATE-----
|
38
|
+
date: 2022-03-06 00:00:00.000000000 Z
|
39
|
+
dependencies:
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: gems
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.2'
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 1.2.0
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '1.2'
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 1.2.0
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: dir-to-xml
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '1.2'
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.2.2
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '1.2'
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 1.2.2
|
80
|
+
description:
|
81
|
+
email: digital.robertson@gmail.com
|
82
|
+
executables: []
|
83
|
+
extensions: []
|
84
|
+
extra_rdoc_files: []
|
85
|
+
files:
|
86
|
+
- lib/gems_deplevel.rb
|
87
|
+
homepage: https://github.com/jrobertson/gems_deplevel
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubygems_version: 3.2.22
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Returns the dependency depth level for a gem's transitive dependencies
|
110
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|