drydock 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +16 -0
- data/LICENSE.txt +22 -0
- data/README.rdoc +70 -0
- data/Rakefile +72 -0
- data/bin/example +152 -0
- data/doc/classes/Drydock.html +535 -0
- data/doc/classes/Drydock/Command.html +180 -0
- data/doc/classes/Drydock/InvalidArgument.html +118 -0
- data/doc/classes/Drydock/MissingArgument.html +88 -0
- data/doc/classes/Drydock/NoCommandsDefined.html +88 -0
- data/doc/classes/Drydock/UnknownCommand.html +118 -0
- data/doc/created.rid +1 -0
- data/doc/files/CHANGES_txt.html +100 -0
- data/doc/files/LICENSE_txt.html +87 -0
- data/doc/files/README_rdoc.html +119 -0
- data/doc/files/bin/example.html +104 -0
- data/doc/files/lib/drydock_rb.html +75 -0
- data/doc/fr_class_index.html +19 -0
- data/doc/fr_file_index.html +24 -0
- data/doc/fr_method_index.html +4459 -0
- data/doc/index.html +15 -0
- data/doc/rdoc-style.css +319 -0
- data/drydock.gemspec +53 -0
- data/lib/drydock.rb +482 -0
- data/test/command_test.rb +40 -0
- metadata +90 -0
@@ -0,0 +1,118 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
2
|
+
<html lang='en'>
|
3
|
+
<head>
|
4
|
+
<title>Class: Drydock::UnknownCommand [Drydock, A seaworthy DSL for command-line apps.]</title>
|
5
|
+
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
|
6
|
+
<link href='../.././rdoc-style.css' media='screen' rel='stylesheet' type='text/css'>
|
7
|
+
<script type='text/javascript'>
|
8
|
+
//<![CDATA[
|
9
|
+
function popupCode(url) {
|
10
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
11
|
+
}
|
12
|
+
|
13
|
+
function toggleCode(id) {
|
14
|
+
var code = document.getElementById(id)
|
15
|
+
|
16
|
+
code.style.display = code.style.display != 'block' ? 'block' : 'none'
|
17
|
+
return true
|
18
|
+
}
|
19
|
+
|
20
|
+
// Make codeblocks hidden by default
|
21
|
+
document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
|
22
|
+
//]]>
|
23
|
+
</script>
|
24
|
+
</head>
|
25
|
+
<body class='page'>
|
26
|
+
<div class='class' id='wrapper'>
|
27
|
+
<div class='header'>
|
28
|
+
<h1 class='name'>
|
29
|
+
<span class='type'>Class</span>
|
30
|
+
Drydock::UnknownCommand
|
31
|
+
</h1>
|
32
|
+
<ol class='paths'>
|
33
|
+
<li>
|
34
|
+
<a href="../../files/lib/drydock_rb.html">lib/drydock.rb</a>
|
35
|
+
</li>
|
36
|
+
</ol>
|
37
|
+
<div class='parent'>
|
38
|
+
Parent:
|
39
|
+
<strong>RuntimeError</strong>
|
40
|
+
</div>
|
41
|
+
</div>
|
42
|
+
<div id='content'>
|
43
|
+
<div id='text'>
|
44
|
+
<div id='method-list'>
|
45
|
+
<h2>Methods</h2>
|
46
|
+
<h3>public class</h3>
|
47
|
+
<ol>
|
48
|
+
<li><a href="#M000022">new</a></li>
|
49
|
+
</ol>
|
50
|
+
<h3>public instance</h3>
|
51
|
+
<ol>
|
52
|
+
<li><a href="#M000023">message</a></li>
|
53
|
+
</ol>
|
54
|
+
</div>
|
55
|
+
<div id='section'>
|
56
|
+
<div id='attribute-list'>
|
57
|
+
<h2 class='section-bar'>Attributes</h2>
|
58
|
+
<div class='name-list'>
|
59
|
+
<table>
|
60
|
+
<tr class='top-aligned-row context-row'>
|
61
|
+
<td class='context-item-name'>name</td>
|
62
|
+
<td class='context-item-value'>[R]</td>
|
63
|
+
<td class='context-item-desc'></td>
|
64
|
+
</tr>
|
65
|
+
</table>
|
66
|
+
</div>
|
67
|
+
</div>
|
68
|
+
<div id='methods'>
|
69
|
+
<h2>Public class methods</h2>
|
70
|
+
<div class='public-class method' id='method-M000022'>
|
71
|
+
<a name='M000022'> </a>
|
72
|
+
<div class='synopsis'>
|
73
|
+
<span class='name'>new</span>
|
74
|
+
<span class='arguments'>(name)</span>
|
75
|
+
</div>
|
76
|
+
<div class='source'>
|
77
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000022-source'); return false">
|
78
|
+
[show source]
|
79
|
+
</a>
|
80
|
+
<pre id='M000022-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 62</span>
62: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">name</span>)
63: <span class="ruby-ivar">@name</span> = <span class="ruby-identifier">name</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">:unknown</span>
64: <span class="ruby-keyword kw">end</span></pre>
|
81
|
+
</div>
|
82
|
+
</div>
|
83
|
+
<h2>Public instance methods</h2>
|
84
|
+
<div class='public-instance method' id='method-M000023'>
|
85
|
+
<a name='M000023'> </a>
|
86
|
+
<div class='synopsis'>
|
87
|
+
<span class='name'>message</span>
|
88
|
+
<span class='arguments'>()</span>
|
89
|
+
</div>
|
90
|
+
<div class='source'>
|
91
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000023-source'); return false">
|
92
|
+
[show source]
|
93
|
+
</a>
|
94
|
+
<pre id='M000023-source'> <span class="ruby-comment cmt"># File lib/drydock.rb, line 65</span>
65: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">message</span>
66: <span class="ruby-node">"Unknown command: #{@name}"</span>
67: <span class="ruby-keyword kw">end</span></pre>
|
95
|
+
</div>
|
96
|
+
</div>
|
97
|
+
</div>
|
98
|
+
</div>
|
99
|
+
</div>
|
100
|
+
</div>
|
101
|
+
<div id='footer-push'></div>
|
102
|
+
</div>
|
103
|
+
<div id='footer'>
|
104
|
+
<a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
|
105
|
+
<script type='text/javascript'>
|
106
|
+
//<![CDATA[
|
107
|
+
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
108
|
+
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/scr
|
109
|
+
|
110
|
+
try {
|
111
|
+
var pageTracker = _gat._getTracker("UA-4642735-10");
|
112
|
+
pageTracker._trackPageview();
|
113
|
+
} catch(err) {}
|
114
|
+
//]]>
|
115
|
+
</script>
|
116
|
+
</div>
|
117
|
+
</body>
|
118
|
+
</html>
|
data/doc/created.rid
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Thu, 05 Feb 2009 12:58:48 -0500
|
@@ -0,0 +1,100 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
2
|
+
<html lang='en'>
|
3
|
+
<head>
|
4
|
+
<title>File: CHANGES.txt [Drydock, A seaworthy DSL for command-line apps.]</title>
|
5
|
+
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
|
6
|
+
<link href='.././rdoc-style.css' media='screen' rel='stylesheet' type='text/css'>
|
7
|
+
<script type='text/javascript'>
|
8
|
+
//<![CDATA[
|
9
|
+
function popupCode(url) {
|
10
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
11
|
+
}
|
12
|
+
|
13
|
+
function toggleCode(id) {
|
14
|
+
var code = document.getElementById(id)
|
15
|
+
|
16
|
+
code.style.display = code.style.display != 'block' ? 'block' : 'none'
|
17
|
+
return true
|
18
|
+
}
|
19
|
+
|
20
|
+
// Make codeblocks hidden by default
|
21
|
+
document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
|
22
|
+
//]]>
|
23
|
+
</script>
|
24
|
+
</head>
|
25
|
+
<body class='page'>
|
26
|
+
<div class='file' id='wrapper'>
|
27
|
+
<div class='header'>
|
28
|
+
<h1 class='name'>CHANGES.txt</h1>
|
29
|
+
<div class='paths'>
|
30
|
+
CHANGES.txt
|
31
|
+
</div>
|
32
|
+
<div class='last-update'>
|
33
|
+
Last Update:
|
34
|
+
<span class='datetime'>Thu Feb 05 12:49:48 -0500 2009</span>
|
35
|
+
</div>
|
36
|
+
</div>
|
37
|
+
<div id='content'>
|
38
|
+
<div id='text'>
|
39
|
+
<div id='description'>
|
40
|
+
<p>
|
41
|
+
DRYDOCK, CHANGES
|
42
|
+
</p>
|
43
|
+
<p>
|
44
|
+
#### 0.3 (2009-02-05) ###############################
|
45
|
+
</p>
|
46
|
+
<ul>
|
47
|
+
<li>Added support for custom Drydock::Commands objects
|
48
|
+
|
49
|
+
</li>
|
50
|
+
<li>Global and command-specific options are now available as attributes of the
|
51
|
+
Drydock::Commands class instance.
|
52
|
+
|
53
|
+
</li>
|
54
|
+
<li>Automatic execution
|
55
|
+
|
56
|
+
</li>
|
57
|
+
<li>Now in a single file (<a href="lib/drydock_rb.html">lib/drydock.rb</a>)
|
58
|
+
|
59
|
+
</li>
|
60
|
+
<li>Started adding tests
|
61
|
+
|
62
|
+
</li>
|
63
|
+
<li>Improved documentation
|
64
|
+
|
65
|
+
</li>
|
66
|
+
</ul>
|
67
|
+
<p>
|
68
|
+
#### 0.2 (2008-12-27) ###############################
|
69
|
+
</p>
|
70
|
+
<ul>
|
71
|
+
<li>Initial release
|
72
|
+
|
73
|
+
</li>
|
74
|
+
<li>Forked from bmizerany/frylock
|
75
|
+
|
76
|
+
</li>
|
77
|
+
</ul>
|
78
|
+
</div>
|
79
|
+
<div id='section'>
|
80
|
+
</div>
|
81
|
+
</div>
|
82
|
+
</div>
|
83
|
+
<div id='footer-push'></div>
|
84
|
+
</div>
|
85
|
+
<div id='footer'>
|
86
|
+
<a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
|
87
|
+
<script type='text/javascript'>
|
88
|
+
//<![CDATA[
|
89
|
+
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
90
|
+
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/scr
|
91
|
+
|
92
|
+
try {
|
93
|
+
var pageTracker = _gat._getTracker("UA-4642735-10");
|
94
|
+
pageTracker._trackPageview();
|
95
|
+
} catch(err) {}
|
96
|
+
//]]>
|
97
|
+
</script>
|
98
|
+
</div>
|
99
|
+
</body>
|
100
|
+
</html>
|
@@ -0,0 +1,87 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
2
|
+
<html lang='en'>
|
3
|
+
<head>
|
4
|
+
<title>File: LICENSE.txt [Drydock, A seaworthy DSL for command-line apps.]</title>
|
5
|
+
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
|
6
|
+
<link href='.././rdoc-style.css' media='screen' rel='stylesheet' type='text/css'>
|
7
|
+
<script type='text/javascript'>
|
8
|
+
//<![CDATA[
|
9
|
+
function popupCode(url) {
|
10
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
11
|
+
}
|
12
|
+
|
13
|
+
function toggleCode(id) {
|
14
|
+
var code = document.getElementById(id)
|
15
|
+
|
16
|
+
code.style.display = code.style.display != 'block' ? 'block' : 'none'
|
17
|
+
return true
|
18
|
+
}
|
19
|
+
|
20
|
+
// Make codeblocks hidden by default
|
21
|
+
document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
|
22
|
+
//]]>
|
23
|
+
</script>
|
24
|
+
</head>
|
25
|
+
<body class='page'>
|
26
|
+
<div class='file' id='wrapper'>
|
27
|
+
<div class='header'>
|
28
|
+
<h1 class='name'>LICENSE.txt</h1>
|
29
|
+
<div class='paths'>
|
30
|
+
LICENSE.txt
|
31
|
+
</div>
|
32
|
+
<div class='last-update'>
|
33
|
+
Last Update:
|
34
|
+
<span class='datetime'>Thu Feb 05 12:49:48 -0500 2009</span>
|
35
|
+
</div>
|
36
|
+
</div>
|
37
|
+
<div id='content'>
|
38
|
+
<div id='text'>
|
39
|
+
<div id='description'>
|
40
|
+
<p>
|
41
|
+
Copyright © 2008 Delano Mandelbaum
|
42
|
+
</p>
|
43
|
+
<p>
|
44
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
45
|
+
copy of this software and associated documentation files (the
|
46
|
+
“Software”), to deal in the Software without restriction,
|
47
|
+
including without limitation the rights to use, copy, modify, merge,
|
48
|
+
publish, distribute, sublicense, and/or sell copies of the Software, and to
|
49
|
+
permit persons to whom the Software is furnished to do so, subject to the
|
50
|
+
following conditions:
|
51
|
+
</p>
|
52
|
+
<p>
|
53
|
+
The above copyright notice and this permission notice shall be included in
|
54
|
+
all copies or substantial portions of the Software.
|
55
|
+
</p>
|
56
|
+
<p>
|
57
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
58
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
59
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
60
|
+
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
61
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
62
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
63
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
64
|
+
</p>
|
65
|
+
</div>
|
66
|
+
<div id='section'>
|
67
|
+
</div>
|
68
|
+
</div>
|
69
|
+
</div>
|
70
|
+
<div id='footer-push'></div>
|
71
|
+
</div>
|
72
|
+
<div id='footer'>
|
73
|
+
<a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
|
74
|
+
<script type='text/javascript'>
|
75
|
+
//<![CDATA[
|
76
|
+
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
77
|
+
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/scr
|
78
|
+
|
79
|
+
try {
|
80
|
+
var pageTracker = _gat._getTracker("UA-4642735-10");
|
81
|
+
pageTracker._trackPageview();
|
82
|
+
} catch(err) {}
|
83
|
+
//]]>
|
84
|
+
</script>
|
85
|
+
</div>
|
86
|
+
</body>
|
87
|
+
</html>
|
@@ -0,0 +1,119 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
2
|
+
<html lang='en'>
|
3
|
+
<head>
|
4
|
+
<title>File: README.rdoc [Drydock, A seaworthy DSL for command-line apps.]</title>
|
5
|
+
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
|
6
|
+
<link href='.././rdoc-style.css' media='screen' rel='stylesheet' type='text/css'>
|
7
|
+
<script type='text/javascript'>
|
8
|
+
//<![CDATA[
|
9
|
+
function popupCode(url) {
|
10
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
11
|
+
}
|
12
|
+
|
13
|
+
function toggleCode(id) {
|
14
|
+
var code = document.getElementById(id)
|
15
|
+
|
16
|
+
code.style.display = code.style.display != 'block' ? 'block' : 'none'
|
17
|
+
return true
|
18
|
+
}
|
19
|
+
|
20
|
+
// Make codeblocks hidden by default
|
21
|
+
document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
|
22
|
+
//]]>
|
23
|
+
</script>
|
24
|
+
</head>
|
25
|
+
<body class='page'>
|
26
|
+
<div class='file' id='wrapper'>
|
27
|
+
<div class='header'>
|
28
|
+
<div class='name'>README.rdoc</div>
|
29
|
+
<div class='paths'>
|
30
|
+
README.rdoc
|
31
|
+
</div>
|
32
|
+
<div class='last-update'>
|
33
|
+
Last Update:
|
34
|
+
<span class='datetime'>Thu Feb 05 12:55:58 -0500 2009</span>
|
35
|
+
</div>
|
36
|
+
</div>
|
37
|
+
<div id='content'>
|
38
|
+
<div id='text'>
|
39
|
+
<div id='description'>
|
40
|
+
<h1><a href="../classes/Drydock.html">Drydock</a> - v0.3</h1>
|
41
|
+
<p>
|
42
|
+
Inspired by github-gem and bmizerany-frylock.
|
43
|
+
</p>
|
44
|
+
<h2>Overview</h2>
|
45
|
+
<p>
|
46
|
+
<a href="../classes/Drydock.html">Drydock</a> is a seaworthy DSL for
|
47
|
+
command line apps. It is contained in a single .rb which can be copied
|
48
|
+
directly into your project.
|
49
|
+
</p>
|
50
|
+
<h2>Install</h2>
|
51
|
+
<p>
|
52
|
+
One of:
|
53
|
+
</p>
|
54
|
+
<ul>
|
55
|
+
<li>gem install drydock
|
56
|
+
|
57
|
+
</li>
|
58
|
+
<li>copy <a href="lib/drydock_rb.html">lib/drydock.rb</a> into your lib
|
59
|
+
directory.
|
60
|
+
|
61
|
+
</li>
|
62
|
+
</ul>
|
63
|
+
<p>
|
64
|
+
Or for GitHub fans:
|
65
|
+
</p>
|
66
|
+
<ul>
|
67
|
+
<li>git clone git://github.com/delano/drydock.git
|
68
|
+
|
69
|
+
</li>
|
70
|
+
<li>gem install delano-drydock
|
71
|
+
|
72
|
+
</li>
|
73
|
+
</ul>
|
74
|
+
<h2>Examples</h2>
|
75
|
+
<p>
|
76
|
+
See <a href="bin/example.html">bin/example</a> for more.
|
77
|
+
</p>
|
78
|
+
<pre>require 'rubygems'
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 "Meatwad: Science is a mystery to man, isn't it Frylock?"
 print "Frylock: At least we have some commands: "

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

option :f, :found, "A boolean value. Did you find the car?"
command :findcar do |options|
# +options+ is a hash containing the options defined above
# Example: ruby bin/example -f findcar

 puts "Frylock: So, did they ever find your car?"

 # The keys to the hash are the long string from the option definition.
 # If only the short string is provided, those will be used instead (i.e. :f).
 puts (!options[:found]) ? "Carl: No" :
 "Carl: Oh, they found part of it, hangin' from a trestle near the turnpike."
end</pre>
|
79
|
+
<h2>More Information</h2>
|
80
|
+
<p>
|
81
|
+
<a
|
82
|
+
href="http://www.youtube.com/watch?v=m_wFEB4Oxlo">www.youtube.com/watch?v=m_wFEB4Oxlo</a>
|
83
|
+
</p>
|
84
|
+
<h2>Credits</h2>
|
85
|
+
<ul>
|
86
|
+
<li>Delano Mandelbaum (delano@solutious.com)
|
87
|
+
|
88
|
+
</li>
|
89
|
+
<li>Bernie Kopell (bernie@solutious.com)
|
90
|
+
|
91
|
+
</li>
|
92
|
+
</ul>
|
93
|
+
<h2>License</h2>
|
94
|
+
<p>
|
95
|
+
See <a href="LICENSE_txt.html">LICENSE.txt</a>
|
96
|
+
</p>
|
97
|
+
</div>
|
98
|
+
<div id='section'>
|
99
|
+
</div>
|
100
|
+
</div>
|
101
|
+
</div>
|
102
|
+
<div id='footer-push'></div>
|
103
|
+
</div>
|
104
|
+
<div id='footer'>
|
105
|
+
<a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
|
106
|
+
<script type='text/javascript'>
|
107
|
+
//<![CDATA[
|
108
|
+
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
109
|
+
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/scr
|
110
|
+
|
111
|
+
try {
|
112
|
+
var pageTracker = _gat._getTracker("UA-4642735-10");
|
113
|
+
pageTracker._trackPageview();
|
114
|
+
} catch(err) {}
|
115
|
+
//]]>
|
116
|
+
</script>
|
117
|
+
</div>
|
118
|
+
</body>
|
119
|
+
</html>
|
@@ -0,0 +1,104 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
2
|
+
<html lang='en'>
|
3
|
+
<head>
|
4
|
+
<title>File: example [Drydock, A seaworthy DSL for command-line apps.]</title>
|
5
|
+
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
|
6
|
+
<link href='../.././rdoc-style.css' media='screen' rel='stylesheet' type='text/css'>
|
7
|
+
<script type='text/javascript'>
|
8
|
+
//<![CDATA[
|
9
|
+
function popupCode(url) {
|
10
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
11
|
+
}
|
12
|
+
|
13
|
+
function toggleCode(id) {
|
14
|
+
var code = document.getElementById(id)
|
15
|
+
|
16
|
+
code.style.display = code.style.display != 'block' ? 'block' : 'none'
|
17
|
+
return true
|
18
|
+
}
|
19
|
+
|
20
|
+
// Make codeblocks hidden by default
|
21
|
+
document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
|
22
|
+
//]]>
|
23
|
+
</script>
|
24
|
+
</head>
|
25
|
+
<body class='page'>
|
26
|
+
<div class='file' id='wrapper'>
|
27
|
+
<div class='header'>
|
28
|
+
<h1 class='name'>example</h1>
|
29
|
+
<div class='paths'>
|
30
|
+
bin/example
|
31
|
+
</div>
|
32
|
+
<div class='last-update'>
|
33
|
+
Last Update:
|
34
|
+
<span class='datetime'>Thu Feb 05 12:49:48 -0500 2009</span>
|
35
|
+
</div>
|
36
|
+
</div>
|
37
|
+
<div id='content'>
|
38
|
+
<div id='text'>
|
39
|
+
<div id='method-list'>
|
40
|
+
<h2>Methods</h2>
|
41
|
+
<h3>public instance</h3>
|
42
|
+
<ol>
|
43
|
+
<li><a href="#M000001">response_code</a></li>
|
44
|
+
</ol>
|
45
|
+
</div>
|
46
|
+
<div id='context'>
|
47
|
+
<div id='requires'>
|
48
|
+
<h2>Required files</h2>
|
49
|
+
<ol>
|
50
|
+
<li>drydock</li>
|
51
|
+
<li>time</li>
|
52
|
+
<li>net/http</li>
|
53
|
+
<li>uri</li>
|
54
|
+
<li>timeout</li>
|
55
|
+
</ol>
|
56
|
+
</div>
|
57
|
+
</div>
|
58
|
+
<div id='section'>
|
59
|
+
<div id='methods'>
|
60
|
+
<h2>Public instance methods</h2>
|
61
|
+
<div class='public-instance method' id='method-M000001'>
|
62
|
+
<a name='M000001'> </a>
|
63
|
+
<div class='synopsis'>
|
64
|
+
<span class='name'>response_code</span>
|
65
|
+
<span class='arguments'>(uri_str, duration=5)</span>
|
66
|
+
</div>
|
67
|
+
<div class='description'>
|
68
|
+
<p>
|
69
|
+
<a href="example.html#M000001">response_code</a>
|
70
|
+
</p>
|
71
|
+
<p>
|
72
|
+
return the HTTP response code for the given URI <tt>uri</tt> A valid HTTP
|
73
|
+
URI <tt>duration</tt> The timeout threshold (in seconds) for the request.
|
74
|
+
</p>
|
75
|
+
</div>
|
76
|
+
<div class='source'>
|
77
|
+
<a class='source-toggle' href='#' onclick="toggleCode('M000001-source'); return false">
|
78
|
+
[show source]
|
79
|
+
</a>
|
80
|
+
<pre id='M000001-source'> <span class="ruby-comment cmt"># File bin/example, line 141</span>
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>)
142: <span class="ruby-identifier">response</span> = <span class="ruby-identifier">:unavailable</span>
143: <span class="ruby-keyword kw">begin</span> 
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>) 
145: <span class="ruby-identifier">timeout</span>(<span class="ruby-identifier">duration</span>) <span class="ruby-keyword kw">do</span>
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>
147: <span class="ruby-keyword kw">end</span> 
148: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ex</span>
149: <span class="ruby-keyword kw">end</span>
150: <span class="ruby-identifier">response</span>
151: <span class="ruby-keyword kw">end</span></pre>
|
81
|
+
</div>
|
82
|
+
</div>
|
83
|
+
</div>
|
84
|
+
</div>
|
85
|
+
</div>
|
86
|
+
</div>
|
87
|
+
<div id='footer-push'></div>
|
88
|
+
</div>
|
89
|
+
<div id='footer'>
|
90
|
+
<a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
|
91
|
+
<script type='text/javascript'>
|
92
|
+
//<![CDATA[
|
93
|
+
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
94
|
+
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/scr
|
95
|
+
|
96
|
+
try {
|
97
|
+
var pageTracker = _gat._getTracker("UA-4642735-10");
|
98
|
+
pageTracker._trackPageview();
|
99
|
+
} catch(err) {}
|
100
|
+
//]]>
|
101
|
+
</script>
|
102
|
+
</div>
|
103
|
+
</body>
|
104
|
+
</html>
|