drydock 0.3.0 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -22,7 +22,6 @@ Or for GitHub fans:
22
22
 
23
23
  See bin/example for more.
24
24
 
25
- require 'rubygems'
26
25
  require 'drydock'
27
26
 
28
27
  default :welcome
@@ -34,27 +33,31 @@ See bin/example for more.
34
33
 
35
34
  command :welcome do
36
35
  # Example: ruby bin/example
37
-
38
- puts "Meatwad: Science is a mystery to man, isn't it Frylock?"
39
- print "Frylock: At least we have some commands: "
40
-
41
- # The commands method returns a hash of Frylock::Command objects
36
+
37
+ puts "Welcome to Drydock. You have the following commands:"
38
+
39
+ # The commands method returns a hash of Drydock::Command objects
42
40
  puts commands.keys.inject([]) { |list, command| list << command.to_s }.sort.join(', ')
43
41
  end
44
-
45
- option :f, :found, "A boolean value. Did you find the car?"
46
- command :findcar do |options|
47
- # +options+ is a hash containing the options defined above
48
- # Example: ruby bin/example -f findcar
42
+
43
+ usage "Example: #{$0} findcar -f"
44
+ option :f, :faster, "A boolean value. Go even faster!"
45
+ command :hurry do |obj|
46
+ # +obj+ is an instance of Drydock::Command. The options you define are available
47
+ # via accessors in this object.
49
48
 
50
- puts "Frylock: So, did they ever find your car?"
51
-
52
- # The keys to the hash are the long string from the option definition.
53
- # If only the short string is provided, those will be used instead (i.e. :f).
54
- puts (!options[:found]) ? "Carl: No" :
55
- "Carl: Oh, they found part of it, hangin' from a trestle near the turnpike."
49
+ puts "Are you hurrying?"
50
+ puts !obj.faster ? "Sort of" : "Yes! I'm literally going as fast as possible"
56
51
  end
52
+
53
+ class JohnWestSmokedOysters < Drydock::Command; end;
54
+ # You can write your own command classes by inheriting from Drydock::Command
55
+ # and referencing it in the command definition.
57
56
 
57
+ command :oysters => JohnWestSmokedOysters do |obj|
58
+ p obj # => #<JohnWestSmokedOysters:0x42179c ... >
59
+ end
60
+
58
61
  == More Information
59
62
 
60
63
  http://www.youtube.com/watch?v=m_wFEB4Oxlo
data/Rakefile CHANGED
@@ -16,13 +16,10 @@ end
16
16
 
17
17
  # PACKAGE =============================================================
18
18
 
19
+ name = "drydock"
20
+ load "#{name}.gemspec"
19
21
 
20
- require File.dirname(__FILE__) + "/lib/drydock"
21
- load "drydock.gemspec"
22
-
23
- version = Drydock::VERSION.to_s
24
-
25
- Drydock.run = false
22
+ version = @spec.version
26
23
 
27
24
  Rake::GemPackageTask.new(@spec) do |p|
28
25
  p.need_tar = true if RUBY_PLATFORM !~ /mswin/
@@ -45,11 +42,11 @@ desc 'Publish website to rubyforge'
45
42
  task 'publish:doc' => 'doc/index.html' do
46
43
  sh 'scp -rp doc/* rubyforge.org:/var/www/gforge-projects/drydock/'
47
44
  end
48
-
45
+ puts "rubyforge add_release drydock drydock #{@spec.version} pkg/drydock-#{@spec.version}.gem "
49
46
  task 'publish:gem' => [:package] do |t|
50
47
  sh <<-end
51
- rubyforge add_release drydock drydock #{@spec.version} pkg/drydock-#{@spec.version}.gem &&
52
- rubyforge add_file drydock drydock #{@spec.version} pkg/drydock-#{@spec.version}.tar.gz
48
+ rubyforge add_release -o Any -a CHANGES.txt -f -n README.rdoc drydock drydock #{@spec.version} pkg/drydock-#{@spec.version}.gem &&
49
+ rubyforge add_file -o Any -a CHANGES.txt -f -n README.rdoc drydock drydock #{@spec.version} pkg/drydock-#{@spec.version}.tgz
53
50
  end
54
51
  end
55
52
 
data/bin/example CHANGED
@@ -74,6 +74,14 @@ command :rogue do |obj, argv|
74
74
  end
75
75
  end
76
76
 
77
+ class JohnWestSmokedOysters < Drydock::Command; end;
78
+ # You can write your own command classes by inheriting from Drydock::Command
79
+ # and referencing it in the command definition.
80
+
81
+ command :oysters => JohnWestSmokedOysters do |obj|
82
+ p obj # => #<JohnWestSmokedOysters:0x42179c ... >
83
+ end
84
+
77
85
  option :c, :check, "Check response codes for each URI"
78
86
  option :d, :delim, String, "Output delimiter"
79
87
  option :t, :timeout, Float, "Timeout value for HTTP request" do |v|
@@ -108,7 +108,7 @@
108
108
  <a class='source-toggle' href='#' onclick="toggleCode('M000007-source'); return false">
109
109
  [show source]
110
110
  </a>
111
- <pre id='M000007-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 165</span>&#x000A;165: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">after</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;166: <span class="ruby-ivar">@@after_block</span> = <span class="ruby-identifier">b</span>&#x000A;167: <span class="ruby-keyword kw">end</span></pre>
111
+ <pre id='M000007-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 166</span>&#x000A;166: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">after</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;167: <span class="ruby-ivar">@@after_block</span> = <span class="ruby-identifier">b</span>&#x000A;168: <span class="ruby-keyword kw">end</span></pre>
112
112
  </div>
