lapidarius 3.2.1 → 3.3.0

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: 5d388607c3bda3fb18fc3ede7edab5fd258311ae
4
- data.tar.gz: fa68f5c1477a6305bb4acabc5786f8a67c157974
3
+ metadata.gz: 268fbbb37aad0f18ae71017ff634a75f3d8a4bf4
4
+ data.tar.gz: bcd7b8100f25e2bd669a89a181d19a613da03a18
5
5
  SHA512:
6
- metadata.gz: ce256af09f34c0df79c33cc5bc86e26b0e9094f017df8407528232ac95a3525aafc3958d7e76732a5cb6ff9be42061dd94c46b9ec27c4b767673a04829c32e2f
7
- data.tar.gz: db87f24f6b0ff2171c23244e6ed67a498de8e58284a092a6279bb6b02f3b740dd0dec7cdf37cebb76a06d6f22088e3891d98ab3e52977534bebf43442c1a856a
6
+ metadata.gz: ca1312eb554fa5a9678e5cd73f4a5c955740ee787e243d427940f72f1da05303625165a65d8f4229c9f6af499c3d75946aef8cc05064acdaecbed07153290d35
7
+ data.tar.gz: edc16c5b9cea8e4aff955c76ca4e76823108df62bbbbdc6330cf3bdad87df85e6a11a2d5adc96df5001537828f9d6a70ebfd99e3b5261eb31d9c8c86a5ee11d2
data/README.md CHANGED
@@ -5,6 +5,7 @@
5
5
  * [gem dep](#gem-dep)
6
6
  * [bundle viz](#bundle-viz)
7
7
  * [Warning](#warning)
8
+ * [Installation](#installation)
8
9
  * [Usage](#usage)
9
10
 
10
11
  ## Scope
@@ -25,13 +26,19 @@ While it is great to visualize inter-dependencies, i have hard times figuring ou
25
26
  Consider only the gems installed on your system are scanned by the library.
26
27
  No remote fetching is performed.
27
28
 
29
+ ## Installation
30
+ Install the gem from your shell:
31
+ ```shell
32
+ gem install lapidarius
33
+ ```
34
+
28
35
  ## Usage
29
36
  This library invokes the `Gem::Commands::DependencyCommand` class recursively to collect all the levels of dependency.
30
37
  Both runtime and development dependencies are counted (identical dependencies are counted once).
31
38
  Just the runtime dependencies tree is printed to screen:
32
39
 
33
40
  ```shell
34
- $ lapidarius --gem=sinatra
41
+ $ lapidarius sinatra
35
42
  sinatra (2.0.0)
36
43
  ├── mustermann (~> 1.0)
37
44
  ├── rack (~> 2.0)
data/bin/lapidarius CHANGED
@@ -4,4 +4,5 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  require "lapidarius"
6
6
 
7
- Lapidarius::CLI.new(ARGV.clone).call
7
+ input = ARGV.fetch(0, "")
8
+ Lapidarius::CLI.new(input).call
@@ -1,37 +1,44 @@
1
- require "optparse"
2
1
  require "lapidarius/cutter"
3
2
 
4
3
  module Lapidarius
5
4
  class CLI
6
- def initialize(args, io = STDOUT)
7
- @args = args
8
- @io = io
9
- @gem = nil
5
+ HELP_FLAGS = %w[-h --help]
6
+ COL_WIDTH = 23
7
+
8
+ def initialize(input,
9
+ pipe = STDOUT,
10
+ command = Command,
11
+ cutter = Cutter,
12
+ tree = Tree)
13
+ @input = input.to_s.strip
14
+ @pipe = pipe
15
+ @cutter = cutter.new(@input, command)
16
+ @tree = tree
10
17
  end
11
18
 
12
- def call(cmd_klass = Command)
13
- parser.parse!(@args)
14
- return @io.puts("specify gem name as: '-g gem_name'") unless @gem
15
- obj = Lapidarius::Cutter.new(@gem, cmd_klass).call
16
- @io.puts Lapidarius::Tree::new(obj).out
17
- rescue Gem::NotInstalledError => e
18
- @io.puts e.message.sub("specified", "\e[1m#{@gem}\e[0m")
19
+ def call
20
+ @pipe.puts output
19
21
  end
20
22
 
21
- private def parser
22
- OptionParser.new do |opts|
23
- opts.banner = "Usage: lapidarius --gem=sinatra"
23
+ private def output
24
+ return help if help?
25
+ return if @input.empty?
26
+ gem = @cutter.call
27
+ @tree::new(gem).out
28
+ rescue Gem::NotInstalledError => e
29
+ e.message.sub("specified", %Q{"#{@input}"})
30
+ end
24
31
 
25
- opts.on("-gGEM", "--gem=GEM", "The gem name to scan") do |gem|
26
- @gem = gem
27
- end
32
+ private def help?
33
+ HELP_FLAGS.include?(@input)
34
+ end
28
35
 
29
- opts.on("-h", "--help", "Prints this help") do
30
- @io.puts opts
31
- exit
32
- end
36
+ private def help
37
+ [].tap do |h|
38
+ h << %q{Usage: lapidarius sinatra}
39
+ h << " %-#{COL_WIDTH}s Print this help" % "-h --help"
40
+ h << " %-#{COL_WIDTH}s Gem's name to cut" % "<gem-name>"
33
41
  end
34
42
  end
35
43
  end
36
44
  end
37
-
@@ -1,3 +1,3 @@
1
1
  module Lapidarius
2
- VERSION = "3.2.1"
2
+ VERSION = "3.3.0"
3
3
  end
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: 3.2.1
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - costajob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-25 00:00:00.000000000 Z
11
+ date: 2017-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler