rbatch 2.1.7 → 2.1.8

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.
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ php:
3
+ - "1.9"
4
+ before_install:
5
+ - gem install rbatch rspec
6
+ before_script:
7
+ script:
8
+ - rake spec
9
+ notifications:
10
+ emails:
11
+ - fetaro@gmail.com
12
+ on_success: always # default: change
13
+ on_failure: always
data/README.ja.md CHANGED
@@ -1,12 +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") | [Document (YardDoc)](http://fetaro.github.io/rbatch/index.html)
2
2
 
3
- RBatch:Ruby-base バッチ スクリプト フレームワーク
3
+ RBatch: バッチスクリプト フレームワーク
4
4
  =============
5
5
 
6
- RBatchについて (version 2)
6
+ RBatchについて
7
7
  --------------
8
8
 
9
- RBatchはRubyで書かれたシンプルなバッチスクリプトのフレームワークです。
9
+ RBatchはRubyで書かれたシンプルなバッチスクリプト(運用スクリプト)のフレームワークです。
10
10
  バッチスクリプト(バックアップやプロセスリロード等)を書く際に便利な機能をフレームワークとして提供しています。
11
11
 
12
12
  主な機能は以下のとおり。
@@ -41,10 +41,21 @@ RBatchはRubyで書かれたシンプルなバッチスクリプトのフレー
41
41
 
42
42
  ### ディレクトリ構成と命名規則
43
43
 
44
+ "設定より規約"の原則に基づいて、
44
45
  RBatchでは、実行スクリプト、設定ファイルおよびログファイルについて、
45
- 配置場所および命名規則が規約で決まっています。
46
+ 配置場所および命名規則が規約で決めています。
47
+ ルールに従えば、ほとんど設定せずに、スクリプト開発に十分な環境が整います。
46
48
 
47
- 具体的には、`${RB_HOME}/bin/hoge.rb`というスクリプトでは、`${RB_HOME}/lib/*.rb`にあるライブラリをロードし、`${RB_HOME}/conf/hoge.yaml`という設定ファイルを読み、`${RB_HOME}/log/YYYYMMDD_HHMMSS_hoge.rb`というログを出力するという規則です。
49
+ ルールは以下の通り
50
+
51
+ * 仮に`${RB_HOME}/bin/hoge.rb`というスクリプトを作った場合
52
+ * 個別設定ファイルは`${RB_HOME}/conf/hoge.yaml`としてください。
53
+ * 共通設定ファイルは`${RB_HOME}/conf/common.yaml`としてください。
54
+ * ライブラリは`${RB_HOME}/lib/*.rb`としてください。
55
+
56
+ すると
57
+
58
+ * `${RB_HOME}/log/YYYYMMDD_HHMMSS_hoge.rb`にログが出ます。
48
59
 
49
60
  例を示すと以下の通りです。
50
61
 
@@ -57,7 +68,7 @@ RBatchでは、実行スクリプト、設定ファイルおよびログファ
57
68
  | |- B.rb
58
69
  |
59
70
  |-conf ←設定ファイル配置場所
60
- | |- A.yaml
71
+ | |- A.yaml ←個別設定ファイル
61
72
  | |- B.yaml
62
73
  | |- common.yaml ←共通設定ファイル
63
74
  |
data/README.md CHANGED
@@ -1,13 +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") | [Document (YardDoc)](http://fetaro.github.io/rbatch/index.html)
2
2
 
3
- RBatch: Framework for Ruby-based Batch Script
3
+ RBatch: Batch Script Framework
4
4
  =============
5
5
 
6
- About RBatch (for ver 2)
6
+ About RBatch
7
7
  --------------
8
8
 
9
-
10
- RBatch is a framework for Ruby-based batch script. RBatch help to make a batch script such as "data backup" or "proccess start ".
9
+ RBatch is a ruby-based framework for batch scripts. RBatch help to make a batch script such as "data backup" or "proccess start ".
11
10
 
12
11
  There are following functions.
13
12
 
@@ -18,7 +17,6 @@ There are following functions.
18
17
  * External Command Wrapper
19
18
  * Double Run Check
20
19
 
21
-
22
20
  Note: RBatch works on Ruby 1.9.
23
21
 
24
22
  Note: This software is released under the MIT License, see LICENSE.txt.
@@ -36,15 +34,26 @@ Overview
36
34
 
37
35
  ### RBatch home directory
38
36
 
39
- When you set `${RB_HOME}` environment variable, RBatch home directory is fix at `${RB_HOME}`.
37
+ When you set `${RB_HOME}` environment variable, RBatch home directory is fixed at `${RB_HOME}`.
40
38
 
