delano-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 CHANGED
@@ -3,10 +3,16 @@ DRYDOCK, CHANGES
3
3
  #### TODO ###############################
4
4
 
5
5
  * Support putting descriptions into resource file (or __END__)
6
- * Define aliases with "command [:name, :alias]"
6
+ * Inline commands aliases. command :cmd1, :cmd2 do; ...; end
7
7
 
8
8
 
9
- #### 0.5.2 (2009-04-05) #############################
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
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008 Delano Mandelbaum
1
+ Copyright (c) 2008-2009 Delano Mandelbaum, Solutious Inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
data/README.rdoc CHANGED
@@ -80,7 +80,6 @@ See bin/example for more.
80
80
  * Delano Mandelbaum (delano@solutious.com)
81
81
  * Bernie Kopell (bernie@solutious.com)
82
82
 
83
-
84
83
  == License
85
84
 
86
85
  See LICENSE.txt
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.2"
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
- (@actions || []) & boolkeys # an array of requested actions (or empty)
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 an command-specific action.
500
+ # Define a command-specific action.
493
501
  #
494
- # This is functionality very similar to option, but with an exciting and buoyant twist:
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 specifiec on the command line Drydock looks for command_action or
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"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delano-drydock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum