rbatch 1.13.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/CHANGELOG +15 -0
  2. data/README.ja.md +81 -49
  3. data/README.md +88 -63
  4. data/Rakefile +2 -31
  5. data/bin/rbatch-init +57 -32
  6. data/{rdocs → doc}/RBatch/Cmd.html +66 -59
  7. data/{rdocs → doc}/RBatch/CmdException.html +9 -3
  8. data/{rdocs → doc}/RBatch/CmdResult.html +40 -34
  9. data/{rdocs → doc}/RBatch/CommonConfig/Exception.html +9 -3
  10. data/{rdocs → doc}/RBatch/CommonConfig.html +22 -17
  11. data/{rdocs → doc}/RBatch/Config/Exception.html +9 -3
  12. data/{rdocs → doc}/RBatch/Config.html +21 -16
  13. data/{rdocs/RBatchException.html → doc/RBatch/DoubleRunCheckException.html} +33 -30
  14. data/doc/RBatch/DoubleRunChecker.html +277 -0
  15. data/{rdocs → doc}/RBatch/Log.html +134 -138
  16. data/doc/RBatch/RunConf/Exception.html +159 -0
  17. data/doc/RBatch/RunConf.html +557 -0
  18. data/doc/RBatch.html +655 -0
  19. data/doc/created.rid +9 -0
  20. data/{rdocs → doc}/index.html +46 -20
  21. data/{rdocs → doc}/lib/rbatch/cmd_rb.html +4 -2
  22. data/{rdocs → doc}/lib/rbatch/common_config_rb.html +2 -2
  23. data/{rdocs → doc}/lib/rbatch/config_rb.html +2 -2
  24. data/doc/lib/rbatch/double_run_checker_rb.html +56 -0
  25. data/{rdocs → doc}/lib/rbatch/log_rb.html +2 -2
  26. data/doc/lib/rbatch/run_conf_rb.html +56 -0
  27. data/{rdocs → doc}/lib/rbatch/version_rb.html +2 -2
  28. data/{rdocs → doc}/lib/rbatch_rb.html +7 -3
  29. data/lib/rbatch/cmd.rb +20 -23
  30. data/lib/rbatch/common_config.rb +2 -3
  31. data/lib/rbatch/config.rb +1 -2
  32. data/lib/rbatch/double_run_checker.rb +24 -0
  33. data/lib/rbatch/log.rb +37 -59
  34. data/lib/rbatch/run_conf.rb +109 -0
  35. data/lib/rbatch/version.rb +1 -1
  36. data/lib/rbatch.rb +37 -56
  37. data/spec/{cmd_test.spec → cmd_spec.rb} +6 -6
  38. data/spec/common_config_spec.rb +54 -0
  39. data/spec/{config_test.spec → config_spec.rb} +2 -1
  40. data/spec/double_run_checker_spec.rb +10 -0
  41. data/spec/{log_test.spec → log_spec.rb} +22 -22
  42. data/spec/rbatch_spec.rb +24 -0
  43. data/spec/run_conf_spec.rb +85 -0
  44. metadata +66 -65
  45. data/rdocs/RBatch.html +0 -713
  46. data/rdocs/created.rid +0 -7
  47. data/spec/rbatch_test.spec +0 -25
  48. data/test/cases/test_cmd.rb +0 -134
  49. data/test/cases/test_common_config.rb +0 -41
  50. data/test/cases/test_config.rb +0 -41
  51. data/test/cases/test_log.rb +0 -613
  52. data/test/mocks/PrintArgs.exe +0 -0
  53. data/test/mocks/win_cmd.exe +0 -0
  54. /data/{rdocs → doc}/images/brick.png +0 -0
  55. /data/{rdocs → doc}/images/brick_link.png +0 -0
  56. /data/{rdocs → doc}/images/bug.png +0 -0
  57. /data/{rdocs → doc}/images/bullet_black.png +0 -0
  58. /data/{rdocs → doc}/images/bullet_toggle_minus.png +0 -0
  59. /data/{rdocs → doc}/images/bullet_toggle_plus.png +0 -0
  60. /data/{rdocs → doc}/images/date.png +0 -0
  61. /data/{rdocs → doc}/images/find.png +0 -0
  62. /data/{rdocs → doc}/images/loadingAnimation.gif +0 -0
  63. /data/{rdocs → doc}/images/macFFBgHack.png +0 -0
  64. /data/{rdocs → doc}/images/package.png +0 -0
  65. /data/{rdocs → doc}/images/page_green.png +0 -0
  66. /data/{rdocs → doc}/images/page_white_text.png +0 -0
  67. /data/{rdocs → doc}/images/page_white_width.png +0 -0
  68. /data/{rdocs → doc}/images/plugin.png +0 -0
  69. /data/{rdocs → doc}/images/ruby.png +0 -0
  70. /data/{rdocs → doc}/images/tag_green.png +0 -0
  71. /data/{rdocs → doc}/images/wrench.png +0 -0
  72. /data/{rdocs → doc}/images/wrench_orange.png +0 -0
  73. /data/{rdocs → doc}/images/zoom.png +0 -0
  74. /data/{rdocs → doc}/js/darkfish.js +0 -0
  75. /data/{rdocs → doc}/js/jquery.js +0 -0
  76. /data/{rdocs → doc}/js/quicksearch.js +0 -0
  77. /data/{rdocs → doc}/js/thickbox-compressed.js +0 -0
  78. /data/{rdocs → doc}/rdoc.css +0 -0