41
- 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)/../` .
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)/../` .
42
40
 
43
41
  ### Directory Structure and File Naming Convention
44
42
 
45
- RBach has convention of file naming and directory structure.
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
48
+
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`
53
+
54
+ then
46
55
 
47
- If you make a script on `${RB_HOME}/bin/hoge.rb`, libraries are `${RB_HOME}/lib/*.rb`, script's config file is `${RB_HOME}/conf/hoge.yaml` , and log file is output at `${RB_HOME}/log/YYYYMMDD_HHMMSS_hoge.log`.
56
+ * log files are output at `${RB_HOME}/log/YYYYMMDD_HHMMSS_hoge.log`
48
57
 
49
58
  For example
50
59
 
@@ -57,9 +66,9 @@ For example
57
66
  | |- B.rb
58
67
  |
59
68
  |- conf <--- Config files
60
- | |- A.yaml
69
+ | |- A.yaml <--- Individual config file
61
70
  | |- B.yaml
62
- | |- common.yaml <--- Common-Config file
71
+ | |- common.yaml <--- Common config file
63
72
  |
64
73
  |- log <--- Log files
65
74
  | |- YYYYMMDD_HHMMSS_A.log
@@ -71,9 +80,9 @@ For example
71
80
 
72
81
  ### Auto Logging
73
82
 
74
- Use auto logging block `RBatch::Log`, RBatch automatically output logfiles.
75
- The default location of log file is `${RB_HOME}/log/YYYYMMDD_HHMMSS_(script base).log`.
76
- If an exception is raised, then RBatch write the stack trace to the logfile.
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.
77
86
 
78
87
  sample
79
88
 
@@ -102,19 +111,19 @@ Run script. Log file is `${RB_HOME}/log/20121020_005953_sample1.log`
102
111
 
103
112
  ### Auto Library Loading
104
113
 
105
- If you make libraries at `${RB_HOME}/lib/*.rb`, those files are required before script run.
114
+ If you make the libraries at `${RB_HOME}/lib/*.rb`, these are loaded(required) before script run.
106
115
 
107
116
  ### Auto Mail Sending
108
117
 
109
- By using `log_send_mail` option, when an error or fatal log is output in script, RBatch sends error-mail.
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.
110
119
 
111
120
  ### Auto Config Reading
112
121
 
113
- If you make configuration file which is located `${RB_HOME}/conf/"(script base).yaml"`, this file is read automatically.
122
+ If you make the configuration file ,`${RB_HOME}/conf/"(script base).yaml"`, this file is read and parsed automatically.
114
123
 
115
124
  sample
116
125
 
117
- make config file `${RB_HOME}/conf/sample2.yaml`.
126
+ make the config file `${RB_HOME}/conf/sample2.yaml`.
118
127
 
119
128
  key: value
120
129
  array:
@@ -122,7 +131,7 @@ make config file `${RB_HOME}/conf/sample2.yaml`.
122
131
  - item2
123
132
  - item3
124
133
 
125
- In script `${RB_HOME}/bin/sample2.rb` , you can read config.
134
+ In script named `${RB_HOME}/bin/sample2.rb`, this config values can be used.
126
135
 
127
136
  ```ruby
128
137
  require 'rbatch'
@@ -137,14 +146,14 @@ p RBatch.config["not_exist"] # => Raise RBatch::ConfigException
137
146
 
138
147
  #### Common Config
139
148
 
140
- If you can use a common config file which is read from all scripts, you make `${RB_HOME}/conf/common.yaml`.
141
- You can change name of common config file by using option `common_conf_name`.
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`.
142
151
 
143
152
  ### External Command Wrapper
144
153
 
145
- RBatch provide a function which wrap external command (such as 'ls').
154
+ `RBatch.cmd` is external command wapper.
146
155
 
147
- This function return a result object which contain command's "STDOUT", "STDERR" ,and "exit status".
156
+ This function return a result object which contains command's "STDOUT", "STDERR" and "exit status".
148
157
 
149
158
  sample
150
159
 
@@ -159,12 +168,12 @@ p r.status # => 0
159
168
 
160
169
  If you want to set a timeout of external command, you can use `cmd_timeout` option.
161
170
 
162
- And by using `cmd_raise` option, if status of command is not 0, raise Exception.
163
- You have no use for an error handring.
171
+ By using `cmd_raise` option, if exit status of command is not 0, RBatch raise an Exception.
172
+ This function help to handle the errors of external command.
164
173
 
165
174
  ### Double Run Check
166
175
 
167
- Using `forbid_double_run` option, two same name scripts cannot run at the same time.
176
+ By using `forbid_double_run` option, two scripts both has same name cannot run at the same time.
168
177
 
169
178
  Manual
170
179
  --------------
@@ -176,7 +185,7 @@ Sample
176
185
 
177
186
  ### AWS EC2 Volume Backup Script
178
187
 
179
- First you make configuration file.
188
+ First you make the configuration file.
180
189
 
181
190
  Config File : `${RB_HOME}/conf/ec2_create_snapshot.yaml`
182
191
 
@@ -186,7 +195,7 @@ secret_key : JoqJSdP8+tpdFYWljVbG0+XXXXXXXXXXXXXXX
186
195
 
187
196
  ```
188
197
 
189
- Next, you write script.
198
+ Next, you write the script.
190
199
 
191
200
  Script : `${RB_HOME}/bin/ec2_create_snapshot.rb`
192
201
 
@@ -225,7 +234,7 @@ end
225
234
 
226
235
  ```
227
236
 
228
- Finally Run script , then following logfile is output.
237
+ Finally you run the script, then following logfile is output.
229
238
 
230
239
  Log file : `${RB_HOME}/log/20140121_123124_ec2_create_snapshot.log`
231
240
 
@@ -242,14 +251,14 @@ Log file : `${RB_HOME}/log/20140121_123124_ec2_create_snapshot.log`
242
251
  [2014-01-21 12:31:25 -0500] [INFO ] sucess
243
252
  ```
244
253
 
245
- Only you write a small code, this batch script has logging and read-config function.
254
+ Only you write a short code, this batch script has logging and read-config function.
246
255
 
247
256
  Customize
248
257
  --------------
249
258
  If you want to customize RBatch, you have two methods.
250
259
 
251
260
  * (1) Write Run-Conf(`${RB_HOME}/.rbatchrc`).
252
- * (2) Pass an option object to constructor in your script.
261
+ * (2) Pass an option object to constructor of RBatch classes in a script.
253
262
 
254
263
  When an option is set in both (1) and (2), (2) is prior to (1).
255
264
 
data/lib/rbatch/log.rb CHANGED
@@ -217,7 +217,7 @@ module RBatch
217
217
  if Dir.exists?(@vars[:log_dir]) && @vars.raw_value(:log_name).include?("<date>")
218
218
  Dir::foreach(@vars[:log_dir]) do |file|
219
219
  r = Regexp.new("^" \
220
- + @vars.raw_value(:log_name).gsub("<prog>",@vars[:program_base])\
220
+ + @vars.raw_value(:log_name).gsub("<prog>",@vars[:program_noext])\
221
221
  .gsub("<time>","[0-2][0-9][0-5][0-9][0-5][0-9]")\
222
222
  .gsub("<date>","([0-9][0-9][0-9][0-9][0-1][0-9][0-3][0-9])")\
223
223
  + "$")
@@ -1,3 +1,3 @@
1
1
  module RBatch
2
- VERSION = "2.1.7"
2
+ VERSION = "2.1.8"
3
3
  end
data/rbatch.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |gem|
8
8
  gem.version = RBatch::VERSION
9
9
  gem.authors = ["fetaro"]
10
10
  gem.email = ["fetaro@gmail.com"]
11
- gem.description = "Simple Framework of Batch Script"
12
- gem.summary = "Simple Framework of Batch Script"
11
+ gem.description = "Batch Script Framework"
12
+ gem.summary = "Batch Script Framework"
13
13
  gem.homepage = "https://github.com/fetaro/rbatch"
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rbatch
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.1.7
5
+ version: 2.1.8
6
6
  platform: ruby
7
7
  authors:
8
8
  - fetaro
@@ -10,10 +10,10 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2014-02-13 00:00:00 Z
13
+ date: 2014-03-17 00:00:00 Z
14
14
  dependencies: []
15
15
 
16
- description: Simple Framework of Batch Script
16
+ description: Batch Script Framework
17
17
  email:
18
18
  - fetaro@gmail.com
19
19
  executables:
@@ -24,6 +24,7 @@ extra_rdoc_files: []
24
24
 
25
25
  files:
26
26
  - .gitignore
27
+ - .travis.yml
27
28
  - CHANGELOG
28
29
  - Gemfile
29
30
  - LICENSE.txt
@@ -93,7 +94,7 @@ rubyforge_project:
93
94
  rubygems_version: 1.7.1
94
95
  signing_key:
95
96
  specification_version: 3
96
- summary: Simple Framework of Batch Script
97
+ summary: Batch Script Framework
97
98
  test_files:
98
99
  - spec/01_rbach_spec.rb
99
100
  - spec/rbatch/cmd_spec.rb