drydock 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +12 -0
- data/README.rdoc +39 -35
- data/Rakefile +11 -6
- data/bin/example +22 -17
- data/doc/classes/Drydock.html +101 -101
- data/doc/classes/Drydock/Command.html +26 -18
- data/doc/classes/Drydock/InvalidArgument.html +11 -11
- data/doc/classes/Drydock/MissingArgument.html +6 -6
- data/doc/classes/Drydock/NoCommandsDefined.html +6 -6
- data/doc/classes/Drydock/UnknownCommand.html +11 -11
- data/doc/created.rid +1 -1
- data/doc/files/CHANGES_txt.html +25 -2
- data/doc/files/LICENSE_txt.html +2 -2
- data/doc/files/README_rdoc.html +14 -6
- data/doc/files/bin/example.html +19 -33
- data/doc/files/lib/drydock_rb.html +2 -2
- data/doc/fr_class_index.html +1 -1
- data/doc/fr_file_index.html +1 -1
- data/doc/fr_method_index.html +59 -61
- data/doc/index.html +1 -1
- data/drydock.gemspec +1 -1
- data/lib/drydock.rb +11 -0
- metadata +1 -1
data/CHANGES.txt
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
DRYDOCK, CHANGES
|
2
2
|
|
3
|
+
TODO:
|
4
|
+
* Fix '-' '_' ambiguity for option names
|
5
|
+
* Calls valid? method (if present) before calling command block.
|
6
|
+
|
7
|
+
|
8
|
+
#### 0.3.3 (2009-02-14) ###############################
|
9
|
+
|
10
|
+
* NEW: init method hook for subclasses of Drydock::Command
|
11
|
+
* UPDATED: Rdocs
|
12
|
+
|
13
|
+
|
3
14
|
#### 0.3 (2009-02-05) ###############################
|
4
15
|
|
5
16
|
* Added support for custom Drydock::Commands objects
|
@@ -10,6 +21,7 @@ DRYDOCK, CHANGES
|
|
10
21
|
* Started adding tests
|
11
22
|
* Improved documentation
|
12
23
|
|
24
|
+
|
13
25
|
#### 0.2 (2008-12-27) ###############################
|
14
26
|
|
15
27
|
* Initial release
|
data/README.rdoc
CHANGED
@@ -22,45 +22,49 @@ Or for GitHub fans:
|
|
22
22
|
|
23
23
|
See bin/example for more.
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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.
|
25
|
+
require 'drydock'
|
26
|
+
|
27
|
+
default :welcome
|
28
|
+
|
29
|
+
before do
|
30
|
+
# You can execute a block before the requests command is executed. Instance
|
31
|
+
# variables defined here will be available to all commands.
|
32
|
+
end
|
33
|
+
|
34
|
+
command :welcome do
|
35
|
+
# Example: ruby bin/example
|
36
|
+
|
37
|
+
puts "Welcome to Drydock. You have the following commands:"
|
38
|
+
|
39
|
+
# The commands method returns a hash of Drydock::Command objects
|
40
|
+
puts commands.keys.inject([]) { |list, command| list << command.to_s }.sort.join(', ')
|
41
|
+
end
|
48
42
|
|
49
|
-
|
50
|
-
|
51
|
-
|
43
|
+
usage "Example: #{$0} laugh [-f]"
|
44
|
+
option :f, :faster, "A boolean value. Go even faster!"
|
45
|
+
command :laugh do |obj|
|
46
|
+
# +obj+ is an instance of Drydock::Command. The options you define are available
|
47
|
+
# via accessors in this object.
|
48
|
+
|
49
|
+
answer = !obj.faster ? "Sort of" : "Yes! I'm literally laughing as fast as possible."
|
50
|
+
|
51
|
+
puts "Captain Stubing: Are you laughing?"
|
52
|
+
puts "Dr. Bricker: " << answer
|
53
|
+
end
|
54
|
+
|
55
|
+
class JohnWestSmokedOysters < Drydock::Command; end;
|
56
|
+
# You can write your own command classes by inheriting from Drydock::Command
|
57
|
+
# and referencing it in the command definition.
|
58
|
+
|
59
|
+
command :oysters => JohnWestSmokedOysters do |obj|
|
60
|
+
p obj # => #<JohnWestSmokedOysters:0x42179c ... >
|
61
|
+
end
|
52
62
|
|
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.
|
56
|
-
|
57
|
-
command :oysters => JohnWestSmokedOysters do |obj|
|
58
|
-
p obj # => #<JohnWestSmokedOysters:0x42179c ... >
|
59
|
-
end
|
60
|
-
|
61
63
|
== More Information
|
62
64
|
|
63
|
-
http://
|
65
|
+
* http://github.com/delano/drydock
|
66
|
+
* http://drydock.rubyforge.org/ (rdocs)
|
67
|
+
* http://www.youtube.com/watch?v=m_wFEB4Oxlo
|
64
68
|
|
65
69
|
== Credits
|
66
70
|
|
data/Rakefile
CHANGED
@@ -11,7 +11,12 @@ task :default => :test
|
|
11
11
|
|
12
12
|
desc 'Run specs with unit test style output'
|
13
13
|
task :test do |t|
|
14
|
-
sh "ruby
|
14
|
+
sh "ruby test/*_test.rb"
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Run bin/example and tryouts'
|
18
|
+
task :tryouts do |t|
|
19
|
+
sh "ruby bin/example"
|
15
20
|
end
|
16
21
|
|
17
22
|
# PACKAGE =============================================================
|
@@ -40,20 +45,20 @@ end
|
|
40
45
|
|
41
46
|
desc 'Publish website to rubyforge'
|
42
47
|
task 'publish:doc' => 'doc/index.html' do
|
43
|
-
sh
|
48
|
+
sh "scp -rp doc/* rubyforge.org:/var/www/gforge-projects/#{name}/"
|
44
49
|
end
|
45
|
-
|
50
|
+
|
46
51
|
task 'publish:gem' => [:package] do |t|
|
47
52
|
sh <<-end
|
48
|
-
rubyforge add_release -o Any -a CHANGES.txt -f -n README.rdoc
|
49
|
-
rubyforge add_file -o Any -a CHANGES.txt -f -n README.rdoc
|
53
|
+
rubyforge add_release -o Any -a CHANGES.txt -f -n README.rdoc #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.gem &&
|
54
|
+
rubyforge add_file -o Any -a CHANGES.txt -f -n README.rdoc #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.tgz
|
50
55
|
end
|
51
56
|
end
|
52
57
|
|
53
58
|
|
54
59
|
Rake::RDocTask.new do |t|
|
55
60
|
t.rdoc_dir = 'doc'
|
56
|
-
t.title =
|
61
|
+
t.title = @spec.summary
|
57
62
|
t.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
|
58
63
|
t.options << '--charset' << 'utf-8'
|
59
64
|
t.rdoc_files.include('LICENSE.txt')
|
data/bin/example
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
# Seafaring Drydock Examples
|
4
|
+
#
|
5
|
+
# This is a functioning script so you can copy it, run it,
|
6
|
+
# and just generally be a longshoreman about things. This is
|
7
|
+
# a Drydock after all.
|
8
|
+
#
|
9
|
+
# If you're reading this via the Rdocs you won't see the code. Try:
|
10
|
+
#
|
11
|
+
# http://github.com/delano/drydock/blob/master/bin/example
|
12
|
+
|
3
13
|
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..')), 'lib'
|
4
14
|
|
5
15
|
require 'drydock'
|
@@ -17,29 +27,24 @@ end
|
|
17
27
|
|
18
28
|
command :welcome do
|
19
29
|
# Example: ruby bin/example
|
20
|
-
|
21
|
-
puts "
|
22
|
-
print "Frylock: At least we have some commands: "
|
30
|
+
|
31
|
+
puts "Welcome to Drydock. You have the following commands:"
|
23
32
|
|
24
33
|
# The commands method returns a hash of Drydock::Command objects
|
25
34
|
puts commands.keys.inject([]) { |list, command| list << command.to_s }.sort.join(', ')
|
26
35
|
end
|
27
36
|
|
37
|
+
usage "Example: #{$0} laugh [-f]"
|
38
|
+
option :f, :faster, "A boolean value. Go even faster!"
|
39
|
+
command :laugh do |obj|
|
40
|
+
# +obj+ is an instance of Drydock::Command. The options you define are available
|
41
|
+
# via accessors in this object.
|
28
42
|
|
29
|
-
|
30
|
-
command :findcar do |obj|
|
31
|
-
# +obj+ is the Drylock::Command object instance. It contains accessors for all options.
|
32
|
-
# Example: ruby bin/example -f findcar
|
33
|
-
|
34
|
-
puts "Frylock: So, did they ever find your car?"
|
35
|
-
|
36
|
-
# The keys to the hash are the long string from the option definition.
|
37
|
-
# If only the short string is provided, those will be used instead (i.e. :f).
|
38
|
-
puts (!obj.found) ? "Carl: No" :
|
39
|
-
"Carl: Oh, they found part of it, hangin' from a trestle near the turnpike."
|
40
|
-
end
|
41
|
-
|
43
|
+
answer = !obj.faster ? "Sort of" : "Yes! I'm literally laughing as fast as possible."
|
42
44
|
|
45
|
+
puts "Captain Stubing: Are you laughing?"
|
46
|
+
puts "Dr. Bricker: " << answer
|
47
|
+
end
|
43
48
|
|
44
49
|
global_usage "USAGE: #{File.basename($0)} [global options] command [command options]"
|
45
50
|
global_option :s, :seconds, "Display values in seconds"
|
@@ -146,7 +151,7 @@ end
|
|
146
151
|
# return the HTTP response code for the given URI
|
147
152
|
# +uri+ A valid HTTP URI
|
148
153
|
# +duration+ The timeout threshold (in seconds) for the request.
|
149
|
-
def response_code(uri_str, duration=5)
|
154
|
+
def response_code(uri_str, duration=5) #:nodoc:
|
150
155
|
response = :unavailable
|
151
156
|
begin
|
152
157
|
uri = (uri_str.kind_of? URI::HTTP) ? uri_str : URI.parse(uri_str)
|
data/doc/classes/Drydock.html
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
2
2
|
<html lang='en'>
|
3
3
|
<head>
|
4
|
-
<title>Module: Drydock [
|
4
|
+
<title>Module: Drydock [A seaworthy DSL for writing command line apps]</title>
|
5
5
|
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
|
6
6
|
<link href='.././rdoc-style.css' media='screen' rel='stylesheet' type='text/css'>
|
7
7
|
<script type='text/javascript'>
|
@@ -47,26 +47,26 @@
|
|
47
47
|
<h2>Methods</h2>
|
48
48
|
<h3>public instance</h3>
|
49
49
|
<ol>
|
50
|
-
<li><a href="#
|
51
|
-
<li><a href="#
|
52
|
-
<li><a href="#
|
53
|
-
<li><a href="#
|
54
|
-
<li><a href="#
|
55
|
-
<li><a href="#
|
56
|
-
<li><a href="#
|
57
|
-
<li><a href="#
|
58
|
-
<li><a href="#
|
59
|
-
<li><a href="#
|
60
|
-
<li><a href="#
|
61
|
-
<li><a href="#
|
62
|
-
<li><a href="#
|
63
|
-
<li><a href="#
|
64
|
-
<li><a href="#
|
65
|
-
<li><a href="#
|
66
|
-
<li><a href="#
|
67
|
-
<li><a href="#
|
68
|
-
<li><a href="#
|
69
|
-
<li><a href="#
|
50
|
+
<li><a href="#M000006">after</a></li>
|
51
|
+
<li><a href="#M000014">alias_command</a></li>
|
52
|
+
<li><a href="#M000005">before</a></li>
|
53
|
+
<li><a href="#M000013">command</a></li>
|
54
|
+
<li><a href="#M000015">command_alias</a></li>
|
55
|
+
<li><a href="#M000016">commands</a></li>
|
56
|
+
<li><a href="#M000001">debug</a></li>
|
57
|
+
<li><a href="#M000002">debug?</a></li>
|
58
|
+
<li><a href="#M000003">default</a></li>
|
59
|
+
<li><a href="#M000009">get_current_option_parser</a></li>
|
60
|
+
<li><a href="#M000011">global_option</a></li>
|
61
|
+
<li><a href="#M000007">global_usage</a></li>
|
62
|
+
<li><a href="#M000019">has_run?</a></li>
|
63
|
+
<li><a href="#M000010">ignore</a></li>
|
64
|
+
<li><a href="#M000012">option</a></li>
|
65
|
+
<li><a href="#M000020">run!</a></li>
|
66
|
+
<li><a href="#M000018">run=</a></li>
|
67
|
+
<li><a href="#M000017">run?</a></li>
|
68
|
+
<li><a href="#M000004">stdin</a></li>
|
69
|
+
<li><a href="#M000008">usage</a></li>
|
70
70
|
</ol>
|
71
71
|
</div>
|
72
72
|
<div id='section'>
|
@@ -92,8 +92,8 @@
|
|
92
92
|
</div>
|
93
93
|
<div id='methods'>
|
94
94
|
<h2>Public instance methods</h2>
|
95
|
-
<div class='public-instance method' id='method-
|
96
|
-
<a name='
|
95
|
+
<div class='public-instance method' id='method-M000006'>
|
96
|
+
<a name='M000006'> </a>
|
97
97
|
<div class='synopsis'>
|
98
98
|
<span class='name'>after</span>
|
99
99
|
<span class='arguments'>(&b)</span>
|
@@ -105,14 +105,14 @@
|
|
105
105
|
</p>
|
106
106
|
</div>
|
107
107
|
<div class='source'>
|
108
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
108
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000006-source'); return false">
|
109
109
|
[show source]
|
110
110
|
</a>
|
111
|
-
<pre id='
|
111
|
+
<pre id='M000006-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 177</span>
177: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">after</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">b</span>)
178: <span class="ruby-ivar">@@after_block</span> = <span class="ruby-identifier">b</span>
179: <span class="ruby-keyword kw">end</span></pre>
|
112
112
|
</div>
|
113
113
|
</div>
|
114
|
-
<div class='public-instance method' id='method-
|
115
|
-
<a name='
|
114
|
+
<div class='public-instance method' id='method-M000014'>
|
115
|
+
<a name='M000014'> </a>
|
116
116
|
<div class='synopsis'>
|
117
117
|
<span class='name'>alias_command</span>
|
118
118
|
<span class='arguments'>(aliaz, cmd)</span>
|
@@ -132,14 +132,14 @@
|
|
132
132
|
</p>
|
133
133
|
</div>
|
134
134
|
<div class='source'>
|
135
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
135
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000014-source'); return false">
|
136
136
|
[show source]
|
137
137
|
</a>
|
138
|
-
<pre id='
|
138
|
+
<pre id='M000014-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 286</span>
286: <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>)
287: <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>
288: <span class="ruby-ivar">@@commands</span>[<span class="ruby-identifier">aliaz</span>] = <span class="ruby-identifier">commands</span>[<span class="ruby-identifier">cmd</span>]
289: <span class="ruby-keyword kw">end</span></pre>
|
139
139
|
</div>
|
140
140
|
</div>
|
141
|
-
<div class='public-instance method' id='method-
|
142
|
-
<a name='
|
141
|
+
<div class='public-instance method' id='method-M000005'>
|
142
|
+
<a name='M000005'> </a>
|
143
143
|
<div class='synopsis'>
|
144
144
|
<span class='name'>before</span>
|
145
145
|
<span class='arguments'>(&b)</span>
|
@@ -151,14 +151,14 @@
|
|
151
151
|
</p>
|
152
152
|
</div>
|
153
153
|
<div class='source'>
|
154
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
154
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000005-source'); return false">
|
155
155
|
[show source]
|
156
156
|
</a>
|
157
|
-
<pre id='
|
157
|
+
<pre id='M000005-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 171</span>
171: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">before</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">b</span>)
172: <span class="ruby-ivar">@@before_block</span> = <span class="ruby-identifier">b</span>
173: <span class="ruby-keyword kw">end</span></pre>
|
158
158
|
</div>
|
159
159
|
</div>
|
160
|
-
<div class='public-instance method' id='method-
|
161
|
-
<a name='
|
160
|
+
<div class='public-instance method' id='method-M000013'>
|
161
|
+
<a name='M000013'> </a>
|
162
162
|
<div class='synopsis'>
|
163
163
|
<span class='name'>command</span>
|
164
164
|
<span class='arguments'>(*cmds, &b)</span>
|
@@ -176,26 +176,26 @@
|
|
176
176
|
<pre>command :task => CustomCommand do
 ...