113
113
  </div>
114
114
  <div class='public-instance method' id='method-M000015'>
@@ -135,7 +135,7 @@
135
135
  <a class='source-toggle' href='#' onclick="toggleCode('M000015-source'); return false">
136
136
  [show source]
137
137
  </a>
138
- <pre id='M000015-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 274</span>&#x000A;274: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">alias_command</span>(<span class="ruby-identifier">aliaz</span>, <span class="ruby-identifier">cmd</span>)&#x000A;275: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">commands</span>.<span class="ruby-identifier">has_key?</span> <span class="ruby-identifier">cmd</span>&#x000A;276: <span class="ruby-ivar">@@commands</span>[<span class="ruby-identifier">aliaz</span>] = <span class="ruby-identifier">commands</span>[<span class="ruby-identifier">cmd</span>]&#x000A;277: <span class="ruby-keyword kw">end</span></pre>
138
+ <pre id='M000015-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 275</span>&#x000A;275: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">alias_command</span>(<span class="ruby-identifier">aliaz</span>, <span class="ruby-identifier">cmd</span>)&#x000A;276: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">commands</span>.<span class="ruby-identifier">has_key?</span> <span class="ruby-identifier">cmd</span>&#x000A;277: <span class="ruby-ivar">@@commands</span>[<span class="ruby-identifier">aliaz</span>] = <span class="ruby-identifier">commands</span>[<span class="ruby-identifier">cmd</span>]&#x000A;278: <span class="ruby-keyword kw">end</span></pre>
139
139
  </div>
140
140
  </div>
141
141
  <div class='public-instance method' id='method-M000006'>
@@ -154,7 +154,7 @@
154
154
  <a class='source-toggle' href='#' onclick="toggleCode('M000006-source'); return false">
155
155
  [show source]
156
156
  </a>
157
- <pre id='M000006-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 159</span>&#x000A;159: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">before</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;160: <span class="ruby-ivar">@@before_block</span> = <span class="ruby-identifier">b</span>&#x000A;161: <span class="ruby-keyword kw">end</span></pre>
157
+ <pre id='M000006-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 160</span>&#x000A;160: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">before</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;161: <span class="ruby-ivar">@@before_block</span> = <span class="ruby-identifier">b</span>&#x000A;162: <span class="ruby-keyword kw">end</span></pre>
158
158
  </div>
159
159
  </div>
160
160
  <div class='public-instance method' id='method-M000014'>
@@ -179,7 +179,7 @@
179
179
  <a class='source-toggle' href='#' onclick="toggleCode('M000014-source'); return false">
180
180
  [show source]
181
181
  </a>
182
- <pre id='M000014-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 244</span>&#x000A;244: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">command</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">cmds</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;245: <span class="ruby-ivar">@@command_index</span> <span class="ruby-operator">||=</span> <span class="ruby-value">0</span>&#x000A;246: <span class="ruby-ivar">@@command_opts_parser</span> <span class="ruby-operator">||=</span> []&#x000A;247: <span class="ruby-ivar">@@command_option_names</span> <span class="ruby-operator">||=</span> []&#x000A;248: <span class="ruby-identifier">cmds</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">cmd</span><span class="ruby-operator">|</span> &#x000A;249: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cmd</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Hash</span>&#x000A;250: <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cmd</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">cmd</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">first</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;251: <span class="ruby-keyword kw">else</span>&#x000A;252: <span class="ruby-identifier">c</span> = <span class="ruby-constant">Drydock</span><span class="ruby-operator">::</span><span class="ruby-constant">Command</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">cmd</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;253: <span class="ruby-keyword kw">end</span>&#x000A;254: <span class="ruby-identifier">commands</span>[<span class="ruby-identifier">c</span>.<span class="ruby-identifier">cmd</span>] = <span class="ruby-identifier">c</span>&#x000A;255: <span class="ruby-identifier">command_index_map</span>[<span class="ruby-identifier">c</span>.<span class="ruby-identifier">cmd</span>] = <span class="ruby-ivar">@@command_index</span>&#x000A;256: <span class="ruby-ivar">@@command_index</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>&#x000A;257: <span class="ruby-keyword kw">end</span>&#x000A;258: &#x000A;259: <span class="ruby-keyword kw">end</span></pre>
182
+ <pre id='M000014-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 245</span>&#x000A;245: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">command</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">cmds</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;246: <span class="ruby-ivar">@@command_index</span> <span class="ruby-operator">||=</span> <span class="ruby-value">0</span>&#x000A;247: <span class="ruby-ivar">@@command_opts_parser</span> <span class="ruby-operator">||=</span> []&#x000A;248: <span class="ruby-ivar">@@command_option_names</span> <span class="ruby-operator">||=</span> []&#x000A;249: <span class="ruby-identifier">cmds</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">cmd</span><span class="ruby-operator">|</span> &#x000A;250: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cmd</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Hash</span>&#x000A;251: <span class="ruby-identifier">c</span> = <span class="ruby-identifier">cmd</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">cmd</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">first</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;252: <span class="ruby-keyword kw">else</span>&#x000A;253: <span class="ruby-identifier">c</span> = <span class="ruby-constant">Drydock</span><span class="ruby-operator">::</span><span class="ruby-constant">Command</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">cmd</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;254: <span class="ruby-keyword kw">end</span>&#x000A;255: <span class="ruby-identifier">commands</span>[<span class="ruby-identifier">c</span>.<span class="ruby-identifier">cmd</span>] = <span class="ruby-identifier">c</span>&#x000A;256: <span class="ruby-identifier">command_index_map</span>[<span class="ruby-identifier">c</span>.<span class="ruby-identifier">cmd</span>] = <span class="ruby-ivar">@@command_index</span>&#x000A;257: <span class="ruby-ivar">@@command_index</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>&#x000A;258: <span class="ruby-keyword kw">end</span>&#x000A;259: &#x000A;260: <span class="ruby-keyword kw">end</span></pre>
183
183
  </div>
