rbatch 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. data/README.ja.md +14 -5
  2. data/README.md +164 -154
  3. data/bin/rbatch-init +21 -13
  4. data/doc/RBatch/Cmd.html +300 -316
  5. data/doc/RBatch/CmdException.html +146 -141
  6. data/doc/RBatch/CmdResult.html +467 -470
  7. data/doc/RBatch/Config.html +392 -433
  8. data/doc/RBatch/Controller.html +374 -0
  9. data/doc/RBatch/DoubleRunCheckException.html +146 -141
  10. data/doc/RBatch/DoubleRunChecker.html +258 -256
  11. data/doc/RBatch/Journal.html +332 -0
  12. data/doc/RBatch/Log.html +636 -805
  13. data/doc/RBatch/LogException.html +164 -0
  14. data/doc/RBatch/RBatch/RBatch/ConfigException.html +164 -0
  15. data/doc/RBatch/RBatch/RBatch.html +163 -0
  16. data/doc/RBatch/RBatch/VariablesException.html +164 -0
  17. data/doc/RBatch/RBatch.html +165 -0
  18. data/doc/RBatch/RunConf/Exception.html +146 -141
  19. data/doc/RBatch/RunConf.html +478 -532
  20. data/doc/RBatch/Variables.html +437 -0
  21. data/doc/RBatch.html +388 -862
  22. data/doc/created.rid +11 -9
  23. data/doc/index.html +178 -184
  24. data/doc/js/darkfish.js +9 -7
  25. data/doc/lib/rbatch/cmd_rb.html +46 -44
  26. data/doc/lib/rbatch/config_rb.html +42 -42
  27. data/doc/lib/rbatch/controller_rb.html +66 -0
  28. data/doc/lib/rbatch/double_run_checker_rb.html +42 -42
  29. data/doc/lib/rbatch/journal_rb.html +52 -0
  30. data/doc/lib/rbatch/log_rb.html +46 -46
  31. data/doc/lib/rbatch/run_conf_rb.html +42 -42
  32. data/doc/lib/rbatch/variables_rb.html +54 -0
  33. data/doc/lib/rbatch/version_rb.html +38 -38
  34. data/doc/lib/rbatch_rb.html +40 -52
  35. data/doc/rdoc.css +365 -308
  36. data/lib/rbatch/cmd.rb +15 -58
  37. data/lib/rbatch/config.rb +7 -7
  38. data/lib/rbatch/controller.rb +37 -61
  39. data/lib/rbatch/double_run_checker.rb +0 -0
  40. data/lib/rbatch/journal.rb +40 -0
  41. data/lib/rbatch/log.rb +71 -129
  42. data/lib/rbatch/run_conf.rb +13 -24
  43. data/lib/rbatch/variables.rb +82 -0
  44. data/lib/rbatch/version.rb +1 -1
  45. data/lib/rbatch.rb +7 -36
  46. data/sample/.rbatchrc +41 -7
  47. data/spec/01_rbach_spec.rb +99 -0
  48. data/spec/{cmd_spec.rb → rbatch/cmd_spec.rb} +40 -43
  49. data/spec/rbatch/config_spec.rb +67 -0
  50. data/spec/rbatch/controller_spec.rb +18 -0
  51. data/spec/{double_run_checker_spec.rb → rbatch/double_run_checker_spec.rb} +3 -0
  52. data/spec/rbatch/journal_spec.rb +29 -0
  53. data/spec/rbatch/log_spec.rb +350 -0
  54. data/spec/{run_conf_spec.rb → rbatch/run_conf_spec.rb} +13 -5
  55. data/spec/rbatch/variables_spec.rb +68 -0
  56. data/spec/spec_helper.rb +4 -5
  57. metadata +33 -17
  58. data/lib/rbatch/common_config.rb +0 -0
  59. data/spec/common_config_spec.rb +0 -85
  60. data/spec/config_spec.rb +0 -79
  61. data/spec/log_spec.rb +0 -430
  62. data/spec/rbatch_spec.rb +0 -22
data/doc/RBatch/Cmd.html CHANGED
@@ -1,336 +1,320 @@
1
- <?xml version="1.0" encoding="utf-8"?>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
2
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
4
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
5
  <head>
