drydock 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +20 -17
- data/Rakefile +6 -9
- data/bin/example +8 -0
- data/doc/classes/Drydock.html +19 -19
- data/doc/created.rid +1 -1
- data/doc/files/CHANGES_txt.html +1 -1
- data/doc/files/LICENSE_txt.html +1 -1
- data/doc/files/README_rdoc.html +2 -2
- data/doc/files/bin/example.html +2 -2
- data/doc/files/lib/drydock_rb.html +1 -1
- data/doc/fr_class_index.html +1 -1
- data/drydock.gemspec +2 -2
- data/lib/drydock.rb +2 -1
- metadata +2 -2
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
|
-
|
39
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
48
|
-
#
|
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 "
|
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
|
-
|
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
|
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|
|
data/doc/classes/Drydock.html
CHANGED
@@ -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
|
111
|
+
<pre id='M000007-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 166</span>
166: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">after</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">b</span>)
167: <span class="ruby-ivar">@@after_block</span> = <span class="ruby-identifier">b</span>
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
|
138
|
+
<pre id='M000015-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 275</span>
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>)
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>
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>]
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
|
157
|
+
<pre id='M000006-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 160</span>
160: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">before</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">b</span>)
161: <span class="ruby-ivar">@@before_block</span> = <span class="ruby-identifier">b</span>
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
|
182
|
+
<pre id='M000014-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 245</span>
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">&</span><span class="ruby-identifier">b</span>)
246: <span class="ruby-ivar">@@command_index</span> <span class="ruby-operator">||=</span> <span class="ruby-value">0</span>
247: <span class="ruby-ivar">@@command_opts_parser</span> <span class="ruby-operator">||=</span> []
248: <span class="ruby-ivar">@@command_option_names</span> <span class="ruby-operator">||=</span> []
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> 
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>
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">&</span><span class="ruby-identifier">b</span>)
252: <span class="ruby-keyword kw">else</span>
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">&</span><span class="ruby-identifier">b</span>)
254: <span class="ruby-keyword kw">end</span>
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>
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>
257: <span class="ruby-ivar">@@command_index</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
258: <span class="ruby-keyword kw">end</span>
259: 
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
|
213
|
+
<pre id='M000017-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 282</span>
282: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">commands</span>
283: <span class="ruby-ivar">@@commands</span> <span class="ruby-operator">||=</span> {}
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
|
235
|
+
<pre id='M000002-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 127</span>
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>)
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>
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>
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>
131: <span class="ruby-keyword kw">else</span>
132: <span class="ruby-ivar">@@debug</span> = (<span class="ruby-operator">!</span><span class="ruby-ivar">@@debug</span>)
133: <span class="ruby-keyword kw">end</span>
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
|
253
|
+
<pre id='M000003-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 136</span>
136: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">debug?</span>
137: <span class="ruby-ivar">@@debug</span>
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
|
272
|
+
<pre id='M000004-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 144</span>
144: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">default</span>(<span class="ruby-identifier">cmd</span>)
145: <span class="ruby-ivar">@@default_command</span> = <span class="ruby-identifier">canonize</span>(<span class="ruby-identifier">cmd</span>)
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
|
291
|
+
<pre id='M000010-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 184</span>
184: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_current_option_parser</span>
185: <span class="ruby-ivar">@@command_opts_parser</span> <span class="ruby-operator">||=</span> []
186: <span class="ruby-ivar">@@command_index</span> <span class="ruby-operator">||=</span> <span class="ruby-value">0</span>
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>)
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
|
309
|
+
<pre id='M000012-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 203</span>
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">&</span><span class="ruby-identifier">b</span>)
204: <span class="ruby-identifier">args</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-identifier">global_opts_parser</span>)
205: <span class="ruby-identifier">global_option_names</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">option_parser</span>(<span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">b</span>)
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
|
328
|
+
<pre id='M000008-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 172</span>
172: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">global_usage</span>(<span class="ruby-identifier">msg</span>)
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>
174: <span class="ruby-identifier">global_opts_parser</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-node">"USAGE: #{msg}"</span>
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
|
346
|
+
<pre id='M000020-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 299</span>
299: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has_run?</span>
300: <span class="ruby-ivar">@@has_run</span>
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
|
374
|
+
<pre id='M000011-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 198</span>
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>)
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>
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
|
409
|
+
<pre id='M000013-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 227</span>
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">&</span><span class="ruby-identifier">b</span>)
228: <span class="ruby-identifier">args</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-identifier">get_current_option_parser</span>)
229: <span class="ruby-identifier">current_command_option_names</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">option_parser</span>(<span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">b</span>)
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
|
431
|
+
<pre id='M000021-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 307</span>
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>)
308: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">has_run?</span>
309: <span class="ruby-ivar">@@has_run</span> = <span class="ruby-keyword kw">true</span>
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>
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>)
312: 
313: <span class="ruby-identifier">cmd_name</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">default_command</span>
314: 
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>)
316: 
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>
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>
319: 
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>)
321: 
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>
323: 
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">></span> <span class="ruby-identifier">ex</span>
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>)
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">></span> <span class="ruby-identifier">ex</span>
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>)
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
|
450
|
+
<pre id='M000019-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 294</span>
294: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run=</span>(<span class="ruby-identifier">v</span>)
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> 
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
|
468
|
+
<pre id='M000018-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 287</span>
287: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run?</span>
288: <span class="ruby-ivar">@@run</span>
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
|
492
|
+
<pre id='M000005-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 154</span>
154: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stdin</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">b</span>)
155: <span class="ruby-ivar">@@stdin_block</span> = <span class="ruby-identifier">b</span>
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
|
511
|
+
<pre id='M000009-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 179</span>
179: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">usage</span>(<span class="ruby-identifier">msg</span>)
180: <span class="ruby-identifier">get_current_option_parser</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-node">"USAGE: #{msg}"</span>
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
|
-
|
1
|
+
Fri, 06 Feb 2009 10:28:08 -0500
|
data/doc/files/CHANGES_txt.html
CHANGED
data/doc/files/LICENSE_txt.html
CHANGED
data/doc/files/README_rdoc.html
CHANGED
@@ -31,7 +31,7 @@
|
|
31
31
|
</div>
|
32
32
|
<div class='last-update'>
|
33
33
|
Last Update:
|
34
|
-
<span class='datetime'>
|
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 '
|
78
|
+
<pre>require 'drydock'

default :welcome

before do
# You can execute a block before the requests command is executed. Instance
# variables defined here will be available to all commands.
end

command :welcome do
# Example: ruby bin/example

 puts "Welcome to Drydock. You have the following commands:"

 # The commands method returns a hash of Drydock::Command objects
 puts commands.keys.inject([]) { |list, command| list << command.to_s }.sort.join(', ')
end

usage "Example: #{$0} findcar -f"
option :f, :faster, "A boolean value. Go even faster!"
command :hurry do |obj|
# +obj+ is an instance of Drydock::Command. The options you define are available
# via accessors in this object.

 puts "Are you hurrying?"
 puts !obj.faster ? "Sort of" : "Yes! I'm literally going as fast as possible"
end

class JohnWestSmokedOysters < Drydock::Command; end;
# You can write your own command classes by inheriting from Drydock::Command
# and referencing it in the command definition.

command :oysters => JohnWestSmokedOysters do |obj|
 p obj # => #<JohnWestSmokedOysters:0x42179c ... >
end</pre>
|
79
79
|
<h2>More Information</h2>
|
80
80
|
<p>
|
81
81
|
<a
|
data/doc/files/bin/example.html
CHANGED
@@ -31,7 +31,7 @@
|
|
31
31
|
</div>
|
32
32
|
<div class='last-update'>
|
33
33
|
Last Update:
|
34
|
-
<span class='datetime'>
|
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
|
80
|
+
<pre id='M000001-source'> <span class="ruby-comment cmt"># File bin/example, line 149</span>
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>)
150: <span class="ruby-identifier">response</span> = <span class="ruby-identifier">:unavailable</span>
151: <span class="ruby-keyword kw">begin</span> 
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>) 
153: <span class="ruby-identifier">timeout</span>(<span class="ruby-identifier">duration</span>) <span class="ruby-keyword kw">do</span>
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>
155: <span class="ruby-keyword kw">end</span> 
156: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ex</span>
157: <span class="ruby-keyword kw">end</span>
158: <span class="ruby-identifier">response</span>
159: <span class="ruby-keyword kw">end</span></pre>
|
81
81
|
</div>
|
82
82
|
</div>
|
83
83
|
</div>
|
data/doc/fr_class_index.html
CHANGED
@@ -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.
|
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
|
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.
|
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:
|