184
184
  </div>
185
185
  <div class='public-instance method' id='method-M000016'>
@@ -210,7 +210,7 @@
210
210
  <a class='source-toggle' href='#' onclick="toggleCode('M000017-source'); return false">
211
211
  [show source]
212
212
  </a>
213
- <pre id='M000017-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 281</span>&#x000A;281: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">commands</span>&#x000A;282: <span class="ruby-ivar">@@commands</span> <span class="ruby-operator">||=</span> {}&#x000A;283: <span class="ruby-keyword kw">end</span></pre>
213
+ <pre id='M000017-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 282</span>&#x000A;282: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">commands</span>&#x000A;283: <span class="ruby-ivar">@@commands</span> <span class="ruby-operator">||=</span> {}&#x000A;284: <span class="ruby-keyword kw">end</span></pre>
214
214
  </div>
215
215
  </div>
216
216
  <div class='public-instance method' id='method-M000002'>
@@ -232,7 +232,7 @@
232
232
  <a class='source-toggle' href='#' onclick="toggleCode('M000002-source'); return false">
233
233
  [show source]
234
234
  </a>
235
- <pre id='M000002-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 126</span>&#x000A;126: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">debug</span>(<span class="ruby-identifier">toggle</span>=<span class="ruby-keyword kw">false</span>)&#x000A;127: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">toggle</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Symbol</span>&#x000A;128: <span class="ruby-ivar">@@debug</span> = <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">toggle</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:on</span>&#x000A;129: <span class="ruby-ivar">@@debug</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">toggle</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:off</span>&#x000A;130: <span class="ruby-keyword kw">else</span>&#x000A;131: <span class="ruby-ivar">@@debug</span> = (<span class="ruby-operator">!</span><span class="ruby-ivar">@@debug</span>)&#x000A;132: <span class="ruby-keyword kw">end</span>&#x000A;133: <span class="ruby-keyword kw">end</span></pre>
235
+ <pre id='M000002-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 127</span>&#x000A;127: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">debug</span>(<span class="ruby-identifier">toggle</span>=<span class="ruby-keyword kw">false</span>)&#x000A;128: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">toggle</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Symbol</span>&#x000A;129: <span class="ruby-ivar">@@debug</span> = <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">toggle</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:on</span>&#x000A;130: <span class="ruby-ivar">@@debug</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">toggle</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:off</span>&#x000A;131: <span class="ruby-keyword kw">else</span>&#x000A;132: <span class="ruby-ivar">@@debug</span> = (<span class="ruby-operator">!</span><span class="ruby-ivar">@@debug</span>)&#x000A;133: <span class="ruby-keyword kw">end</span>&#x000A;134: <span class="ruby-keyword kw">end</span></pre>
236
236
  </div>
237
237
  </div>
238
238
  <div class='public-instance method' id='method-M000003'>
@@ -250,7 +250,7 @@
250
250
  <a class='source-toggle' href='#' onclick="toggleCode('M000003-source'); return false">
251
251
  [show source]
252
252
  </a>
253
- <pre id='M000003-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 135</span>&#x000A;135: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">debug?</span>&#x000A;136: <span class="ruby-ivar">@@debug</span>&#x000A;137: <span class="ruby-keyword kw">end</span></pre>
253
+ <pre id='M000003-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 136</span>&#x000A;136: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">debug?</span>&#x000A;137: <span class="ruby-ivar">@@debug</span>&#x000A;138: <span class="ruby-keyword kw">end</span></pre>
254
254
  </div>
255
255
  </div>
256
256
  <div class='public-instance method' id='method-M000004'>
@@ -269,7 +269,7 @@
269
269
  <a class='source-toggle' href='#' onclick="toggleCode('M000004-source'); return false">
270
270
  [show source]
271
271
  </a>
272
- <pre id='M000004-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 143</span>&#x000A;143: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">default</span>(<span class="ruby-identifier">cmd</span>)&#x000A;144: <span class="ruby-ivar">@@default_command</span> = <span class="ruby-identifier">canonize</span>(<span class="ruby-identifier">cmd</span>)&#x000A;145: <span class="ruby-keyword kw">end</span></pre>
272
+ <pre id='M000004-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 144</span>&#x000A;144: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">default</span>(<span class="ruby-identifier">cmd</span>)&#x000A;145: <span class="ruby-ivar">@@default_command</span> = <span class="ruby-identifier">canonize</span>(<span class="ruby-identifier">cmd</span>)&#x000A;146: <span class="ruby-keyword kw">end</span></pre>
273
273
  </div>
274
274
  </div>