6
- <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
6
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
7
7
 
8
- <title>Class: RBatch::Cmd</title>
8
+ <title>Class: RBatch::Cmd</title>
9
9
 
10
- <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
10
+ <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
11
11
 
12
- <script src="../js/jquery.js" type="text/javascript"
13
- charset="utf-8"></script>
14
- <script src="../js/thickbox-compressed.js" type="text/javascript"
15
- charset="utf-8"></script>
16
- <script src="../js/quicksearch.js" type="text/javascript"
17
- charset="utf-8"></script>
18
- <script src="../js/darkfish.js" type="text/javascript"
19
- charset="utf-8"></script>
12
+ <script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script>
13
+ <script src="../js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
14
+ <script src="../js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
15
+ <script src="../js/darkfish.js" type="text/javascript" charset="utf-8"></script>
20
16
 
21
17
  </head>
22
- <body class="class">
18
+ <body id="top" class="class">
23
19
 
24
- <div id="metadata">
25
- <div id="home-metadata">
26
- <div id="home-section" class="section">
20
+ <div id="metadata">
21
+ <div id="home-metadata">
22
+ <div id="home-section" class="section">
27
23
  <h3 class="section-header">
28
24
  <a href="../index.html">Home</a>
29
25
  <a href="../index.html#classes">Classes</a>
30
26
  <a href="../index.html#methods">Methods</a>
31
27
  </h3>
32
- </div>
33
- </div>
34
-
35
- <div id="file-metadata">
36
- <div id="file-list-section" class="section">
37
- <h3 class="section-header">In Files</h3>
38
- <div class="section-body">
39
- <ul>
40
-
41
- <li><a href="../lib/rbatch/cmd_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
42
- class="thickbox" title="lib/rbatch/cmd.rb">lib/rbatch/cmd.rb</a></li>
43
-
44
- </ul>
45
- </div>
46
- </div>
47
-
48
-
49
- </div>
50
-
51
- <div id="class-metadata">
52
-
53
- <!-- Parent Class -->
54
-
55
- <div id="parent-class-section" class="section">
56
- <h3 class="section-header">Parent</h3>
57
-
58
- <p class="link">Object</p>
59
-
60
- </div>
61
-
62
-
63
- <!-- Namespace Contents -->
64
-
65
-
66
- <!-- Method Quickref -->
67
-
68
- <div id="method-list-section" class="section">
69
- <h3 class="section-header">Methods</h3>
70
- <ul class="link-list">
71
-
72
- <li><a href="#method-c-new">::new</a></li>
73
-
74
- <li><a href="#method-i-run">#run</a></li>
75
-
76
- </ul>
77
- </div>
78
-
79
-
80
- <!-- Included Modules -->
81
-
82
- </div>
83
-
84
- <div id="project-metadata">
85
-
86
-
87
-
88
- <div id="classindex-section" class="section project-section">
89
- <h3 class="section-header">Class Index
90
- <span class="search-toggle"><img src="../images/find.png"
91
- height="16" width="16" alt="[+]"
92
- title="show/hide quicksearch" /></span></h3>
93
- <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
94
- <fieldset>
95
- <legend>Quicksearch</legend>
96
- <input type="text" name="quicksearch" value=""
97
- class="quicksearch-field" />
98
- </fieldset>
99
- </form>
100
-
101
- <ul class="link-list">
102
-
103
- <li><a href="../RBatch.html">RBatch</a></li>
104
-
105
- <li><a href="../RBatch/Cmd.html">RBatch::Cmd</a></li>
106
-
107
- <li><a href="../RBatch/CmdException.html">RBatch::CmdException</a></li>
108
-
109
- <li><a href="../RBatch/CmdResult.html">RBatch::CmdResult</a></li>
110
-
111
- <li><a href="../RBatch/CommonConfig.html">RBatch::CommonConfig</a></li>
112
-
113
- <li><a href="../RBatch/CommonConfig/Exception.html">RBatch::CommonConfig::Exception</a></li>
114
-
115
- <li><a href="../RBatch/Config.html">RBatch::Config</a></li>
116
-
117
- <li><a href="../RBatch/Config/Exception.html">RBatch::Config::Exception</a></li>
118
-
119
- <li><a href="../RBatch/DoubleRunCheckException.html">RBatch::DoubleRunCheckException</a></li>
120
-
121
- <li><a href="../RBatch/DoubleRunChecker.html">RBatch::DoubleRunChecker</a></li>
122
-
123
- <li><a href="../RBatch/Log.html">RBatch::Log</a></li>
124
-
125
- <li><a href="../RBatch/RunConf.html">RBatch::RunConf</a></li>
126
-
127
- <li><a href="../RBatch/RunConf/Exception.html">RBatch::RunConf::Exception</a></li>
128
-
129
- </ul>
130
- <div id="no-class-search-results" style="display: none;">No matching classes.</div>
131
- </div>
132
-
133
-
134
- </div>
135
- </div>
136
-
137
- <div id="documentation">
138
- <h1 class="class">RBatch::Cmd</h1>
139
-
140
- <div id="description">
141
- <pre>
142
- External command runcher.
143
- </pre>
144
- <p>
145
- This module is a wrapper of Kernel#spawn.
146
- </p>
28
+ </div>
29
+ </div>
30
+
31
+ <div id="file-metadata">
32
+ <div id="file-list-section" class="section">
33
+ <h3 class="section-header">In Files</h3>
34
+ <div class="section-body">
35
+ <ul>
36
+
37
+ <li><a href="../lib/rbatch/cmd_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
38
+ class="thickbox" title="lib/rbatch/cmd.rb">lib/rbatch/cmd.rb</a></li>
39
+
40
+ </ul>
41
+ </div>
42
+ </div>
43
+
44
+
45
+ </div>
46
+
47
+ <div id="class-metadata">
48
+
49
+ <!-- Parent Class -->
50
+ <div id="parent-class-section" class="section">
51
+ <h3 class="section-header">Parent</h3>
52
+
53
+ <p class="link">Object</p>
54
+
55
+ </div>
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+ <!-- Method Quickref -->
64
+ <div id="method-list-section" class="section">
65
+ <h3 class="section-header">Methods</h3>
66
+ <ul class="link-list">
67
+
68
+ <li><a href="#method-c-def_vars-3D">::def_vars=</a></li>
69
+
70
+ <li><a href="#method-c-new">::new</a></li>
71
+
72
+ <li><a href="#method-i-run">#run</a></li>
73
+
74
+ </ul>
75
+ </div>
76
+
77
+
78
+
79
+ </div>
80
+
81
+ <div id="project-metadata">
82
+
83
+
84
+
85
+ <div id="classindex-section" class="section project-section">
86
+ <h3 class="section-header">Class/Module Index
87
+ <span class="search-toggle"><img src="../images/find.png"
88
+ height="16" width="16" alt="[+]"
89
+ title="show/hide quicksearch" /></span></h3>
90
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
91
+ <fieldset>
92
+ <legend>Quicksearch</legend>
93
+ <input type="text" name="quicksearch" value=""
94
+ class="quicksearch-field" />
95
+ </fieldset>
96
+ </form>
97
+
98
+ <ul class="link-list">
99
+
100
+ <li><a href="../RBatch.html">RBatch</a></li>
101
+
102
+ <li><a href="../RBatch/Cmd.html">RBatch::Cmd</a></li>
103
+
104
+ <li><a href="../RBatch/CmdException.html">RBatch::CmdException</a></li>
105
+
106
+ <li><a href="../RBatch/CmdResult.html">RBatch::CmdResult</a></li>
107
+
108
+ <li><a href="../RBatch/Config.html">RBatch::Config</a></li>
109
+
110
+ <li><a href="../RBatch/Controller.html">RBatch::Controller</a></li>
111
+
112
+ <li><a href="../RBatch/DoubleRunCheckException.html">RBatch::DoubleRunCheckException</a></li>
113
+
114
+ <li><a href="../RBatch/DoubleRunChecker.html">RBatch::DoubleRunChecker</a></li>
115
+
116
+ <li><a href="../RBatch/Journal.html">RBatch::Journal</a></li>
117
+
118
+ <li><a href="../RBatch/Log.html">RBatch::Log</a></li>
119
+
120
+ <li><a href="../RBatch/LogException.html">RBatch::LogException</a></li>
121
+
122
+ <li><a href="../RBatch/RBatch.html">RBatch::RBatch</a></li>
123
+
124
+ <li><a href="../RBatch/RBatch/RBatch.html">RBatch::RBatch::RBatch</a></li>
125
+
126
+ <li><a href="../RBatch/RBatch/RBatch/ConfigException.html">RBatch::RBatch::RBatch::ConfigException</a></li>
127
+
128
+ <li><a href="../RBatch/RBatch/VariablesException.html">RBatch::RBatch::VariablesException</a></li>
129
+
130
+ <li><a href="../RBatch/RunConf.html">RBatch::RunConf</a></li>
131
+
132
+ <li><a href="../RBatch/RunConf/Exception.html">RBatch::RunConf::Exception</a></li>
133
+
134
+ <li><a href="../RBatch/Variables.html">RBatch::Variables</a></li>
135
+
136
+ </ul>
137
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
138
+ </div>
139
+
140
+
141
+ </div>
142
+ </div>
143
+
144
+ <div id="documentation">
145
+ <h1 class="class">RBatch::Cmd</h1>
146
+
147
+ <div id="description" class="description">
148
+
149
+ </div><!-- description -->
150
+
151
+
152
+
153
+
154
+ <div id="5Buntitled-5D" class="documentation-section">
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+ <!-- Methods -->
164
+
165
+ <div id="public-class-method-details" class="method-section section">
166
+ <h3 class="section-header">Public Class Methods</h3>
167
+
168
+
169
+ <div id="def_vars-3D-method" class="method-detail ">
170
+ <a name="method-c-def_vars-3D"></a>
171
+
172
+
173
+ <div class="method-heading">
174
+ <span class="method-name">def_vars=</span><span
175
+ class="method-args">(a)</span>
176
+ <span class="method-click-advice">click to toggle source</span>
177
+ </div>
178
+
179
+
180
+ <div class="method-description">
181
+
182
+
183
+
184
+
185
+
186
+ <div class="method-source-code" id="def_vars-3D-source">
147
187
  <pre>
