rbatch 1.9.0 → 1.10.0

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/CHANGELOG CHANGED
@@ -44,4 +44,8 @@ initial
44
44
  1.9.0(2013/02/11)
45
45
  ----
46
46
  * add "<host>" keyword to log_name option
47
- * Environmental variables ($TMPDIR and $HOSTNAME) are checked strictly
47
+ * Environmental variables ($TMPDIR and $HOSTNAME) are checked strictly
48
+
49
+ 1.10.0(2013/02/12)
50
+ ----
51
+ * add rbatch-init command
data/README.ja.md CHANGED
@@ -124,53 +124,17 @@ RBatchの共通設定ファイルに"forbid_double_run: true"の設定を書け
124
124
 
125
125
  クイックスタート
126
126
  --------------
127
- ### ステップ1: インストール
128
127
 
129
- ```
130
- # gem install rbatch
131
- ```
132
-
133
- ### ステップ2: ディレクトリ作成
134
-
135
- ```
136
- $ mkdir bin log conf
137
- ```
138
-
139
- ### ステップ3: バッチスクリプト作成
140
-
141
- bin/backup.rbは以下の通り。
142
- ```
143
- require 'rbatch'
128
+ $ sudo gem install rbatch
144
129
 
145
- RBatch::Log.new(){|log|
146
- log.info( "start backup" )
147
- result = RBatch::cmd( "cp -p /var/log/message /backup")
148
- log.info( result )
149
- log.error ( "backup failed") if result.status != 0
150
- }
151
- ```
152
-
153
- ### ステップ4: 実行
154
-
155
- ```
156
- $ ruby bin/backup.rb
157
- ```
158
-
159
- ### ステップ5: 確認
130
+ $ rbatch-init # => ディレクトリとサンプルスクリプトが作られます
160
131
 
161
- 自動的にlog/YYYYMMDD_HHMMSS_backup.logにログファイルが出ます。
132
+ $ ruby bin/hello_world.rb
162
133
 