275
275
  <div class='public-instance method' id='method-M000010'>
@@ -288,7 +288,7 @@
288
288
  <a class='source-toggle' href='#' onclick="toggleCode('M000010-source'); return false">
289
289
  [show source]
290
290
  </a>
291
- <pre id='M000010-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 183</span>&#x000A;183: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_current_option_parser</span>&#x000A;184: <span class="ruby-ivar">@@command_opts_parser</span> <span class="ruby-operator">||=</span> []&#x000A;185: <span class="ruby-ivar">@@command_index</span> <span class="ruby-operator">||=</span> <span class="ruby-value">0</span>&#x000A;186: (<span class="ruby-ivar">@@command_opts_parser</span>[<span class="ruby-ivar">@@command_index</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span>)&#x000A;187: <span class="ruby-keyword kw">end</span></pre>
291
+ <pre id='M000010-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 184</span>&#x000A;184: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_current_option_parser</span>&#x000A;185: <span class="ruby-ivar">@@command_opts_parser</span> <span class="ruby-operator">||=</span> []&#x000A;186: <span class="ruby-ivar">@@command_index</span> <span class="ruby-operator">||=</span> <span class="ruby-value">0</span>&#x000A;187: (<span class="ruby-ivar">@@command_opts_parser</span>[<span class="ruby-ivar">@@command_index</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span>)&#x000A;188: <span class="ruby-keyword kw">end</span></pre>
292
292
  </div>
293
293
  </div>
294
294
  <div class='public-instance method' id='method-M000012'>
@@ -306,7 +306,7 @@
306
306
  <a class='source-toggle' href='#' onclick="toggleCode('M000012-source'); return false">
307
307
  [show source]
308
308
  </a>
309
- <pre id='M000012-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 202</span>&#x000A;202: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">global_option</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;203: <span class="ruby-identifier">args</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-identifier">global_opts_parser</span>)&#x000A;204: <span class="ruby-identifier">global_option_names</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">option_parser</span>(<span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;205: <span class="ruby-keyword kw">end</span></pre>
309
+ <pre id='M000012-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 203</span>&#x000A;203: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">global_option</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;204: <span class="ruby-identifier">args</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-identifier">global_opts_parser</span>)&#x000A;205: <span class="ruby-identifier">global_option_names</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">option_parser</span>(<span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;206: <span class="ruby-keyword kw">end</span></pre>
310
310
  </div>
311
311
  </div>
312
312
  <div class='public-instance method' id='method-M000008'>
@@ -325,7 +325,7 @@
325
325
  <a class='source-toggle' href='#' onclick="toggleCode('M000008-source'); return false">
326
326
  [show source]
327
327
  </a>
328
- <pre id='M000008-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 171</span>&#x000A;171: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">global_usage</span>(<span class="ruby-identifier">msg</span>)&#x000A;172: <span class="ruby-ivar">@@global_options</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">OpenStruct</span>.<span class="ruby-identifier">new</span>&#x000A;173: <span class="ruby-identifier">global_opts_parser</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-node">&quot;USAGE: #{msg}&quot;</span>&#x000A;174: <span class="ruby-keyword kw">end</span></pre>
328
+ <pre id='M000008-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 172</span>&#x000A;172: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">global_usage</span>(<span class="ruby-identifier">msg</span>)&#x000A;173: <span class="ruby-ivar">@@global_options</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">OpenStruct</span>.<span class="ruby-identifier">new</span>&#x000A;174: <span class="ruby-identifier">global_opts_parser</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-node">&quot;USAGE: #{msg}&quot;</span>&#x000A;175: <span class="ruby-keyword kw">end</span></pre>
329
329
  </div>
330
330
  </div>
331
331
  <div class='public-instance method' id='method-M000020'>
@@ -343,7 +343,7 @@
343
343
  <a class='source-toggle' href='#' onclick="toggleCode('M000020-source'); return false">
344
344
  [show source]
345
345
  </a>
346
- <pre id='M000020-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 298</span>&#x000A;298: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has_run?</span>&#x000A;299: <span class="ruby-ivar">@@has_run</span>&#x000A;300: <span class="ruby-keyword kw">end</span></pre>
346
+ <pre id='M000020-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 299</span>&#x000A;299: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has_run?</span>&#x000A;300: <span class="ruby-ivar">@@has_run</span>&#x000A;301: <span class="ruby-keyword kw">end</span></pre>
347
347
  </div>
348
348
  </div>
349
349
  <div class='public-instance method' id='method-M000011'>
@@ -371,7 +371,7 @@
371
371
  <a class='source-toggle' href='#' onclick="toggleCode('M000011-source'); return false">
372
372
  [show source]
373
373
  </a>
374
- <pre id='M000011-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 197</span>&#x000A;197: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ignore</span>(<span class="ruby-identifier">what</span>=<span class="ruby-identifier">:nothing</span>)&#x000A;198: <span class="ruby-ivar">@@command_opts_parser</span>[<span class="ruby-ivar">@@command_index</span>] = <span class="ruby-identifier">:ignore</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">what</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:options</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">what</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:all</span>&#x000A;199: <span class="ruby-keyword kw">end</span></pre>
374
+ <pre id='M000011-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 198</span>&#x000A;198: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ignore</span>(<span class="ruby-identifier">what</span>=<span class="ruby-identifier">:nothing</span>)&#x000A;199: <span class="ruby-ivar">@@command_opts_parser</span>[<span class="ruby-ivar">@@command_index</span>] = <span class="ruby-identifier">:ignore</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">what</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:options</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">what</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:all</span>&#x000A;200: <span class="ruby-keyword kw">end</span></pre>
375
375
  </div>