148
- * Arguments(cmd_params) are inputed to Kernel#spawn directly and run command.
149
- * Return an object of RBatch::CmdResult which includes stdout, stderr, and exit status.
150
-
151
- ==== Sample 1
152
- require 'rbatch'
153
- result = RBatch::cmd(&quot;ls&quot;)
154
- p result.stdout
155
- =&gt; &quot;fileA\nfileB\n&quot;
156
-
157
- ==== Sample 2 (use option)
158
- require 'rbatch'
159
- result = RBatch::cmd(&quot;ls&quot;,{:timeout =&gt; 1})
160
- p result.stdout
161
- =&gt; &quot;fileA\nfileB\n&quot;
162
-
163
- ==== Sample 3 (use instance)
164
- require 'rbatch'
165
- cmd = RBatch::Cmd.new(&quot;ls&quot;)
166
- result = cmd.run
167
- p result.stdout
168
- =&gt; &quot;fileA\nfileB\n&quot;</pre>
169
-
170
- </div>
171
-
172
- <!-- Constants -->
173
-
174
-
175
- <!-- Attributes -->
176
-
177
-
178
- <!-- Methods -->
179
-
180
- <div id="public-class-method-details" class="method-section section">
181
- <h3 class="section-header">Public Class Methods</h3>
182
-
183
-
184
- <div id="new-method" class="method-detail ">
185
- <a name="method-c-new"></a>
186
-
187
- <div class="method-heading">
188
-
189
- <span class="method-name">new</span><span
190
- class="method-args">(cmd_str,opt = nil)</span>
191
- <span class="method-click-advice">click to toggle source</span>
192
-
193
- </div>
194
-
195
- <div class="method-description">
196
-
197
- <p>
198
- <a href="Cmd.html">Cmd</a> instance
199
- </p>
200
- <h4>Params</h4>
201
- <p>
202
- <tt>cmd_str</tt> = Command string such as &#8220;ls -l&#8221; <tt>opt</tt>
203
- = Option hash object.
204
- </p>
205
- <ul>
206
- <li><p>
207
- <tt>:raise</tt> (Boolean) = If command exit status is not 0, raise
208
- exception. Default is false.
209
- </p>
210
- </li>
211
- <li><p>
212
- <tt>:timeout</tt> (Integer) = If command timeout , raise exception and kill
213
- process. Default is 0 sec ( 0 means disable) .
214
- </p>
215
- </li>
216
- </ul>
217
-
218
-
219
-
220
- <div class="method-source-code"
221
- id="new-source">
188
+ <span class="ruby-comment"># File lib/rbatch/cmd.rb, line 9</span>
189
+ <span class="ruby-keyword">def</span> <span class="ruby-constant">Cmd</span>.<span class="ruby-identifier">def_vars=</span>(<span class="ruby-identifier">a</span>) ; <span class="ruby-identifier">@@def_vars</span>=<span class="ruby-identifier">a</span> ; <span class="ruby-keyword">end</span></pre>
190
+ </div><!-- def_vars-3D-source -->
191
+
192
+ </div>
193
+
194
+
195
+
196
+
197
+ </div><!-- def_vars-3D-method -->
198
+
199
+
200
+ <div id="new-method" class="method-detail ">
201
+ <a name="method-c-new"></a>
202
+
203
+
204
+ <div class="method-heading">
205
+ <span class="method-name">new</span><span
206
+ class="method-args">(cmd_str,opt = nil)</span>
207
+ <span class="method-click-advice">click to toggle source</span>
208
+ </div>
209
+
210
+
211
+ <div class="method-description">
212
+
213
+
214
+
215
+
216
+
217
+ <div class="method-source-code" id="new-source">
222
218
  <pre>