data/CHANGELOG CHANGED
@@ -3,6 +3,10 @@ CHANGE LOG
3
3
  This document includes functions which is added or changed, does not include bugfix.
4
4
  About bugfix, see commit log of https://github.com/fetaro/rbatch .
5
5
 
6
+ ===================
7
+ version 1
8
+ ===================
9
+
6
10
  1.0
7
11
  -----
8
12
  * initial
@@ -68,3 +72,14 @@ About bugfix, see commit log of https://github.com/fetaro/rbatch .
68
72
  ----
69
73
  * add customize point that can change RBatch home directory by using the environment variables, ${RB_HOME}.
70
74
 
75
+ ===================
76
+ version 2
77
+ ===================
78
+
79
+ 2.0.0 (2013/12/28)
80
+ ----
81
+ * change Run-Conf path from "${RB_HOME}/conf/rbatch.yaml" to "${RB_HOME}/.rbatchrc"
82
+ * add checking existence of Run-Conf keys.
83
+ * add option. "conf_dir", "common_conf_name", and "cmd_timeout" are added.
84
+ * when cmd_timeout occured, RBatch kill child process now.
85
+ * change test code from Test::Unit to RSpec.
data/README.ja.md CHANGED
@@ -1,10 +1,11 @@
1
1
  [[English]](https://github.com/fetaro/rbatch/blob/master/README.md "english") [[Japanese]](https://github.com/fetaro/rbatch/blob/master/README.ja.md "japanese")
2
2
 
3
- RBatch:Ruby-base バッチスクリプトフレームワーク
3
+ RBatch:Ruby-base バッチ スクリプト フレームワーク
4
4
  =============
5
5
 
6
- RBatchについて
6
+ RBatchについて (version 2)
7
7
  --------------
8
+
8
9
  これはRubyで書かれたシンプルなバッチスクリプトのフレームワークです。
9
10
  バッチスクリプト(バックアップやプロセスリロード等)を書く際に便利な機能をフレームワークとして提供しています。
10
11
 
@@ -16,11 +17,28 @@ RBatchについて
16
17
  * 外部コマンド実行
17
18
  * 二重起動チェック
18
19
 
19
- 注意:このフレームワークはRuby 1.9.x以降で動作します。また、Rubyプラットフォームは"linux","mswin","mingw","cygwin"で動作します。
20
+ 注意:このフレームワークはRuby 1.9で動作します。
20
21
 
21
22
  このソフトウェアは、MITライセンスのもとで公開しています。LICENSE.txtを見てください。
22
23
 
23
- ### はじめに
24
+ クイックスタート
25
+ --------------
26
+
27
+ $ sudo gem install rbatch
28
+ $ rbatch-init # => ディレクトリとサンプルスクリプトが作られます
29
+ $ ruby bin/hello_world.rb
30
+ $ cat log/YYYYMMDD_HHMMSS_hello_world.log
31
+
32
+ マニュアル
33
+ --------------
34
+
35
+ ### RBatchホームディレクトリ
36
+
37
+ 環境変数${RB_HOME}を定義する事で、その場所をRBatchのホームディレクトリに固定することができます。
38
+
39
+ 環境変数${RB_HOME}を定義していない場合は、「実行するスクリプトが配置されているディレクトリの親ディレクトリ」が${RB_HOME}になります。言い換えると${RB_HOME}のデフォルト値は"(実行するスクリプトのパス)/../"です。
40
+
41
+ ### ディレクトリ構成と命名規則
24
42
 
25
43
  RBatchでは、実行スクリプト、設定ファイルおよびログファイルについて、
26
44
  配置場所および命名規則が規約で決まっています。
@@ -30,7 +48,10 @@ RBatchでは、実行スクリプト、設定ファイルおよびログファ
30
48
  例を示すと以下の通りです。
31
49
 
32
50
  ```
33
- ${RB_HOME}
51
+ ${RB_HOME} ←RBatchホームディレクトリ
52
+ |
53
+ |-.rbatchrc ←Run-Conf
54
+ |
34
55
  |-bin ←実行スクリプト配置場所
35
56
  | |- A.rb
36
57
  | |- B.rb
@@ -38,21 +59,12 @@ ${RB_HOME}
38
59
  |-conf ←設定ファイル配置場所
39
60
  | |- A.yaml
40
61
  | |- B.yaml
41
- | |- rbatch.yaml ←RBatch全体設定ファイル
42
62
  |
43
63
  |-log ←ログ出力場所
44
64
  |- YYYYMMDD_HHMMSS_A.log
45
65
  |- YYYYMMDD_HHMMSS_B.log
46
66
  ```
47
67
 
48
- ### RBatchホームディレクトリ
49
-
50
- 環境変数${RB_HOME}を定義する事で、その場所をRBatchのホームディレクトリに固定することができます。
51
-
52
- 環境変数${RB_HOME}を定義していない場合は、「実行するスクリプトが配置されているディレクトリの親ディレクトリ」が${RB_HOME}になります。言い換えると${RB_HOME}のデフォルト値は"(実行するスクリプトのパス)/../"です。
53
-
54
- となります。
55
-
56
68
  ### 自動ログ出力
57
69
 
58
70
  Logging blockを使うことで、自動的にログファイルに出力することができます。
@@ -92,7 +104,7 @@ RBatch::Log.new(){ |log| # Logging block
92
104
  ### 自動設定ファイル読み込み
93
105
 
94
106
  RBatchは簡単にデフォルトの位置の設定ファイルを読み込めます。
95
- デフォルトの位置は"${RB_HOME}/conf/${PROG_NAME}.yaml"です。
107
+ デフォルトの位置は"${RB_HOME}/conf/(プログラムbase名).yaml"です。
96
108
 
97
109
  サンプル
98
110
 
@@ -118,7 +130,10 @@ p RBatch::config["not_exist"]
118
130
  => Raise Exception
119
131
  ```
120
132
 
133
+ すべてのスクリプトから共通で読み込む設定ファイルを作りたい場合は、${RB_HOME}/conf/common.yamlというファイルを作ることで可能です。
134
+
121
135
  ### 外部コマンド実行
136
+
122
137
  RBatchは外部コマンド(たとえば"ls -l")を実行するラッパー関数を提供します。
123
138
 
124
139
  この関数は、実行結果をオブジェクトで返し、そのオブジェクトは標準出力、標準エラー出力、およびexitステータスを含みます。
@@ -137,44 +152,30 @@ p r.status
137
152
 
138
153
  ### 二重起動チェック
139
154
 
140
- RBatchの共通設定ファイルに"forbid_double_run: true"の設定を書けば、RBatchを利用したスクリプトの二重起動チェックができます。
155
+ RBatchの共通設定ファイルに"forbid_double_run: true"の設定を書けば、RBatchを利用したプログラムの二重起動チェックができます。
141
156
 
142
- クイックスタート
143
- --------------
144
-
145
- $ sudo gem install rbatch
146
- $ rbatch-init # => ディレクトリとサンプルスクリプトが作られます
147
- $ ruby bin/hello_world.rb
148
- $ cat log/YYYYMMDD_HHMMSS_hello_world.log
149
-
150
-
151
- オプション
157
+ カスタマイズ
152
158
  --------------
153
159
 
154
160
  RBatchではオプションの指定の仕方は以下の二つがあります。
155
161
 
156
- 1. 全体設定ファイル(${RB_HOME}/conf/rbatch.yaml)に書く
157
- 2. コンストラクタの引数に指定する
158
-
159
- 全体設定ファイルにオプションを書くと、全てのスクリプトに効果がありますが、コンストラクタの引数に指定した場合はそのインスタンスのみ効果があります。
160
-
161
- 全体設定ファイルとコンストラクタの引数に同じオプションが指定された場合、コンストラクタの引数が優先されます。
162
+ (1) Run-Conf(${RB_HOME}/.rbatchrc)に書く
163
+ (2) スクリプト内でオプションオブジェクトをコンストラクタの引数に渡す
162
164
 
163
- 全体設定ファイルのキーの名前と、コンストラクタオプションのキーの名前は、対応関係があります。全体設定ファイルのキー名は「(クラス名)_(キー名)」となります。
164
- たとえばRBatch::Logクラスのコンストラクタオプションで「:name」というキーは、全体設定ファイルでは「log_name」というキーになります。
165
+ 同じオプションを(1)(2)の両方で指定すると、(2)が優先されます。
165
166
 
166
- ### 全体設定ファイルによるオプション指定
167
+ ### Run-Conf(.rbatchrc)によるカスタマイズ
167
168
 
168
169
  以下の場所にRBatch全体設定ファイルを配置すると、全てのスクリプトにてオプションが適用されます。
169
170
 
170
171
 
171
- ${RB_HOME}/conf/rbatch.yaml
172
+ ${RB_HOME}/.rbatchrc
172
173
 
173
174
 
174
175
  設定ファイルのサンプルは以下の通り
175
176
 
176
177
  ```
177
- # RBatch 全体設定
178
+ # RBatch Run-Conf (.rbatchrc)
178
179
  #
179
180
  # 設定ファイルの形式はYAML形式です
180
181
  #
@@ -183,6 +184,21 @@ RBatchではオプションの指定の仕方は以下の二つがあります
183
184
  # 全体
184
185
  # -------------------
185
186
 
187
+ # Conf ディレクトリ
188
+ #
189
+ # デフォルトは "<home>/conf"
190
+ #
191
+ # <home> は ${RB_HOME} に置き換わります
192
+ #
193
+ #conf_dir: <home>/config
194
+ #conf_dir: /etc/rbatch/
195
+
196
+ # スクリプト間共通設定ファイル名
197
+ #
198
+ # デフォルトは"common.yaml"
199
+ #
200
+ #common_conf_name: share.yaml
201
+
186
202
  # スクリプトの二重起動を可能にするかどうか
187
203
  #
188
204
  # デフォルト値はfalse。
@@ -203,28 +219,37 @@ RBatchではオプションの指定の仕方は以下の二つがあります
203
219
  #cmd_raise: true
204
220
  #cmd_raise: false
205
221
 
222
+ # 外部コマンドのタイムアウト
223
+ #
224
+ # デフォルト値は0[sec]。
225
+ #
226
+ #cmd_timeout: 5
227
+
206
228
  # -------------------
207
229
  # ログ関連
208
230
  # -------------------
209
231
 
232
+ # ログディレクトリ
233
+ #
234
+ # デフォルトは "<home>/log"
235
+ #
236
+ # <home> は ${RB_HOME} に置き換わります
237
+ #
238
+ #log_dir: <home>/rb_log
239
+ #log_dir: /var/log/rbatch/
240
+
210
241
  # ログファイル名
211
242
  #
212
243
  # デフォルト値は"<date>_<time>_<prog>.log"。
213
244
  # 以下の文字列は予約語
214
- # <data> --> YYYYMMDDの日付形式に置換されます
215
- # <time> --> hhmmssの時刻形式に置換されます
216
- # <prog> --> 拡張子を除いたファイル名に置換されます
217
- # <host> --> ホスト名に置換されます
245
+ # <data> YYYYMMDDの日付形式に置換されます
246
+ # <time> hhmmssの時刻形式に置換されます
247
+ # <prog> は拡張子を除いたファイル名に置換されます
248
+ # <host> はホスト名に置換されます
218
249
  #
219
250
  #log_name : "<date>_<time>_<prog>.log"
220
251
  #log_name : "<date>_<prog>.log"
221
252
 
222
- # ログ出力ディレクトリ
223
- #
224
- # デフォルト値は"${RB_HOME}/log"。
225
- #
226
- #log_dir : "/tmp/log"
227
-
228
253
  # ログを追記するかどうか
229
254
  #
230
255
  # デフォルト値はture。
@@ -291,7 +316,6 @@ RBatchではオプションの指定の仕方は以下の二つがあります
291
316
 
292
317
  #### RBatch::Logクラス
293
318
 
294
- RBatch::Log.new(opt = nil)
295
319
  opt = {
296
320
  :name => "<date>_<time>_<prog>.log",
297
321
  :dir => "/var/log/",
@@ -307,10 +331,18 @@ RBatchではオプションの指定の仕方は以下の二つがあります
307
331
  :mail_server_port => 25
308
332
  }
309
333
 
334
+ RBatch::Log.new(opt)
335
+
310
336
  #### RBatch::Cmdクラス
311
337
 
312
- RBatch::Log.new(cmd_str, opt = nil)
313
338
  opt = {
314
339
  :raise => false,
315
340
  :timeout => 0
316
341
  }
342
+
343
+ RBatch::Log.new(cmd_str, opt)
344
+
345
+ version 1 から 2 へのマイグレーション
346
+ --------------
347
+
348
+ "${RB_HOME}/conf/rbatch.yaml" を "${RB_HOME}/.rbatchrc" に移動してください。
data/README.md CHANGED
@@ -1,11 +1,12 @@
1
1
  [[English]](https://github.com/fetaro/rbatch/blob/master/README.md "english") [[Japanese]](https://github.com/fetaro/rbatch/blob/master/README.ja.md "japanese")
2
2
 
3
- RBatch:Ruby-base Simple Batch Framework
3
+ RBatch:Ruby-base Batch-Script Framework
4
4
  =============
5
5
 
6
- About RBatch
6
+ About RBatch (version 2)
7
7
  --------------
8
- This is Ruby-base Batch Script Framework. RBatch has many fanctions to help with your making a batch script such as "data backup script" or "proccess starting script".
8
+
9
+ RBatch is Ruby-base Batch Script Framework. RBatch has many fanctions to help with your making a batch script such as "data backup" or "proccess starting".
9
10
 
10
11
  There are following functions.
11
12
 
@@ -16,19 +17,39 @@ There are following functions.
16
17
  * Double Run Check
17
18
 
18
19
 
19
- Note: RBatch works on Ruby 1.9.x or later, and on Ruby platform of "linux","mswin","mingw","cygwin".
20
+ Note: RBatch works on Ruby 1.9.
20
21
 
21
22
  Note: This software is released under the MIT License, see LICENSE.txt.
22
23
 
23
- ### First
24
+ Quick Start
25
+ --------------
26
+
27
+ $ sudo gem install rbatch
28
+ $ rbatch-init # => make directories and sample scripts
29
+ $ ruby bin/hello_world.rb
30
+ $ cat log/YYYYMMDD_HHMMSS_hello_world.log
31
+
32
+ Manual
33
+ --------------
34
+
35
+ ### RBatch home directory
36
+
37
+ When you set ${RB_HOME} environment variable, RBatch home directory is fix at ${RB_HOME}.
38
+
39
+ When you do NOT set ${RB_HOME}, ${RB_HOME} is the parent directory of the directory which script is located at. In other words, default of ${RB_HOME} is "(script path)/../" .
40
+
41
+ ### Directory Structure and Naming Convention
24
42
 
25
43
  RBach has convention of file naming and directorory structure.
26
44
 
27
- If you make "${RB_HOME}/bin/hoge.rb", you should name config file to "${RB_HOME}/conf/hoge.yaml". And the name of log file is decided on "${RB_HOME}/log/YYYYMMDD_HHMMSS_hoge.rb"
45
+ If you make a script on "${RB_HOME}/bin/hoge.rb", script's config file is "${RB_HOME}/conf/hoge.yaml" , and log file is "${RB_HOME}/log/YYYYMMDD_HHMMSS_hoge.rb".
28
46
 
29
47
  For example
30
48
  ```
31
49
  ${RB_HOME}/ <--- RBatch home
50
+ |
51
+ |-.rbatchrc <--- RBatch Run Conf
52
+ |
32
53
  |-bin <--- Scripts
33
54
  | |- A.rb
34
55
  | |- B.rb
@@ -36,20 +57,12 @@ ${RB_HOME}/ <--- RBatch home
36
57
  |-conf <--- Configuration files
37
58
  | |- A.yaml
38
59
  | |- B.yaml
39
- | |- rbatch.yaml <--- RBatch global config
40
60
  |
41
61
  |-log <--- Log files
42
62
  |- YYYYMMDD_HHMMSS_A.log
43
63
  |- YYYYMMDD_HHMMSS_B.log
44
64
  ```
45
65
 
46
- ### RBatch home directory
47
-
48
- When you set ${RB_HOME} environment variable, RBatch home directory is fix.
49
-
50
- When you do NOT set ${RB_HOME}, ${RB_HOME} is the parent directory of the directory which script is located at. In other words, default of ${RB_HOME} is "(script path)/../" .
51
-
52
-
53
66
  ### Auto Logging
54
67
 
55
68
  Use "Auto Logging block", RBatch automatically writes to logfile.
@@ -86,13 +99,10 @@ logfile : ${RB_HOME}/log/20121020_005953_sample1.log
86
99
 
87
100
  By using "log_send_mail" option, when an error occurs in script, RBatch sends an error-mail automatically.
88
101
 
89
-
90
102
  ### Auto Config Reading
91
103
 
92
104
  By using RBatch, your script read a configuration file easily.
93
- First you make configuration file which is named "(script base name).yaml" ,
94
- Then, put it to ${RB_HOME}/conf/ .
95
- So your script read it automatically.
105
+ If you make configuration file which is located ${RB_HOME}/conf/"(program base name).yaml", this file is read automatically.
96
106
 
97
107
  sample
98
108
 
@@ -141,54 +151,53 @@ p r.status
141
151
 
142
152
  ### Double Run Check
143
153
 
144
- Using "forbid_double_run" option, you forbit double run of the RBatch script.
145
-
154
+ Using "forbid_double_run: true" option, two same name scripts cannot run at the same time.
146
155
 
147
- Quick Start
156
+ Customize
148
157
  --------------
158
+ If you want to customize RBatch, you have two methods.
149
159
 
150
- $ sudo gem install rbatch
151
- $ rbatch-init # => make directories and sample scripts
152
- $ ruby bin/hello_world.rb
153
- $ cat log/YYYYMMDD_HHMMSS_hello_world.log
160
+ (1) Write Run-Conf (${RB_HOME}/.rbatchrc).
161
+ (2) Pass an option object to constructor in your script.
154
162
 
155
- Option
156
- --------------
157
-
158
- The optional designated way has following two in RBatch.
159
-
160
- 1. Global configuration file (conf/rbatch.yaml)
161
- 2. Argument of the constructer
162
-
163
- If you write an option to the global configuration file, all scripts are effective. On the other hand, if you set it in the argument of the constructer, there is an effect in only the instance.
163
+ When an option is set in both (1) and (2), (2) is prior to (1).
164
164
 
165
- When the same option is set, the argument of the constructer is given priority to over the global configuration.
165
+ #### Customize by writing Run-Conf (.rbatchrc)
166
166
 
167
- The name of the key to global configuration file and the name of the key to constructer option have correspondency. The key name in global configuration file is "(class name)_(key name)".
167
+ If you make a follow config file, configurations effect to all scripts.
168
168
 
169
- #### Set by Grobal Configuration File
170
-
171
- If you make follow config file, option value effect to all scripts.
172
-
173
- ```
174
- ${RB_HOME}/conf/rbatch.yaml
175
- ```
169
+ ${RB_HOME}/.rbatchrc
176
170
 
177
- Config Sample
171
+ Run-Conf Sample
178
172
  ```
179
- # RBatch Common Config
173
+ # RBatch Run-Conf (.rbatchrc)
180
174
  #
181
- # This file format is YAML.
175
+ # This format is YAML.
182
176
  #
183
177
 
184
178
  # -------------------
185
179
  # Global setting
186
180
  # -------------------
187
181
 
182
+ # Conf Directory
183
+ #
184
+ # Default is "<home>/conf"
185
+ #
186
+ # <home> is replaced to ${RB_HOME}
187
+ #
188
+ #conf_dir: <home>/config
189
+ #conf_dir: /etc/rbatch/
190
+
191
+ # Common config file name
192
+ #
193
+ # Default is "common.yaml"
194
+ #
195
+ #common_conf_name: share.yaml
196
+
188
197
  # Forbit Script Double Run
189
198
  #
190
199
  # Default is false.
191
- # If this option is true, two same script cannot start at the same time.
200
+ # If this option is true, two same name scripts cannot run at the same time.
192
201
  #
193
202
  #forbid_double_run: true
194
203
  #forbid_double_run: false
@@ -205,29 +214,37 @@ Config Sample
205
214
  #cmd_raise : true
206
215
  #cmd_raise : false
207
216
 
217
+ # Command Timeout
218
+ #
219
+ # Default is 0 [sec].
220
+ #
221
+ #cmd_timeout: 5
208
222
 
209
223
  # -------------------
210
224
  # Log setting
211
225
  # -------------------
212
226
 
227
+ # Log Directory
228
+ #
229
+ # Default is "<home>/log"
230
+ #
231
+ # <home> is replaced to ${RB_HOME}
232
+ #
233
+ #log_dir: <home>/rb_log
234
+ #log_dir: /var/log/rbatch/
235
+
213
236
  # Log File Name
214
237
  #
215
238
  # Default is "<date>_<time>_<prog>.log".
216
239
  # Reservation words are follows.
217
- # <data> --> Replace to YYYYMMDD date string
218
- # <time> --> Replace to HHMMSS time string
219
- # <prog> --> Replace to Program file base name (except extention).
220
- # <host> --> Replace to Hostname.
240
+ # <data> is replaced to YYYYMMDD date string
241
+ # <time> is replaced to HHMMSS time string
242
+ # <prog> is replaced to Program file base name (except extention).
243
+ # <host> is replaced to Hostname.
221
244
  #
222
245
  #log_name : "<date>_<time>_<prog>.log"
223
246
  #log_name : "<date>_<prog>.log"
224
247
 
225
- # Log Output Directory
226
- #
227
- # Default is "${RB_HOME}/log".
228
- #
229
- #log_dir : "/tmp/log"
230
-
231
248
  # Append log or not
232
249
  #
233
250
  # Default is ture.
@@ -246,7 +263,7 @@ Config Sample
246
263
  #log_level : "error"
247
264
  #log_level : "fatal"
248
265
 
249
- # Print log-string both file and STDOUT
266
+ # Print log string both file and STDOUT
250
267
  #
251
268
  # Default is false.
252
269
  #
@@ -276,7 +293,7 @@ Config Sample
276
293
  #
277
294
  #log_send_mail : true
278
295
 
279
- # Send mail parameters
296
+ # Mail parameters
280
297
  #
281
298
  #log_mail_to : "xxx@sample.com"
282
299
  #log_mail_from : "xxx@sample.com"
@@ -285,16 +302,15 @@ Config Sample
285
302
 
286
303
  ```
287
304
 
288
- ### Set by argument of the constracter
305
+ ### Customize by passing option object to constructor
289
306
 
290
307
  If you want to set options in a script, you hand an argument of options to a constructor.
291
308
 
292
309
  #### class RBatch::Log
293
310
 
294
- RBatch::Log.new(opt = nil)
295
311
  opt = {
296
312
  :name => "<date>_<time>_<prog>.log",
297
- :dir => "/var/log/",
313
+ :dir => "/var/log",
298
314
  :append => true,
299
315
  :level => "info",
300
316
  :stdout => false,
@@ -307,10 +323,19 @@ If you want to set options in a script, you hand an argument of options to a con
307
323
  :mail_server_port => 25
308
324
  }
309
325
 
326
+ RBatch::Log.new(opt)
327
+
310
328
  #### class RBatch::Cmd
311
329
 
312
- RBatch::Log.new(cmd_str, opt = nil)
313
330
  opt = {
314
331
  :raise => false,
315
332
  :timeout => 0
316
333
  }
334
+
335
+ RBatch::Log.new(cmd_str, opt)
336
+
337
+
338
+ Migration from version 1 to version 2
339
+ --------------
340
+
341
+ Move "${RB_HOME}/conf/rbatch.yaml" to "${RB_HOME}/.rbatchrc" .
data/Rakefile CHANGED
@@ -1,32 +1,3 @@
1
1
  require "bundler/gem_tasks"
2
-
3
- desc "Test lib/ by using test/cases/test_*.rb"
4
- task :test do
5
- result = 0
6
- cases = FileList["test/cases/*.rb"]
7
- cases.each do | c |
8
- cmd_str="ruby -I lib #{c}"
9
- stdout_file = Tempfile::new("rbatch_tmpout",".")
10
- stderr_file = Tempfile::new("rbatch_tmperr",".")
11
- pid = spawn(cmd_str,:out => [stdout_file,"w"],:err => [stderr_file,"w"])
12
- status = Process.waitpid2(pid)[1] >> 8
13
- puts ""
14
- puts "> " + cmd_str
15
- puts "------------------------------"
16
- puts File.read(stdout_file)
17
- puts "------------------------------"
18
- if status != 0
19
- result = 1
20
- end
21
- end
22
- if result == 0
23
- puts "\nTest Success \n"
24
- else
25
- puts "\nTest Failed \n"
26
- exit 1
27
- end
28
- end
29
-
30
-
31
- desc "Test, Make RDoc, Release"
32
- task :all => [:test, :rdoc, :release]
2
+ require "rspec/core/rake_task"
3
+ RSpec::Core::RakeTask.new(:spec)