376
376
  </div>
377
377
  <div class='public-instance method' id='method-M000013'>
@@ -406,7 +406,7 @@
406
406
  <a class='source-toggle' href='#' onclick="toggleCode('M000013-source'); return false">
407
407
  [show source]
408
408
  </a>
409
- <pre id='M000013-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 226</span>&#x000A;226: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">option</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;227: <span class="ruby-identifier">args</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-identifier">get_current_option_parser</span>)&#x000A;228: <span class="ruby-identifier">current_command_option_names</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">option_parser</span>(<span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;229: <span class="ruby-keyword kw">end</span></pre>
409
+ <pre id='M000013-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 227</span>&#x000A;227: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">option</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;228: <span class="ruby-identifier">args</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-identifier">get_current_option_parser</span>)&#x000A;229: <span class="ruby-identifier">current_command_option_names</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">option_parser</span>(<span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;230: <span class="ruby-keyword kw">end</span></pre>
410
410
  </div>
411
411
  </div>
412
412
  <div class='public-instance method' id='method-M000021'>
@@ -428,7 +428,7 @@
428
428
  <a class='source-toggle' href='#' onclick="toggleCode('M000021-source'); return false">
429
429
  [show source]
430
430
  </a>
431
- <pre id='M000021-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 306</span>&#x000A;306: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run!</span>(<span class="ruby-identifier">argv</span>=[], <span class="ruby-identifier">stdin</span>=<span class="ruby-constant">STDIN</span>)&#x000A;307: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">has_run?</span>&#x000A;308: <span class="ruby-ivar">@@has_run</span> = <span class="ruby-keyword kw">true</span>&#x000A;309: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NoCommandsDefined</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">commands</span>&#x000A;310: <span class="ruby-ivar">@@global_options</span>, <span class="ruby-identifier">cmd_name</span>, <span class="ruby-ivar">@@command_options</span>, <span class="ruby-identifier">argv</span> = <span class="ruby-identifier">process_arguments</span>(<span class="ruby-identifier">argv</span>)&#x000A;311: &#x000A;312: <span class="ruby-identifier">cmd_name</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">default_command</span>&#x000A;313: &#x000A;314: <span class="ruby-identifier">raise</span> <span class="ruby-constant">UnknownCommand</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">cmd_name</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">command?</span>(<span class="ruby-identifier">cmd_name</span>)&#x000A;315: &#x000A;316: <span class="ruby-identifier">stdin</span> = (<span class="ruby-keyword kw">defined?</span> <span class="ruby-ivar">@@stdin_block</span>) <span class="ruby-operator">?</span> <span class="ruby-ivar">@@stdin_block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">stdin</span>, []) <span class="ruby-operator">:</span> <span class="ruby-identifier">stdin</span>&#x000A;317: <span class="ruby-ivar">@@before_block</span>.<span class="ruby-identifier">call</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">defined?</span> <span class="ruby-ivar">@@before_block</span>&#x000A;318: &#x000A;319: <span class="ruby-identifier">call_command</span>(<span class="ruby-identifier">cmd_name</span>, <span class="ruby-identifier">argv</span>, <span class="ruby-identifier">stdin</span>)&#x000A;320: &#x000A;321: <span class="ruby-ivar">@@after_block</span>.<span class="ruby-identifier">call</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">defined?</span> <span class="ruby-ivar">@@after_block</span>&#x000A;322: &#x000A;323: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidOption</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">ex</span>&#x000A;324: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Drydock</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidArgument</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ex</span>.<span class="ruby-identifier">args</span>)&#x000A;325: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">MissingArgument</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">ex</span>&#x000A;326: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Drydock</span><span class="ruby-operator">::</span><span class="ruby-constant">MissingArgument</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ex</span>.<span class="ruby-identifier">args</span>)&#x000A;327: <span class="ruby-keyword kw">end</span></pre>
431
+ <pre id='M000021-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 307</span>&#x000A;307: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run!</span>(<span class="ruby-identifier">argv</span>=[], <span class="ruby-identifier">stdin</span>=<span class="ruby-constant">STDIN</span>)&#x000A;308: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">has_run?</span>&#x000A;309: <span class="ruby-ivar">@@has_run</span> = <span class="ruby-keyword kw">true</span>&#x000A;310: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NoCommandsDefined</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">commands</span>.<span class="ruby-identifier">empty?</span>&#x000A;311: <span class="ruby-ivar">@@global_options</span>, <span class="ruby-identifier">cmd_name</span>, <span class="ruby-ivar">@@command_options</span>, <span class="ruby-identifier">argv</span> = <span class="ruby-identifier">process_arguments</span>(<span class="ruby-identifier">argv</span>)&#x000A;312: &#x000A;313: <span class="ruby-identifier">cmd_name</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">default_command</span>&#x000A;314: &#x000A;315: <span class="ruby-identifier">raise</span> <span class="ruby-constant">UnknownCommand</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">cmd_name</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">command?</span>(<span class="ruby-identifier">cmd_name</span>)&#x000A;316: &#x000A;317: <span class="ruby-identifier">stdin</span> = (<span class="ruby-keyword kw">defined?</span> <span class="ruby-ivar">@@stdin_block</span>) <span class="ruby-operator">?</span> <span class="ruby-ivar">@@stdin_block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">stdin</span>, []) <span class="ruby-operator">:</span> <span class="ruby-identifier">stdin</span>&#x000A;318: <span class="ruby-ivar">@@before_block</span>.<span class="ruby-identifier">call</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">defined?</span> <span class="ruby-ivar">@@before_block</span>&#x000A;319: &#x000A;320: <span class="ruby-identifier">call_command</span>(<span class="ruby-identifier">cmd_name</span>, <span class="ruby-identifier">argv</span>, <span class="ruby-identifier">stdin</span>)&#x000A;321: &#x000A;322: <span class="ruby-ivar">@@after_block</span>.<span class="ruby-identifier">call</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">defined?</span> <span class="ruby-ivar">@@after_block</span>&#x000A;323: &#x000A;324: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidOption</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">ex</span>&#x000A;325: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Drydock</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidArgument</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ex</span>.<span class="ruby-identifier">args</span>)&#x000A;326: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">MissingArgument</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">ex</span>&#x000A;327: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Drydock</span><span class="ruby-operator">::</span><span class="ruby-constant">MissingArgument</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ex</span>.<span class="ruby-identifier">args</span>)&#x000A;328: <span class="ruby-keyword kw">end</span></pre>
432
432
  </div>
