rbatch 2.1.4 → 2.1.5
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/.gitignore +1 -0
- data/README.ja.md +94 -95
- data/README.md +75 -70
- data/bin/rbatch-init +64 -51
- data/lib/rbatch/journal.rb +3 -7
- data/lib/rbatch/log.rb +4 -1
- data/lib/rbatch/run_conf.rb +6 -6
- data/lib/rbatch/variables.rb +0 -6
- data/lib/rbatch/version.rb +1 -1
- data/rbatch.gemspec +2 -2
- data/sample/.rbatchrc +43 -45
- data/spec/rbatch/journal_spec.rb +0 -12
- data/spec/rbatch/run_conf_spec.rb +5 -6
- data/spec/rbatch/variables_spec.rb +0 -4
- metadata +4 -16
- data/sample/bin/ftp_get.rb +0 -20
- data/sample/bin/store_to_idm.rb +0 -10
- data/sample/data/access_log.1 +0 -50
- data/sample/data/access_log.2012-07-10 +0 -50
- data/sample/data/amAgent_localhost_80.log.1 +0 -39
- data/sample/data/amAgent_localhost_80.log.2012-07-10 +0 -40
- data/sample/data/amAuthentication.access.1 +0 -30
- data/sample/data/amAuthentication.access.2012-07-10 +0 -30
- data/sample/data/amAuthentication.error.1 +0 -10
- data/sample/data/amAuthentication.error.2012-07-10 +0 -6
- data/sample/lib/openidm_common_func.rb +0 -46
- data/sample/log/empty +0 -0
- /data/sample/{conf/store_to_idm.yaml → lib/.gitkeep} +0 -0
data/bin/rbatch-init
CHANGED
@@ -15,55 +15,56 @@ contents[".rbatchrc"] = <<EOF
|
|
15
15
|
# Default is "<home>/conf"
|
16
16
|
# <home> is replaced to ${RB_HOME}
|
17
17
|
#
|
18
|
-
#conf_dir: <home>/config/
|
19
|
-
#conf_dir: /etc/rbatch/
|
18
|
+
#conf_dir : <home>/config/
|
19
|
+
#conf_dir : /etc/rbatch/
|
20
20
|
|
21
|
-
# Common
|
21
|
+
# Common Config file name
|
22
22
|
#
|
23
23
|
# Default is "common.yaml"
|
24
24
|
#
|
25
|
-
#common_conf_name: share.yaml
|
25
|
+
#common_conf_name : share.yaml
|
26
26
|
|
27
27
|
# Library Directory
|
28
28
|
#
|
29
29
|
# Default is "<home>/lib"
|
30
30
|
# <home> is replaced to ${RB_HOME}
|
31
31
|
#
|
32
|
-
#lib_dir: /usr/local/lib/rbatch/
|
32
|
+
#lib_dir : /usr/local/lib/rbatch/
|
33
33
|
|
34
34
|
# Auto Library Load
|
35
35
|
#
|
36
36
|
# Default is true
|
37
37
|
# If true, require "(library directory)/*.rb" before script run.
|
38
38
|
#
|
39
|
-
#auto_lib_load: true
|
40
|
-
#auto_lib_load: false
|
39
|
+
#auto_lib_load : true
|
40
|
+
#auto_lib_load : false
|
41
41
|
|
42
|
-
# Forbit Script
|
42
|
+
# Forbit Script Running Doubly
|
43
43
|
#
|
44
44
|
# Default is false.
|
45
|
-
# If true, two same name scripts cannot run at the same time.
|
45
|
+
# If true, two same name scripts cannot run at the same time.
|
46
46
|
#
|
47
|
-
#forbid_double_run: true
|
48
|
-
#forbid_double_run: false
|
47
|
+
#forbid_double_run : true
|
48
|
+
#forbid_double_run : false
|
49
49
|
|
50
|
-
#
|
51
|
-
# Cmd setting
|
52
|
-
# -------------------
|
53
|
-
|
54
|
-
# Raise Exception
|
50
|
+
# Journal Message Level
|
55
51
|
#
|
56
|
-
# Default is
|
57
|
-
# If
|
52
|
+
# Default is 1
|
53
|
+
# If 2, put more journal messages to STDOUT.
|
54
|
+
# If 0, put nothing.
|
55
|
+
# Example of journal essages are follows.
|
56
|
+
# [RBatch] Load Config : "../conf/hoge.yaml"
|
58
57
|
#
|
59
|
-
#
|
60
|
-
#
|
58
|
+
#rbatch_journal_level : 2
|
59
|
+
#rbatch_journal_level : 0
|
61
60
|
|
62
|
-
#
|
61
|
+
# Mix Journal Message to Logs
|
63
62
|
#
|
64
|
-
# Default is
|
63
|
+
# Default is true.
|
64
|
+
# If true, mix RBatch journal messages to log file(s) which is(are) opened at time.
|
65
65
|
#
|
66
|
-
#
|
66
|
+
#mix_rbatch_journal_to_logs : true
|
67
|
+
#mix_rbatch_journal_to_logs : false
|
67
68
|
|
68
69
|
# -------------------
|
69
70
|
# Log setting
|
@@ -74,8 +75,8 @@ contents[".rbatchrc"] = <<EOF
|
|
74
75
|
# Default is "<home>/log"
|
75
76
|
# <home> is replaced to ${RB_HOME}
|
76
77
|
#
|
77
|
-
#log_dir: <home>/rb_log
|
78
|
-
#log_dir: /var/log/rbatch/
|
78
|
+
#log_dir : <home>/rb_log
|
79
|
+
#log_dir : /var/log/rbatch/
|
79
80
|
|
80
81
|
# Log File Name
|
81
82
|
#
|
@@ -101,12 +102,9 @@ contents[".rbatchrc"] = <<EOF
|
|
101
102
|
# Effective values are "debug","info","wran","error",and "fatal".
|
102
103
|
#
|
103
104
|
#log_level : "debug"
|
104
|
-
#log_level : "info"
|
105
105
|
#log_level : "warn"
|
106
|
-
#log_level : "error"
|
107
|
-
#log_level : "fatal"
|
108
106
|
|
109
|
-
# Print log string both file and STDOUT
|
107
|
+
# Print log string both log file and STDOUT
|
110
108
|
#
|
111
109
|
# Default is false.
|
112
110
|
#
|
@@ -120,16 +118,16 @@ contents[".rbatchrc"] = <<EOF
|
|
120
118
|
# A log file to delete is a log file which was made by the
|
121
119
|
# RBatch::Log instance, and log filename format include "<date>".
|
122
120
|
#
|
123
|
-
#log_delete_old_log: true
|
124
|
-
#log_delete_old_log: false
|
121
|
+
#log_delete_old_log : true
|
122
|
+
#log_delete_old_log : false
|
125
123
|
|
126
|
-
#
|
124
|
+
# Expire Date of Log Files
|
127
125
|
#
|
128
126
|
# Default is 7.
|
129
127
|
#
|
130
|
-
#log_delete_old_log_date: 14
|
128
|
+
#log_delete_old_log_date : 14
|
131
129
|
|
132
|
-
# Send
|
130
|
+
# Send Mail
|
133
131
|
#
|
134
132
|
# Default is false.
|
135
133
|
# When log.error(msg) or log.fatal(msg) called , send e-mail
|
@@ -137,47 +135,62 @@ contents[".rbatchrc"] = <<EOF
|
|
137
135
|
#
|
138
136
|
#log_send_mail : true
|
139
137
|
|
140
|
-
# Mail
|
138
|
+
# Mail Parameters
|
141
139
|
#
|
142
140
|
#log_mail_to : "xxx@sample.com"
|
143
141
|
#log_mail_from : "xxx@sample.com"
|
144
142
|
#log_mail_server_host : "localhost"
|
145
143
|
#log_mail_server_port : 25
|
146
144
|
|
147
|
-
#
|
145
|
+
# -------------------
|
146
|
+
# Cmd setting
|
147
|
+
# -------------------
|
148
|
+
|
149
|
+
# Raise Exception
|
148
150
|
#
|
149
|
-
# Default is
|
150
|
-
# If
|
151
|
-
# If 0, put nothing.
|
152
|
-
# Example of journal essages are follows.
|
153
|
-
# [RBatch] Load Config : "../conf/hoge.yaml"
|
151
|
+
# Default is false.
|
152
|
+
# If true, when command exit status is not 0, raise exception.
|
154
153
|
#
|
155
|
-
#
|
156
|
-
#
|
154
|
+
#cmd_raise : true
|
155
|
+
#cmd_raise : false
|
157
156
|
|
158
|
-
#
|
157
|
+
# Command Timeout
|
159
158
|
#
|
160
|
-
# Default is
|
161
|
-
# If true, mix RBatch journal messages to log file(s) which is(are) opened at time.
|
159
|
+
# Default is 0 [sec] (=no timeout).
|
162
160
|
#
|
163
|
-
#
|
164
|
-
|
161
|
+
#cmd_timeout : 5
|
162
|
+
|
165
163
|
EOF
|
166
164
|
|
167
165
|
contents["bin/hello_world.rb"] = <<EOF
|
168
166
|
require 'rbatch'
|
169
167
|
|
168
|
+
# Config
|
169
|
+
p RBatch.config["key1"]
|
170
|
+
p RBatch.config["key2"]
|
171
|
+
|
172
|
+
# cmd
|
173
|
+
result = RBatch.cmd("ls")
|
174
|
+
p result.stdout
|
175
|
+
p result.stderr
|
176
|
+
p result.status
|
177
|
+
p result
|
178
|
+
|
179
|
+
# Log
|
170
180
|
RBatch::Log.new{|log|
|
171
181
|
log.info("hello world")
|
172
|
-
log.
|
173
|
-
|
174
|
-
log.info(result)
|
182
|
+
log.error("this is error")
|
183
|
+
raise "Exception here"
|
175
184
|
}
|
176
185
|
|
177
186
|
EOF
|
178
187
|
|
179
188
|
contents["conf/hello_world.yaml"] = <<EOF
|
180
189
|
key1 : value1
|
190
|
+
key2 :
|
191
|
+
- a
|
192
|
+
- b
|
193
|
+
- c
|
181
194
|
EOF
|
182
195
|
|
183
196
|
|
data/lib/rbatch/journal.rb
CHANGED
@@ -4,14 +4,10 @@ module RBatch
|
|
4
4
|
def Journal.def_vars=(a) ; @@def_vars=a ; end
|
5
5
|
attr :journals,:journal_verbose,:user_logs
|
6
6
|
def initialize(verbose=nil)
|
7
|
-
if verbose.nil?
|
8
|
-
if ENV["RB_VERBOSE"]
|
9
|
-
@journal_verbose = ENV["RB_VERBOSE"].to_i
|
10
|
-
else
|
11
|
-
@journal_verbose = 1
|
12
|
-
end
|
13
|
-
else
|
7
|
+
if ! verbose.nil?
|
14
8
|
@journal_verbose = verbose
|
9
|
+
else
|
10
|
+
@journal_verbose = @@def_vars[:rbatch_journal_level]
|
15
11
|
end
|
16
12
|
@journals = []
|
17
13
|
@user_logs = []
|
data/lib/rbatch/log.rb
CHANGED
@@ -55,6 +55,9 @@ module RBatch
|
|
55
55
|
@vars.merge!(tmp)
|
56
56
|
end
|
57
57
|
@path = File.join(@vars[:log_dir],@vars[:log_name])
|
58
|
+
unless Dir.exist? @vars[:log_dir]
|
59
|
+
raise LogException,"Log directory \"#{@vars[:log_dir]}\" does not exist"
|
60
|
+
end
|
58
61
|
# create Logger instance
|
59
62
|
begin
|
60
63
|
if @vars[:log_append] && File.exist?(@path)
|
@@ -120,7 +123,7 @@ module RBatch
|
|
120
123
|
end
|
121
124
|
|
122
125
|
def journal(a)
|
123
|
-
@log.info(a)
|
126
|
+
@log.info("[RBatch] " + a)
|
124
127
|
end
|
125
128
|
|
126
129
|
def close
|
data/lib/rbatch/run_conf.rb
CHANGED
@@ -49,7 +49,7 @@ module RBatch
|
|
49
49
|
if @@def_opt.has_key?(key.to_sym)
|
50
50
|
@opt[key.to_sym]=@yaml[key]
|
51
51
|
else
|
52
|
-
raise RBatch::
|
52
|
+
raise RBatch::RunConfException, "\"#{key}\" is not available option"
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -64,7 +64,7 @@ module RBatch
|
|
64
64
|
if @opt.has_key?(key)
|
65
65
|
@opt[key] = opt[key]
|
66
66
|
else
|
67
|
-
raise RBatch::
|
67
|
+
raise RBatch::RunConfException, "\"#{key}\" is not available option"
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
@@ -75,7 +75,7 @@ module RBatch
|
|
75
75
|
if tmp.has_key?(key)
|
76
76
|
tmp[key] = opt[key]
|
77
77
|
else
|
78
|
-
raise RBatch::
|
78
|
+
raise RBatch::RunConfException, "\"#{key}\" is not available option"
|
79
79
|
end
|
80
80
|
end
|
81
81
|
return tmp
|
@@ -83,19 +83,19 @@ module RBatch
|
|
83
83
|
|
84
84
|
def[](key)
|
85
85
|
if @opt[key].nil?
|
86
|
-
raise RBatch::
|
86
|
+
raise RBatch::RunConfException, "Value of key=\"#{key}\" is nil"
|
87
87
|
end
|
88
88
|
@opt[key]
|
89
89
|
end
|
90
90
|
|
91
91
|
def[]=(key,value)
|
92
92
|
if ! @opt.has_key?(key)
|
93
|
-
raise RBatch::
|
93
|
+
raise RBatch::RunConfException, "Key=\"#{key}\" does not exist"
|
94
94
|
end
|
95
95
|
@opt[key]=value
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
-
class
|
99
|
+
class RunConfException < Exception ; end
|
100
100
|
|
101
101
|
end
|
data/lib/rbatch/variables.rb
CHANGED
@@ -15,12 +15,6 @@ module RBatch
|
|
15
15
|
}
|
16
16
|
@vars[:program_noext] = Pathname(@vars[:program_base]).sub_ext("").to_s
|
17
17
|
|
18
|
-
if ENV["RB_VERBOSE"]
|
19
|
-
@vars[:journal_verbose] = ENV["RB_VERBOSE"].to_i
|
20
|
-
else
|
21
|
-
@vars[:journal_verbose] = 1
|
22
|
-
end
|
23
|
-
|
24
18
|
case RUBY_PLATFORM
|
25
19
|
when /mswin|mingw/
|
26
20
|
@vars[:host_name] = ENV["COMPUTERNAME"] ? ENV["COMPUTERNAME"] : "unknownhost"
|
data/lib/rbatch/version.rb
CHANGED
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 = "
|
12
|
-
gem.summary = "
|
11
|
+
gem.description = "Simple Framework of Batch Script"
|
12
|
+
gem.summary = "Simple Framework of Batch Script"
|
13
13
|
gem.homepage = "https://github.com/fetaro/rbatch"
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
data/sample/.rbatchrc
CHANGED
@@ -12,55 +12,56 @@
|
|
12
12
|
# Default is "<home>/conf"
|
13
13
|
# <home> is replaced to ${RB_HOME}
|
14
14
|
#
|
15
|
-
#conf_dir: <home>/config/
|
16
|
-
#conf_dir: /etc/rbatch/
|
15
|
+
#conf_dir : <home>/config/
|
16
|
+
#conf_dir : /etc/rbatch/
|
17
17
|
|
18
|
-
# Common
|
18
|
+
# Common Config file name
|
19
19
|
#
|
20
20
|
# Default is "common.yaml"
|
21
21
|
#
|
22
|
-
#common_conf_name: share.yaml
|
22
|
+
#common_conf_name : share.yaml
|
23
23
|
|
24
24
|
# Library Directory
|
25
25
|
#
|
26
26
|
# Default is "<home>/lib"
|
27
27
|
# <home> is replaced to ${RB_HOME}
|
28
28
|
#
|
29
|
-
#lib_dir: /usr/local/lib/rbatch/
|
29
|
+
#lib_dir : /usr/local/lib/rbatch/
|
30
30
|
|
31
31
|
# Auto Library Load
|
32
32
|
#
|
33
33
|
# Default is true
|
34
34
|
# If true, require "(library directory)/*.rb" before script run.
|
35
35
|
#
|
36
|
-
#auto_lib_load: true
|
37
|
-
#auto_lib_load: false
|
36
|
+
#auto_lib_load : true
|
37
|
+
#auto_lib_load : false
|
38
38
|
|
39
|
-
# Forbit Script
|
39
|
+
# Forbit Script Running Doubly
|
40
40
|
#
|
41
41
|
# Default is false.
|
42
|
-
# If true, two same name scripts cannot run at the same time.
|
42
|
+
# If true, two same name scripts cannot run at the same time.
|
43
43
|
#
|
44
|
-
#forbid_double_run: true
|
45
|
-
#forbid_double_run: false
|
44
|
+
#forbid_double_run : true
|
45
|
+
#forbid_double_run : false
|
46
46
|
|
47
|
-
#
|
48
|
-
# Cmd setting
|
49
|
-
# -------------------
|
50
|
-
|
51
|
-
# Raise Exception
|
47
|
+
# Journal Message Level
|
52
48
|
#
|
53
|
-
# Default is
|
54
|
-
# If
|
49
|
+
# Default is 1
|
50
|
+
# If 2, put more journal messages to STDOUT.
|
51
|
+
# If 0, put nothing.
|
52
|
+
# Example of journal essages are follows.
|
53
|
+
# [RBatch] Load Config : "../conf/hoge.yaml"
|
55
54
|
#
|
56
|
-
#
|
57
|
-
#
|
55
|
+
#rbatch_journal_level : 2
|
56
|
+
#rbatch_journal_level : 0
|
58
57
|
|
59
|
-
#
|
58
|
+
# Mix Journal Message to Logs
|
60
59
|
#
|
61
|
-
# Default is
|
60
|
+
# Default is true.
|
61
|
+
# If true, mix RBatch journal messages to log file(s) which is(are) opened at time.
|
62
62
|
#
|
63
|
-
#
|
63
|
+
#mix_rbatch_journal_to_logs : true
|
64
|
+
#mix_rbatch_journal_to_logs : false
|
64
65
|
|
65
66
|
# -------------------
|
66
67
|
# Log setting
|
@@ -71,8 +72,8 @@
|
|
71
72
|
# Default is "<home>/log"
|
72
73
|
# <home> is replaced to ${RB_HOME}
|
73
74
|
#
|
74
|
-
#log_dir: <home>/rb_log
|
75
|
-
#log_dir: /var/log/rbatch/
|
75
|
+
#log_dir : <home>/rb_log
|
76
|
+
#log_dir : /var/log/rbatch/
|
76
77
|
|
77
78
|
# Log File Name
|
78
79
|
#
|
@@ -98,12 +99,9 @@
|
|
98
99
|
# Effective values are "debug","info","wran","error",and "fatal".
|
99
100
|
#
|
100
101
|
#log_level : "debug"
|
101
|
-
#log_level : "info"
|
102
102
|
#log_level : "warn"
|
103
|
-
#log_level : "error"
|
104
|
-
#log_level : "fatal"
|
105
103
|
|
106
|
-
# Print log string both file and STDOUT
|
104
|
+
# Print log string both log file and STDOUT
|
107
105
|
#
|
108
106
|
# Default is false.
|
109
107
|
#
|
@@ -120,13 +118,13 @@
|
|
120
118
|
#log_delete_old_log: true
|
121
119
|
#log_delete_old_log: false
|
122
120
|
|
123
|
-
#
|
121
|
+
# Expire Date of Log Files
|
124
122
|
#
|
125
123
|
# Default is 7.
|
126
124
|
#
|
127
125
|
#log_delete_old_log_date: 14
|
128
126
|
|
129
|
-
# Send
|
127
|
+
# Send Mail
|
130
128
|
#
|
131
129
|
# Default is false.
|
132
130
|
# When log.error(msg) or log.fatal(msg) called , send e-mail
|
@@ -134,28 +132,28 @@
|
|
134
132
|
#
|
135
133
|
#log_send_mail : true
|
136
134
|
|
137
|
-
# Mail
|
135
|
+
# Mail Parameters
|
138
136
|
#
|
139
137
|
#log_mail_to : "xxx@sample.com"
|
140
138
|
#log_mail_from : "xxx@sample.com"
|
141
139
|
#log_mail_server_host : "localhost"
|
142
140
|
#log_mail_server_port : 25
|
143
141
|
|
144
|
-
#
|
142
|
+
# -------------------
|
143
|
+
# Cmd setting
|
144
|
+
# -------------------
|
145
|
+
|
146
|
+
# Raise Exception
|
145
147
|
#
|
146
|
-
# Default is
|
147
|
-
# If
|
148
|
-
# If 0, put nothing.
|
149
|
-
# Example of journal essages are follows.
|
150
|
-
# [RBatch] Load Config : "../conf/hoge.yaml"
|
148
|
+
# Default is false.
|
149
|
+
# If true, when command exit status is not 0, raise exception.
|
151
150
|
#
|
152
|
-
#
|
153
|
-
#
|
151
|
+
#cmd_raise : true
|
152
|
+
#cmd_raise : false
|
154
153
|
|
155
|
-
#
|
154
|
+
# Command Timeout
|
156
155
|
#
|
157
|
-
# Default is
|
158
|
-
# If true, mix RBatch journal messages to log file(s) which is(are) opened at time.
|
156
|
+
# Default is 0 [sec] (=no timeout).
|
159
157
|
#
|
160
|
-
#
|
161
|
-
|
158
|
+
#cmd_timeout : 5
|
159
|
+
|
data/spec/rbatch/journal_spec.rb
CHANGED
@@ -13,17 +13,5 @@ describe RBatch::Journal do
|
|
13
13
|
@j = RBatch::Journal.new(2)
|
14
14
|
expect(@j.journal_verbose) == 2
|
15
15
|
end
|
16
|
-
|
17
|
-
it "ENV is set" do
|
18
|
-
ENV["RB_VERBOSE"] = "0"
|
19
|
-
@j = RBatch::Journal.new
|
20
|
-
expect(@j.journal_verbose) == 0
|
21
|
-
end
|
22
|
-
|
23
|
-
it "both argument and ENV are set" do
|
24
|
-
ENV["RB_VERBOSE"] = "0"
|
25
|
-
@j = RBatch::Journal.new(2)
|
26
|
-
expect(@j.journal_verbose) == 2
|
27
|
-
end
|
28
16
|
end
|
29
17
|
|
@@ -9,7 +9,6 @@ describe RBatch::RunConf do
|
|
9
9
|
@HOME_DIR = File.join(Dir.tmpdir, "rbatch_test_" + Time.now.strftime("%Y%m%d%H%M%S"))
|
10
10
|
Dir.mkdir(@HOME_DIR)
|
11
11
|
ENV["RB_HOME"]=@HOME_DIR
|
12
|
-
ENV["RB_VERBOSE"]="0"
|
13
12
|
@home = ENV["RB_HOME"]
|
14
13
|
@config = File.join(@home,"run_conf_test.yaml")
|
15
14
|
end
|
@@ -39,7 +38,7 @@ describe RBatch::RunConf do
|
|
39
38
|
end
|
40
39
|
|
41
40
|
it "raise when key does not exist" do
|
42
|
-
expect{@rc[:not_exist_key]}.to raise_error(RBatch::
|
41
|
+
expect{@rc[:not_exist_key]}.to raise_error(RBatch::RunConfException)
|
43
42
|
end
|
44
43
|
|
45
44
|
it "read run conf" do
|
@@ -50,7 +49,7 @@ describe RBatch::RunConf do
|
|
50
49
|
|
51
50
|
it "raise when run_conf has unreserved key" do
|
52
51
|
open( @config , "w" ){|f| f.write("unreserved: hoge")}
|
53
|
-
expect{tmp = RBatch::RunConf.new(@config)}.to raise_error(RBatch::
|
52
|
+
expect{tmp = RBatch::RunConf.new(@config)}.to raise_error(RBatch::RunConfException)
|
54
53
|
end
|
55
54
|
|
56
55
|
describe "[]= method" do
|
@@ -61,7 +60,7 @@ describe RBatch::RunConf do
|
|
61
60
|
end
|
62
61
|
|
63
62
|
it "raise when set unreserved key" do
|
64
|
-
expect{@rc[:unreservied] = "hoge"}.to raise_error(RBatch::
|
63
|
+
expect{@rc[:unreservied] = "hoge"}.to raise_error(RBatch::RunConfException)
|
65
64
|
end
|
66
65
|
end
|
67
66
|
|
@@ -74,7 +73,7 @@ describe RBatch::RunConf do
|
|
74
73
|
|
75
74
|
it "raise when key does not exist" do
|
76
75
|
opt={ :unreserved => "error"}
|
77
|
-
expect{@rc.merge!(opt)}.to raise_error(RBatch::
|
76
|
+
expect{@rc.merge!(opt)}.to raise_error(RBatch::RunConfException)
|
78
77
|
end
|
79
78
|
end
|
80
79
|
|
@@ -88,7 +87,7 @@ describe RBatch::RunConf do
|
|
88
87
|
|
89
88
|
it "raise when key does not exist" do
|
90
89
|
opt={ :unreserved => "error"}
|
91
|
-
expect{@rc.merge(opt)}.to raise_error(RBatch::
|
90
|
+
expect{@rc.merge(opt)}.to raise_error(RBatch::RunConfException)
|
92
91
|
end
|
93
92
|
end
|
94
93
|
end
|
@@ -12,12 +12,10 @@ describe RBatch::Variables do
|
|
12
12
|
|
13
13
|
before :each do
|
14
14
|
ENV["RB_HOME"]=@home
|
15
|
-
ENV["RB_VERBOSE"]="0"
|
16
15
|
end
|
17
16
|
|
18
17
|
it "default" do
|
19
18
|
@vars = RBatch::Variables.new()
|
20
|
-
expect(@vars[:journal_verbose]).to eq 0
|
21
19
|
#expect(@vars[:host_name]).to eq ""
|
22
20
|
#expect(@vars[:program_name]).to eq "rspec"
|
23
21
|
#expect(@vars[:program_path]).to eq "rspec"
|
@@ -38,10 +36,8 @@ describe RBatch::Variables do
|
|
38
36
|
|
39
37
|
it "success when ENV Change" do
|
40
38
|
ENV["RB_HOME"]="/var"
|
41
|
-
ENV["RB_VERBOSE"]="3"
|
42
39
|
|
43
40
|
@vars = RBatch::Variables.new()
|
44
|
-
expect(@vars[:journal_verbose]).to eq 3
|
45
41
|
expect(@vars[:home_dir]).to eq "/var"
|
46
42
|
expect(@vars[:log_dir]).to eq File.join("/var","log")
|
47
43
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rbatch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 2.1.
|
5
|
+
version: 2.1.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- fetaro
|
@@ -13,7 +13,7 @@ cert_chain: []
|
|
13
13
|
date: 2014-01-16 00:00:00 Z
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description:
|
16
|
+
description: Simple Framework of Batch Script
|
17
17
|
email:
|
18
18
|
- fetaro@gmail.com
|
19
19
|
executables:
|
@@ -104,12 +104,10 @@ files:
|
|
104
104
|
- sample/.rbatchrc
|
105
105
|
- sample/bin/apache_log_insert.rb
|
106
106
|
- sample/bin/file_batch_copy.rb
|
107
|
-
- sample/bin/ftp_get.rb
|
108
107
|
- sample/bin/log_backup.rb
|
109
108
|
- sample/bin/mysql_data_backup.rb
|
110
109
|
- sample/bin/openam_log_insert.rb
|
111
110
|
- sample/bin/openldap_backup.rb
|
112
|
-
- sample/bin/store_to_idm.rb
|
113
111
|
- sample/bin/webagent_log_insert.rb
|
114
112
|
- sample/conf/apache_log_insert.yaml
|
115
113
|
- sample/conf/common.yaml
|
@@ -118,18 +116,8 @@ files:
|
|
118
116
|
- sample/conf/mysql_data_backup.yaml
|
119
117
|
- sample/conf/openam_log_insert.yaml
|
120
118
|
- sample/conf/openldap_backup.yaml
|
121
|
-
- sample/conf/store_to_idm.yaml
|
122
119
|
- sample/conf/webagent_log_insert.yaml
|
123
|
-
- sample/
|
124
|
-
- sample/data/access_log.2012-07-10
|
125
|
-
- sample/data/amAgent_localhost_80.log.1
|
126
|
-
- sample/data/amAgent_localhost_80.log.2012-07-10
|
127
|
-
- sample/data/amAuthentication.access.1
|
128
|
-
- sample/data/amAuthentication.access.2012-07-10
|
129
|
-
- sample/data/amAuthentication.error.1
|
130
|
-
- sample/data/amAuthentication.error.2012-07-10
|
131
|
-
- sample/lib/openidm_common_func.rb
|
132
|
-
- sample/log/empty
|
120
|
+
- sample/lib/.gitkeep
|
133
121
|
- spec/01_rbach_spec.rb
|
134
122
|
- spec/rbatch/cmd_spec.rb
|
135
123
|
- spec/rbatch/config_spec.rb
|
@@ -166,7 +154,7 @@ rubyforge_project:
|
|
166
154
|
rubygems_version: 1.7.1
|
167
155
|
signing_key:
|
168
156
|
specification_version: 3
|
169
|
-
summary:
|
157
|
+
summary: Simple Framework of Batch Script
|
170
158
|
test_files:
|
171
159
|
- spec/01_rbach_spec.rb
|
172
160
|
- spec/rbatch/cmd_spec.rb
|
data/sample/bin/ftp_get.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require "rbatch"
|
2
|
-
require "net/ftp"
|
3
|
-
|
4
|
-
server=""
|
5
|
-
user=""
|
6
|
-
password=""
|
7
|
-
target_files=["",""]
|
8
|
-
|
9
|
-
RBatch::Log.new do | log |
|
10
|
-
ftp = Net::FTP.new(server,user,password)
|
11
|
-
log.info("ftp login: server=#{server},user=#{user},password=#{password}")
|
12
|
-
ftp.login
|
13
|
-
ftp.passive = true
|
14
|
-
ftp.chdir('pub/ruby')
|
15
|
-
files = ftp.list('ruby*')
|
16
|
-
target_files.each do |file|
|
17
|
-
ftp.getbinaryfile(file)
|
18
|
-
end
|
19
|
-
ftp.close
|
20
|
-
end
|
data/sample/bin/store_to_idm.rb
DELETED