223
- <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 44</span>
224
- 44: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">cmd_str</span>,<span class="ruby-identifier">opt</span> = <span class="ruby-keyword kw">nil</span>)
225
- 45: <span class="ruby-identifier">raise</span>(<span class="ruby-constant">CmdException</span>,<span class="ruby-value str">&quot;Command string is nil&quot;</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cmd_str</span>.<span class="ruby-identifier">nil?</span>
226
- 46: <span class="ruby-ivar">@cmd_str</span> = <span class="ruby-identifier">cmd_str</span>
227
- 47: <span class="ruby-identifier">tmp</span> = {}
228
- 48: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opt</span>.<span class="ruby-identifier">nil?</span>
229
- 49: <span class="ruby-ivar">@opt</span>=<span class="ruby-constant">RBatch</span>.<span class="ruby-identifier">run_conf</span>.<span class="ruby-identifier">clone</span>
230
- 50: <span class="ruby-keyword kw">else</span>
231
- 51: <span class="ruby-identifier">opt</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
232
- 52: <span class="ruby-identifier">tmp</span>[(<span class="ruby-value str">&quot;cmd_&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>).<span class="ruby-identifier">to_sym</span>] = <span class="ruby-identifier">opt</span>[<span class="ruby-identifier">key</span>]
233
- 53: <span class="ruby-keyword kw">end</span>
234
- 54: <span class="ruby-ivar">@opt</span>=<span class="ruby-constant">RBatch</span>.<span class="ruby-identifier">run_conf</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">tmp</span>)
235
- 55: <span class="ruby-keyword kw">end</span>
236
- 56: <span class="ruby-keyword kw">end</span></pre>
237
- </div>
238
-
239
- </div>
240
-
241
-
242
-
243
-
244
- </div>
245
-
246
-
247
- </div>
248
-
249
- <div id="public-instance-method-details" class="method-section section">
250
- <h3 class="section-header">Public Instance Methods</h3>
251
-
252
-
253
- <div id="run-method" class="method-detail ">
254
- <a name="method-i-run"></a>
255
-
256
- <div class="method-heading">
257
-
258
- <span class="method-name">run</span><span
259
- class="method-args">()</span>
260
- <span class="method-click-advice">click to toggle source</span>
261
-
262
- </div>
263
-
264
- <div class="method-description">
265
-
266
- <p>
267
- Run command
268
- </p>
269
- <h4>Return</h4>
270
- <p>
271
- instance of <a href="CmdResult.html">RBatch::CmdResult</a>
272
- </p>
273
-
274
-
275
-
276
- <div class="method-source-code"
277
- id="run-source">
219
+ <span class="ruby-comment"># File lib/rbatch/cmd.rb, line 13</span>
220
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">cmd_str</span>,<span class="ruby-identifier">opt</span> = <span class="ruby-keyword">nil</span>)
221
+ <span class="ruby-identifier">raise</span>(<span class="ruby-constant">CmdException</span>,<span class="ruby-string">&quot;Command string is nil&quot;</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">cmd_str</span>.<span class="ruby-identifier">nil?</span>
222
+ <span class="ruby-ivar">@cmd_str</span> = <span class="ruby-identifier">cmd_str</span>
223
+ <span class="ruby-ivar">@vars</span> = <span class="ruby-identifier">@@def_vars</span>.<span class="ruby-identifier">clone</span>
224
+ <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span> <span class="ruby-identifier">opt</span>.<span class="ruby-identifier">nil?</span>
225
+ <span class="ruby-comment"># change opt key from &quot;hoge&quot; to &quot;log_hoge&quot;</span>
226
+ <span class="ruby-identifier">tmp</span> = {}
227
+ <span class="ruby-identifier">opt</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
228
+ <span class="ruby-identifier">tmp</span>[(<span class="ruby-string">&quot;cmd_&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>).<span class="ruby-identifier">to_sym</span>] = <span class="ruby-identifier">opt</span>[<span class="ruby-identifier">key</span>]
229
+ <span class="ruby-keyword">end</span>
230
+ <span class="ruby-ivar">@vars</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">tmp</span>)
231
+ <span class="ruby-keyword">end</span>
232
+ <span class="ruby-keyword">end</span></pre>
233
+ </div><!-- new-source -->
234
+
235
+ </div>
236
+
237
+
238
+
239
+
240
+ </div><!-- new-method -->
241
+
242
+
243
+ </div><!-- public-class-method-details -->
244
+
245
+ <div id="public-instance-method-details" class="method-section section">
246
+ <h3 class="section-header">Public Instance Methods</h3>
247
+
248
+
249
+ <div id="run-method" class="method-detail ">
250
+ <a name="method-i-run"></a>
251
+
252
+
253
+ <div class="method-heading">
254
+ <span class="method-name">run</span><span
255
+ class="method-args">()</span>
256
+ <span class="method-click-advice">click to toggle source</span>
257
+ </div>
258
+
259
+
260
+ <div class="method-description">
261
+
262
+
263
+
264
+
265
+
266
+ <div class="method-source-code" id="run-source">
278
267
  <pre>
279
- <span class="ruby-comment cmt"># File lib/rbatch/cmd.rb, line 62</span>
280
- 62: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>()
281
- 63: <span class="ruby-identifier">stdout_file</span> = <span class="ruby-constant">Tempfile</span><span class="ruby-operator">::</span><span class="ruby-identifier">new</span>(<span class="ruby-value str">&quot;rbatch_tmpout&quot;</span>,<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">tmpdir</span>)
282
- 64: <span class="ruby-identifier">stderr_file</span> = <span class="ruby-constant">Tempfile</span><span class="ruby-operator">::</span><span class="ruby-identifier">new</span>(<span class="ruby-value str">&quot;rbatch_tmperr&quot;</span>,<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">tmpdir</span>)
283
- 65: <span class="ruby-identifier">pid</span> = <span class="ruby-identifier">spawn</span>(<span class="ruby-ivar">@cmd_str</span>,<span class="ruby-value">:out</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-identifier">stdout_file</span>,<span class="ruby-value str">&quot;w&quot;</span>],<span class="ruby-value">:err</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-identifier">stderr_file</span>,<span class="ruby-value str">&quot;w&quot;</span>])
284
- 66: <span class="ruby-identifier">status</span> = <span class="ruby-keyword kw">nil</span>
285
- 67: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@opt</span>[<span class="ruby-value">:cmd_timeout</span>] <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>
286
- 68: <span class="ruby-keyword kw">begin</span>
287
- 69: <span class="ruby-identifier">timeout</span>(<span class="ruby-ivar">@opt</span>[<span class="ruby-value">:cmd_timeout</span>]) <span class="ruby-keyword kw">do</span>
288
- 70: <span class="ruby-identifier">status</span> = <span class="ruby-constant">Process</span>.<span class="ruby-identifier">waitpid2</span>(<span class="ruby-identifier">pid</span>)[<span class="ruby-value">1</span>] <span class="ruby-operator">&gt;&gt;</span> <span class="ruby-value">8</span>
289
- 71: <span class="ruby-keyword kw">end</span>
290
- 72: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Timeout</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
291
- 73: <span class="ruby-keyword kw">begin</span>
292
- 74: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">kill</span>(<span class="ruby-value str">'SIGINT'</span>, <span class="ruby-identifier">pid</span>)
293
- 75: <span class="ruby-identifier">raise</span>(<span class="ruby-constant">CmdException</span>,<span class="ruby-node">&quot;Run time of command \&quot;#{@cmd_str}\&quot; is over #{@opt[:cmd_timeout].to_s} sec. Success to kill process : PID=#{pid}&quot;</span> )
294
- 76: <span class="ruby-keyword kw">rescue</span>
295
- 77: <span class="ruby-identifier">raise</span>(<span class="ruby-constant">CmdException</span>,<span class="ruby-node">&quot;Run time of command \&quot;#{@cmd_str}\&quot; is over #{@opt[:cmd_timeout].to_s} sec. Fail to kill process : PID=#{pid}&quot;</span> )
296
- 78: <span class="ruby-keyword kw">end</span>
297
- 79: <span class="ruby-keyword kw">end</span>
298
- 80: <span class="ruby-keyword kw">else</span>
299
- 81: <span class="ruby-identifier">status</span> = <span class="ruby-constant">Process</span>.<span class="ruby-identifier">waitpid2</span>(<span class="ruby-identifier">pid</span>)[<span class="ruby-value">1</span>] <span class="ruby-operator">&gt;&gt;</span> <span class="ruby-value">8</span>
300
- 82: <span class="ruby-keyword kw">end</span>
301
- 83: <span class="ruby-identifier">result</span> = <span class="ruby-constant">RBatch</span><span class="ruby-operator">::</span><span class="ruby-constant">CmdResult</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">stdout_file</span>,<span class="ruby-identifier">stderr_file</span>,<span class="ruby-identifier">status</span>,<span class="ruby-ivar">@cmd_str</span>)
302
- 84: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@opt</span>[<span class="ruby-value">:cmd_raise</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">status</span> <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>
303
- 85: <span class="ruby-identifier">raise</span>(<span class="ruby-constant">CmdException</span>,<span class="ruby-value str">&quot;Command exit status is not 0. result: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">to_s</span>)
304
- 86: <span class="ruby-keyword kw">end</span>
305
- 87: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">result</span>
306
- 88: <span class="ruby-keyword kw">end</span></pre>
307
- </div>
308
-
309
- </div>
310
-
311
-
312
-
313
-
314
- </div>
315
-
316
-
317
- </div>
318
-
319
-
320
- </div>
321
-
322
-
323
- <div id="rdoc-debugging-section-dump" class="debugging-section">
324
-
325
- <p>Disabled; run with --debug to generate this.</p>
326
-
327
- </div>
328
-
329
- <div id="validator-badges">
330
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
331
- <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
332
- Rdoc Generator</a> 1.1.6</small>.</p>
333
- </div>
268
+ <span class="ruby-comment"># File lib/rbatch/cmd.rb, line 27</span>
269
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">run</span>()
270
+ <span class="ruby-identifier">stdout_file</span> = <span class="ruby-constant">Tempfile</span><span class="ruby-operator">::</span><span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;rbatch_tmpout&quot;</span>,<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">tmpdir</span>)
271
+ <span class="ruby-identifier">stderr_file</span> = <span class="ruby-constant">Tempfile</span><span class="ruby-operator">::</span><span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;rbatch_tmperr&quot;</span>,<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">tmpdir</span>)
272
+ <span class="ruby-identifier">pid</span> = <span class="ruby-identifier">spawn</span>(<span class="ruby-ivar">@cmd_str</span>,<span class="ruby-value">:out</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-identifier">stdout_file</span>,<span class="ruby-string">&quot;w&quot;</span>],<span class="ruby-value">:err</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-identifier">stderr_file</span>,<span class="ruby-string">&quot;w&quot;</span>])
273
+ <span class="ruby-identifier">status</span> = <span class="ruby-keyword">nil</span>
274
+ <span class="ruby-keyword">if</span> <span class="ruby-ivar">@vars</span>[<span class="ruby-value">:cmd_timeout</span>] <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>
275
+ <span class="ruby-keyword">begin</span>
276
+ <span class="ruby-identifier">timeout</span>(<span class="ruby-ivar">@vars</span>[<span class="ruby-value">:cmd_timeout</span>]) <span class="ruby-keyword">do</span>
277
+ <span class="ruby-identifier">status</span> = <span class="ruby-constant">Process</span>.<span class="ruby-identifier">waitpid2</span>(<span class="ruby-identifier">pid</span>)[<span class="ruby-value">1</span>] <span class="ruby-operator">&gt;&gt;</span> <span class="ruby-value">8</span>
278
+ <span class="ruby-keyword">end</span>
279
+ <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Timeout</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
280
+ <span class="ruby-keyword">begin</span>
281
+ <span class="ruby-constant">Process</span>.<span class="ruby-identifier">kill</span>(<span class="ruby-string">'SIGINT'</span>, <span class="ruby-identifier">pid</span>)
282
+ <span class="ruby-identifier">raise</span>(<span class="ruby-constant">CmdException</span>,<span class="ruby-node">&quot;Run time of command \&quot;#{@cmd_str}\&quot; is over #{@vars[:cmd_timeout].to_s} sec. Success to kill process : PID=#{pid}&quot;</span> )
283
+ <span class="ruby-keyword">rescue</span>
284
+ <span class="ruby-identifier">raise</span>(<span class="ruby-constant">CmdException</span>,<span class="ruby-node">&quot;Run time of command \&quot;#{@cmd_str}\&quot; is over #{@vars[:cmd_timeout].to_s} sec. Fail to kill process : PID=#{pid}&quot;</span> )
285
+ <span class="ruby-keyword">end</span>
286
+ <span class="ruby-keyword">end</span>
287
+ <span class="ruby-keyword">else</span>
288
+ <span class="ruby-identifier">status</span> = <span class="ruby-constant">Process</span>.<span class="ruby-identifier">waitpid2</span>(<span class="ruby-identifier">pid</span>)[<span class="ruby-value">1</span>] <span class="ruby-operator">&gt;&gt;</span> <span class="ruby-value">8</span>
289
+ <span class="ruby-keyword">end</span>
290
+ <span class="ruby-identifier">result</span> = <span class="ruby-constant">RBatch</span><span class="ruby-operator">::</span><span class="ruby-constant">CmdResult</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">stdout_file</span>,<span class="ruby-identifier">stderr_file</span>,<span class="ruby-identifier">status</span>,<span class="ruby-ivar">@cmd_str</span>)
291
+ <span class="ruby-keyword">if</span> <span class="ruby-ivar">@vars</span>[<span class="ruby-value">:cmd_raise</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">status</span> <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>
292
+ <span class="ruby-identifier">raise</span>(<span class="ruby-constant">CmdException</span>,<span class="ruby-string">&quot;Command exit status is not 0. result: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">to_s</span>)
293
+ <span class="ruby-keyword">end</span>
294
+ <span class="ruby-keyword">return</span> <span class="ruby-identifier">result</span>
295
+ <span class="ruby-keyword">end</span></pre>
296
+ </div><!-- run-source -->
297
+
298
+ </div>
299
+
300
+
301
+
302
+
303
+ </div><!-- run-method -->
304
+
305
+
306
+ </div><!-- public-instance-method-details -->
307
+
308
+ </div><!-- 5Buntitled-5D -->
309
+
310
+
311
+ </div><!-- documentation -->
312
+
313
+ <div id="validator-badges">
314
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
315
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
316
+ Rdoc Generator</a> 2</small>.</p>
317
+ </div>
334
318
 
335
319
  </body>
336
320
  </html>