433
433
  </div>
434
434
  <div class='public-instance method' id='method-M000019'>
@@ -447,7 +447,7 @@
447
447
  <a class='source-toggle' href='#' onclick="toggleCode('M000019-source'); return false">
448
448
  [show source]
449
449
  </a>
450
- <pre id='M000019-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 293</span>&#x000A;293: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run=</span>(<span class="ruby-identifier">v</span>)&#x000A;294: <span class="ruby-ivar">@@run</span> = (<span class="ruby-identifier">v</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span> &#x000A;295: <span class="ruby-keyword kw">end</span></pre>
450
+ <pre id='M000019-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 294</span>&#x000A;294: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run=</span>(<span class="ruby-identifier">v</span>)&#x000A;295: <span class="ruby-ivar">@@run</span> = (<span class="ruby-identifier">v</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span> &#x000A;296: <span class="ruby-keyword kw">end</span></pre>
451
451
  </div>
452
452
  </div>
453
453
  <div class='public-instance method' id='method-M000018'>
@@ -465,7 +465,7 @@
465
465
  <a class='source-toggle' href='#' onclick="toggleCode('M000018-source'); return false">
466
466
  [show source]
467
467
  </a>
468
- <pre id='M000018-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 286</span>&#x000A;286: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run?</span>&#x000A;287: <span class="ruby-ivar">@@run</span>&#x000A;288: <span class="ruby-keyword kw">end</span></pre>
468
+ <pre id='M000018-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 287</span>&#x000A;287: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run?</span>&#x000A;288: <span class="ruby-ivar">@@run</span>&#x000A;289: <span class="ruby-keyword kw">end</span></pre>
469
469
  </div>
470
470
  </div>
471
471
  <div class='public-instance method' id='method-M000005'>
@@ -489,7 +489,7 @@
489
489
  <a class='source-toggle' href='#' onclick="toggleCode('M000005-source'); return false">
490
490
  [show source]
491
491
  </a>
492
- <pre id='M000005-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 153</span>&#x000A;153: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stdin</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;154: <span class="ruby-ivar">@@stdin_block</span> = <span class="ruby-identifier">b</span>&#x000A;155: <span class="ruby-keyword kw">end</span></pre>
492
+ <pre id='M000005-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 154</span>&#x000A;154: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stdin</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">b</span>)&#x000A;155: <span class="ruby-ivar">@@stdin_block</span> = <span class="ruby-identifier">b</span>&#x000A;156: <span class="ruby-keyword kw">end</span></pre>
493
493
  </div>
494
494
  </div>
495
495
  <div class='public-instance method' id='method-M000009'>
@@ -508,7 +508,7 @@
508
508
  <a class='source-toggle' href='#' onclick="toggleCode('M000009-source'); return false">
509
509
  [show source]
510
510
  </a>
511
- <pre id='M000009-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 178</span>&#x000A;178: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">usage</span>(<span class="ruby-identifier">msg</span>)&#x000A;179: <span class="ruby-identifier">get_current_option_parser</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-node">&quot;USAGE: #{msg}&quot;</span>&#x000A;180: <span class="ruby-keyword kw">end</span></pre>
511
+ <pre id='M000009-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 179</span>&#x000A;179: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">usage</span>(<span class="ruby-identifier">msg</span>)&#x000A;180: <span class="ruby-identifier">get_current_option_parser</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-node">&quot;USAGE: #{msg}&quot;</span>&#x000A;181: <span class="ruby-keyword kw">end</span></pre>
512
512
  </div>
513
513
  </div>
514
514
  </div>
data/doc/created.rid CHANGED
@@ -1 +1 @@
1
- Thu, 05 Feb 2009 12:58:48 -0500
1
+ Fri, 06 Feb 2009 10:28:08 -0500
@@ -31,7 +31,7 @@
31
31
  </div>
32
32
  <div class='last-update'>
33
33
  Last Update:
34
- <span class='datetime'>Thu Feb 05 12:49:48 -0500 2009</span>
34
+ <span class='datetime'>Thu Feb 05 13:19:37 -0500 2009</span>
35
35
  </div>
