rbatch 2.3.1 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -2,99 +2,106 @@ CHANGE LOG
2
2
 
3
3
  This document includes functions which is added or changed.
4
4
  This document does NOT include bugfix.
5
+
5
6
  If you want to know about bug fix, please see commit logs of https://github.com/fetaro/rbatch .
6
7
 
7
8
  ===================
8
- version 1
9
+ version 2
9
10
  ===================
10
11
 
11
- 1.0
12
- -----
13
- * initial
12
+ 2.4.0 (2015/06/08)
13
+ ----
14
+ * [add] new option : "log_output_exit_status"
15
+ * [change] log massage has been changed when you use "exit" in RBatch Log block.
14
16
 
15
- 1.1 (2012/11/9)
16
- -----
17
- * [add] common config file
18
- * [change] new option : "log"
17
+ 2.3.0 (2014/10/28)
18
+ ----
19
+ * [add] new option : "log_bufferd"
20
+ * [change] before log output is bufferd, now not.
21
+ * [bugfix] fix that it raises error if .rbatchrc is empty.
19
22
 
20
- 1.2 (2012/11/13)
21
- -----
22
- * [change] log level option format
23
- * [add] new option : "log_append"
23
+ 2.2.0 (2014/4/15)
24
+ ----
25
+ * [add] now "log_mail_to" option accepts multiple recipients, before it accepts only one recipient.
24
26
 
25
- 1.3 (2012/12/30)
26
- -----
27
- * [add] add customize point to RBatch::Log's constructor
28
- * [add] new option : "double_run_check"
27
+ 2.1.0 (2013/1/10)
28
+ ----
29
+ * [add] add an error handling when user mistake key class as Symbol for String in config file.
30
+ * [add] add function of auto library file reading
31
+ * [add] new option : "mix_rbatch_msg_to_log"
32
+ * [change] config reading timing. before ondemand, now initial.
29
33
 
30
- 1.4 (2013/1/5)
34
+ 2.0.0 (2013/12/28)
31
35
  ----
32
- * [add] new options : "log_stdout", "cmd_raise", "log_delete_old_log"
33
- * [add] add sample code
36
+ * [change] Change Run-Conf path from "${RB_HOME}/conf/rbatch.yaml" to "${RB_HOME}/.rbatchrc"
37
+ * [add] add function of checking existence of Run-Conf's keys.
38
+ * [add] new options : "conf_dir", "common_conf_name", "cmd_timeout".
39
+ * [add] when cmd_timeout occured, RBatch kill child process now.
40
+ * [change] Change test code from Test::Unit to RSpec.
34
41
 
35
- 1.5 (2013/1/11)
42
+
43
+ ===================
44
+ version 1
45
+ ===================
46
+
47
+ 1.13 (2013/12/19)
36
48
  ----
37
- * [change] change default config dir from "../config" to "../conf"
49
+ * [add] add customize point that can change RBatch home directory by using the environment variables, ${RB_HOME}.
38
50
 
39
- 1.6 (2013/1/14)
51
+ 1.12 (2013/11/19)
40
52
  ----
41
- * [add] add function of cheking config keys
53
+ * [add] add Common Config Function
42
54
 
43
- 1.7 (2013/01/30)
55
+ 1.11 (2013/02/24)
44
56
  ----
45
- * [change] log format
46
- * [delete] change log format option
57
+ * [add] support for MAC-OSX environment (change handling of the environment variable about hostname and temporary directory)
47
58
 
48
- 1.8 (2013/02/10)
59
+ 1.10 (2013/02/12)
49
60
  ----
50
- * [add] new option : "log_send_mail", "cmd_timeout"
61
+ * [add] add rbatch-init command
51
62
 
52
63
  1.9 (2013/02/11)
53
64
  ----
54
65
  * [add] add "<host>" keyword to log_name option
55
66
  * [change] Environmental variables ($TMPDIR and $HOSTNAME) are checked strictly
56
67
 
57
- 1.10 (2013/02/12)
68
+ 1.8 (2013/02/10)
58
69
  ----
59
- * [add] add rbatch-init command
70
+ * [add] new option : "log_send_mail", "cmd_timeout"
60
71
 
61
- 1.11 (2013/02/24)
72
+ 1.7 (2013/01/30)
62
73
  ----
63
- * [add] support for MAC-OSX environment (change handling of the environment variable about hostname and temporary directory)
74
+ * [change] log format
75
+ * [delete] change log format option
64
76
 
65
- 1.12 (2013/11/19)
77
+ 1.6 (2013/1/14)
66
78
  ----
67
- * [add] add Common Config Function
79
+ * [add] add function of cheking config keys
68
80
 
69
- 1.13 (2013/12/19)
81
+ 1.5 (2013/1/11)
70
82
  ----
71
- * [add] add customize point that can change RBatch home directory by using the environment variables, ${RB_HOME}.
72
-
73
- ===================
74
- version 2
75
- ===================
83
+ * [change] change default config dir from "../config" to "../conf"
76
84
 
77
- 2.0.0 (2013/12/28)
85
+ 1.4 (2013/1/5)
78
86
  ----
79
- * [change] Change Run-Conf path from "${RB_HOME}/conf/rbatch.yaml" to "${RB_HOME}/.rbatchrc"
80
- * [add] add function of checking existence of Run-Conf's keys.
81
- * [add] new options : "conf_dir", "common_conf_name", "cmd_timeout".
82
- * [add] when cmd_timeout occured, RBatch kill child process now.
83
- * [change] Change test code from Test::Unit to RSpec.
87
+ * [add] new options : "log_stdout", "cmd_raise", "log_delete_old_log"
88
+ * [add] add sample code
84
89
 
85
- 2.1.0 (2013/1/10)
86
- ----
87
- * [add] add an error handling when user mistake key class as Symbol for String in config file.
88
- * [add] add function of auto library file reading
89
- * [add] new option : "mix_rbatch_msg_to_log"
90
- * [change] config reading timing. before ondemand, now initial.
90
+ 1.3 (2012/12/30)
91
+ -----
92
+ * [add] add customize point to RBatch::Log's constructor
93
+ * [add] new option : "double_run_check"
91
94
 
92
- 2.2.0 (2014/4/15)
93
- ----
94
- * [add] now "log_mail_to" option accepts multiple recipients, before it accepts only one recipient.
95
+ 1.2 (2012/11/13)
96
+ -----
97
+ * [change] log level option format
98
+ * [add] new option : "log_append"
95
99
 
96
- 2.3.0 (2014/10/28)
97
- ----
98
- * [add] new option : "log_bufferd"
99
- * [change] before log output is bufferd, now not.
100
- * [bugfix] fix that it raises error if .rbatchrc is empty.
100
+ 1.1 (2012/11/9)
101
+ -----
102
+ * [add] common config file
103
+ * [change] new option : "log"
104
+
105
+ 1.0
106
+ -----
107
+ * initial
data/README.ja.md CHANGED
@@ -1,5 +1,7 @@
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") | [Document (YardDoc)](http://fetaro.github.io/rbatch/index.html)
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/rbatch.svg)](http://badge.fury.io/rb/rbatch)
4
+ [![Build Status](https://travis-ci.org/fetaro/rbatch.svg?branch=master)](https://travis-ci.org/fetaro/rbatch)
3
5
  RBatch: バッチスクリプト フレームワーク
4
6
  =============
5
7
 
@@ -412,6 +414,15 @@ Run-Conf(`${RB_HOME}/.rbatchrc`)のサンプルは以下の通り
412
414
  #log_bufferd : true
413
415
  #log_bufferd : false
414
416
 
417
+ # exitステータスをログに出すかどうか
418
+ #
419
+ # デフォルトはtrue。
420
+ # ログブロック内で "exist" メソッドを使った時に、
421
+ # exitステータスをログファイルに出力する。
422
+ #
423
+ #log_output_exit_status : true
424
+ #log_output_exit_status : false
425
+
415
426
  # メール送信するかどうか
416
427
  #
417
428
  # デフォルト値は false。
@@ -470,6 +481,7 @@ opt = {
470
481
  :delete_old_log => false,
471
482
  :delete_old_log_date => 7,
472
483
  :bufferd => false,
484
+ :log_output_exit_status => true,
473
485
  :send_mail => false,
474
486
  :mail_to => nil,
475
487
  :mail_from => "rbatch.localhost",
data/README.md CHANGED
@@ -1,14 +1,23 @@
1
- [English](https://github.com/fetaro/rbatch/blob/master/README.md "english") | [Japanese ](https://github.com/fetaro/rbatch/blob/master/README.ja.md "japanese") | [Document (YardDoc)](http://fetaro.github.io/rbatch/index.html)
2
1
 
2
+
3
+ [English](https://github.com/fetaro/rbatch/blob/master/README.md
4
+ "english") | [Japanese
5
+ ](https://github.com/fetaro/rbatch/blob/master/README.ja.md
6
+ "japanese") | [Document
7
+ (YardDoc)](http://fetaro.github.io/rbatch/index.html)
8
+
9
+ [![Gem Version](https://badge.fury.io/rb/rbatch.svg)](http://badge.fury.io/rb/rbatch)
10
+ [![Build Status](https://travis-ci.org/fetaro/rbatch.svg?branch=master)](https://travis-ci.org/fetaro/rbatch)
3
11
  RBatch: Batch Script Framework
4
12
  =============
5
13
 
6
14
  About RBatch
7
15
  --------------
8
16
 
9
- RBatch is a ruby-based framework for batch scripts. RBatch help to make a batch script such as "data backup" or "proccess start ".
17
+ RBatch is a ruby-based framework for batch scripts. RBatch help to
18
+ make batch scripts such as "data backup" or "proccess controll ".
10
19
 
11
- There are following functions.
20
+ There are following functions:
12
21
 
13
22
  * Auto Logging
14
23
  * Auto Library Loading
@@ -17,7 +26,7 @@ There are following functions.
17
26
  * External Command Wrapper
18
27
  * Double Run Check
19
28
 
20
- Note: RBatch works on Ruby 1.9.
29
+ Note: RBatch works on Ruby 1.9 above.
21
30
 
22
31
  Note: This software is released under the MIT License, see LICENSE.txt.
23
32
 
@@ -34,26 +43,26 @@ Overview
34
43
 
35
44
  ### RBatch home directory
36
45
 
37
- When you set `${RB_HOME}` environment variable, RBatch home directory is fixed at `${RB_HOME}`.
38
-
39
- When you do NOT set `${RB_HOME}`, `${RB_HOME}` is the parent directory of the directory where the script is located. In other words, default of `${RB_HOME}` is `(script path)/../` .
46
+ If you set the `${RB_HOME}` as environment variable, RBatch home
47
+ directory is fixed at `${RB_HOME}`.
48
+ Otherwise, `${RB_HOME}` is the parent directory of the directory where
49
+ the script is located. In other words, default of `${RB_HOME}` is
50
+ `(script path)/../` .
40
51
 
41
52
  ### Directory Structure and File Naming Convention
42
53
 
43
- Follow the rule of "convention over configuration",
44
- RBach has convention of file naming and directory structure in advance.
45
- If you follow these rules, you will gain plenty development environment without any configurations.
46
-
47
- The rules are
54
+ RBatch is made based on the rule of "convention over configuration".
55
+ So there are conventions of file naming and directory structure.
56
+ If you follow these rules, you will gain plenty development
57
+ environment without any configurations.
48
58
 
49
- * If you make `${RB_HOME}/bin/hoge.rb` as the script...
50
- * individual config file should be `${RB_HOME}/conf/hoge.yaml`
51
- * common(shared) config file should be `${RB_HOME}/conf/common.yaml`
52
- * libraries should be `${RB_HOME}/lib/*.rb`
59
+ The rules are below:
53
60
 
54
- then
55
-
56
- * log files are output at `${RB_HOME}/log/YYYYMMDD_HHMMSS_hoge.log`
61
+ * Script should be `${RB_HOME}/bin/hoge.rb`
62
+ * Config file should be `${RB_HOME}/conf/hoge.yaml`
63
+ * Common config file should be `${RB_HOME}/conf/common.yaml`
64
+ * Libraries should be `${RB_HOME}/lib/*.rb`
65
+ * Log files should be `${RB_HOME}/log/YYYYMMDD_HHMMSS_hoge.log`
57
66
 
58
67
  For example
59
68
 
@@ -80,13 +89,16 @@ For example
80
89
 
81
90
  ### Auto Logging
82
91
 
83
- Use the auto logging block ,`RBatch::Log`, RBatch automatically output logfiles.
84
- The default location of log files are `${RB_HOME}/log/YYYYMMDD_HHMMSS_(script base).log`.
85
- If an exception is raised in auto logging block, RBatch rescue and write the stack trace to the logfile.
92
+ By using the auto logging block ,`RBatch::Log`, RBatch automatically
93
+ output logfiles.
94
+ The default location of log files are
95
+ `${RB_HOME}/log/YYYYMMDD_HHMMSS_(script base).log`.
96
+ If exceptions are raised in auto logging block, RBatch will rescue it
97
+ and output its stack trace to the logfile.
86
98
 
87
- sample
99
+ Sample
88
100
 
89
- make script `${RB_HOME}/bin/sample1.rb`
101
+ Make script `${RB_HOME}/bin/sample1.rb`
90
102
 
91
103
  ```ruby
92
104
  require 'rbatch'
@@ -105,25 +117,30 @@ Run script. Log file is `${RB_HOME}/log/20121020_005953_sample1.log`
105
117
  [2012-10-20 00:59:53 +900] [FATAL] Caught exception; existing 1
106
118
  [2012-10-20 00:59:53 +900] [FATAL] exception (RuntimeError)
107
119
  [backtrace] test.rb:6:in `block in <main>'
108
- [backtrace] /usr/local/lib/ruby192/lib/ruby/gems/1.9.1/gems/rbatch-1.0.0/lib/rbatch/auto_logger.rb:37:in `initialize'
120
+ [backtrace]
121
+ /usr/local/lib/ruby192/lib/ruby/gems/1.9.1/gems/rbatch-1.0.0/lib/rbatch/auto_logger.rb:37:in
122
+ `initialize'
109
123
  [backtrace] test.rb:3:in `new'
110
124
  [backtrace] test.rb:3:in `<main>'
111
125
 
112
126
  ### Auto Library Loading
113
127
 
114
- If you make the libraries at `${RB_HOME}/lib/*.rb`, these are loaded(required) before script run.
128
+ If you make libraries at `${RB_HOME}/lib/*.rb`, these are
129
+ loaded(required) before scripts run.
115
130
 
116
131
  ### Auto Mail Sending
117
132
 
118
- By using `log_send_mail` option, when the logs with ERROR or FATAL level are output, RBatch sends the error messages by e-mail.
133
+ By using `log_send_mail` option, RBatch sends error messages by e-mail
134
+ when ERROR or FATAL level logs are raised.
119
135
 
120
136
  ### Auto Config Reading
121
137
 
122
- If you make the configuration file ,`${RB_HOME}/conf/"(script base).yaml"`, this file is read and parsed automatically.
138
+ By putting the configuration file as `${RB_HOME}/conf/"(script
139
+ base).yaml"`, the file is read and parsed automatically.
123
140
 
124
- sample
141
+ Sample
125
142
 
126
- make the config file `${RB_HOME}/conf/sample2.yaml`.
143
+ Make the config file `${RB_HOME}/conf/sample2.yaml`.
127
144
 
128
145
  key: value
129
146
  array:
@@ -137,7 +154,7 @@ In script named `${RB_HOME}/bin/sample2.rb`, this config values can be used.
137
154
  require 'rbatch'
138
155
 
139
156
  # You can read config value without loading file.
140
- p RBatch.config["key"] # => "value"
157
+ p RBatch.config["key"] # => "value"
141
158
  p RBatch.config["array"] # => ["item1", "item2", "item3"]
142
159
 
143
160
  # If key does not exist, raise exception
@@ -146,16 +163,20 @@ p RBatch.config["not_exist"] # => Raise RBatch::ConfigException
146
163
 
147
164
  #### Common Config
148
165
 
149
- If you can use the common config file , `${RB_HOME}/conf/common.yaml`, this config values can be used by all scripts.
150
- The name of common config file is changed by option `common_conf_name`.
166
+ By putting shard config file at `${RB_HOME}/conf/common.yaml`, the
167
+ values in the file are shared by all scripts.
168
+ If you want to change the name of the config file, you cau use the
169
+ `common_conf_name` option.
151
170
 
152
171
  ### External Command Wrapper
153
172
 
154
- `RBatch.cmd` is external command wapper.
173
+ RBatch have useful functions of external command execution.
174
+ `RBatch.cmd` is wrapper of `Kernel.#Spawn`.
155
175
 
156
- This function return a result object which contains command's "STDOUT", "STDERR" and "exit status".
176
+ This function return a result object which contains command's string,
177
+ STDOUT, STDERR and exit status.
157
178
 
158
- sample
179
+ Sample
159
180
 
160
181
  ```ruby
161
182
  require 'rbatch'
@@ -166,14 +187,17 @@ p r.stderr # => ""
166
187
  p r.status # => 0
167
188
  ```
168
189
 
169
- If you want to set a timeout of external command, you can use `cmd_timeout` option.
190
+ If you want to set a timeout of external command, you can use
191
+ `cmd_timeout` option.
170
192
 
171
- By using `cmd_raise` option, if exit status of command is not 0, RBatch raise an Exception.
193
+ By using `cmd_raise` option, if exit status is not 0,
194
+ RBatch raise an Exception.
172
195
  This function help to handle the errors of external command.
173
196
 
174
197
  ### Double Run Check
175
198
 
176
- By using `forbid_double_run` option, two scripts both has same name cannot run at the same time.
199
+ By using `forbid_double_run` option, two scripts both has same name
200
+ cannot run at the same time.
177
201
 
178
202
  Manual
179
203
  --------------
@@ -204,21 +228,25 @@ require 'rbatch' # <= require rbatch
204
228
  require 'aws-sdk'
205
229
  require 'net/http'
206
230
 
207
- RBatch::Log.new do |log| # <= Start Log block. And write main logic in this block.
231
+ RBatch::Log.new do |log| # <= Start Log block. And write main logic in
232
+ this block.
208
233
  # get ec2 region
209
234
  @ec2_region = "ec2." +
210
- Net::HTTP.get("169.254.169.254", "/latest/meta-data/placement/availability-zone").chop +
235
+ Net::HTTP.get("169.254.169.254",
236
+ "/latest/meta-data/placement/availability-zone").chop +
211
237
  ".amazonaws.com"
212
238
  log.info("ec2 region : #{@ec2_region}") # <= Output Log
213
239
 
214
240
  #create ec2 instance
215
- @ec2 = AWS::EC2.new(:access_key_id => RBatch.config["access_key"], # <= Read Config
241
+ @ec2 = AWS::EC2.new(:access_key_id =>
242
+ RBatch.config["access_key"], # <= Read Config
216
243
  :secret_access_key => RBatch.config["secret_key"],
217
244
  :ec2_endpoint => @ec2_region)
218
245
 
219
246
 
220
247
  # create instance
221
- @instance_id = Net::HTTP.get("169.254.169.254", "/latest/meta-data/instance-id")
248
+ @instance_id = Net::HTTP.get("169.254.169.254",
249
+ "/latest/meta-data/instance-id")
222
250
  @instance = @ec2.instances[@instance_id]
223
251
  log.info("instance_id : #{@instance_id}")
224
252
 
@@ -234,7 +262,7 @@ end
234
262
 
235
263
  ```
236
264
 
237
- Finally you run the script, then following logfile is output.
265
+ Finally, you run the script, then following logfile is output.
238
266
 
239
267
  Log file : `${RB_HOME}/log/20140121_123124_ec2_create_snapshot.log`
240
268
 
@@ -242,16 +270,22 @@ Log file : `${RB_HOME}/log/20140121_123124_ec2_create_snapshot.log`
242
270
  [2014-01-21 12:31:24 -0500] [INFO ] === START RBatch === (PID=10095)
243
271
  [2014-01-21 12:31:24 -0500] [INFO ] RB_HOME : "/opt/MyProject"
244
272
  [2014-01-21 12:31:24 -0500] [INFO ] Load Run-Conf: "/opt/MyProject/.rbatchrc"
245
- [2014-01-21 12:31:24 -0500] [INFO ] Load Config : "/opt/MyProject/conf/ec2_create_snapshot.yaml"
246
- [2014-01-21 12:31:24 -0500] [INFO ] Start Script : "/opt/MyProject/bin/ec2_create_snapshot.rb"
247
- [2014-01-21 12:31:24 -0500] [INFO ] Logging Start: "/opt/MyProject/log/20140121_123124_ec2_create_snapshot.log"
248
- [2014-01-21 12:31:24 -0500] [INFO ] ec2 region : ec2.ap-northeast-1.amazonaws.com
273
+ [2014-01-21 12:31:24 -0500] [INFO ] Load Config :
274
+ "/opt/MyProject/conf/ec2_create_snapshot.yaml"
275
+ [2014-01-21 12:31:24 -0500] [INFO ] Start Script :
276
+ "/opt/MyProject/bin/ec2_create_snapshot.rb"
277
+ [2014-01-21 12:31:24 -0500] [INFO ] Logging Start:
278
+ "/opt/MyProject/log/20140121_123124_ec2_create_snapshot.log"
279
+ [2014-01-21 12:31:24 -0500] [INFO ] ec2 region :
280
+ ec2.ap-northeast-1.amazonaws.com
249
281
  [2014-01-21 12:31:25 -0500] [INFO ] instance_id : i-cc25f1c9
250
- [2014-01-21 12:31:25 -0500] [INFO ] create snapshot : i-cc25f1c9 /dev/sda1 vol-82483ea7 2014/01/21 12:31
282
+ [2014-01-21 12:31:25 -0500] [INFO ] create snapshot : i-cc25f1c9
283
+ /dev/sda1 vol-82483ea7 2014/01/21 12:31
251
284
  [2014-01-21 12:31:25 -0500] [INFO ] sucess
252
285
  ```
253
286
 
254
- Only you write a short code, this batch script has logging and read-config function.
287
+ Only you write a short code, this batch script has logging and
288
+ reading config function.
255
289
 
256
290
  Customize
257
291
  --------------
@@ -316,7 +350,7 @@ Sample of RBatch Run-Conf `${RB_HOME}/.rbatchrc`.
316
350
  # RBatch Journal Level
317
351
  #
318
352
  # Default is 1
319
- # RBatch Journal is message of RBatch and is output to STDOUT.
353
+ # RBatch Journal is message of RBatch and is output to STDOUT.
320
354
  # If 2, put much more information.
321
355
  # If 0, put nothing.
322
356
  #
@@ -407,6 +441,15 @@ Sample of RBatch Run-Conf `${RB_HOME}/.rbatchrc`.
407
441
  #log_bufferd : true
408
442
  #log_bufferd : false
409
443
 
444
+ # Output Exit Status
445
+ #
446
+ # Default is true.
447
+ # When you use the "exist" method in a log block,
448
+ # output exit status into the log file.
449
+ #
450
+ #log_output_exit_status : true
451
+ #log_output_exit_status : false
452
+
410
453
  # Send Mail
411
454
  #
412
455
  # Default is false.
@@ -451,7 +494,8 @@ Sample of RBatch Run-Conf `${RB_HOME}/.rbatchrc`.
451
494
 
452
495
  ### Customize by passing option object to constructor
453
496
 
454
- If you want to change options in a script, you pass an options object to the constructor of RBatch::Log or RBatch::Cmd.
497
+ If you want to change options in a script, you pass an options object
498
+ to the constructor of RBatch::Log or RBatch::Cmd.
455
499
 
456
500
  #### option of RBatch::Log
457
501
 
@@ -492,4 +536,5 @@ Migration from version 1 to version 2
492
536
  --------------
493
537
 
494
538
  Move `${RB_HOME}/conf/rbatch.yaml` to `${RB_HOME}/.rbatchrc` .
495
- That's all.
539
+
540
+
data/bin/rbatch-init CHANGED
@@ -142,6 +142,15 @@ contents[".rbatchrc"] = <<EOF
142
142
  #log_bufferd : true
143
143
  #log_bufferd : false
144
144
 
145
+ # Output Exit Status
146
+ #
147
+ # Default is true.
148
+ # When you use the "exist" method in a log block,
149
+ # output exit status into the log file.
150
+ #
151
+ #log_output_exit_status : true
152
+ #log_output_exit_status : false
153
+
145
154
  # Send Mail
146
155
  #
147
156
  # Default is false.
data/lib/rbatch/log.rb CHANGED
@@ -86,6 +86,9 @@ module RBatch
86
86
  # If this is true, delete old log files when this is called.
87
87
  # If log filename does not include "<date>", do nothing.
88
88
  # @option opt [Integer] :delete_old_log_date
89
+ # @option opt [Boolean] :output_exit_status
90
+ # When you use the "exist" method in a log block,
91
+ # output exit status into the log file.
89
92
  # @option opt [Boolean] :send_mail
90
93
  # When log.error(str) is called,
91
94
  # log.fatal(str) is called , or rescue an Exception,
@@ -112,7 +115,6 @@ module RBatch
112
115
  # RBatch::Log.new({:name => "hoge.log"}){ |log|
113
116
  # log.info "info string"
114
117
  # }
115
-
116
118
  def initialize(opt=nil)
117
119
  @opt = opt
118
120
  @vars = @@def_vars.clone
@@ -158,16 +160,18 @@ module RBatch
158
160
  begin
159
161
  yield self
160
162
  rescue SystemExit => e
161
- if e.status == 0
162
- exit 0
163
- else
164
- fatal(e)
165
- fatal("Caught SystemExit. RBatch Exit with status " + e.status.to_s)
166
- exit e.status
163
+ if @vars[:log_output_exit_status]
164
+ if e.status == 0
165
+ info("RBatch catch SystemExit. Exit with status " + e.status.to_s)
166
+ else
167
+ fatal(e)
168
+ fatal("RBatch catch SystemExit. Exit with status " + e.status.to_s)
169
+ end
167
170
  end
171
+ exit e.status
168
172
  rescue Exception => e
169
173
  fatal(e)
170
- fatal("Caught exception. RBatch Exit with status 1")
174
+ fatal("RBatch catch an exception. Exit with status 1")
171
175
  exit 1
172
176
  ensure
173
177
  close
@@ -22,6 +22,7 @@ module RBatch
22
22
  :log_delete_old_log_date => 7,
23
23
  :log_send_mail => false,
24
24
  :log_bufferd => false,
25
+ :log_output_exit_status => true,
25
26
  :log_mail_to => nil,
26
27
  :log_mail_from => "rbatch.localhost",
27
28
  :log_mail_server_host => "localhost",
@@ -1,3 +1,3 @@
1
1
  module RBatch
2
- VERSION = "2.3.1"
2
+ VERSION = "2.4.0"
3
3
  end
data/sample/.rbatchrc CHANGED
@@ -138,6 +138,15 @@
138
138
  #log_bufferd : true
139
139
  #log_bufferd : false
140
140
 
141
+ # Output Exit Status
142
+ #
143
+ # Default is true.
144
+ # When you use the "exist" method in a log block,
145
+ # output exit status into the log file.
146
+ #
147
+ #log_output_exit_status : true
148
+ #log_output_exit_status : false
149
+
141
150
  # Send Mail
142
151
  #
143
152
  # Default is false.
@@ -96,279 +96,327 @@ describe RBatch::Log do
96
96
  end
97
97
 
98
98
  describe "option by argument" do
99
- it "change log name" do
100
- opt = {:name => "name1.log" }
101
- RBatch::Log.new(opt) { | log | log.info("hoge") }
102
- File::open(File.join(@log_dir , "name1.log")) {|f|
103
- expect(f.read).to match /hoge/
104
- }
105
- end
106
-
107
- it "change log name 2" do
108
- opt = {:name => "<prog><date>name.log" }
109
- RBatch::Log.new(opt) { | log | log.info("hoge") }
110
-
111
- File::open(File.join(@log_dir , "rspec" + Time.now.strftime("%Y%m%d") + "name.log")) {|f|
112
- expect(f.read).to match /hoge/
113
- }
114
- end
115
-
116
- it "change log name 3" do
117
- opt = {:name => "<prog>-<date>-name.log" }
118
- RBatch::Log.new(opt) { | log | log.info("hoge") }
119
-
120
- File::open(File.join(@log_dir , "rspec-" + Time.now.strftime("%Y%m%d") + "-name.log")) {|f|
121
- expect(f.read).to match /hoge/
122
- }
123
- end
124
-
125
- it "change log dir" do
126
- @tmp = File.join(ENV["RB_HOME"],"log3")
127
- Dir.mkdir(@tmp)
128
- opt = {:name => "c.log", :dir=> @tmp }
129
- RBatch::Log.new(opt) { | log | log.info("hoge") }
130
-
131
- File::open(File.join(@tmp , "c.log")) {|f|
132
- expect(f.read).to match /hoge/
133
- }
134
- FileUtils.rm(File.join(@tmp , "c.log"))
135
- Dir.rmdir(@tmp)
136
- end
137
-
138
- it "is append mode" do
139
- opt = {:append => true, :name => "a.log" }
140
- RBatch::Log.new(opt) { | log | log.info("line1") }
141
-
142
- opt = {:append => true, :name => "a.log" }
143
- RBatch::Log.new(opt) { | log | log.info("line2") }
144
-
145
- File::open(File.join(@log_dir , "a.log")) {|f|
146
- str = f.read
147
- expect(str).to match /line1/
148
- expect(str).to match /line2/
149
- }
150
- end
151
-
152
- it "is overwrite mode" do
153
- opt = {:append => false, :name => "a.log" }
154
- RBatch::Log.new(opt) { | log | log.info("line1") }
155
-
156
- opt = {:append => false, :name => "a.log" }
157
- RBatch::Log.new(opt) { | log | log.info("line2") }
158
-
159
- File::open(File.join(@log_dir , "a.log")) {|f|
160
- str = f.read
161
- expect(str).to_not match /line1/
162
- expect(str).to match /line2/
163
- }
164
- end
165
-
166
- it "is debug level" do
167
- opt = { :level => "debug",:name => "a.log" }
168
- RBatch::Log.new(opt) do | log |
169
- log.debug("test_debug")
170
- log.info("test_info")
171
- log.warn("test_warn")
172
- log.error("test_error")
173
- log.fatal("test_fatal")
99
+ describe ":name option" do
100
+ it "change log name" do
101
+ opt = {:name => "name1.log" }
102
+ RBatch::Log.new(opt) { | log | log.info("hoge") }
103
+ File::open(File.join(@log_dir , "name1.log")) {|f|
104
+ expect(f.read).to match /hoge/
105
+ }
174
106
  end
175
-
176
- File::open(File.join(@log_dir , "a.log")) {|f|
177
- str = f.read
178
- expect(str).to match /test_debug/
179
- expect(str).to match /test_info/
180
- expect(str).to match /test_warn/
181
- expect(str).to match /test_error/
182
- expect(str).to match /test_fatal/
183
- }
184
- end
185
-
186
- it "is info level" do
187
- opt = { :level => "info",:name => "a.log" }
188
- RBatch::Log.new(opt) do | log |
189
- log.debug("test_debug")
190
- log.info("test_info")
191
- log.warn("test_warn")
192
- log.error("test_error")
193
- log.fatal("test_fatal")
107
+
108
+ it "change log name 2" do
109
+ opt = {:name => "<prog><date>name.log" }
110
+ RBatch::Log.new(opt) { | log | log.info("hoge") }
111
+
112
+ File::open(File.join(@log_dir , "rspec" + Time.now.strftime("%Y%m%d") + "name.log")) {|f|
113
+ expect(f.read).to match /hoge/
114
+ }
194
115
  end
195
-
196
- File::open(File.join(@log_dir , "a.log")) {|f|
197
- str = f.read
198
- expect(str).to_not match /test_debug/
199
- expect(str).to match /test_info/
200
- expect(str).to match /test_warn/
201
- expect(str).to match /test_error/
202
- expect(str).to match /test_fatal/
203
- }
204
- end
205
-
206
- it "is warn level" do
207
- opt = { :level => "warn",:name => "a.log" }
208
- RBatch::Log.new(opt) do | log |
209
- log.debug("test_debug")
210
- log.info("test_info")
211
- log.warn("test_warn")
212
- log.error("test_error")
213
- log.fatal("test_fatal")
116
+
117
+ it "change log name 3" do
118
+ opt = {:name => "<prog>-<date>-name.log" }
119
+ RBatch::Log.new(opt) { | log | log.info("hoge") }
120
+
121
+ File::open(File.join(@log_dir , "rspec-" + Time.now.strftime("%Y%m%d") + "-name.log")) {|f|
122
+ expect(f.read).to match /hoge/
123
+ }
214
124
  end
215
-
216
- File::open(File.join(@log_dir , "a.log")) {|f|
217
- str = f.read
218
- expect(str).to_not match /test_debug/
219
- expect(str).to_not match /test_info/
220
- expect(str).to match /test_warn/
221
- expect(str).to match /test_error/
222
- expect(str).to match /test_fatal/
223
- }
224
125
  end
225
-
226
- it "is error level" do
227
- opt = { :level => "error",:name => "a.log" }
228
- RBatch::Log.new(opt) do | log |
229
- log.debug("test_debug")
230
- log.info("test_info")
231
- log.warn("test_warn")
232
- log.error("test_error")
233
- log.fatal("test_fatal")
126
+
127
+ describe ":dir option" do
128
+ it "change log dir" do
129
+ @tmp = File.join(ENV["RB_HOME"],"log3")
130
+ Dir.mkdir(@tmp)
131
+ opt = {:name => "c.log", :dir=> @tmp }
132
+ RBatch::Log.new(opt) { | log | log.info("hoge") }
133
+
134
+ File::open(File.join(@tmp , "c.log")) {|f|
135
+ expect(f.read).to match /hoge/
136
+ }
137
+ FileUtils.rm(File.join(@tmp , "c.log"))
138
+ Dir.rmdir(@tmp)
234
139
  end
235
-
236
- File::open(File.join(@log_dir , "a.log")) {|f|
237
- str = f.read
238
- expect(str).to_not match /test_debug/
239
- expect(str).to_not match /test_info/
240
- expect(str).to_not match /test_warn/
241
- expect(str).to match /test_error/
242
- expect(str).to match /test_fatal/
243
- }
244
140
  end
245
141
 
246
- it "is fatal level" do
247
- opt = { :level => "fatal",:name => "a.log" }
248
- RBatch::Log.new(opt) do | log |
249
- log.debug("test_debug")
250
- log.info("test_info")
251
- log.warn("test_warn")
252
- log.error("test_error")
253
- log.fatal("test_fatal")
142
+ describe ":append option" do
143
+ it "is append mode" do
144
+ opt = {:append => true, :name => "a.log" }
145
+ RBatch::Log.new(opt) { | log | log.info("line1") }
146
+
147
+ opt = {:append => true, :name => "a.log" }
148
+ RBatch::Log.new(opt) { | log | log.info("line2") }
149
+
150
+ File::open(File.join(@log_dir , "a.log")) {|f|
151
+ str = f.read
152
+ expect(str).to match /line1/
153
+ expect(str).to match /line2/
154
+ }
254
155
  end
255
-
256
- File::open(File.join(@log_dir , "a.log")) {|f|
257
- str = f.read
258
- expect(str).to_not match /test_debug/
259
- expect(str).to_not match /test_info/
260
- expect(str).to_not match /test_warn/
261
- expect(str).to_not match /test_error/
262
- expect(str).to match /test_fatal/
263
- }
264
- end
265
-
266
- it "is default level" do
267
- opt = {:name => "a.log" }
268
- RBatch::Log.new(opt) do | log |
269
- log.debug("test_debug")
270
- log.info("test_info")
271
- log.warn("test_warn")
272
- log.error("test_error")
273
- log.fatal("test_fatal")
156
+
157
+ it "is overwrite mode" do
158
+ opt = {:append => false, :name => "a.log" }
159
+ RBatch::Log.new(opt) { | log | log.info("line1") }
160
+
161
+ opt = {:append => false, :name => "a.log" }
162
+ RBatch::Log.new(opt) { | log | log.info("line2") }
163
+
164
+ File::open(File.join(@log_dir , "a.log")) {|f|
165
+ str = f.read
166
+ expect(str).to_not match /line1/
167
+ expect(str).to match /line2/
168
+ }
274
169
  end
275
-
276
- File::open(File.join(@log_dir , "a.log")) {|f|
277
- str = f.read
278
- expect(str).to_not match /test_debug/
279
- expect(str).to match /test_info/
280
- expect(str).to match /test_warn/
281
- expect(str).to match /test_error/
282
- expect(str).to match /test_fatal/
283
- }
284
170
  end
285
-
286
- it "delete old log which name include <date>" do
287
- loglist = [*0..20].map do |day|
288
- File.join(@log_dir , (Date.today - day).strftime("%Y%m%d") + "_test_delete.log")
171
+ describe ":level option" do
172
+ it "is debug level" do
173
+ opt = { :level => "debug",:name => "a.log" }
174
+ RBatch::Log.new(opt) do | log |
175
+ log.debug("test_debug")
176
+ log.info("test_info")
177
+ log.warn("test_warn")
178
+ log.error("test_error")
179
+ log.fatal("test_fatal")
180
+ end
181
+
182
+ File::open(File.join(@log_dir , "a.log")) {|f|
183
+ str = f.read
184
+ expect(str).to match /test_debug/
185
+ expect(str).to match /test_info/
186
+ expect(str).to match /test_warn/
187
+ expect(str).to match /test_error/
188
+ expect(str).to match /test_fatal/
189
+ }
289
190
  end
290
- FileUtils.touch(loglist)
291
-
292
- opt = { :name => "<date>_test_delete.log",:delete_old_log => true}
293
- RBatch::Log.new(opt) { | log | }
294
-
295
- loglist[1..6].each do |filename|
296
- expect(File.exists?(filename)).to be true
191
+
192
+ it "is info level" do
193
+ opt = { :level => "info",:name => "a.log" }
194
+ RBatch::Log.new(opt) do | log |
195
+ log.debug("test_debug")
196
+ log.info("test_info")
197
+ log.warn("test_warn")
198
+ log.error("test_error")
199
+ log.fatal("test_fatal")
200
+ end
201
+
202
+ File::open(File.join(@log_dir , "a.log")) {|f|
203
+ str = f.read
204
+ expect(str).to_not match /test_debug/
205
+ expect(str).to match /test_info/
206
+ expect(str).to match /test_warn/
207
+ expect(str).to match /test_error/
208
+ expect(str).to match /test_fatal/
209
+ }
297
210
  end
298
- loglist[7..20].each do |filename|
299
- expect(File.exists?(filename)).to be false
211
+
212
+ it "is warn level" do
213
+ opt = { :level => "warn",:name => "a.log" }
214
+ RBatch::Log.new(opt) do | log |
215
+ log.debug("test_debug")
216
+ log.info("test_info")
217
+ log.warn("test_warn")
218
+ log.error("test_error")
219
+ log.fatal("test_fatal")
220
+ end
221
+
222
+ File::open(File.join(@log_dir , "a.log")) {|f|
223
+ str = f.read
224
+ expect(str).to_not match /test_debug/
225
+ expect(str).to_not match /test_info/
226
+ expect(str).to match /test_warn/
227
+ expect(str).to match /test_error/
228
+ expect(str).to match /test_fatal/
229
+ }
230
+ end
231
+
232
+ it "is error level" do
233
+ opt = { :level => "error",:name => "a.log" }
234
+ RBatch::Log.new(opt) do | log |
235
+ log.debug("test_debug")
236
+ log.info("test_info")
237
+ log.warn("test_warn")
238
+ log.error("test_error")
239
+ log.fatal("test_fatal")
240
+ end
241
+
242
+ File::open(File.join(@log_dir , "a.log")) {|f|
243
+ str = f.read
244
+ expect(str).to_not match /test_debug/
245
+ expect(str).to_not match /test_info/
246
+ expect(str).to_not match /test_warn/
247
+ expect(str).to match /test_error/
248
+ expect(str).to match /test_fatal/
249
+ }
250
+ end
251
+
252
+ it "is fatal level" do
253
+ opt = { :level => "fatal",:name => "a.log" }
254
+ RBatch::Log.new(opt) do | log |
255
+ log.debug("test_debug")
256
+ log.info("test_info")
257
+ log.warn("test_warn")
258
+ log.error("test_error")
259
+ log.fatal("test_fatal")
260
+ end
261
+
262
+ File::open(File.join(@log_dir , "a.log")) {|f|
263
+ str = f.read
264
+ expect(str).to_not match /test_debug/
265
+ expect(str).to_not match /test_info/
266
+ expect(str).to_not match /test_warn/
267
+ expect(str).to_not match /test_error/
268
+ expect(str).to match /test_fatal/
269
+ }
270
+ end
271
+
272
+ it "is default level" do
273
+ opt = {:name => "a.log" }
274
+ RBatch::Log.new(opt) do | log |
275
+ log.debug("test_debug")
276
+ log.info("test_info")
277
+ log.warn("test_warn")
278
+ log.error("test_error")
279
+ log.fatal("test_fatal")
280
+ end
281
+
282
+ File::open(File.join(@log_dir , "a.log")) {|f|
283
+ str = f.read
284
+ expect(str).to_not match /test_debug/
285
+ expect(str).to match /test_info/
286
+ expect(str).to match /test_warn/
287
+ expect(str).to match /test_error/
288
+ expect(str).to match /test_fatal/
289
+ }
300
290
  end
301
291
  end
302
-
303
- it "delete old log which name include <date> even if <date> position is changed" do
304
- loglist = [*0..20].map do |day|
305
- File.join(@log_dir , "235959-" + (Date.today - day).strftime("%Y%m%d") + "_test_delete.log")
292
+ describe ":delete_old_log option" do
293
+ it "delete old log which name include <date>" do
294
+ loglist = [*0..20].map do |day|
295
+ File.join(@log_dir , (Date.today - day).strftime("%Y%m%d") + "_test_delete.log")
296
+ end
297
+ FileUtils.touch(loglist)
298
+
299
+ opt = { :name => "<date>_test_delete.log",:delete_old_log => true}
300
+ RBatch::Log.new(opt) { | log | }
301
+
302
+ loglist[1..6].each do |filename|
303
+ expect(File.exists?(filename)).to be true
304
+ end
305
+ loglist[7..20].each do |filename|
306
+ expect(File.exists?(filename)).to be false
307
+ end
306
308
  end
307
- FileUtils.touch(loglist)
308
-
309
- opt = { :name => "<time>-<date>_test_delete.log",:delete_old_log => true}
310
- RBatch::Log.new(opt) { | log | }
311
-
312
- loglist[1..6].each do |filename|
313
- expect(File.exists?(filename)).to be true
309
+
310
+ it "delete old log which name include <date> even if <date> position is changed" do
311
+ loglist = [*0..20].map do |day|
312
+ File.join(@log_dir , "235959-" + (Date.today - day).strftime("%Y%m%d") + "_test_delete.log")
313
+ end
314
+ FileUtils.touch(loglist)
315
+
316
+ opt = { :name => "<time>-<date>_test_delete.log",:delete_old_log => true}
317
+ RBatch::Log.new(opt) { | log | }
318
+
319
+ loglist[1..6].each do |filename|
320
+ expect(File.exists?(filename)).to be true
321
+ end
322
+ loglist[7..20].each do |filename|
323
+ expect(File.exists?(filename)).to be false
324
+ end
314
325
  end
315
- loglist[7..20].each do |filename|
316
- expect(File.exists?(filename)).to be false
326
+
327
+ it "does not delete old log which name does not include <date>" do
328
+ opt = { :name => "test_delete.log",:delete_old_log => true}
329
+ RBatch::Log.new(opt) { | log | }
330
+
331
+ expect(File.exists?(File.join(@log_dir,"test_delete.log"))).to be true
317
332
  end
318
333
  end
319
-
320
- it "does not delete old log which name does not include <date>" do
321
- opt = { :name => "test_delete.log",:delete_old_log => true}
322
- RBatch::Log.new(opt) { | log | }
323
-
324
- expect(File.exists?(File.join(@log_dir,"test_delete.log"))).to be true
334
+
335
+ describe ":bufferd option" do
336
+ it "works bufferd is true" do
337
+ opt = { :name => "test_buffer.log",:bufferd => true}
338
+ RBatch::Log.new(opt) { | log | log.info("hoge") }
339
+ File::open(File.join(@log_dir , "test_buffer.log")) {|f|
340
+ expect(f.read).to match /hoge/
341
+ }
342
+ end
343
+ it "works bufferd is false" do
344
+ opt = { :name => "test_buffer2.log",:bufferd => false}
345
+ RBatch::Log.new(opt) { | log | log.info("hoge") }
346
+ File::open(File.join(@log_dir , "test_buffer2.log")) {|f|
347
+ expect(f.read).to match /hoge/
348
+ }
349
+ end
325
350
  end
326
351
 
327
- it "works bufferd is true" do
328
- opt = { :name => "test_buffer.log",:bufferd => true}
329
- RBatch::Log.new(opt) { | log | log.info("hoge") }
330
- File::open(File.join(@log_dir , "test_buffer.log")) {|f|
331
- expect(f.read).to match /hoge/
332
- }
333
- end
334
- it "works bufferd is false" do
335
- opt = { :name => "test_buffer2.log",:bufferd => false}
336
- RBatch::Log.new(opt) { | log | log.info("hoge") }
337
- File::open(File.join(@log_dir , "test_buffer2.log")) {|f|
338
- expect(f.read).to match /hoge/
339
- }
352
+ describe ":output_exit_status option" do
353
+ describe "option is true" do
354
+ it "output FATAL error when exit status is 1" do
355
+ opt = { :name => "test_output_system_exit.log",:output_exit_status => true}
356
+ expect{RBatch::Log.new(opt) { | log | exit 1 }}.to raise_error(SystemExit)
357
+ File::open(File.join(@log_dir , "test_output_system_exit.log")) {|f|
358
+ expect(f.read).to match /.FATAL. RBatch catch SystemExit. Exit with status 1/
359
+ }
360
+ end
361
+ it "output nothing when exit status is 0" do
362
+ opt = { :name => "test_output_system_exit2.log",:output_exit_status => true}
363
+ expect{RBatch::Log.new(opt) { | log | exit 0 }}.to raise_error(SystemExit)
364
+ File::open(File.join(@log_dir , "test_output_system_exit2.log")) {|f|
365
+ expect(f.read).not_to match /.INFO. RBatch catch SystemExit. Exit with status 0/
366
+ }
367
+ end
368
+ end
369
+ describe "option is false" do
370
+ it "output nothing when exit status is not 1" do
371
+ opt = { :name => "test_output_system_exit3.log",:output_exit_status => false}
372
+ expect{RBatch::Log.new(opt) { | log | exit 1 }}.to raise_error(SystemExit)
373
+ File::open(File.join(@log_dir , "test_output_system_exit3.log")) {|f|
374
+ expect(f.read).not_to match /RBatch catch SystemExit/
375
+ }
376
+ end
377
+ it "output nothing when exit status is 0" do
378
+ opt = { :name => "test_output_system_exit4.log",:output_exit_status => false}
379
+ expect{RBatch::Log.new(opt) { | log | exit 0 }}.to raise_error(SystemExit)
380
+ File::open(File.join(@log_dir , "test_output_system_exit4.log")) {|f|
381
+ expect(f.read).not_to match /RBatch catch SystemExit/
382
+ }
383
+ end
384
+ end
340
385
  end
341
-
342
-
343
386
  end
344
387
 
345
388
  describe "option by run_conf" do
346
- it "change log name" do
347
- @def_vars.merge!({:log_name => "name1.log"})
348
- RBatch::Log.def_vars = @def_vars
349
- RBatch::Log.new { | log | log.info("hoge") }
350
-
351
- File::open(File.join(@log_dir , "name1.log")) {|f|
352
- expect(f.read).to match /hoge/
353
- }
389
+ describe "log_name option" do
390
+ it "change log name" do
391
+ @def_vars.merge!({:log_name => "name1.log"})
392
+ RBatch::Log.def_vars = @def_vars
393
+ RBatch::Log.new { | log | log.info("hoge") }
394
+
395
+ File::open(File.join(@log_dir , "name1.log")) {|f|
396
+ expect(f.read).to match /hoge/
397
+ }
398
+ end
354
399
  end
355
400
 
356
- it "change log dir" do
357
- @tmp = File.join(ENV["RB_HOME"],"log2")
358
- Dir.mkdir(@tmp)
359
- @def_vars.merge!({:log_dir => @tmp})
360
- RBatch::Log.def_vars = @def_vars
361
-
362
- opt = {:name => "c.log" }
363
- RBatch::Log.new(opt) { | log | log.info("hoge") }
364
-
365
- File::open(File.join(@tmp , "c.log")) {|f|
366
- expect(f.read).to match /hoge/
367
- }
368
- FileUtils.rm(File.join(@tmp , "c.log"))
369
- Dir.rmdir(@tmp)
401
+ describe "log_dir option" do
402
+ it "change log dir" do
403
+ @tmp = File.join(ENV["RB_HOME"],"log2")
404
+ Dir.mkdir(@tmp)
405
+ @def_vars.merge!({:log_dir => @tmp})
406
+ RBatch::Log.def_vars = @def_vars
407
+
408
+ opt = {:name => "c.log" }
409
+ RBatch::Log.new(opt) { | log | log.info("hoge") }
410
+
411
+ File::open(File.join(@tmp , "c.log")) {|f|
412
+ expect(f.read).to match /hoge/
413
+ }
414
+ FileUtils.rm(File.join(@tmp , "c.log"))
415
+ Dir.rmdir(@tmp)
416
+ end
370
417
  end
371
418
  end
419
+
372
420
  describe "option both run_conf and opt" do
373
421
  it "change log name" do
374
422
  @def_vars.merge!({:log_name => "name1.log"})
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rbatch
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.3.1
5
+ version: 2.4.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - fetaro
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2014-12-08 00:00:00 Z
13
+ date: 2015-06-08 00:00:00 Z
14
14
  dependencies: []
15
15
 
16
16
  description: Batch Script Framework