rbatch 1.10.0 → 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -1
- data/README.ja.md +48 -10
- data/README.md +41 -6
- data/lib/rbatch/version.rb +1 -1
- data/lib/rbatch.rb +6 -2
- metadata +2 -2
data/CHANGELOG
CHANGED
data/README.ja.md
CHANGED
@@ -126,26 +126,36 @@ RBatchの共通設定ファイルに"forbid_double_run: true"の設定を書け
|
|
126
126
|
--------------
|
127
127
|
|
128
128
|
$ sudo gem install rbatch
|
129
|
-
|
130
129
|
$ rbatch-init # => ディレクトリとサンプルスクリプトが作られます
|
131
|
-
|
132
130
|
$ ruby bin/hello_world.rb
|
131
|
+
$ cat log/YYYYMMDD_HHMMSS_hello_world.log
|
133
132
|
|
134
|
-
$ cat log/YYYYMMDD_HHMMSS_backup.log
|
135
133
|
|
136
|
-
|
137
|
-
設定ファイル
|
134
|
+
オプション
|
138
135
|
--------------
|
139
136
|
|
140
|
-
|
137
|
+
RBatchではオプションの指定の仕方は以下の二つがあります。
|
141
138
|
|
142
|
-
|
139
|
+
1. 全体設定ファイル(conf/rbatch.yaml)に書く
|
140
|
+
2. コンストラクタの引数に指定する
|
141
|
+
|
142
|
+
全体設定ファイルにオプションを書くと、全てのスクリプトに効果がありますが、コンストラクタの引数に指定した場合はそのインスタンスのみ効果があります。
|
143
|
+
|
144
|
+
全体設定ファイルとコンストラクタの引数に同じオプションが指定された場合、コンストラクタの引数が優先されます。
|
145
|
+
|
146
|
+
全体設定ファイルのキーの名前と、コンストラクタオプションのキーの名前は、対応関係があります。全体設定ファイルのキー名は「(クラス名)_(キー名)」となります。
|
147
|
+
たとえばRBatch::Logクラスのコンストラクタオプションで「:name」というキーは、全体設定ファイルでは「log_name」というキーになります。
|
148
|
+
|
149
|
+
### 全体設定ファイルによるオプション指定
|
150
|
+
|
151
|
+
以下の場所にRBatch全体設定ファイルを配置すると、全てのスクリプトにてオプションが適用されます。
|
152
|
+
|
153
|
+
|
154
|
+
(スクリプトのパス)/../conf/rbatch.yaml
|
143
155
|
|
144
|
-
```
|
145
|
-
(スクリプトのパス)/../conf/rbatch.yaml
|
146
|
-
```
|
147
156
|
|
148
157
|
設定ファイルのサンプルは以下の通り
|
158
|
+
|
149
159
|
```
|
150
160
|
# RBatch 全体設定
|
151
161
|
#
|
@@ -257,3 +267,31 @@ RBatchの共通設定ファイルに"forbid_double_run: true"の設定を書け
|
|
257
267
|
#log_mail_server_port : 25
|
258
268
|
|
259
269
|
```
|
270
|
+
|
271
|
+
### コンストラクタの引数によるオプション指定
|
272
|
+
|
273
|
+
#### RBatch::Logクラス
|
274
|
+
|
275
|
+
RBatch::Log.new(opt = nil)
|
276
|
+
opt = {
|
277
|
+
:name => "<date>_<time>_<prog>.log",
|
278
|
+
:dir => "/var/log/",
|
279
|
+
:append => true,
|
280
|
+
:level => "info",
|
281
|
+
:stdout => false,
|
282
|
+
:delete_old_log => false,
|
283
|
+
:delete_old_log_date => 7,
|
284
|
+
:send_mail => false,
|
285
|
+
:mail_to => nil,
|
286
|
+
:mail_from => "rbatch.localhost",
|
287
|
+
:mail_server_host => "localhost",
|
288
|
+
:mail_server_port => 25
|
289
|
+
}
|
290
|
+
|
291
|
+
#### RBatch::Cmdクラス
|
292
|
+
|
293
|
+
RBatch::Log.new(cmd_str, opt = nil)
|
294
|
+
opt = {
|
295
|
+
:raise => false,
|
296
|
+
:timeout => 0
|
297
|
+
}
|
data/README.md
CHANGED
@@ -123,17 +123,25 @@ Quick Start
|
|
123
123
|
--------------
|
124
124
|
|
125
125
|
$ sudo gem install rbatch
|
126
|
-
|
127
126
|
$ rbatch-init # => make directories and sample scripts
|
128
|
-
|
129
127
|
$ ruby bin/hello_world.rb
|
128
|
+
$ cat log/YYYYMMDD_HHMMSS_hello_world.log
|
130
129
|
|
131
|
-
|
132
|
-
|
133
|
-
Config
|
130
|
+
Option
|
134
131
|
--------------
|
135
132
|
|
136
|
-
|
133
|
+
The optional designated way has following two in RBatch.
|
134
|
+
|
135
|
+
1. Global configuration file (conf/rbatch.yaml)
|
136
|
+
2. Argument of the constructer
|
137
|
+
|
138
|
+
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.
|
139
|
+
|
140
|
+
When the same option is set, the argument of the constructer is given priority to over the global configuration.
|
141
|
+
|
142
|
+
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)".
|
143
|
+
|
144
|
+
#### Set by Grobal Configuration File
|
137
145
|
|
138
146
|
If you make follow config file, option value effect to all scripts.
|
139
147
|
|
@@ -252,3 +260,30 @@ Config Sample
|
|
252
260
|
|
253
261
|
```
|
254
262
|
|
263
|
+
### Set by argument of the constracter
|
264
|
+
|
265
|
+
#### class RBatch::Log
|
266
|
+
|
267
|
+
RBatch::Log.new(opt = nil)
|
268
|
+
opt = {
|
269
|
+
:name => "<date>_<time>_<prog>.log",
|
270
|
+
:dir => "/var/log/",
|
271
|
+
:append => true,
|
272
|
+
:level => "info",
|
273
|
+
:stdout => false,
|
274
|
+
:delete_old_log => false,
|
275
|
+
:delete_old_log_date => 7,
|
276
|
+
:send_mail => false,
|
277
|
+
:mail_to => nil,
|
278
|
+
:mail_from => "rbatch.localhost",
|
279
|
+
:mail_server_host => "localhost",
|
280
|
+
:mail_server_port => 25
|
281
|
+
}
|
282
|
+
|
283
|
+
#### class RBatch::Cmd
|
284
|
+
|
285
|
+
RBatch::Log.new(cmd_str, opt = nil)
|
286
|
+
opt = {
|
287
|
+
:raise => false,
|
288
|
+
:timeout => 0
|
289
|
+
}
|
data/lib/rbatch/version.rb
CHANGED
data/lib/rbatch.rb
CHANGED
@@ -13,7 +13,7 @@ module RBatch
|
|
13
13
|
when /cygwin|linux/
|
14
14
|
return ENV["HOSTNAME"] ? ENV["HOSTNAME"] : "unknownhost"
|
15
15
|
else
|
16
|
-
|
16
|
+
return "unknownhost"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
# tmp dir
|
@@ -28,7 +28,11 @@ module RBatch
|
|
28
28
|
when /cygwin|linux/
|
29
29
|
return ENV["TMPDIR"] ? ENV["TMPDIR"] : "/tmp"
|
30
30
|
else
|
31
|
-
|
31
|
+
if ENV["TMPDIR"].nil? && ENV["TEMP"].nil?
|
32
|
+
raise "Unknown RUBY_PRATFORM : " + RUBY_PLATFORM
|
33
|
+
else
|
34
|
+
return ENV["TMPDIR"] || ENV["TEMP"]
|
35
|
+
end
|
32
36
|
end
|
33
37
|
end
|
34
38
|
def common_config_path
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rbatch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.11.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: 2013-02-
|
13
|
+
date: 2013-02-23 00:00:00 Z
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: Ruby-based simple batch framework
|