clamp 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/lib/clamp/command.rb +2 -0
- data/lib/clamp/subcommand/declaration.rb +10 -0
- data/lib/clamp/version.rb +1 -1
- data/spec/clamp/command_group_spec.rb +22 -0
- data/spec/spec_helper.rb +4 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8d58bd5db9ac6b414b75d34a947149720909757
|
4
|
+
data.tar.gz: d61add398880941423c32234e2e9c1d57a1c38f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7df1c2418b54a047af268ca936cabc828ecc2ac2f24bb9ca7a0b8a83768dd9b03679178d61ae79b18cd5a932626c5ae5da3d98d353d8517f2f668b00f4971cb4
|
7
|
+
data.tar.gz: 9298c454fd95f1ad91e4a852fabf51bc0ebb3b915c6164a0f2e012625b2ed1a8e170244c376ec6a54580583c471d3b7a0bd1cab45d5ac1a0437bc739989b819a
|
data/CHANGES.md
CHANGED
data/lib/clamp/command.rb
CHANGED
@@ -35,6 +35,16 @@ module Clamp
|
|
35
35
|
recognised_subcommands.find { |sc| sc.is_called?(name) }
|
36
36
|
end
|
37
37
|
|
38
|
+
def find_subcommand_class(*names)
|
39
|
+
names.inject(self) do |command_class, name|
|
40
|
+
if command_class
|
41
|
+
if subcommand = command_class.find_subcommand(name)
|
42
|
+
subcommand.subcommand_class
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
38
48
|
def parameters_before_subcommand
|
39
49
|
parameters.take_while { |p| p != @subcommand_parameter }
|
40
50
|
end
|
data/lib/clamp/version.rb
CHANGED
@@ -66,6 +66,15 @@ describe Clamp::Command do
|
|
66
66
|
|
67
67
|
end
|
68
68
|
|
69
|
+
describe ".find_subcommand_class" do
|
70
|
+
|
71
|
+
it "finds subcommand classes" do
|
72
|
+
flip_class = command_class.find_subcommand_class("flip")
|
73
|
+
expect(flip_class.new("xx").message).to eq("FLIPPED")
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
69
78
|
end
|
70
79
|
|
71
80
|
context "with an aliased subcommand" do
|
@@ -112,9 +121,14 @@ describe Clamp::Command do
|
|
112
121
|
subcommand "foo", "Foo!" do
|
113
122
|
|
114
123
|
subcommand "bar", "Baaaa!" do
|
124
|
+
|
125
|
+
def self.this_is_bar
|
126
|
+
end
|
127
|
+
|
115
128
|
def execute
|
116
129
|
puts "FUBAR"
|
117
130
|
end
|
131
|
+
|
118
132
|
end
|
119
133
|
|
120
134
|
end
|
@@ -126,6 +140,14 @@ describe Clamp::Command do
|
|
126
140
|
expect(stdout).to match /FUBAR/
|
127
141
|
end
|
128
142
|
|
143
|
+
describe ".find_subcommand_class" do
|
144
|
+
|
145
|
+
it "finds nested subcommands" do
|
146
|
+
expect(command_class.find_subcommand_class("foo", "bar")).to respond_to(:this_is_bar)
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
|
129
151
|
end
|
130
152
|
|
131
153
|
context "with a default subcommand" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clamp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02
|
11
|
+
date: 2015-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
Clamp provides an object-model for command-line utilities.
|