163
- ```
164
- $ cat log/YYYYMMDD_HHMMSS_backup.log
165
-
166
- # Logfile created on 2012-10-20 00:19:23 +0900 by logger.rb/25413
167
- [2012-10-20 00:19:23 +0900] [INFO ] start backup
168
- [2012-10-20 00:19:23 +0900] [INFO ] {:stdout=>"", :stderr=>"cp: cannot stat `/var/log/message': No such file or directory\n", :status=>1}
169
- [2012-10-20 00:19:23 +0900] [ERROR] backup failed
170
- ```
134
+ $ cat log/YYYYMMDD_HHMMSS_backup.log
171
135
 
172
136
 
173
- マニュアル
137
+ 設定ファイル
174
138
  --------------
175
139
 
176
140
  ### RBatch全体設定ファイル
data/README.md CHANGED
@@ -121,53 +121,16 @@ Forbit double run of the RBatch script by writing option "forbid_double_run: tru
121
121
 
122
122
  Quick Start
123
123
  --------------
124
- ### Step1: Install
125
124
 
126
- ```
127
- # gem install rbatch
128
- ```
129
-
130
- ### Step2: Make directories
131
-
132
- ```
133
- $ mkdir bin log conf
134
- ```
125
+ $ sudo gem install rbatch
135
126
 
136
- ### Step3: Write batch script
127
+ $ rbatch-init # => make directories and sample scripts
137
128
 
138
- for bin/backup.rb
139
- ```
140
- require 'rbatch'
141
-
142
- RBatch::Log.new(){|log|
143
- log.info( "start backup" )
144
- result = RBatch::cmd( "cp -p /var/log/message /backup")
145
- log.info( result )
146
- log.error ( "backup failed") if result.status != 0
147
- }
148
- ```
149
-
150
- ### Step4: Run
151
-
152
- ```
153
- $ ruby bin/backup.rb
154
- ```
155
-
156
- ### Step5: Check
157
-
158
- Log file is generated automatically.
159
-
160
- ```
161
- $ cat log/YYYYMMDD_HHMMSS_backup.log
162
-
163
- # Logfile created on 2012-10-20 00:19:23 +0900 by logger.rb/25413
164
- [2012-10-20 00:19:23 +0900] [INFO ] start backup
165
- [2012-10-20 00:19:23 +0900] [INFO ] {:stdout=>"", :stderr=>"cp: cannot stat `/var/log/message': No such file or directory\n", :status=>1}
166
- [2012-10-20 00:19:23 +0900] [ERROR] backup failed
167
- ```
129
+ $ ruby bin/hello_world.rb
168
130
 
131
+ $ cat log/YYYYMMDD_HHMMSS_backup.log
169
132
 
170
- Manual
133
+ Config
171
134
  --------------
172
135
 
173
136
  ### RBatch Grobal Config File
data/bin/rbatch-init ADDED
@@ -0,0 +1,147 @@
1
+ #!/usr/local/bin/ruby
2
+
3
+ contents = {}
4
+ contents["bin/hello_world.rb"] = <<EOF
5
+ require 'rbatch'
6
+
7
+ RBatch::Log.new{|log|
8
+ log.info("hello world")
9
+ log.info("config value: " + RBatch::config["key1"])
10
+ result = RBatch.cmd("ls")
11
+ log.info(result)
12
+ }
13
+
14
+ EOF
15
+
16
+ contents["conf/hello_world.yaml"] = <<EOF
17
+ key1 : value1
18
+ EOF
19
+
20
+ contents["conf/rbatch.yaml"] = <<EOF
21
+ # RBatch Common Config
22
+ #
23
+ # This file format is YAML.
24
+ #
25
+
26
+ # -------------------
27
+ # Global setting
28
+ # -------------------
29
+
30
+ # Forbit Script Double Run
31
+ #
32
+ # Default is false.
33
+ # If this option is true, two same script cannot start at the same time.
34
+ #
35
+ #forbid_double_run: true
36
+ #forbid_double_run: false
37
+
38
+ # -------------------
39
+ # Cmd setting
40
+ # -------------------
41
+
42
+ # Raise Exception
43
+ #
44
+ # Default is false.
45
+ # If command exit status is not 0, raise exception.
46
+ #
47
+ #cmd_raise : true
48
+ #cmd_raise : false
49
+
50
+
51
+ # -------------------
52
+ # Log setting
53
+ # -------------------
54
+
55
+ # Log File Name
56
+ #
57
+ # Default is "<date>_<time>_<prog>.log".
58
+ # Reservation words are follows.
59
+ # <data> --> Replace to YYYYMMDD date string
60
+ # <time> --> Replace to HHMMSS time string
61
+ # <prog> --> Replace to Program file base name (except extention).
62
+ # <host> --> Replace to Hostname.
63
+ #
64
+ #log_name : "<date>_<time>_<prog>.log"
65
+ #log_name : "<date>_<prog>.log"
66
+
67
+ # Log Output Directory
68
+ #
69
+ # Default is "(Script path)/../log".
70
+ #
71
+ #log_dir : "/tmp/log"
72
+
73
+ # Append log or not
74
+ #
75
+ # Default is ture.
76
+ #
77
+ #log_append : true
78
+ #log_append : false
79
+
80
+ # Log Level
81
+ #
82
+ # Default is "info".
83
+ # Effective values are "debug","info","wran","error",and "fatal".
84
+ #
85
+ #log_level : "debug"
86
+ #log_level : "info"
87
+ #log_level : "warn"
88
+ #log_level : "error"
89
+ #log_level : "fatal"
90
+
91
+ # Print log-string both file and STDOUT
92
+ #
93
+ # Default is false.
94
+ #
95
+ #log_stdout : true
96
+ #log_stdout : false
97
+
98
+ # Delete old log files
99
+ #
100
+ # Default is false.
101
+ # If this is true, delete old log file when RBatch::Log.new is called.
102
+ # A log file to delete is a log file which was made by the RBatch::Log instance,
103
+ # and log filename format include "<date>".
104
+ #
105
+ #log_delete_old_log: true
106
+ #log_delete_old_log: false
107
+
108
+ # The day of leaving log files
109
+ #
110
+ # Default is 7.
111
+ #
112
+ #log_delete_old_log_date: 14
113
+
114
+ # Send mail or not
115
+ #
116
+ # Default is false.
117
+ # When log.error(msg) or log.fatal(msg) called , send e-mail including "msg".
118
+ #
119
+ #log_send_mail : true
120
+
121
+ # Send mail parameters
122
+ #
123
+ #log_mail_to : "xxx@sample.com"
124
+ #log_mail_from : "xxx@sample.com"
125
+ #log_mail_server_host : "localhost"
126
+ #log_mail_server_port : 25
127
+
128
+ EOF
129
+
130
+ require 'fileutils'
131
+ ["bin","conf","log"].each do | dir |
132
+ if ! Dir.exists?(dir)
133
+ FileUtils.mkdir(dir)
134
+ puts "create ./" + dir
135
+ else
136
+ puts "exist ./" + dir + " (not create)"
137
+ end
138
+ end
139
+ ["bin/hello_world.rb","conf/hello_world.yaml","conf/rbatch.yaml"].each do | file |
140
+ if ! File.exists?(file)
141
+ File.open(file, "w") { |f| f.puts contents[file] }
142
+ puts "create ./" + file
143
+ else
144
+ puts "exist ./" + file + " (not create)"
145
+ end
146
+ end
147
+
@@ -1,3 +1,3 @@
1
1
  module Rbatch
2
- VERSION = "1.9.0"
2
+ VERSION = "1.10.0"
3
3
  end
data/rbatch.gemspec CHANGED
@@ -8,7 +8,7 @@ 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 = ""
11
+ gem.description = "Ruby-based simple batch framework"
12
12
  gem.summary = "Ruby-based simple batch framework"
13
13
  gem.homepage = "https://github.com/fetaro/rbatch"
14
14
 
@@ -16,4 +16,6 @@ Gem::Specification.new do |gem|
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
+
20
+ gem.required_ruby_version = ">= 1.9.0"
19
21
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rbatch
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.9.0
5
+ version: 1.10.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - fetaro
@@ -13,11 +13,11 @@ cert_chain: []
13
13
  date: 2013-02-11 00:00:00 Z
14
14
  dependencies: []
15
15
 
16
- description: ""
16
+ description: Ruby-based simple batch framework
17
17
  email:
18
18
  - fetaro@gmail.com
19
- executables: []
20
-
19
+ executables:
20
+ - rbatch-init
21
21
  extensions: []
22
22
 
23
23
  extra_rdoc_files: []
@@ -31,6 +31,7 @@ files:
31
31
  - README.ja.md
32
32
  - README.md
33
33
  - Rakefile
34
+ - bin/rbatch-init
34
35
  - doc/rdoc/CHANGELOG.html
35
36
  - doc/rdoc/LICENSE.html
36
37
  - doc/rdoc/RBatch.html
@@ -120,7 +121,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
121
  requirements:
121
122
  - - ">="
122
123
  - !ruby/object:Gem::Version
123
- version: "0"
124
+ version: 1.9.0
124
125
  required_rubygems_version: !ruby/object:Gem::Requirement
125
126
  none: false
126
127
  requirements: