rook 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +124 -37
- data/bin/rook +8 -902
- data/doc-api/classes/BZ2.html +111 -0
- data/doc-api/classes/BZ2/Reader.html +234 -0
- data/doc-api/classes/Digest.html +107 -0
- data/doc-api/classes/Digest/Base.html +254 -0
- data/doc-api/classes/Enumerable.html +430 -0
- data/doc-api/classes/File.html +208 -0
- data/doc-api/classes/FileUtils.html +758 -0
- data/doc-api/classes/Kernel.html +317 -0
- data/doc-api/classes/Rook.html +148 -0
- data/doc-api/classes/Rook/Assertion.html +164 -0
- data/doc-api/classes/Rook/AssertionError.html +111 -0
- data/doc-api/classes/Rook/CommandOptionError.html +113 -0
- data/doc-api/classes/Rook/Commands.html +1158 -0
- data/doc-api/classes/Rook/Cookbook.html +357 -0
- data/doc-api/classes/Rook/CookbookError.html +161 -0
- data/doc-api/classes/Rook/CookbookValidator.html +215 -0
- data/doc-api/classes/Rook/Kitchen.html +875 -0
- data/doc-api/classes/Rook/KitchenHelper.html +386 -0
- data/doc-api/classes/Rook/Main.html +325 -0
- data/doc-api/classes/Rook/Parameters.html +443 -0
- data/doc-api/classes/Rook/Recipe.html +546 -0
- data/doc-api/classes/Rook/RookError.html +111 -0
- data/doc-api/classes/Rook/Util.html +408 -0
- data/doc-api/classes/Rook/Util/UndefinedPropertyError.html +160 -0
- data/doc-api/created.rid +1 -0
- data/doc-api/files/__/README_txt.html +313 -0
- data/doc-api/files/rook/commands_rb.html +115 -0
- data/doc-api/files/rook/cookbook_rb.html +115 -0
- data/doc-api/files/rook/helper/bz2_rb.html +114 -0
- data/doc-api/files/rook/helper/digest_rb.html +114 -0
- data/doc-api/files/rook/helper/enumerable_rb.html +107 -0
- data/doc-api/files/rook/helper/file_rb.html +107 -0
- data/doc-api/files/rook/helper/fileutils_rb.html +124 -0
- data/doc-api/files/rook/helper/kernel_rb.html +107 -0
- data/doc-api/files/rook/kitchen_rb.html +117 -0
- data/doc-api/files/rook/main_rb.html +117 -0
- data/doc-api/files/rook/recipe_rb.html +114 -0
- data/doc-api/files/rook/util_rb.html +115 -0
- data/doc-api/files/rook_rb.html +122 -0
- data/doc-api/fr_class_index.html +50 -0
- data/doc-api/fr_file_index.html +40 -0
- data/doc-api/fr_method_index.html +181 -0
- data/doc-api/index.html +24 -0
- data/doc-api/rdoc-style.css +208 -0
- data/examples/hello_c/Rookbook.rb +37 -0
- data/examples/hello_c/Rookbook.yaml +45 -0
- data/examples/hello_c/hello.c +6 -3
- data/examples/project/README.txt +8 -0
- data/examples/project/Rookbook.props +1 -0
- data/examples/project/Rookbook.rb +120 -0
- data/examples/project/Rookbook.yaml +117 -0
- data/examples/project/bin/example +12 -0
- data/examples/project/example.gemspec +29 -0
- data/examples/project/lib/example.rb +36 -0
- data/examples/{archive → project}/lib/example/bar.rb +0 -0
- data/examples/{archive → project}/lib/example/baz.rb +0 -0
- data/examples/{archive → project}/lib/example/foo.rb +0 -0
- data/examples/project/setup.rb +1331 -0
- data/examples/project/test/test.rb +27 -0
- data/lib/rook.rb +50 -0
- data/lib/rook/commands.rb +426 -0
- data/lib/rook/cookbook.rb +237 -0
- data/lib/rook/helper/bz2.rb +39 -0
- data/lib/rook/helper/digest.rb +76 -0
- data/lib/rook/helper/enumerable.rb +121 -0
- data/lib/rook/helper/file.rb +50 -0
- data/lib/rook/helper/fileutils.rb +340 -0
- data/lib/rook/helper/kernel.rb +108 -0
- data/lib/rook/kitchen.rb +668 -0
- data/lib/rook/main.rb +280 -0
- data/lib/rook/recipe.rb +259 -0
- data/lib/rook/rookbook.schema.yaml +156 -0
- data/lib/rook/util.rb +172 -0
- data/rook.gemspec +56 -0
- metadata +139 -45
- data/examples/archive/COPYING +0 -340
- data/examples/archive/README.txt +0 -1
- data/examples/archive/Rookbook +0 -56
- data/examples/archive/bin/example +0 -0
- data/examples/archive/doc/index.html +0 -0
- data/examples/archive/doc/index.txt +0 -0
- data/examples/archive/lib/example.rb +0 -0
- data/examples/archive/test/test1.rb +0 -0
- data/examples/archive/test/test2.rb +0 -0
- data/examples/hello_c/Rookbook +0 -24
@@ -0,0 +1,386 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Module: Rook::KitchenHelper</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Module</strong></td>
|
53
|
+
<td class="class-name-in-header">Rook::KitchenHelper</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/rook/kitchen_rb.html">
|
59
|
+
rook/kitchen.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
</table>
|
66
|
+
</div>
|
67
|
+
<!-- banner header -->
|
68
|
+
|
69
|
+
<div id="bodyContent">
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
<div id="contextContent">
|
74
|
+
|
75
|
+
<div id="description">
|
76
|
+
<p>
|
77
|
+
add functions for DSL (ruby-style cookbook)
|
78
|
+
</p>
|
79
|
+
|
80
|
+
</div>
|
81
|
+
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<div id="method-list">
|
86
|
+
<h3 class="section-bar">Methods</h3>
|
87
|
+
|
88
|
+
<div class="name-list">
|
89
|
+
<a href="#M000076">desc</a>
|
90
|
+
<a href="#M000075">material</a>
|
91
|
+
<a href="#M000073">property</a>
|
92
|
+
<a href="#M000077">recipe</a>
|
93
|
+
<a href="#M000074">variable</a>
|
94
|
+
</div>
|
95
|
+
</div>
|
96
|
+
|
97
|
+
</div>
|
98
|
+
|
99
|
+
|
100
|
+
<!-- if includes -->
|
101
|
+
|
102
|
+
<div id="section">
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
<!-- if method_list -->
|
112
|
+
<div id="methods">
|
113
|
+
<h3 class="section-bar">Private Instance methods</h3>
|
114
|
+
|
115
|
+
<div id="method-M000076" class="method-detail">
|
116
|
+
<a name="M000076"></a>
|
117
|
+
|
118
|
+
<div class="method-heading">
|
119
|
+
<a href="#M000076" class="method-signature">
|
120
|
+
<span class="method-name">desc</span><span class="method-args">(text)</span>
|
121
|
+
</a>
|
122
|
+
</div>
|
123
|
+
|
124
|
+
<div class="method-description">
|
125
|
+
<p>
|
126
|
+
specify description of recipe in Rookbook.rb
|
127
|
+
</p>
|
128
|
+
<p>
|
129
|
+
ex. (in Rookbook.rb)
|
130
|
+
</p>
|
131
|
+
<pre>
|
132
|
+
desc 'create *.o from *.c'
|
133
|
+
recipe '*.o', '$(1).c' do
|
134
|
+
sys "gcc -c #{@ingreds[0]}"
|
135
|
+
end
|
136
|
+
</pre>
|
137
|
+
<p>
|
138
|
+
the above is equivarent to the following in Rookbook.yaml:
|
139
|
+
</p>
|
140
|
+
<pre>
|
141
|
+
recipes:
|
142
|
+
- product: *.o
|
143
|
+
desc: create *.o from *.c
|
144
|
+
ingreds: [ $(1).c ]
|
145
|
+
method: |
|
146
|
+
sys "gcc -c #{@ingreds[0]}"
|
147
|
+
</pre>
|
148
|
+
<p><a class="source-toggle" href="#"
|
149
|
+
onclick="toggleCode('M000076-source');return false;">[Source]</a></p>
|
150
|
+
<div class="method-source-code" id="M000076-source">
|
151
|
+
<pre>
|
152
|
+
<span class="ruby-comment cmt"># File rook/kitchen.rb, line 132</span>
|
153
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">desc</span>(<span class="ruby-identifier">text</span>) <span class="ruby-comment cmt"># :doc:</span>
|
154
|
+
<span class="ruby-ivar">@_desc</span> = <span class="ruby-identifier">text</span>
|
155
|
+
<span class="ruby-keyword kw">end</span>
|
156
|
+
</pre>
|
157
|
+
</div>
|
158
|
+
</div>
|
159
|
+
</div>
|
160
|
+
|
161
|
+
<div id="method-M000075" class="method-detail">
|
162
|
+
<a name="M000075"></a>
|
163
|
+
|
164
|
+
<div class="method-heading">
|
165
|
+
<a href="#M000075" class="method-signature">
|
166
|
+
<span class="method-name">material</span><span class="method-args">(material_name)</span>
|
167
|
+
</a>
|
168
|
+
</div>
|
169
|
+
|
170
|
+
<div class="method-description">
|
171
|
+
<p>
|
172
|
+
specify material (= non-products) in Rookbook.rb
|
173
|
+
</p>
|
174
|
+
<p>
|
175
|
+
ex. (in Rookbook.rb)
|
176
|
+
</p>
|
177
|
+
<pre>
|
178
|
+
material 'index.html'
|
179
|
+
material 'readme.html'
|
180
|
+
</pre>
|
181
|
+
<p>
|
182
|
+
the above is equivarent to the following in Rookbook.yaml:
|
183
|
+
</p>
|
184
|
+
<pre>
|
185
|
+
materials:
|
186
|
+
- index.html
|
187
|
+
- readme.html
|
188
|
+
</pre>
|
189
|
+
<p><a class="source-toggle" href="#"
|
190
|
+
onclick="toggleCode('M000075-source');return false;">[Source]</a></p>
|
191
|
+
<div class="method-source-code" id="M000075-source">
|
192
|
+
<pre>
|
193
|
+
<span class="ruby-comment cmt"># File rook/kitchen.rb, line 100</span>
|
194
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">material</span>(<span class="ruby-identifier">material_name</span>) <span class="ruby-comment cmt"># :doc:</span>
|
195
|
+
<span class="ruby-identifier">add_material</span>(<span class="ruby-identifier">material_name</span>)
|
196
|
+
<span class="ruby-keyword kw">end</span>
|
197
|
+
</pre>
|
198
|
+
</div>
|
199
|
+
</div>
|
200
|
+
</div>
|
201
|
+
|
202
|
+
<div id="method-M000073" class="method-detail">
|
203
|
+
<a name="M000073"></a>
|
204
|
+
|
205
|
+
<div class="method-heading">
|
206
|
+
<a href="#M000073" class="method-signature">
|
207
|
+
<span class="method-name">property</span><span class="method-args">(name, value, options={})</span>
|
208
|
+
</a>
|
209
|
+
</div>
|
210
|
+
|
211
|
+
<div class="method-description">
|
212
|
+
<p>
|
213
|
+
define a property in Rookbook.rb
|
214
|
+
</p>
|
215
|
+
<p>
|
216
|
+
ex. (in Rookbook.rb)
|
217
|
+
</p>
|
218
|
+
<pre>
|
219
|
+
property 'release', '1.0.0', :desc=>'release number'
|
220
|
+
property 'project', 'myapp'
|
221
|
+
</pre>
|
222
|
+
<p>
|
223
|
+
the above is equivarent to the following (in Rookbook.yaml):
|
224
|
+
</p>
|
225
|
+
<pre>
|
226
|
+
properties:
|
227
|
+
- release : 1.0.0
|
228
|
+
:desc : 'release number'
|
229
|
+
- project : myapp
|
230
|
+
</pre>
|
231
|
+
<p>
|
232
|
+
this method define a global variable which name is the same as property
|
233
|
+
name. for example, global variables $release and $project are defined in
|
234
|
+
above ex.
|
235
|
+
</p>
|
236
|
+
<p>
|
237
|
+
property value can be overwrited by command-line option.
|
238
|
+
</p>
|
239
|
+
<p>
|
240
|
+
ex. (in command-line)
|
241
|
+
</p>
|
242
|
+
<pre>
|
243
|
+
$ rook --release=1.2.3 --project='myapp2'
|
244
|
+
</pre>
|
245
|
+
<p><a class="source-toggle" href="#"
|
246
|
+
onclick="toggleCode('M000073-source');return false;">[Source]</a></p>
|
247
|
+
<div class="method-source-code" id="M000073-source">
|
248
|
+
<pre>
|
249
|
+
<span class="ruby-comment cmt"># File rook/kitchen.rb, line 48</span>
|
250
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">property</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">options</span>={}) <span class="ruby-comment cmt"># :doc:</span>
|
251
|
+
<span class="ruby-identifier">hash</span> = { <span class="ruby-value str">'name'</span>=<span class="ruby-operator">></span><span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-value str">'value'</span>=<span class="ruby-operator">></span><span class="ruby-identifier">value</span> }
|
252
|
+
<span class="ruby-identifier">options</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>] = <span class="ruby-identifier">value</span> }
|
253
|
+
<span class="ruby-identifier">add_property</span>(<span class="ruby-identifier">hash</span>)
|
254
|
+
<span class="ruby-keyword kw">end</span>
|
255
|
+
</pre>
|
256
|
+
</div>
|
257
|
+
</div>
|
258
|
+
</div>
|
259
|
+
|
260
|
+
<div id="method-M000077" class="method-detail">
|
261
|
+
<a name="M000077"></a>
|
262
|
+
|
263
|
+
<div class="method-heading">
|
264
|
+
<a href="#M000077" class="method-signature">
|
265
|
+
<span class="method-name">recipe</span><span class="method-args">(product, *args, &block)</span>
|
266
|
+
</a>
|
267
|
+
</div>
|
268
|
+
|
269
|
+
<div class="method-description">
|
270
|
+
<p>
|
271
|
+
define a recipe in Rookbook.rb
|
272
|
+
</p>
|
273
|
+
<p>
|
274
|
+
ex. (in Rookbook.rb)
|
275
|
+
</p>
|
276
|
+
<pre>
|
277
|
+
recipe '*.o' , '$(1).c', :options=>['$(1).h'], :desc=>'compile *.c' do
|
278
|
+
sys "gcc -c #{@ingreds[0]}"
|
279
|
+
end
|
280
|
+
</pre>
|
281
|
+
<p>
|
282
|
+
the above is equivarent to the following in Rookbook.yaml:
|
283
|
+
</p>
|
284
|
+
<pre>
|
285
|
+
recipes:
|
286
|
+
- product: *.o
|
287
|
+
ingreds: [ $(1).c ]
|
288
|
+
options: [ $(1).h ]
|
289
|
+
desc: compile *.c
|
290
|
+
method: |
|
291
|
+
sys "gcc -c #{@ingreds[0]}"
|
292
|
+
</pre>
|
293
|
+
<p>
|
294
|
+
return value is a recipe created.
|
295
|
+
</p>
|
296
|
+
<p><a class="source-toggle" href="#"
|
297
|
+
onclick="toggleCode('M000077-source');return false;">[Source]</a></p>
|
298
|
+
<div class="method-source-code" id="M000077-source">
|
299
|
+
<pre>
|
300
|
+
<span class="ruby-comment cmt"># File rook/kitchen.rb, line 157</span>
|
301
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">recipe</span>(<span class="ruby-identifier">product</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>) <span class="ruby-comment cmt"># :doc:</span>
|
302
|
+
<span class="ruby-identifier">hash</span> = {}
|
303
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>[<span class="ruby-value">-1</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
|
304
|
+
<span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">val</span><span class="ruby-operator">|</span>
|
305
|
+
<span class="ruby-keyword kw">case</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>
|
306
|
+
<span class="ruby-keyword kw">when</span> <span class="ruby-value str">'option'</span>, <span class="ruby-value str">'coprod'</span>, <span class="ruby-value str">'byprod'</span>
|
307
|
+
<span class="ruby-identifier">hash</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-value str">'s'</span>] = [<span class="ruby-identifier">val</span>]
|
308
|
+
<span class="ruby-keyword kw">else</span>
|
309
|
+
<span class="ruby-identifier">hash</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>] = <span class="ruby-identifier">val</span>
|
310
|
+
<span class="ruby-keyword kw">end</span>
|
311
|
+
<span class="ruby-keyword kw">end</span>
|
312
|
+
<span class="ruby-keyword kw">end</span>
|
313
|
+
<span class="ruby-identifier">hash</span>[<span class="ruby-value str">'product'</span>] = <span class="ruby-identifier">product</span>
|
314
|
+
<span class="ruby-identifier">hash</span>[<span class="ruby-value str">'ingreds'</span>] = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">flatten</span>
|
315
|
+
<span class="ruby-identifier">hash</span>[<span class="ruby-value str">'block'</span>] = <span class="ruby-identifier">block</span>
|
316
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@_desc</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
317
|
+
<span class="ruby-identifier">hash</span>[<span class="ruby-value str">'desc'</span>] = <span class="ruby-ivar">@_desc</span>
|
318
|
+
<span class="ruby-ivar">@_desc</span> = <span class="ruby-keyword kw">nil</span>
|
319
|
+
<span class="ruby-keyword kw">end</span>
|
320
|
+
<span class="ruby-identifier">r</span> = <span class="ruby-constant">Recipe</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">hash</span>)
|
321
|
+
<span class="ruby-identifier">add_recipe</span>(<span class="ruby-identifier">r</span>)
|
322
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">r</span>
|
323
|
+
<span class="ruby-keyword kw">end</span>
|
324
|
+
</pre>
|
325
|
+
</div>
|
326
|
+
</div>
|
327
|
+
</div>
|
328
|
+
|
329
|
+
<div id="method-M000074" class="method-detail">
|
330
|
+
<a name="M000074"></a>
|
331
|
+
|
332
|
+
<div class="method-heading">
|
333
|
+
<a href="#M000074" class="method-signature">
|
334
|
+
<span class="method-name">variable</span><span class="method-args">(name, value, options={})</span>
|
335
|
+
</a>
|
336
|
+
</div>
|
337
|
+
|
338
|
+
<div class="method-description">
|
339
|
+
<p>
|
340
|
+
define a variable in Rookbook.rb
|
341
|
+
</p>
|
342
|
+
<p>
|
343
|
+
ex. (in Rookbook.rb)
|
344
|
+
</p>
|
345
|
+
<pre>
|
346
|
+
variable :srcdir, 'src'
|
347
|
+
variable :files, Dir.glob('src/*.rb')
|
348
|
+
variable :rook_product, :all
|
349
|
+
</pre>
|
350
|
+
<p>
|
351
|
+
the above code is equivalent to the following in Rookbook.yaml:
|
352
|
+
</p>
|
353
|
+
<pre>
|
354
|
+
variables:
|
355
|
+
- srcdir : src
|
356
|
+
- files* : Dir.glob('src/*.rb')
|
357
|
+
- rook_product : :all
|
358
|
+
</pre>
|
359
|
+
<p><a class="source-toggle" href="#"
|
360
|
+
onclick="toggleCode('M000074-source');return false;">[Source]</a></p>
|
361
|
+
<div class="method-source-code" id="M000074-source">
|
362
|
+
<pre>
|
363
|
+
<span class="ruby-comment cmt"># File rook/kitchen.rb, line 81</span>
|
364
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">variable</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">options</span>={}) <span class="ruby-comment cmt"># :doc:</span>
|
365
|
+
<span class="ruby-identifier">hash</span> = { <span class="ruby-value str">'name'</span>=<span class="ruby-operator">></span><span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-value str">'value'</span>=<span class="ruby-operator">></span><span class="ruby-identifier">value</span> }
|
366
|
+
<span class="ruby-identifier">options</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>] = <span class="ruby-identifier">value</span> }
|
367
|
+
<span class="ruby-identifier">add_variable</span>(<span class="ruby-identifier">hash</span>)
|
368
|
+
<span class="ruby-keyword kw">end</span>
|
369
|
+
</pre>
|
370
|
+
</div>
|
371
|
+
</div>
|
372
|
+
</div>
|
373
|
+
|
374
|
+
|
375
|
+
</div>
|
376
|
+
|
377
|
+
|
378
|
+
</div>
|
379
|
+
|
380
|
+
|
381
|
+
<div id="validator-badges">
|
382
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
383
|
+
</div>
|
384
|
+
|
385
|
+
</body>
|
386
|
+
</html>
|
@@ -0,0 +1,325 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Rook::Main</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Rook::Main</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/rook/main_rb.html">
|
59
|
+
rook/main.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<div id="method-list">
|
86
|
+
<h3 class="section-bar">Methods</h3>
|
87
|
+
|
88
|
+
<div class="name-list">
|
89
|
+
<a href="#M000093">execute</a>
|
90
|
+
<a href="#M000092">main</a>
|
91
|
+
<a href="#M000091">new</a>
|
92
|
+
</div>
|
93
|
+
</div>
|
94
|
+
|
95
|
+
</div>
|
96
|
+
|
97
|
+
|
98
|
+
<!-- if includes -->
|
99
|
+
|
100
|
+
<div id="section">
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
<!-- if method_list -->
|
110
|
+
<div id="methods">
|
111
|
+
<h3 class="section-bar">Public Class methods</h3>
|
112
|
+
|
113
|
+
<div id="method-M000092" class="method-detail">
|
114
|
+
<a name="M000092"></a>
|
115
|
+
|
116
|
+
<div class="method-heading">
|
117
|
+
<a href="#M000092" class="method-signature">
|
118
|
+
<span class="method-name">main</span><span class="method-args">(argv=ARGV, stdout=$stdout, stderr=$stderr)</span>
|
119
|
+
</a>
|
120
|
+
</div>
|
121
|
+
|
122
|
+
<div class="method-description">
|
123
|
+
<p><a class="source-toggle" href="#"
|
124
|
+
onclick="toggleCode('M000092-source');return false;">[Source]</a></p>
|
125
|
+
<div class="method-source-code" id="M000092-source">
|
126
|
+
<pre>
|
127
|
+
<span class="ruby-comment cmt"># File rook/main.rb, line 40</span>
|
128
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">main</span>(<span class="ruby-identifier">argv</span>=<span class="ruby-constant">ARGV</span>, <span class="ruby-identifier">stdout</span>=<span class="ruby-identifier">$stdout</span>, <span class="ruby-identifier">stderr</span>=<span class="ruby-identifier">$stderr</span>)
|
129
|
+
<span class="ruby-identifier">status</span> = <span class="ruby-value">0</span>
|
130
|
+
<span class="ruby-keyword kw">begin</span>
|
131
|
+
<span class="ruby-identifier">main</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">argv</span>, <span class="ruby-identifier">stdout</span>, <span class="ruby-identifier">stderr</span>)
|
132
|
+
<span class="ruby-identifier">main</span>.<span class="ruby-identifier">execute</span>()
|
133
|
+
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">RookError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ex</span>
|
134
|
+
<span class="ruby-identifier">status</span> = <span class="ruby-value">1</span>
|
135
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">ex</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$rook_debug</span>
|
136
|
+
<span class="ruby-identifier">stderr</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"*** error: #{ex.message}"</span>
|
137
|
+
<span class="ruby-keyword kw">end</span>
|
138
|
+
<span class="ruby-identifier">exit</span> <span class="ruby-identifier">status</span>
|
139
|
+
<span class="ruby-keyword kw">end</span>
|
140
|
+
</pre>
|
141
|
+
</div>
|
142
|
+
</div>
|
143
|
+
</div>
|
144
|
+
|
145
|
+
<div id="method-M000091" class="method-detail">
|
146
|
+
<a name="M000091"></a>
|
147
|
+
|
148
|
+
<div class="method-heading">
|
149
|
+
<a href="#M000091" class="method-signature">
|
150
|
+
<span class="method-name">new</span><span class="method-args">(argv=ARGV, stdout=$stdout, stderr=$stderr)</span>
|
151
|
+
</a>
|
152
|
+
</div>
|
153
|
+
|
154
|
+
<div class="method-description">
|
155
|
+
<p><a class="source-toggle" href="#"
|
156
|
+
onclick="toggleCode('M000091-source');return false;">[Source]</a></p>
|
157
|
+
<div class="method-source-code" id="M000091-source">
|
158
|
+
<pre>
|
159
|
+
<span class="ruby-comment cmt"># File rook/main.rb, line 30</span>
|
160
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">argv</span>=<span class="ruby-constant">ARGV</span>, <span class="ruby-identifier">stdout</span>=<span class="ruby-identifier">$stdout</span>, <span class="ruby-identifier">stderr</span>=<span class="ruby-identifier">$stderr</span>)
|
161
|
+
<span class="ruby-ivar">@argv</span> = <span class="ruby-identifier">argv</span>
|
162
|
+
<span class="ruby-ivar">@stdout</span> = <span class="ruby-identifier">stdout</span>
|
163
|
+
<span class="ruby-ivar">@stderr</span> = <span class="ruby-identifier">stderr</span>
|
164
|
+
<span class="ruby-ivar">@options</span>, <span class="ruby-ivar">@properties</span> = <span class="ruby-identifier">parse_argv</span>(<span class="ruby-ivar">@argv</span>)
|
165
|
+
<span class="ruby-ivar">@options</span>[<span class="ruby-value">?h</span>] = <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@properties</span>[<span class="ruby-value str">'help'</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>
|
166
|
+
<span class="ruby-ivar">@products</span> = <span class="ruby-identifier">argv</span>
|
167
|
+
<span class="ruby-keyword kw">end</span>
|
168
|
+
</pre>
|
169
|
+
</div>
|
170
|
+
</div>
|
171
|
+
</div>
|
172
|
+
|
173
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
174
|
+
|
175
|
+
<div id="method-M000093" class="method-detail">
|
176
|
+
<a name="M000093"></a>
|
177
|
+
|
178
|
+
<div class="method-heading">
|
179
|
+
<a href="#M000093" class="method-signature">
|
180
|
+
<span class="method-name">execute</span><span class="method-args">()</span>
|
181
|
+
</a>
|
182
|
+
</div>
|
183
|
+
|
184
|
+
<div class="method-description">
|
185
|
+
<p><a class="source-toggle" href="#"
|
186
|
+
onclick="toggleCode('M000093-source');return false;">[Source]</a></p>
|
187
|
+
<div class="method-source-code" id="M000093-source">
|
188
|
+
<pre>
|
189
|
+
<span class="ruby-comment cmt"># File rook/main.rb, line 54</span>
|
190
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">execute</span>
|
191
|
+
<span class="ruby-identifier">options</span> = <span class="ruby-ivar">@options</span>
|
192
|
+
<span class="ruby-identifier">properties</span> = <span class="ruby-ivar">@properties</span>
|
193
|
+
<span class="ruby-identifier">products</span> = <span class="ruby-ivar">@products</span>
|
194
|
+
|
195
|
+
<span class="ruby-comment cmt">##</span>
|
196
|
+
<span class="ruby-identifier">$rook_debug</span> = <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-value">?D</span>] <span class="ruby-comment cmt"># or $DEBUG</span>
|
197
|
+
<span class="ruby-identifier">$KCODE</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-value">?k</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-value">?k</span>]
|
198
|
+
|
199
|
+
<span class="ruby-comment cmt">## help and version</span>
|
200
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-value">?h</span>] <span class="ruby-operator">||</span> <span class="ruby-ivar">@options</span>[<span class="ruby-value">?v</span>]
|
201
|
+
<span class="ruby-identifier">cmdname</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">$0</span>)
|
202
|
+
<span class="ruby-comment cmt">#desc = "#{cmdname} - a SCM (software configuration management) tool like Make, Rake, Ant, or Cook.\n"</span>
|
203
|
+
<span class="ruby-identifier">desc</span> = <span class="ruby-node">"#{cmdname} - a SCM (Software Cooking Management) tool like Make, Rake, Ant, or Cook.\n"</span>
|
204
|
+
<span class="ruby-ivar">@stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">version</span>() <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-value">?v</span>]
|
205
|
+
<span class="ruby-ivar">@stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">desc</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-value">?h</span>]
|
206
|
+
<span class="ruby-ivar">@stdout</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">help</span>() <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-value">?h</span>]
|
207
|
+
<span class="ruby-keyword kw">return</span>
|
208
|
+
<span class="ruby-keyword kw">end</span>
|
209
|
+
|
210
|
+
<span class="ruby-comment cmt">## require libraries</span>
|
211
|
+
<span class="ruby-ivar">@options</span>[<span class="ruby-value">?r</span>].<span class="ruby-identifier">split</span>(<span class="ruby-regexp re">/,/</span>).<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">lib</span><span class="ruby-operator">|</span> <span class="ruby-identifier">require</span> <span class="ruby-identifier">lib</span> } <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-value">?r</span>]
|
212
|
+
|
213
|
+
<span class="ruby-comment cmt">## bookname</span>
|
214
|
+
<span class="ruby-identifier">bookname</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-value">?f</span>] <span class="ruby-operator">||</span> <span class="ruby-ivar">@options</span>[<span class="ruby-value">?b</span>]
|
215
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">bookname</span>
|
216
|
+
<span class="ruby-identifier">test</span>(<span class="ruby-value">?f</span>, <span class="ruby-identifier">bookname</span>) <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-constant">CommandOptionError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"cookbook '#{bookname}' not found."</span>)
|
217
|
+
<span class="ruby-keyword kw">else</span>
|
218
|
+
[<span class="ruby-value str">'.yaml'</span>, <span class="ruby-value str">'.yml'</span>, <span class="ruby-value str">'.rb'</span>, <span class="ruby-value str">''</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">suffix</span><span class="ruby-operator">|</span>
|
219
|
+
<span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">test</span>(<span class="ruby-value">?f</span>, <span class="ruby-identifier">bookname</span> = <span class="ruby-node">"Rookbook#{suffix}"</span>)
|
220
|
+
<span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">test</span>(<span class="ruby-value">?f</span>, <span class="ruby-identifier">bookname</span> = <span class="ruby-node">"rookbook#{suffix}"</span>)
|
221
|
+
<span class="ruby-identifier">bookname</span> = <span class="ruby-keyword kw">nil</span>
|
222
|
+
<span class="ruby-keyword kw">end</span>
|
223
|
+
<span class="ruby-identifier">bookname</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-constant">CommandOptionError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">"cookbook 'Rookbook.yaml' or 'Rookbook.rb' not found."</span>)
|
224
|
+
<span class="ruby-keyword kw">end</span>
|
225
|
+
|
226
|
+
<span class="ruby-comment cmt">## properties filename</span>
|
227
|
+
<span class="ruby-identifier">propfile</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-value">?P</span>]
|
228
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">propfile</span>
|
229
|
+
<span class="ruby-identifier">test</span>(<span class="ruby-value">?f</span>, <span class="ruby-identifier">propfile</span>) <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-constant">CommandOptionError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"file '#{propfile}' not found."</span>)
|
230
|
+
<span class="ruby-keyword kw">else</span>
|
231
|
+
<span class="ruby-node">%w[Rookbook.props properties.yaml]</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
|
232
|
+
<span class="ruby-keyword kw">break</span> <span class="ruby-identifier">propfile</span> = <span class="ruby-identifier">f</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">test</span>(<span class="ruby-value">?f</span>, <span class="ruby-identifier">f</span>)
|
233
|
+
<span class="ruby-keyword kw">end</span>
|
234
|
+
<span class="ruby-keyword kw">end</span>
|
235
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">propfile</span>
|
236
|
+
<span class="ruby-identifier">props</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load_file</span>(<span class="ruby-identifier">propfile</span>)
|
237
|
+
<span class="ruby-identifier">props</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
238
|
+
<span class="ruby-ivar">@properties</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">v</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@properties</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">k</span>)
|
239
|
+
<span class="ruby-keyword kw">end</span>
|
240
|
+
<span class="ruby-keyword kw">end</span>
|
241
|
+
|
242
|
+
<span class="ruby-comment cmt">## global options</span>
|
243
|
+
<span class="ruby-identifier">$rook_verbose</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-value">?V</span>] <span class="ruby-operator">?</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> (<span class="ruby-ivar">@options</span>[<span class="ruby-value">?q</span>] <span class="ruby-operator">?</span> <span class="ruby-keyword kw">false</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>)
|
244
|
+
<span class="ruby-identifier">$rook_forced</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-value">?F</span>]
|
245
|
+
<span class="ruby-identifier">$rook_noexec</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-value">?n</span>] <span class="ruby-operator">?</span> <span class="ruby-value">1</span> <span class="ruby-operator">:</span> (<span class="ruby-ivar">@options</span>[<span class="ruby-value">?N</span>] <span class="ruby-operator">?</span> <span class="ruby-value">2</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>)
|
246
|
+
|
247
|
+
<span class="ruby-comment cmt"># kitchen</span>
|
248
|
+
<span class="ruby-identifier">props</span> = { <span class="ruby-identifier">:verbose=</span><span class="ruby-operator">></span><span class="ruby-identifier">$rook_verbose</span>, <span class="ruby-identifier">:forced=</span><span class="ruby-operator">></span><span class="ruby-identifier">$rook_forced</span>, <span class="ruby-identifier">:noexec=</span><span class="ruby-operator">></span><span class="ruby-identifier">$rook_noexec</span> }
|
249
|
+
<span class="ruby-identifier">kitchen</span> = <span class="ruby-constant">Kitchen</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@properties</span>, <span class="ruby-identifier">props</span>)
|
250
|
+
|
251
|
+
<span class="ruby-comment cmt">## cookbook</span>
|
252
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">bookname</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/\.ya?ml\z/</span>
|
253
|
+
<span class="ruby-identifier">flag_expand_tab</span> = <span class="ruby-operator">!</span><span class="ruby-identifier">options</span>[<span class="ruby-value">?T</span>]
|
254
|
+
<span class="ruby-keyword kw">begin</span>
|
255
|
+
<span class="ruby-identifier">cookbook</span> = <span class="ruby-constant">Cookbook</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">bookname</span>, <span class="ruby-keyword kw">true</span>, <span class="ruby-identifier">flag_expand_tab</span>)
|
256
|
+
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">CookbookError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ex</span>
|
257
|
+
<span class="ruby-ivar">@stderr</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">"validation error:"</span>
|
258
|
+
<span class="ruby-identifier">ex</span>.<span class="ruby-identifier">errors</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">error</span><span class="ruby-operator">|</span>
|
259
|
+
<span class="ruby-identifier">e</span> = <span class="ruby-identifier">error</span>
|
260
|
+
<span class="ruby-ivar">@stderr</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">" - line #{e.linenum}: [#{e.path}] #{e.message}"</span>
|
261
|
+
<span class="ruby-keyword kw">end</span>
|
262
|
+
<span class="ruby-keyword kw">return</span>
|
263
|
+
<span class="ruby-keyword kw">end</span>
|
264
|
+
<span class="ruby-identifier">kitchen</span>.<span class="ruby-identifier">load_book</span>(<span class="ruby-identifier">cookbook</span>)
|
265
|
+
<span class="ruby-keyword kw">else</span>
|
266
|
+
<span class="ruby-identifier">kitchen</span>.<span class="ruby-identifier">load_script</span>(<span class="ruby-identifier">bookname</span>)
|
267
|
+
<span class="ruby-keyword kw">end</span>
|
268
|
+
|
269
|
+
<span class="ruby-comment cmt">## list recipes</span>
|
270
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-value">?l</span>] <span class="ruby-operator">||</span> <span class="ruby-ivar">@options</span>[<span class="ruby-value">?L</span>]
|
271
|
+
<span class="ruby-identifier">show_all</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-value">?L</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>
|
272
|
+
<span class="ruby-identifier">list_properties</span>(<span class="ruby-identifier">kitchen</span>, <span class="ruby-identifier">show_all</span>)
|
273
|
+
<span class="ruby-ivar">@stdout</span>.<span class="ruby-identifier">puts</span>
|
274
|
+
<span class="ruby-identifier">list_recipes</span>(<span class="ruby-identifier">kitchen</span>, <span class="ruby-ivar">@options</span>[<span class="ruby-value">?L</span>])
|
275
|
+
<span class="ruby-keyword kw">return</span>
|
276
|
+
<span class="ruby-keyword kw">end</span>
|
277
|
+
|
278
|
+
<span class="ruby-comment cmt">## show property value</span>
|
279
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-value">?p</span>]
|
280
|
+
<span class="ruby-ivar">@options</span>[<span class="ruby-value">?p</span>].<span class="ruby-identifier">split</span>(<span class="ruby-regexp re">/,/</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">pname</span><span class="ruby-operator">|</span>
|
281
|
+
<span class="ruby-identifier">pp</span> <span class="ruby-identifier">kitchen</span>.<span class="ruby-identifier">get_property</span>(<span class="ruby-identifier">pname</span>)
|
282
|
+
<span class="ruby-keyword kw">end</span>
|
283
|
+
<span class="ruby-keyword kw">return</span>
|
284
|
+
<span class="ruby-keyword kw">end</span>
|
285
|
+
|
286
|
+
<span class="ruby-comment cmt">## target product</span>
|
287
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@products</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@products</span>.<span class="ruby-identifier">empty?</span>
|
288
|
+
<span class="ruby-identifier">products</span> = <span class="ruby-ivar">@products</span>
|
289
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">kitchen</span>.<span class="ruby-identifier">find_specific_recipe</span>(<span class="ruby-identifier">:default</span>)
|
290
|
+
<span class="ruby-identifier">products</span> = [ <span class="ruby-identifier">:default</span> ]
|
291
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">prod</span> = <span class="ruby-identifier">kitchen</span>.<span class="ruby-identifier">get_variable</span>(<span class="ruby-value str">'rook_product'</span>)
|
292
|
+
<span class="ruby-identifier">products</span> = [ <span class="ruby-identifier">prod</span> ]
|
293
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">prod</span> = <span class="ruby-identifier">kitchen</span>.<span class="ruby-identifier">get_property</span>(<span class="ruby-value str">'rook_product'</span>)
|
294
|
+
<span class="ruby-identifier">products</span> = [ <span class="ruby-identifier">prod</span> ]
|
295
|
+
<span class="ruby-keyword kw">else</span>
|
296
|
+
<span class="ruby-ivar">@stderr</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">"*** no product specified."</span>
|
297
|
+
<span class="ruby-identifier">list_recipes</span>(<span class="ruby-identifier">kitchen</span>)
|
298
|
+
<span class="ruby-keyword kw">return</span>
|
299
|
+
<span class="ruby-keyword kw">end</span>
|
300
|
+
|
301
|
+
<span class="ruby-comment cmt">## start cooking</span>
|
302
|
+
<span class="ruby-identifier">products</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">product</span><span class="ruby-operator">|</span>
|
303
|
+
<span class="ruby-identifier">product</span> = <span class="ruby-identifier">product</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp re">/\A:/</span>, <span class="ruby-value str">''</span>).<span class="ruby-identifier">intern</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">product</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">product</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?:</span>
|
304
|
+
<span class="ruby-identifier">kitchen</span>.<span class="ruby-identifier">start_cooking</span>(<span class="ruby-identifier">product</span>)
|
305
|
+
<span class="ruby-keyword kw">end</span>
|
306
|
+
|
307
|
+
<span class="ruby-keyword kw">end</span>
|
308
|
+
</pre>
|
309
|
+
</div>
|
310
|
+
</div>
|
311
|
+
</div>
|
312
|
+
|
313
|
+
|
314
|
+
</div>
|
315
|
+
|
316
|
+
|
317
|
+
</div>
|
318
|
+
|
319
|
+
|
320
|
+
<div id="validator-badges">
|
321
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
322
|
+
</div>
|
323
|
+
|
324
|
+
</body>
|
325
|
+
</html>
|