36
36
  </div>
37
37
  <div id='content'>
@@ -31,7 +31,7 @@
31
31
  </div>
32
32
  <div class='last-update'>
33
33
  Last Update:
34
- <span class='datetime'>Thu Feb 05 12:49:48 -0500 2009</span>
34
+ <span class='datetime'>Thu Feb 05 13:19:38 -0500 2009</span>
35
35
  </div>
36
36
  </div>
37
37
  <div id='content'>
@@ -31,7 +31,7 @@
31
31
  </div>
32
32
  <div class='last-update'>
33
33
  Last Update:
34
- <span class='datetime'>Thu Feb 05 12:55:58 -0500 2009</span>
34
+ <span class='datetime'>Fri Feb 06 10:27:45 -0500 2009</span>
35
35
  </div>
36
36
  </div>
37
37
  <div id='content'>
@@ -75,7 +75,7 @@
75
75
  <p>
76
76
  See <a href="bin/example.html">bin/example</a> for more.
77
77
  </p>
78
- <pre>require 'rubygems'&#x000A;require 'drydock'&#x000A;&#x000A;default :welcome&#x000A;&#x000A;before do&#x000A;# You can execute a block before the requests command is executed. Instance&#x000A;# variables defined here will be available to all commands.&#x000A;end&#x000A;&#x000A;command :welcome do&#x000A;# Example: ruby bin/example&#x000A;&#x000A; puts &quot;Meatwad: Science is a mystery to man, isn't it Frylock?&quot;&#x000A; print &quot;Frylock: At least we have some commands: &quot;&#x000A;&#x000A; # The commands method returns a hash of Frylock::Command objects&#x000A; puts commands.keys.inject([]) { |list, command| list &lt;&lt; command.to_s }.sort.join(', ')&#x000A;end&#x000A;&#x000A;option :f, :found, &quot;A boolean value. Did you find the car?&quot;&#x000A;command :findcar do |options|&#x000A;# +options+ is a hash containing the options defined above&#x000A;# Example: ruby bin/example -f findcar&#x000A;&#x000A; puts &quot;Frylock: So, did they ever find your car?&quot;&#x000A;&#x000A; # The keys to the hash are the long string from the option definition.&#x000A; # If only the short string is provided, those will be used instead (i.e. :f).&#x000A; puts (!options[:found]) ? &quot;Carl: No&quot; :&#x000A; &quot;Carl: Oh, they found part of it, hangin' from a trestle near the turnpike.&quot;&#x000A;end</pre>
78
+ <pre>require 'drydock'&#x000A;&#x000A;default :welcome&#x000A;&#x000A;before do&#x000A;# You can execute a block before the requests command is executed. Instance&#x000A;# variables defined here will be available to all commands.&#x000A;end&#x000A;&#x000A;command :welcome do&#x000A;# Example: ruby bin/example&#x000A;&#x000A; puts &quot;Welcome to Drydock. You have the following commands:&quot;&#x000A;&#x000A; # The commands method returns a hash of Drydock::Command objects&#x000A; puts commands.keys.inject([]) { |list, command| list &lt;&lt; command.to_s }.sort.join(', ')&#x000A;end&#x000A;&#x000A;usage &quot;Example: #{$0} findcar -f&quot;&#x000A;option :f, :faster, &quot;A boolean value. Go even faster!&quot;&#x000A;command :hurry do |obj|&#x000A;# +obj+ is an instance of Drydock::Command. The options you define are available&#x000A;# via accessors in this object.&#x000A;&#x000A; puts &quot;Are you hurrying?&quot;&#x000A; puts !obj.faster ? &quot;Sort of&quot; : &quot;Yes! I'm literally going as fast as possible&quot;&#x000A;end&#x000A;&#x000A;class JohnWestSmokedOysters &lt; Drydock::Command; end;&#x000A;# You can write your own command classes by inheriting from Drydock::Command&#x000A;# and referencing it in the command definition.&#x000A;&#x000A;command :oysters =&gt; JohnWestSmokedOysters do |obj|&#x000A; p obj # =&gt; #&lt;JohnWestSmokedOysters:0x42179c ... &gt;&#x000A;end</pre>
79
79
  <h2>More Information</h2>
80
80
  <p>
81
81
  <a
@@ -31,7 +31,7 @@
31
31
  </div>
32
32
  <div class='last-update'>
33
33
  Last Update:
34
- <span class='datetime'>Thu Feb 05 12:49:48 -0500 2009</span>
34
+ <span class='datetime'>Fri Feb 06 10:27:45 -0500 2009</span>
35
35
  </div>
36
36
  </div>
37
37
  <div id='content'>
@@ -77,7 +77,7 @@
77
77
  <a class='source-toggle' href='#' onclick="toggleCode('M000001-source'); return false">
78
78
  [show source]
79
79
  </a>