end</pre>
|
177
177
|
</div>
|
178
178
|
<div class='source'>
|
179
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
179
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000013-source'); return false">
|
180
180
|
[show source]
|
181
181
|
</a>
|
182
|
-
<pre id='
|
182
|
+
<pre id='M000013-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 256</span>
256: <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>)
257: <span class="ruby-ivar">@@command_index</span> <span class="ruby-operator">||=</span> <span class="ruby-value">0</span>
258: <span class="ruby-ivar">@@command_opts_parser</span> <span class="ruby-operator">||=</span> []
259: <span class="ruby-ivar">@@command_option_names</span> <span class="ruby-operator">||=</span> []
260: <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> 
261: <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>
262: <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>)
263: <span class="ruby-keyword kw">else</span>
264: <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>)
265: <span class="ruby-keyword kw">end</span>
266: <span class="ruby-identifier">commands</span>[<span class="ruby-identifier">c</span>.<span class="ruby-identifier">cmd</span>] = <span class="ruby-identifier">c</span>
267: <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>
268: <span class="ruby-ivar">@@command_index</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
269: <span class="ruby-keyword kw">end</span>
270: 
271: <span class="ruby-keyword kw">end</span></pre>
|
183
183
|
</div>
|
184
184
|
</div>
|
185
|
-
<div class='public-instance method' id='method-
|
186
|
-
<a name='
|
185
|
+
<div class='public-instance method' id='method-M000015'>
|
186
|
+
<a name='M000015'> </a>
|
187
187
|
<div class='synopsis'>
|
188
188
|
<span class='name'>command_alias</span>
|
189
189
|
<span class='arguments'>(aliaz, cmd)</span>
|
190
190
|
</div>
|
191
191
|
<div class='description'>
|
192
192
|
<p>
|
193
|
-
Alias for <a href="Drydock.html#
|
193
|
+
Alias for <a href="Drydock.html#M000014">alias_command</a>
|
194
194
|
</p>
|
195
195
|
</div>
|
196
196
|
</div>
|
197
|
-
<div class='public-instance method' id='method-
|
198
|
-
<a name='
|
197
|
+
<div class='public-instance method' id='method-M000016'>
|
198
|
+
<a name='M000016'> </a>
|
199
199
|
<div class='synopsis'>
|
200
200
|
<span class='name'>commands</span>
|
201
201
|
<span class='arguments'>()</span>
|
@@ -207,14 +207,14 @@
|
|
207
207
|
</p>
|
208
208
|
</div>
|
209
209
|
<div class='source'>
|
210
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
210
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000016-source'); return false">
|
211
211
|
[show source]
|
212
212
|
</a>
|
213
|
-
<pre id='
|
213
|
+
<pre id='M000016-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 293</span>
293: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">commands</span>
294: <span class="ruby-ivar">@@commands</span> <span class="ruby-operator">||=</span> {}
295: <span class="ruby-keyword kw">end</span></pre>
|
214
214
|
</div>
|
215
215
|
</div>
|
216
|
-
<div class='public-instance method' id='method-
|
217
|
-
<a name='
|
216
|
+
<div class='public-instance method' id='method-M000001'>
|
217
|
+
<a name='M000001'> </a>
|
218
218
|
<div class='synopsis'>
|
219
219
|
<span class='name'>debug</span>
|
220
220
|
<span class='arguments'>(toggle=false)</span>
|
@@ -229,14 +229,14 @@
|
|
229
229
|
</p>
|
230
230
|
</div>
|
231
231
|
<div class='source'>
|
232
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
232
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000001-source'); return false">
|
233
233
|
[show source]
|
234
234
|
</a>
|
235
|
-
<pre id='
|
235
|
+
<pre id='M000001-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 138</span>
138: <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>)
139: <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>
140: <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>
141: <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>
142: <span class="ruby-keyword kw">else</span>
143: <span class="ruby-ivar">@@debug</span> = (<span class="ruby-operator">!</span><span class="ruby-ivar">@@debug</span>)
144: <span class="ruby-keyword kw">end</span>
145: <span class="ruby-keyword kw">end</span></pre>
|
236
236
|
</div>
|
237
237
|
</div>
|
238
|
-
<div class='public-instance method' id='method-
|
239
|
-
<a name='
|
238
|
+
<div class='public-instance method' id='method-M000002'>
|
239
|
+
<a name='M000002'> </a>
|
240
240
|
<div class='synopsis'>
|
241
241
|
<span class='name'>debug?</span>
|
242
242
|
<span class='arguments'>()</span>
|
@@ -247,14 +247,14 @@
|
|
247
247
|
</p>
|
248
248
|
</div>
|
249
249
|
<div class='source'>
|
250
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
250
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000002-source'); return false">
|
251
251
|
[show source]
|
252
252
|
</a>
|
253
|
-
<pre id='
|
253
|
+
<pre id='M000002-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 147</span>
147: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">debug?</span>
148: <span class="ruby-ivar">@@debug</span>
149: <span class="ruby-keyword kw">end</span></pre>
|
254
254
|
</div>
|
255
255
|
</div>
|
256
|
-
<div class='public-instance method' id='method-
|
257
|
-
<a name='
|
256
|
+
<div class='public-instance method' id='method-M000003'>
|
257
|
+
<a name='M000003'> </a>
|
258
258
|
<div class='synopsis'>
|
259
259
|
<span class='name'>default</span>
|
260
260
|
<span class='arguments'>(cmd)</span>
|
@@ -266,14 +266,14 @@
|
|
266
266
|
<pre>default :task</pre>
|
267
267
|
</div>
|
268
268
|
<div class='source'>
|
269
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
269
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000003-source'); return false">
|
270
270
|
[show source]
|
271
271
|
</a>
|
272
|
-
<pre id='
|
272
|
+
<pre id='M000003-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 155</span>
155: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">default</span>(<span class="ruby-identifier">cmd</span>)
156: <span class="ruby-ivar">@@default_command</span> = <span class="ruby-identifier">canonize</span>(<span class="ruby-identifier">cmd</span>)
157: <span class="ruby-keyword kw">end</span></pre>
|
273
273
|
</div>
|
274
274
|
</div>
|
275
|
-
<div class='public-instance method' id='method-
|
276
|
-
<a name='
|
275
|
+
<div class='public-instance method' id='method-M000009'>
|
276
|
+
<a name='M000009'> </a>
|
277
277
|
<div class='synopsis'>
|
278
278
|
<span class='name'>get_current_option_parser</span>
|
279
279
|
<span class='arguments'>()</span>
|
@@ -285,14 +285,14 @@
|
|
285
285
|
</p>
|
286
286
|
</div>
|
287
287
|
<div class='source'>
|
288
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
288
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000009-source'); return false">
|
289
289
|
[show source]
|
290
290
|
</a>
|
291
|
-
<pre id='
|
291
|
+
<pre id='M000009-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 195</span>
195: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_current_option_parser</span>
196: <span class="ruby-ivar">@@command_opts_parser</span> <span class="ruby-operator">||=</span> []
197: <span class="ruby-ivar">@@command_index</span> <span class="ruby-operator">||=</span> <span class="ruby-value">0</span>
198: (<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>)
199: <span class="ruby-keyword kw">end</span></pre>
|
292
292
|
</div>
|
293
293
|
</div>
|
294
|
-
<div class='public-instance method' id='method-
|
295
|
-
<a name='
|
294
|
+
<div class='public-instance method' id='method-M000011'>
|
295
|
+
<a name='M000011'> </a>
|
296
296
|
<div class='synopsis'>
|
297
297
|
<span class='name'>global_option</span>
|
298
298
|
<span class='arguments'>(*args, &b)</span>
|
@@ -303,14 +303,14 @@
|
|
303
303
|
</p>
|
304
304
|
</div>
|
305
305
|
<div class='source'>
|
306
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
306
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000011-source'); return false">
|
307
307
|
[show source]
|
308
308
|
</a>
|
309
|
-
<pre id='
|
309
|
+
<pre id='M000011-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 214</span>
214: <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>)
215: <span class="ruby-identifier">args</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-identifier">global_opts_parser</span>)
216: <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>)
217: <span class="ruby-keyword kw">end</span></pre>
|
310
310
|
</div>
|
311
311
|
</div>
|
312
|
-
<div class='public-instance method' id='method-
|
313
|
-
<a name='
|
312
|
+
<div class='public-instance method' id='method-M000007'>
|
313
|
+
<a name='M000007'> </a>
|
314
314
|
<div class='synopsis'>
|
315
315
|
<span class='name'>global_usage</span>
|
316
316
|
<span class='arguments'>(msg)</span>
|
@@ -322,14 +322,14 @@
|
|
322
322
|
</p>
|
323
323
|
</div>
|
324
324
|
<div class='source'>
|
325
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
325
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000007-source'); return false">
|
326
326
|
[show source]
|
327
327
|
</a>
|
328
|
-
<pre id='
|
328
|
+
<pre id='M000007-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 183</span>
183: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">global_usage</span>(<span class="ruby-identifier">msg</span>)
184: <span class="ruby-ivar">@@global_options</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">OpenStruct</span>.<span class="ruby-identifier">new</span>
185: <span class="ruby-identifier">global_opts_parser</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-node">"USAGE: #{msg}"</span>
186: <span class="ruby-keyword kw">end</span></pre>
|
329
329
|
</div>
|
330
330
|
</div>
|
331
|
-
<div class='public-instance method' id='method-
|
332
|
-
<a name='
|
331
|
+
<div class='public-instance method' id='method-M000019'>
|
332
|
+
<a name='M000019'> </a>
|
333
333
|
<div class='synopsis'>
|
334
334
|
<span class='name'>has_run?</span>
|
335
335
|
<span class='arguments'>()</span>
|
@@ -340,14 +340,14 @@
|
|
340
340
|
</p>
|
341
341
|
</div>
|
342
342
|
<div class='source'>
|
343
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
343
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000019-source'); return false">
|
344
344
|
[show source]
|
345
345
|
</a>
|
346
|
-
<pre id='
|
346
|
+
<pre id='M000019-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 310</span>
310: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">has_run?</span>
311: <span class="ruby-ivar">@@has_run</span>
312: <span class="ruby-keyword kw">end</span></pre>
|
347
347
|
</div>
|
348
348
|
</div>
|
349
|
-
<div class='public-instance method' id='method-
|
350
|
-
<a name='
|
349
|
+
<div class='public-instance method' id='method-M000010'>
|
350
|
+
<a name='M000010'> </a>
|
351
351
|
<div class='synopsis'>
|
352
352
|
<span class='name'>ignore</span>
|
353
353
|
<span class='arguments'>(what=:nothing)</span>
|
@@ -368,14 +368,14 @@
|
|
368
368
|
</p>
|
369
369
|
</div>
|
370
370
|
<div class='source'>
|
371
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
371
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000010-source'); return false">
|
372
372
|
[show source]
|
373
373
|
</a>
|
374
|
-
<pre id='
|
374
|
+
<pre id='M000010-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 209</span>
209: <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>)
210: <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>
211: <span class="ruby-keyword kw">end</span></pre>
|
375
375
|
</div>
|
376
376
|
</div>
|
377
|
-
<div class='public-instance method' id='method-
|
378
|
-
<a name='
|
377
|
+
<div class='public-instance method' id='method-M000012'>
|
378
|
+
<a name='M000012'> </a>
|
379
379
|
<div class='synopsis'>
|
380
380
|
<span class='name'>option</span>
|
381
381
|
<span class='arguments'>(*args, &b)</span>
|
@@ -403,14 +403,14 @@
|
|
403
403
|
</p>
|
404
404
|
</div>
|
405
405
|
<div class='source'>
|
406
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
406
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000012-source'); return false">
|
407
407
|
[show source]
|
408
408
|
</a>
|
409
|
-
<pre id='
|
409
|
+
<pre id='M000012-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 238</span>
238: <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>)
239: <span class="ruby-identifier">args</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-identifier">get_current_option_parser</span>)
240: <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>)
241: <span class="ruby-keyword kw">end</span></pre>
|
410
410
|
</div>
|
411
411
|
</div>
|
412
|
-
<div class='public-instance method' id='method-
|
413
|
-
<a name='
|
412
|
+
<div class='public-instance method' id='method-M000020'>
|
413
|
+
<a name='M000020'> </a>
|
414
414
|
<div class='synopsis'>
|
415
415
|
<span class='name'>run!</span>
|
416
416
|
<span class='arguments'>(argv=[], stdin=STDIN)</span>
|
@@ -420,19 +420,19 @@
|
|
420
420
|
Execute the given command. By default, <a href="Drydock.html">Drydock</a>
|
421
421
|
automatically executes itself and provides handlers for known errors. You
|
422
422
|
can override this functionality by calling <tt><a
|
423
|
-
href="Drydock.html#
|
423
|
+
href="Drydock.html#M000020">Drydock.run!</a></tt> yourself. <a
|
424
424
|
href="Drydock.html">Drydock</a> will only call <tt>run!</tt> once.
|
425
425
|
</p>
|
426
426
|
</div>
|
427
427
|
<div class='source'>
|
428
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
428
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000020-source'); return false">
|
429
429
|
[show source]
|
430
430
|
</a>
|
431
|
-
<pre id='
|
431
|
+
<pre id='M000020-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 318</span>
318: <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>)
319: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">has_run?</span>
320: <span class="ruby-ivar">@@has_run</span> = <span class="ruby-keyword kw">true</span>
321: <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>
322: <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>)
323: 
324: <span class="ruby-identifier">cmd_name</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">default_command</span>
325: 
326: <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>)
327: 
328: <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>
329: <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>
330: 
331: <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>)
332: 
333: <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>
334: 
335: <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>
336: <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>)
337: <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>
338: <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>)
339: <span class="ruby-keyword kw">end</span></pre>
|
432
432
|
</div>
|
433
433
|
</div>
|
434
|
-
<div class='public-instance method' id='method-
|
435
|
-
<a name='
|
434
|
+
<div class='public-instance method' id='method-M000018'>
|
435
|
+
<a name='M000018'> </a>
|
436
436
|
<div class='synopsis'>
|
437
437
|
<span class='name'>run=</span>
|
438
438
|
<span class='arguments'>(v)</span>
|
@@ -444,14 +444,14 @@
|
|
444
444
|
<pre>Drydock.run = false</pre>
|
445
445
|
</div>
|
446
446
|
<div class='source'>
|
447
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
447
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000018-source'); return false">
|
448
448
|
[show source]
|
449
449
|
</a>
|
450
|
-
<pre id='
|
450
|
+
<pre id='M000018-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 305</span>
305: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run=</span>(<span class="ruby-identifier">v</span>)
306: <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> 
307: <span class="ruby-keyword kw">end</span></pre>
|
451
451
|
</div>
|
452
452
|
</div>
|
453
|
-
<div class='public-instance method' id='method-
|
454
|
-
<a name='
|
453
|
+
<div class='public-instance method' id='method-M000017'>
|
454
|
+
<a name='M000017'> </a>
|
455
455
|
<div class='synopsis'>
|
456
456
|
<span class='name'>run?</span>
|
457
457
|
<span class='arguments'>()</span>
|
@@ -462,14 +462,14 @@
|
|
462
462
|
</p>
|
463
463
|
</div>
|
464
464
|
<div class='source'>
|
465
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
465
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000017-source'); return false">
|
466
466
|
[show source]
|
467
467
|
</a>
|
468
|
-
<pre id='
|
468
|
+
<pre id='M000017-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 298</span>
298: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run?</span>
299: <span class="ruby-ivar">@@run</span>
300: <span class="ruby-keyword kw">end</span></pre>
|
469
469
|
</div>
|
470
470
|
</div>
|
471
|
-
<div class='public-instance method' id='method-
|
472
|
-
<a name='
|
471
|
+
<div class='public-instance method' id='method-M000004'>
|
472
|
+
<a name='M000004'> </a>
|
473
473
|
<div class='synopsis'>
|
474
474
|
<span class='name'>stdin</span>
|
475
475
|
<span class='arguments'>(&b)</span>
|
@@ -486,14 +486,14 @@
|
|
486
486
|
</p>
|
487
487
|
</div>
|
488
488
|
<div class='source'>
|
489
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
489
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000004-source'); return false">
|
490
490
|
[show source]
|
491
491
|
</a>
|
492
|
-
<pre id='
|
492
|
+
<pre id='M000004-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 165</span>
165: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stdin</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">b</span>)
166: <span class="ruby-ivar">@@stdin_block</span> = <span class="ruby-identifier">b</span>
167: <span class="ruby-keyword kw">end</span></pre>
|
493
493
|
</div>
|
494
494
|
</div>
|
495
|
-
<div class='public-instance method' id='method-
|
496
|
-
<a name='
|
495
|
+
<div class='public-instance method' id='method-M000008'>
|
496
|
+
<a name='M000008'> </a>
|
497
497
|
<div class='synopsis'>
|
498
498
|
<span class='name'>usage</span>
|
499
499
|
<span class='arguments'>(msg)</span>
|
@@ -505,10 +505,10 @@
|
|
505
505
|
</p>
|
506
506
|
</div>
|
507
507
|
<div class='source'>
|
508
|
-
<a class='source-toggle' href='#' onclick="toggleCode('
|
508
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000008-source'); return false">
|
509
509
|
[show source]
|
510
510
|
</a>
|
511
|
-
<pre id='
|
511
|
+
<pre id='M000008-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 190</span>
190: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">usage</span>(<span class="ruby-identifier">msg</span>)
191: <span class="ruby-identifier">get_current_option_parser</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-node">"USAGE: #{msg}"</span>
192: <span class="ruby-keyword kw">end</span></pre>
|
512
512
|
</div>
|
513
513
|
</div>
|
514
514
|
</div>
|