cobra_commander 0.3.1 → 0.4.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
  SHA256:
3
- metadata.gz: c6691293eef47b4d36057d148675f31b8cb4b3c8c856a0735e2c0bef2103360f
4
- data.tar.gz: 65a81c3b9a38e14f56b9fe77e278aff31934659dd1cc8f165a437d41c46088bc
3
+ metadata.gz: fb2f9f51193bd4ec022e4f12eae0b43f02d0f4f7adac086ac8c38f2bd7f3bf56
4
+ data.tar.gz: bb44e1c12845cab98efdcb8cf1da499f67fa335bd781bf14f4c07d11ed3c9eb5
5
5
  SHA512:
6
- metadata.gz: 29f6dcff1cda4a0f4275c6df455b8f7a5669f41a66377ee5ce66e70255a5d599dfdc728ded2c04e767f414a26d12782d59e92c7597ac4a87102dc49f99933dfa
7
- data.tar.gz: b30229ef24c4ccd6f32edd8c9d8163f9d62986901741e4bd497b374c3c9b2b49b0ea2e0141499df0d1c26a26e72f497226ba321f73ccd7bad763e3e61b6a506b
6
+ metadata.gz: fd838a67943d9e2ae8cc7038b81ccacaaea719f8cc08cea7704df5147ffc1609ef2a91622549d423954003465d1ec310b0d09bf10ec8f3cf915850e0dbdbe39c
7
+ data.tar.gz: a4dec3544d6a5fbcd258b759b9ba143955acf054b4ff44af1fb25d0f3391f37741e9c2d9e31221fd192ec08c843f39b62833a6741de6313e17453e37ca82722b
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## Version 0.4.0 - 2018-09-06
6
+
7
+ * Add `dependencies_of` command to permit listing or counting the dependencies of a particular component. PR [#24](https://github.com/powerhome/cobra_commander/pull/24)
8
+ * Fix indentation of tree output. PR [#23](https://github.com/powerhome/cobra_commander/pull/23)
9
+
5
10
  ## Version 0.3.1 - 2018-08-15
6
11
 
7
12
  * Resolve Bundler API version issue causing breakage building a ComponentTree. PR [#19](https://github.com/powerhome/cobra_commander/pull/19)
@@ -10,6 +10,13 @@ module CobraCommander
10
10
  puts FormattedOutput.new(app_path).run!
11
11
  end
12
12
 
13
+ desc "dependencies_of APP_PATH", "Outputs count of components in APP_PATH dependent on COMPONENT"
14
+ method_option :component, required: true, aliases: "-c", desc: "Name of component. Ex: my_component"
15
+ method_option :format, default: "count", aliases: "-f", desc: "count or list"
16
+ def dependencies_of(app_path)
17
+ puts FormattedOutput.new(app_path).dependencies_of!(@options[:component], @options[:format])
18
+ end
19
+
13
20
  desc "version", "Prints version"
14
21
  def version
15
22
  puts CobraCommander::VERSION
@@ -22,8 +22,29 @@ module CobraCommander
22
22
  nil
23
23
  end
24
24
 
25
+ def dependencies_of!(component_name, format)
26
+ @component_name = component_name
27
+
28
+ results = @tree[:dependencies].map do |component|
29
+ if @component_name == component[:name]
30
+ @tree[:name]
31
+ elsif dependency?(component)
32
+ component[:name]
33
+ end
34
+ end.compact
35
+
36
+ "list" == format ? results : results.size
37
+ end
38
+
25
39
  private
26
40
 
41
+ def dependency?(deps)
42
+ deps[:dependencies].each do |dep|
43
+ return true if @component_name == dep[:name] || dependency?(dep)
44
+ end
45
+ false
46
+ end
47
+
27
48
  def list_dependencies(deps, outdents = [])
28
49
  deps[:dependencies].each do |dep|
29
50
  decide_on_line(deps, dep, outdents)
@@ -40,7 +61,7 @@ module CobraCommander
40
61
 
41
62
  def add_tee(outdents, dep)
42
63
  puts line(outdents, TEE, dep[:name])
43
- list_dependencies(dep, ([BAR] + outdents))
64
+ list_dependencies(dep, (outdents + [BAR]))
44
65
  end
45
66
 
46
67
  def add_corner(outdents, dep)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CobraCommander
4
- VERSION = "0.3.1"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cobra_commander
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Langfeld
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-08-15 00:00:00.000000000 Z
12
+ date: 2018-09-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  version: '0'
194
194
  requirements: []
195
195
  rubyforge_project:
196
- rubygems_version: 2.7.7
196
+ rubygems_version: 2.7.3
197
197
  signing_key:
198
198
  specification_version: 4
199
199
  summary: Tools for working with Component Based Rails Apps