80
- <pre id='M000001-source'> <span class="ruby-comment cmt"># File bin/example, line 141</span>&#x000A;141: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response_code</span>(<span class="ruby-identifier">uri_str</span>, <span class="ruby-identifier">duration</span>=<span class="ruby-value">5</span>)&#x000A;142: <span class="ruby-identifier">response</span> = <span class="ruby-identifier">:unavailable</span>&#x000A;143: <span class="ruby-keyword kw">begin</span> &#x000A;144: <span class="ruby-identifier">uri</span> = (<span class="ruby-identifier">uri_str</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">uri_str</span> <span class="ruby-operator">:</span> <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri_str</span>) &#x000A;145: <span class="ruby-identifier">timeout</span>(<span class="ruby-identifier">duration</span>) <span class="ruby-keyword kw">do</span>&#x000A;146: <span class="ruby-identifier">response</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">get_response</span>(<span class="ruby-identifier">uri</span>).<span class="ruby-identifier">code</span>&#x000A;147: <span class="ruby-keyword kw">end</span> &#x000A;148: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">ex</span>&#x000A;149: <span class="ruby-keyword kw">end</span>&#x000A;150: <span class="ruby-identifier">response</span>&#x000A;151: <span class="ruby-keyword kw">end</span></pre>
80
+ <pre id='M000001-source'> <span class="ruby-comment cmt"># File bin/example, line 149</span>&#x000A;149: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response_code</span>(<span class="ruby-identifier">uri_str</span>, <span class="ruby-identifier">duration</span>=<span class="ruby-value">5</span>)&#x000A;150: <span class="ruby-identifier">response</span> = <span class="ruby-identifier">:unavailable</span>&#x000A;151: <span class="ruby-keyword kw">begin</span> &#x000A;152: <span class="ruby-identifier">uri</span> = (<span class="ruby-identifier">uri_str</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">uri_str</span> <span class="ruby-operator">:</span> <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri_str</span>) &#x000A;153: <span class="ruby-identifier">timeout</span>(<span class="ruby-identifier">duration</span>) <span class="ruby-keyword kw">do</span>&#x000A;154: <span class="ruby-identifier">response</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">get_response</span>(<span class="ruby-identifier">uri</span>).<span class="ruby-identifier">code</span>&#x000A;155: <span class="ruby-keyword kw">end</span> &#x000A;156: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">ex</span>&#x000A;157: <span class="ruby-keyword kw">end</span>&#x000A;158: <span class="ruby-identifier">response</span>&#x000A;159: <span class="ruby-keyword kw">end</span></pre>
81
81
  </div>
82
82
  </div>
83
83
  </div>
@@ -31,7 +31,7 @@
31
31
  </div>
32
32
  <div class='last-update'>
33
33
  Last Update:
34
- <span class='datetime'>Thu Feb 05 12:49:48 -0500 2009</span>
34
+ <span class='datetime'>Fri Feb 06 10:27:45 -0500 2009</span>
35
35
  </div>
36
36
  </div>
37
37
  <div id='content'>
@@ -12,7 +12,7 @@
12
12
  <ol class='classes' id='index-entries'>
13
13
  <li><a href="classes/Drydock.html">Drydock</a>
14
14
  <ol><li><a href="classes/Drydock/Command.html"><span class="parent">Drydock::</span>Command</a></li><li><a href="classes/Drydock/InvalidArgument.html"><span class="parent">Drydock::</span>InvalidArgument</a></li><li><a href="classes/Drydock/MissingArgument.html"><span class="parent">Drydock::</span>MissingArgument</a></li><li><a href="classes/Drydock/NoCommandsDefined.html"><span class="parent">Drydock::</span>NoCommandsDefined</a></li><li><a href="classes/Drydock/UnknownCommand.html"><span class="parent">Drydock::</span>UnknownCommand</a></li>
15
- </ol></li>
15
+ </ol></li><li><a href="classes/JohnWestSmokedOysters.html">JohnWestSmokedOysters</a></li>
16
16
  </ol>
17
17
  </div>
18
18
  </body>
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.3.0"
3
+ s.version = "0.3.2"
4
4
  s.specification_version = 1 if s.respond_to? :specification_version=
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
 
@@ -44,7 +44,7 @@
44
44
  s.has_rdoc = true
45
45
  s.homepage = %q{http://github.com/delano/drydock}
46
46
  s.extra_rdoc_files = %w[README.rdoc LICENSE.txt CHANGES.txt]
47
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Drydock: a DSL for command-line apps", "--main", "README.rdoc"]
47
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Drydock: a seaworthy DSL for command-line apps", "--main", "README.rdoc"]
48
48
  s.require_paths = ["lib"]
49
49
  s.rubygems_version = %q{1.1.1}
50
50
  s.summary = %q{A seaworthy DSL for writing command line apps}
data/lib/drydock.rb CHANGED
@@ -113,6 +113,7 @@ module Drydock
113
113
  @@debug = false
114
114
  @@has_run = false
115
115
  @@run = true
116
+ @@default_command = nil
116
117
 
117
118
  public
118
119
  # Enable or disable debug output.
@@ -305,7 +306,7 @@ module Drydock
305
306
  def run!(argv=[], stdin=STDIN)
306
307
  return if has_run?
307
308
  @@has_run = true
308
- raise NoCommandsDefined.new unless commands
309
+ raise NoCommandsDefined.new if commands.empty?
309
310
  @@global_options, cmd_name, @@command_options, argv = process_arguments(argv)
310
311
 
311
312
  cmd_name ||= default_command
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drydock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum
@@ -62,7 +62,7 @@ rdoc_options:
62
62
  - --line-numbers
63
63
  - --inline-source
64
64
  - --title
65
- - "Drydock: a DSL for command-line apps"
65
+ - "Drydock: a seaworthy DSL for command-line apps"
66
66
  - --main
67
67
  - README.rdoc
68
68
  require_paths: