drydock 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +9 -2
- data/LICENSE.txt +1 -1
- data/README.rdoc +0 -1
- data/drydock.gemspec +1 -1
- data/lib/drydock.rb +13 -5
- metadata +1 -1
data/CHANGES.txt
CHANGED
@@ -3,10 +3,16 @@ DRYDOCK, CHANGES
|
|
3
3
|
#### TODO ###############################
|
4
4
|
|
5
5
|
* Support putting descriptions into resource file (or __END__)
|
6
|
-
*
|
6
|
+
* Inline commands aliases. command :cmd1, :cmd2 do; ...; end
|
7
7
|
|
8
8
|
|
9
|
-
#### 0.5.
|
9
|
+
#### 0.5.3 (2009-04-05) #############################
|
10
|
+
|
11
|
+
* FIXED: Command actions were not being handled correctly. Added rdocs to
|
12
|
+
clarify the code.
|
13
|
+
|
14
|
+
|
15
|
+
#### 0.5.2 (2009-04-04) #############################
|
10
16
|
|
11
17
|
* ADDED: before and after blocks now receive a primed reference to the
|
12
18
|
command object (which gives them access to the globals and options)
|
@@ -65,6 +71,7 @@ and sending to other methods manually.
|
|
65
71
|
* UPDATED: Rdocs
|
66
72
|
* CHANGE: added method command_aliaz to mirror aliaz_command
|
67
73
|
|
74
|
+
|
68
75
|
#### 0.3 (2009-02-05) ###############################
|
69
76
|
|
70
77
|
* Added support for custom Drydock::Commands objects
|
data/LICENSE.txt
CHANGED
data/README.rdoc
CHANGED
data/drydock.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
@spec = Gem::Specification.new do |s|
|
2
2
|
s.name = %q{drydock}
|
3
|
-
s.version = "0.5.
|
3
|
+
s.version = "0.5.3"
|
4
4
|
s.date = %q{2009-04-05}
|
5
5
|
s.specification_version = 1 if s.respond_to? :specification_version=
|
6
6
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
data/lib/drydock.rb
CHANGED
@@ -151,10 +151,13 @@ module Drydock
|
|
151
151
|
#
|
152
152
|
def call
|
153
153
|
self.print_header if self.respond_to? :print_header
|
154
|
+
|
155
|
+
# Execute the command block if it exists
|
154
156
|
if @b
|
155
157
|
run_validation
|
156
158
|
@b.call(self)
|
157
|
-
|
159
|
+
|
160
|
+
# Otherwise check to see if an action was specified
|
158
161
|
elsif !(chosen = find_action(self.option)).empty?
|
159
162
|
raise "Only one action at a time please! I can't #{chosen.join(' AND ')}." if chosen.size > 1
|
160
163
|
criteria = [[@cmd, chosen.first], [chosen.first, @cmd]]
|
@@ -170,9 +173,12 @@ module Drydock
|
|
170
173
|
run_validation(meth)
|
171
174
|
self.send(meth)
|
172
175
|
|
176
|
+
# No block and no action. We'll try for the method name in the Drydock::Command class.
|
173
177
|
elsif self.respond_to? @cmd.to_sym
|
174
178
|
run_validation(@cmd)
|
175
179
|
self.send(@cmd)
|
180
|
+
|
181
|
+
# Well, then I have no idea what you want me to do!
|
176
182
|
else
|
177
183
|
raise "The command #{@alias} has no block and #{self.class} has no #{@cmd} method!"
|
178
184
|
end
|
@@ -211,7 +217,9 @@ module Drydock
|
|
211
217
|
def find_action(options)
|
212
218
|
options = options.marshal_dump if options.is_a?(OpenStruct)
|
213
219
|
boolkeys = options.keys.select { |n| options[n] == true } || []
|
214
|
-
|
220
|
+
boolkeys = boolkeys.collect { |n| n.to_s } # @agents contains Strings.
|
221
|
+
# Returns the elements in @actions that are also found in boolkeys
|
222
|
+
(@actions || []) & boolkeys
|
215
223
|
end
|
216
224
|
private :find_action
|
217
225
|
|
@@ -489,11 +497,11 @@ module Drydock
|
|
489
497
|
current_command_option_names << option_parser(args, &b)
|
490
498
|
end
|
491
499
|
|
492
|
-
# Define
|
500
|
+
# Define a command-specific action.
|
493
501
|
#
|
494
|
-
# This is
|
502
|
+
# This is functionally very similar to option, but with an exciting and buoyant twist:
|
495
503
|
# Drydock keeps track of actions for each command (in addition to treating it like an option).
|
496
|
-
# When an action is
|
504
|
+
# When an action is specified on the command line Drydock looks for command_action or
|
497
505
|
# action_command methods in the command class.
|
498
506
|
#
|
499
507
|
# action :E, :eat, "Eat something"
|