lapidarius 3.4.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +26 -20
- data/bin/lapidarius +1 -1
- data/lib/lapidarius/cli.rb +36 -24
- data/lib/lapidarius/command.rb +10 -2
- data/lib/lapidarius/cutter.rb +8 -7
- data/lib/lapidarius/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa85a20faa777803fdff22b4f680bf050de0e09229181f91efd54c03e50858d2
|
4
|
+
data.tar.gz: fb490c7133b98e4c364032ac1fbff5cb4d8b350dc0a1df61eaace7eaf716ad2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc2067d98c1c09e9297e6642e79ace764a0c282e677f04e6894121d8aed861935cdaf78a2bb6ef4cf666c461f1a3f6c6774064ba14478230ec29554fa5db3a2b
|
7
|
+
data.tar.gz: e2251cd404033b04a5c680b94d62d7ba5178eef71ce7415721969e87ce6b4b4012c670cd8acac1732ce9fc5c33631669ba72ce03772169ca1d65e943306ece26
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -4,10 +4,10 @@
|
|
4
4
|
* [Alternatives](#alternatives)
|
5
5
|
* [gem dep](#gem-dep)
|
6
6
|
* [bundle viz](#bundle-viz)
|
7
|
-
* [Warning](#warning)
|
8
7
|
* [Installation](#installation)
|
9
8
|
* [Usage](#usage)
|
10
9
|
* [Version](#version)
|
10
|
+
* [Remote](#remote)
|
11
11
|
|
12
12
|
## Scope
|
13
13
|
This gem is aimed to recursively collect the `runtime dependencies` footprint of the specified gem.
|
@@ -17,16 +17,12 @@ The output of the library mimics the `tree` shell utility, highlighting the nest
|
|
17
17
|
Some alternatives exists:
|
18
18
|
|
19
19
|
#### gem dep
|
20
|
-
The standard
|
20
|
+
The standard `gem dep` command just unearth one level of dependencies.
|
21
21
|
|
22
22
|
#### bundle viz
|
23
|
-
The
|
23
|
+
The `bundle viz` command relies on the Gemfile and the [graphviz](http://www.graphviz.org/) library to generate a visual representation of the gem inter-dependencies.
|
24
24
|
While it is great to visualize inter-dependencies, i have hard times figuring out gem's runtime footprint.
|
25
25
|
|
26
|
-
## Warning
|
27
|
-
Consider only the gems local to your system are scanned by the library.
|
28
|
-
No remote fetching is performed.
|
29
|
-
|
30
26
|
## Installation
|
31
27
|
Install the gem from your shell:
|
32
28
|
```shell
|
@@ -35,10 +31,25 @@ gem install lapidarius
|
|
35
31
|
|
36
32
|
## Usage
|
37
33
|
This library invokes the `Gem::Commands::DependencyCommand` class recursively to collect all the levels of dependency.
|
38
|
-
Both runtime and development dependencies are counted (identical dependencies are counted once)
|
39
|
-
Just the runtime dependencies tree is printed to screen:
|
34
|
+
Both runtime and development dependencies are counted (identical dependencies are counted once), but just the former are printed on screen:
|
40
35
|
|
41
36
|
```shell
|
37
|
+
> lapidarius sinatra
|
38
|
+
sinatra (2.0.0)
|
39
|
+
├── mustermann (~> 1.0)
|
40
|
+
├── rack (~> 2.0)
|
41
|
+
├── rack-protection (= 2.0.0)
|
42
|
+
│ └── rack (>= 0)
|
43
|
+
└── tilt (~> 2.0)
|
44
|
+
|
45
|
+
4 runtime, 4 development
|
46
|
+
```
|
47
|
+
|
48
|
+
### Version
|
49
|
+
By default this library scans for the first version `>= 0` found at [rubygems.org](https://rubygems.org/).
|
50
|
+
In case you are interested on a specific version just specify the `-v` option:
|
51
|
+
```shell
|
52
|
+
> lapidarius sinatra -v 1.4.7
|
42
53
|
sinatra (1.4.7)
|
43
54
|
├── rack (~> 1.5)
|
44
55
|
├── rack-protection (~> 1.4)
|
@@ -48,17 +59,12 @@ sinatra (1.4.7)
|
|
48
59
|
3 runtime, 4 development
|
49
60
|
```
|
50
61
|
|
51
|
-
###
|
52
|
-
By default this library
|
53
|
-
In case you have multiple versions of a gem installed, just specify the version you need to cut as the second argument:
|
62
|
+
### Remote
|
63
|
+
By default this library scan for local gems, if you want to scan for remote ones specify the `-r` option (be aware of slowness):
|
54
64
|
```shell
|
55
|
-
$ lapidarius
|
56
|
-
|
57
|
-
|
58
|
-
├── rack (~> 2.0)
|
59
|
-
├── rack-protection (= 2.0.0)
|
60
|
-
│ └── rack (>= 0)
|
61
|
-
└── tilt (~> 2.0)
|
65
|
+
$ lapidarius roda -v 3.3.0 -r
|
66
|
+
roda (3.3.0)
|
67
|
+
└── rack (>= 0)
|
62
68
|
|
63
|
-
|
69
|
+
1 runtime, 10 development
|
64
70
|
```
|
data/bin/lapidarius
CHANGED
data/lib/lapidarius/cli.rb
CHANGED
@@ -1,47 +1,59 @@
|
|
1
|
+
require "optparse"
|
1
2
|
require "lapidarius/cutter"
|
2
3
|
|
3
4
|
module Lapidarius
|
4
5
|
class CLI
|
5
6
|
HELP_FLAGS = %w[-h --help]
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
command = Command,
|
13
|
-
cutter = Cutter,
|
14
|
-
tree = Tree)
|
15
|
-
@name, @version = Array(input).map(&:strip)
|
16
|
-
@out = out
|
17
|
-
@cutter = cutter.new(name: @name, cmd_klass: command, version: @version)
|
7
|
+
|
8
|
+
attr_reader :name, :version, :remote
|
9
|
+
|
10
|
+
def initialize(args: [], io: STDOUT, command: Command, cutter: Cutter, tree: Tree)
|
11
|
+
@args = args
|
12
|
+
@io = io
|
18
13
|
@tree = tree
|
14
|
+
@command = command
|
15
|
+
@cutter = cutter
|
16
|
+
@name = @args.shift unless help?
|
17
|
+
parser.parse!(@args)
|
19
18
|
end
|
20
19
|
|
21
20
|
def call
|
22
|
-
@
|
21
|
+
@io.puts output
|
22
|
+
end
|
23
|
+
|
24
|
+
private def cutter
|
25
|
+
@cutter.new(name: @name, cmd_klass: @command, version: @version, remote: @remote)
|
23
26
|
end
|
24
27
|
|
25
28
|
private def output
|
26
|
-
return help if help?
|
27
29
|
return unless @name
|
28
|
-
gem =
|
30
|
+
gem = cutter.call
|
29
31
|
@tree::new(gem).to_s
|
30
32
|
rescue Gem::NotInstalledError => e
|
31
33
|
e.message
|
32
34
|
end
|
33
35
|
|
34
|
-
private def
|
35
|
-
|
36
|
-
|
36
|
+
private def parser
|
37
|
+
OptionParser.new do |opts|
|
38
|
+
opts.banner = %q{Usage: lapidarius sinatra --version=1.4.7 --remote}
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
opts.on("-vVERSION", "--version=VERSION", "Specify the gem version to cut") do |version|
|
41
|
+
@version = version
|
42
|
+
end
|
43
|
+
|
44
|
+
opts.on("-r", "--remote", "Fetch gem remotely") do |remote|
|
45
|
+
@remote = true
|
46
|
+
end
|
47
|
+
|
48
|
+
opts.on(*HELP_FLAGS, "Prints this help") do
|
49
|
+
@io.puts opts
|
50
|
+
exit
|
51
|
+
end
|
44
52
|
end
|
45
53
|
end
|
54
|
+
|
55
|
+
private def help?
|
56
|
+
HELP_FLAGS.any? { |h| @args.first == h }
|
57
|
+
end
|
46
58
|
end
|
47
59
|
end
|
data/lib/lapidarius/command.rb
CHANGED
@@ -11,11 +11,19 @@ module Lapidarius
|
|
11
11
|
@dep.ui = ui_klass.new
|
12
12
|
end
|
13
13
|
|
14
|
-
def call(
|
14
|
+
def call(*args)
|
15
15
|
@dep.ui.clear!
|
16
|
-
|
16
|
+
@dep.invoke(*options(args))
|
17
17
|
@dep.ui.out
|
18
18
|
end
|
19
|
+
|
20
|
+
private def options(args)
|
21
|
+
name, version, remote = args
|
22
|
+
[name].tap do |args|
|
23
|
+
args.concat(["-v", version]) if version
|
24
|
+
args.concat(["-b", "-B", "10000"]) if remote
|
25
|
+
end
|
26
|
+
end
|
19
27
|
end
|
20
28
|
end
|
21
29
|
|
data/lib/lapidarius/cutter.rb
CHANGED
@@ -6,12 +6,13 @@ module Lapidarius
|
|
6
6
|
class Cutter
|
7
7
|
DEVELOPMENT = "development"
|
8
8
|
|
9
|
-
attr_reader :version
|
9
|
+
attr_reader :version, :remote
|
10
10
|
|
11
|
-
def initialize(name:, cmd_klass: Command, version: nil)
|
11
|
+
def initialize(name:, cmd_klass: Command, version: nil, remote: nil)
|
12
12
|
@name = name
|
13
13
|
@cmd = cmd_klass.new
|
14
14
|
@version = version
|
15
|
+
@remote = remote
|
15
16
|
@dev_deps = []
|
16
17
|
end
|
17
18
|
|
@@ -21,14 +22,14 @@ module Lapidarius
|
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
|
-
private def recurse(name
|
25
|
-
tokens = tokenize(name, version)
|
25
|
+
private def recurse(name: @name, gem: nil, version: @version, remote: @remote)
|
26
|
+
tokens = tokenize(name, version, remote)
|
26
27
|
token = tokens.shift
|
27
28
|
gem ||= Gem.factory(token)
|
28
29
|
tokens.each do |t|
|
29
30
|
next unless dep = Gem.factory(t)
|
30
31
|
gem << dep
|
31
|
-
recurse(dep.name, dep, nil)
|
32
|
+
recurse(name: dep.name, gem: dep, version: nil, remote: remote)
|
32
33
|
end
|
33
34
|
gem
|
34
35
|
end
|
@@ -37,8 +38,8 @@ module Lapidarius
|
|
37
38
|
@dev_deps.map { |e| e.split(" ").first }.uniq.count
|
38
39
|
end
|
39
40
|
|
40
|
-
private def tokenize(name, version)
|
41
|
-
src = @cmd.call(name, version)
|
41
|
+
private def tokenize(name, version, remote)
|
42
|
+
src = @cmd.call(name, version, remote)
|
42
43
|
data = normalize(src)
|
43
44
|
dev, tokens = data.partition { |token| token.match(/#{DEVELOPMENT}/) }
|
44
45
|
@dev_deps.concat(dev)
|
data/lib/lapidarius/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lapidarius
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- costajob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|