rbatch 2.1.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/README.ja.md +14 -5
  2. data/README.md +164 -154
  3. data/bin/rbatch-init +21 -13
  4. data/doc/RBatch/Cmd.html +300 -316
  5. data/doc/RBatch/CmdException.html +146 -141
  6. data/doc/RBatch/CmdResult.html +467 -470
  7. data/doc/RBatch/Config.html +392 -433
  8. data/doc/RBatch/Controller.html +374 -0
  9. data/doc/RBatch/DoubleRunCheckException.html +146 -141
  10. data/doc/RBatch/DoubleRunChecker.html +258 -256
  11. data/doc/RBatch/Journal.html +332 -0
  12. data/doc/RBatch/Log.html +636 -805
  13. data/doc/RBatch/LogException.html +164 -0
  14. data/doc/RBatch/RBatch/RBatch/ConfigException.html +164 -0
  15. data/doc/RBatch/RBatch/RBatch.html +163 -0
  16. data/doc/RBatch/RBatch/VariablesException.html +164 -0
  17. data/doc/RBatch/RBatch.html +165 -0
  18. data/doc/RBatch/RunConf/Exception.html +146 -141
  19. data/doc/RBatch/RunConf.html +478 -532
  20. data/doc/RBatch/Variables.html +437 -0
  21. data/doc/RBatch.html +388 -862
  22. data/doc/created.rid +11 -9
  23. data/doc/index.html +178 -184
  24. data/doc/js/darkfish.js +9 -7
  25. data/doc/lib/rbatch/cmd_rb.html +46 -44
  26. data/doc/lib/rbatch/config_rb.html +42 -42
  27. data/doc/lib/rbatch/controller_rb.html +66 -0
  28. data/doc/lib/rbatch/double_run_checker_rb.html +42 -42
  29. data/doc/lib/rbatch/journal_rb.html +52 -0
  30. data/doc/lib/rbatch/log_rb.html +46 -46
  31. data/doc/lib/rbatch/run_conf_rb.html +42 -42
  32. data/doc/lib/rbatch/variables_rb.html +54 -0
  33. data/doc/lib/rbatch/version_rb.html +38 -38
  34. data/doc/lib/rbatch_rb.html +40 -52
  35. data/doc/rdoc.css +365 -308
  36. data/lib/rbatch/cmd.rb +15 -58
  37. data/lib/rbatch/config.rb +7 -7
  38. data/lib/rbatch/controller.rb +37 -61
  39. data/lib/rbatch/double_run_checker.rb +0 -0
  40. data/lib/rbatch/journal.rb +40 -0
  41. data/lib/rbatch/log.rb +71 -129
  42. data/lib/rbatch/run_conf.rb +13 -24
  43. data/lib/rbatch/variables.rb +82 -0
  44. data/lib/rbatch/version.rb +1 -1
  45. data/lib/rbatch.rb +7 -36
  46. data/sample/.rbatchrc +41 -7
  47. data/spec/01_rbach_spec.rb +99 -0
  48. data/spec/{cmd_spec.rb → rbatch/cmd_spec.rb} +40 -43
  49. data/spec/rbatch/config_spec.rb +67 -0
  50. data/spec/rbatch/controller_spec.rb +18 -0
  51. data/spec/{double_run_checker_spec.rb → rbatch/double_run_checker_spec.rb} +3 -0
  52. data/spec/rbatch/journal_spec.rb +29 -0
  53. data/spec/rbatch/log_spec.rb +350 -0
  54. data/spec/{run_conf_spec.rb → rbatch/run_conf_spec.rb} +13 -5
  55. data/spec/rbatch/variables_spec.rb +68 -0
  56. data/spec/spec_helper.rb +4 -5
  57. metadata +33 -17
  58. data/lib/rbatch/common_config.rb +0 -0
  59. data/spec/common_config_spec.rb +0 -85
  60. data/spec/config_spec.rb +0 -79
  61. data/spec/log_spec.rb +0 -430
  62. data/spec/rbatch_spec.rb +0 -22
@@ -0,0 +1,350 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ require 'rbatch/journal'
5
+ require 'rbatch/variables'
6
+ require 'rbatch/log'
7
+ require 'tmpdir'
8
+
9
+ describe RBatch::Log do
10
+ before :each do
11
+ @home = File.join(Dir.tmpdir, "rbatch_test_" + rand.to_s)
12
+ @log_dir = File.join(@home,"log")
13
+ ENV["RB_HOME"]=@home
14
+
15
+ Dir.mkdir(@home)
16
+ Dir::mkdir(@log_dir)
17
+ @def_vars = RBatch::Variables.new()
18
+ RBatch::Log.def_vars = @def_vars
19
+ RBatch::Journal.def_vars = @def_vars
20
+ @journal = RBatch::Journal.new(0)
21
+ RBatch::Log.journal = @journal
22
+ end
23
+
24
+ after :each do
25
+ if Dir.exists? @log_dir
26
+ Dir::foreach(@log_dir) do |f|
27
+ File::delete(File.join(@log_dir , f)) if ! (/\.+$/ =~ f)
28
+ end
29
+ end
30
+ Dir::rmdir(@log_dir)
31
+ Dir::rmdir(@home)
32
+ @def_vars = nil
33
+ @journal = nil
34
+ end
35
+
36
+ it "is run" do
37
+ RBatch::Log.new do | log |
38
+ log.info("test_log")
39
+ end
40
+
41
+ Dir::foreach(@log_dir) do |f|
42
+ if ! (/\.+$/ =~ f)
43
+ File::open(File.join(@log_dir , f)) {|f|
44
+ expect(f.read).to match /test_log/
45
+ }
46
+ end
47
+ end
48
+ end
49
+
50
+ it "is rescue exception" do
51
+ expect {
52
+ RBatch::Log.new do | log |
53
+ raise Exception.new
54
+ end
55
+ }.to raise_error SystemExit
56
+ end
57
+
58
+ it "raise error when log dir does not exist" do
59
+ Dir::rmdir(@log_dir)
60
+ expect{
61
+ RBatch::Log.new {|log|}
62
+ }.to raise_error(RBatch::LogException)
63
+ Dir::mkdir(@log_dir)
64
+ end
65
+
66
+ it "run when log block is nested" do
67
+ RBatch::Log.new({:name => "name1"}) do | log |
68
+ log.info("name1")
69
+ RBatch::Log.new({:name => "name2"})do | log |
70
+ log.info("name2")
71
+ end
72
+ end
73
+
74
+ File::open(File.join(@log_dir,"name1")) {|f| expect(f.read).to match /name1/ }
75
+ File::open(File.join(@log_dir,"name2")) {|f| expect(f.read).to match /name2/ }
76
+ end
77
+
78
+ describe "option by argument" do
79
+ it "change log name" do
80
+ opt = {:name => "name1.log" }
81
+ RBatch::Log.new(opt) { | log | log.info("hoge") }
82
+ File::open(File.join(@log_dir , "name1.log")) {|f|
83
+ expect(f.read).to match /hoge/
84
+ }
85
+ end
86
+
87
+ it "change log name 2" do
88
+ opt = {:name => "<prog><date>name.log" }
89
+ RBatch::Log.new(opt) { | log | log.info("hoge") }
90
+
91
+ File::open(File.join(@log_dir , "rspec" + Time.now.strftime("%Y%m%d") + "name.log")) {|f|
92
+ expect(f.read).to match /hoge/
93
+ }
94
+ end
95
+
96
+ it "change log name 3" do
97
+ opt = {:name => "<prog>-<date>-name.log" }
98
+ RBatch::Log.new(opt) { | log | log.info("hoge") }
99
+
100
+ File::open(File.join(@log_dir , "rspec-" + Time.now.strftime("%Y%m%d") + "-name.log")) {|f|
101
+ expect(f.read).to match /hoge/
102
+ }
103
+ end
104
+
105
+ it "change log dir" do
106
+ @tmp = File.join(ENV["RB_HOME"],"log3")
107
+ Dir.mkdir(@tmp)
108
+ opt = {:name => "c.log", :dir=> @tmp }
109
+ RBatch::Log.new(opt) { | log | log.info("hoge") }
110
+
111
+ File::open(File.join(@tmp , "c.log")) {|f|
112
+ expect(f.read).to match /hoge/
113
+ }
114
+ FileUtils.rm(File.join(@tmp , "c.log"))
115
+ Dir.rmdir(@tmp)
116
+ end
117
+
118
+ it "is append mode" do
119
+ opt = {:append => true, :name => "a.log" }
120
+ RBatch::Log.new(opt) { | log | log.info("line1") }
121
+
122
+ opt = {:append => true, :name => "a.log" }
123
+ RBatch::Log.new(opt) { | log | log.info("line2") }
124
+
125
+ File::open(File.join(@log_dir , "a.log")) {|f|
126
+ str = f.read
127
+ expect(str).to match /line1/
128
+ expect(str).to match /line2/
129
+ }
130
+ end
131
+
132
+ it "is overwrite mode" do
133
+ opt = {:append => false, :name => "a.log" }
134
+ RBatch::Log.new(opt) { | log | log.info("line1") }
135
+
136
+ opt = {:append => false, :name => "a.log" }
137
+ RBatch::Log.new(opt) { | log | log.info("line2") }
138
+
139
+ File::open(File.join(@log_dir , "a.log")) {|f|
140
+ str = f.read
141
+ expect(str).to_not match /line1/
142
+ expect(str).to match /line2/
143
+ }
144
+ end
145
+
146
+ it "is debug level" do
147
+ opt = { :level => "debug",:name => "a.log" }
148
+ RBatch::Log.new(opt) do | log |
149
+ log.debug("test_debug")
150
+ log.info("test_info")
151
+ log.warn("test_warn")
152
+ log.error("test_error")
153
+ log.fatal("test_fatal")
154
+ end
155
+
156
+ File::open(File.join(@log_dir , "a.log")) {|f|
157
+ str = f.read
158
+ expect(str).to match /test_debug/
159
+ expect(str).to match /test_info/
160
+ expect(str).to match /test_warn/
161
+ expect(str).to match /test_error/
162
+ expect(str).to match /test_fatal/
163
+ }
164
+ end
165
+
166
+ it "is info level" do
167
+ opt = { :level => "info",: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")
174
+ end
175
+
176
+ File::open(File.join(@log_dir , "a.log")) {|f|
177
+ str = f.read
178
+ expect(str).to_not 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 warn level" do
187
+ opt = { :level => "warn",: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")
194
+ 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_not 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 error level" do
207
+ opt = { :level => "error",: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")
214
+ 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_not match /test_warn/
221
+ expect(str).to match /test_error/
222
+ expect(str).to match /test_fatal/
223
+ }
224
+ end
225
+
226
+ it "is fatal level" do
227
+ opt = { :level => "fatal",: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")
234
+ 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_not match /test_error/
242
+ expect(str).to match /test_fatal/
243
+ }
244
+ end
245
+
246
+ it "is default level" do
247
+ opt = {: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")
254
+ 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 match /test_info/
260
+ expect(str).to match /test_warn/
261
+ expect(str).to match /test_error/
262
+ expect(str).to match /test_fatal/
263
+ }
264
+ end
265
+
266
+ it "delete old log which name include <date>" do
267
+ loglist = [*0..20].map do |day|
268
+ File.join(@log_dir , (Date.today - day).strftime("%Y%m%d") + "_test_delete.log")
269
+ end
270
+ FileUtils.touch(loglist)
271
+
272
+ opt = { :name => "<date>_test_delete.log",:delete_old_log => true}
273
+ RBatch::Log.new(opt) { | log | }
274
+
275
+ loglist[1..6].each do |filename|
276
+ expect(File.exists?(filename)).to be true
277
+ end
278
+ loglist[7..20].each do |filename|
279
+ expect(File.exists?(filename)).to be false
280
+ end
281
+ end
282
+
283
+ it "delete old log which name include <date> even if <date> position is changed" do
284
+ loglist = [*0..20].map do |day|
285
+ File.join(@log_dir , "235959-" + (Date.today - day).strftime("%Y%m%d") + "_test_delete.log")
286
+ end
287
+ FileUtils.touch(loglist)
288
+
289
+ opt = { :name => "<time>-<date>_test_delete.log",:delete_old_log => true}
290
+ RBatch::Log.new(opt) { | log | }
291
+
292
+ loglist[1..6].each do |filename|
293
+ expect(File.exists?(filename)).to be true
294
+ end
295
+ loglist[7..20].each do |filename|
296
+ expect(File.exists?(filename)).to be false
297
+ end
298
+ end
299
+
300
+ it "does not delete old log which name does not include <date>" do
301
+ opt = { :name => "test_delete.log",:delete_old_log => true}
302
+ RBatch::Log.new(opt) { | log | }
303
+
304
+ expect(File.exists?(File.join(@log_dir,"test_delete.log"))).to be true
305
+ end
306
+
307
+
308
+ end
309
+
310
+ describe "option by run_conf" do
311
+ it "change log name" do
312
+ @def_vars.merge!({:log_name => "name1.log"})
313
+ RBatch::Log.def_vars = @def_vars
314
+ RBatch::Log.new { | log | log.info("hoge") }
315
+
316
+ File::open(File.join(@log_dir , "name1.log")) {|f|
317
+ expect(f.read).to match /hoge/
318
+ }
319
+ end
320
+
321
+ it "change log dir" do
322
+ @tmp = File.join(ENV["RB_HOME"],"log2")
323
+ Dir.mkdir(@tmp)
324
+ @def_vars.merge!({:log_dir => @tmp})
325
+ RBatch::Log.def_vars = @def_vars
326
+
327
+ opt = {:name => "c.log" }
328
+ RBatch::Log.new(opt) { | log | log.info("hoge") }
329
+
330
+ File::open(File.join(@tmp , "c.log")) {|f|
331
+ expect(f.read).to match /hoge/
332
+ }
333
+ FileUtils.rm(File.join(@tmp , "c.log"))
334
+ Dir.rmdir(@tmp)
335
+ end
336
+ end
337
+ describe "option both run_conf and opt" do
338
+ it "change log name" do
339
+ @def_vars.merge!({:log_name => "name1.log"})
340
+ RBatch::Log.def_vars = @def_vars
341
+
342
+ opt = {:name => "name2.log"}
343
+ RBatch::Log.new(opt) { | log | log.info("hoge") }
344
+
345
+ File::open(File.join(@log_dir , "name2.log")) {|f|
346
+ expect(f.read).to match /hoge/
347
+ }
348
+ end
349
+ end
350
+ end
@@ -1,9 +1,15 @@
1
- require File.expand_path(File.join( File.dirname(__FILE__), 'spec_helper'))
1
+ require 'simplecov'
2
+ SimpleCov.start
2
3
 
3
4
  require 'rbatch/run_conf'
5
+ require 'tmpdir'
4
6
 
5
7
  describe RBatch::RunConf do
6
8
  before :all do
9
+ @HOME_DIR = File.join(Dir.tmpdir, "rbatch_test_" + Time.now.strftime("%Y%m%d%H%M%S"))
10
+ Dir.mkdir(@HOME_DIR)
11
+ ENV["RB_HOME"]=@HOME_DIR
12
+ ENV["RB_VERBOSE"]="0"
7
13
  @home = ENV["RB_HOME"]
8
14
  @config = File.join(@home,"run_conf_test.yaml")
9
15
  end
@@ -11,7 +17,7 @@ describe RBatch::RunConf do
11
17
  before :each do
12
18
  FileUtils.rm @config if File.exists? @config
13
19
  open( @config , "w" ){|f| f.write("")}
14
- @rc = RBatch::RunConf.new(@config,@home)
20
+ @rc = RBatch::RunConf.new(@config)
15
21
  end
16
22
 
17
23
  after :each do
@@ -22,12 +28,14 @@ describe RBatch::RunConf do
22
28
 
23
29
  it "is default when run_conf is empty" do
24
30
  expect(@rc[:log_level]).to eq "info"
31
+ expect(@rc[:conf_dir]).to eq "<home>/conf"
25
32
  end
26
33
 
27
34
  it "is default when run_conf does not exist" do
28
35
  FileUtils.rm @config
29
- tmp = RBatch::RunConf.new(@config,@home)
36
+ tmp = RBatch::RunConf.new(@config)
30
37
  expect(tmp[:log_level]).to eq "info"
38
+ expect(tmp[:conf_dir]).to eq "<home>/conf"
31
39
  end
32
40
 
33
41
  it "raise when key does not exist" do
@@ -36,13 +44,13 @@ describe RBatch::RunConf do
36
44
 
37
45
  it "read run conf" do
38
46
  open( @config , "w" ){|f| f.write("log_level: hoge")}
39
- tmp = RBatch::RunConf.new(@config,@home)
47
+ tmp = RBatch::RunConf.new(@config)
40
48
  expect(tmp[:log_level]).to eq "hoge"
41
49
  end
42
50
 
43
51
  it "raise when run_conf has unreserved key" do
44
52
  open( @config , "w" ){|f| f.write("unreserved: hoge")}
45
- expect{tmp = RBatch::RunConf.new(@config,@home)}.to raise_error(RBatch::RunConf::Exception)
53
+ expect{tmp = RBatch::RunConf.new(@config)}.to raise_error(RBatch::RunConf::Exception)
46
54
  end
47
55
 
48
56
  describe "[]= method" do
@@ -0,0 +1,68 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ require 'tmpdir'
5
+ require 'rbatch/variables'
6
+
7
+ describe RBatch::Variables do
8
+
9
+ before :all do
10
+ @home = File.join(Dir.tmpdir, "rbatch_test_" + Time.now.strftime("%Y%m%d%H%M%S"))
11
+ end
12
+
13
+ before :each do
14
+ ENV["RB_HOME"]=@home
15
+ ENV["RB_VERBOSE"]="0"
16
+ end
17
+
18
+ it "default" do
19
+ @vars = RBatch::Variables.new()
20
+ expect(@vars[:journal_verbose]).to eq 0
21
+ #expect(@vars[:host_name]).to eq ""
22
+ #expect(@vars[:program_name]).to eq "rspec"
23
+ #expect(@vars[:program_path]).to eq "rspec"
24
+ expect(@vars[:program_base]).to eq "rspec"
25
+ expect(@vars[:home_dir]).to eq @home
26
+ expect(@vars[:log_dir]).to eq File.join(@home,"log")
27
+ expect(@vars[:conf_dir]).to eq File.join(@home,"conf")
28
+ expect(@vars[:lib_dir]).to eq File.join(@home,"lib")
29
+ expect(@vars[:run_conf_path]).to eq File.join(@home,".rbatchrc")
30
+ expect(@vars[:config_path]).to eq File.join(@home,"conf","rspec.yaml")
31
+ expect(@vars[:common_config_path]).to eq File.join(@home,"conf","common.yaml")
32
+ expect(@vars.run_conf[:log_dir]).to eq "<home>/log"
33
+ expect(@vars.run_conf[:conf_dir]).to eq "<home>/conf"
34
+ expect(@vars.run_conf[:lib_dir]).to eq "<home>/lib"
35
+ expect(@vars.run_conf[:log_name]).to eq "<date>_<time>_<prog>.log"
36
+ expect(@vars[:log_name]).to_not eq "<date>_<time>_<prog>.log"
37
+ end
38
+
39
+ it "success when ENV Change" do
40
+ ENV["RB_HOME"]="/var"
41
+ ENV["RB_VERBOSE"]="3"
42
+
43
+ @vars = RBatch::Variables.new()
44
+ expect(@vars[:journal_verbose]).to eq 3
45
+ expect(@vars[:home_dir]).to eq "/var"
46
+ expect(@vars[:log_dir]).to eq File.join("/var","log")
47
+ end
48
+
49
+ describe "merge!" do
50
+ it "success" do
51
+ @vars = RBatch::Variables.new()
52
+ @vars.merge!({:log_name => "hoge"})
53
+ expect(@vars[:log_name]).to eq "hoge"
54
+ end
55
+ end
56
+
57
+ describe "run conf" do
58
+ it "return runconf value via method missing" do
59
+ @vars = RBatch::Variables.new()
60
+ expect(@vars[:log_level]).to eq "info"
61
+ end
62
+
63
+ it "raise when key does not exist in run_conf" do
64
+ @vars = RBatch::Variables.new()
65
+ expect{@vars[:hoge]}.to raise_error RBatch::VariablesException
66
+ end
67
+ end
68
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,4 @@
1
- require 'tmpdir'
2
- @HOME_DIR = File.join(Dir.tmpdir, "rbatch_test_" + Time.now.strftime("%Y%m%d%H%M%S"))
3
- Dir.mkdir(@HOME_DIR)
4
- ENV["RB_HOME"]=@HOME_DIR
5
- ENV["RB_VERBOSE"]="0"
1
+ require 'simplecov'
2
+
3
+ SimpleCov.start
4
+
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rbatch
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.1.1
5
+ version: 2.1.2
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-01-10 00:00:00 Z
13
+ date: 2014-01-15 00:00:00 Z
14
14
  dependencies: []
15
15
 
16
16
  description: RBatch has many fanctions to help with your making a batch script such as "data backup script" or "proccess starting script".
@@ -39,11 +39,19 @@ files:
39
39
  - doc/RBatch/CommonConfig/Exception.html
40
40
  - doc/RBatch/Config.html
41
41
  - doc/RBatch/Config/Exception.html
42
+ - doc/RBatch/Controller.html
42
43
  - doc/RBatch/DoubleRunCheckException.html
43
44
  - doc/RBatch/DoubleRunChecker.html
45
+ - doc/RBatch/Journal.html
44
46
  - doc/RBatch/Log.html
47
+ - doc/RBatch/LogException.html
48
+ - doc/RBatch/RBatch.html
49
+ - doc/RBatch/RBatch/RBatch.html
50
+ - doc/RBatch/RBatch/RBatch/ConfigException.html
51
+ - doc/RBatch/RBatch/VariablesException.html
45
52
  - doc/RBatch/RunConf.html
46
53
  - doc/RBatch/RunConf/Exception.html
54
+ - doc/RBatch/Variables.html
47
55
  - doc/created.rid
48
56
  - doc/images/brick.png
49
57
  - doc/images/brick_link.png
@@ -73,20 +81,24 @@ files:
73
81
  - doc/lib/rbatch/cmd_rb.html
74
82
  - doc/lib/rbatch/common_config_rb.html
75
83
  - doc/lib/rbatch/config_rb.html
84
+ - doc/lib/rbatch/controller_rb.html
76
85
  - doc/lib/rbatch/double_run_checker_rb.html
86
+ - doc/lib/rbatch/journal_rb.html
77
87
  - doc/lib/rbatch/log_rb.html
78
88
  - doc/lib/rbatch/run_conf_rb.html
89
+ - doc/lib/rbatch/variables_rb.html
79
90
  - doc/lib/rbatch/version_rb.html
80
91
  - doc/lib/rbatch_rb.html
81
92
  - doc/rdoc.css
82
93
  - lib/rbatch.rb
83
94
  - lib/rbatch/cmd.rb
84
- - lib/rbatch/common_config.rb
85
95
  - lib/rbatch/config.rb
86
96
  - lib/rbatch/controller.rb
87
97
  - lib/rbatch/double_run_checker.rb
98
+ - lib/rbatch/journal.rb
88
99
  - lib/rbatch/log.rb
89
100
  - lib/rbatch/run_conf.rb
101
+ - lib/rbatch/variables.rb
90
102
  - lib/rbatch/version.rb
91
103
  - rbatch.gemspec
92
104
  - sample/.rbatchrc
@@ -118,13 +130,15 @@ files:
118
130
  - sample/data/amAuthentication.error.2012-07-10
119
131
  - sample/lib/openidm_common_func.rb
120
132
  - sample/log/empty
121
- - spec/cmd_spec.rb
122
- - spec/common_config_spec.rb
123
- - spec/config_spec.rb
124
- - spec/double_run_checker_spec.rb
125
- - spec/log_spec.rb
126
- - spec/rbatch_spec.rb
127
- - spec/run_conf_spec.rb
133
+ - spec/01_rbach_spec.rb
134
+ - spec/rbatch/cmd_spec.rb
135
+ - spec/rbatch/config_spec.rb
136
+ - spec/rbatch/controller_spec.rb
137
+ - spec/rbatch/double_run_checker_spec.rb
138
+ - spec/rbatch/journal_spec.rb
139
+ - spec/rbatch/log_spec.rb
140
+ - spec/rbatch/run_conf_spec.rb
141
+ - spec/rbatch/variables_spec.rb
128
142
  - spec/spec_helper.rb
129
143
  homepage: https://github.com/fetaro/rbatch
130
144
  licenses:
@@ -154,11 +168,13 @@ signing_key:
154
168
  specification_version: 3
155
169
  summary: Ruby-based simple batch framework
156
170
  test_files:
157
- - spec/cmd_spec.rb
158
- - spec/common_config_spec.rb
159
- - spec/config_spec.rb
160
- - spec/double_run_checker_spec.rb
161
- - spec/log_spec.rb
162
- - spec/rbatch_spec.rb
163
- - spec/run_conf_spec.rb
171
+ - spec/01_rbach_spec.rb
172
+ - spec/rbatch/cmd_spec.rb
173
+ - spec/rbatch/config_spec.rb
174
+ - spec/rbatch/controller_spec.rb
175
+ - spec/rbatch/double_run_checker_spec.rb
176
+ - spec/rbatch/journal_spec.rb
177
+ - spec/rbatch/log_spec.rb
178
+ - spec/rbatch/run_conf_spec.rb
179
+ - spec/rbatch/variables_spec.rb
164
180
  - spec/spec_helper.rb
File without changes
@@ -1,85 +0,0 @@
1
- require File.expand_path(File.join( File.dirname(__FILE__), 'spec_helper'))
2
-
3
- require 'rbatch'
4
-
5
- describe RBatch::Config do
6
- before :all do
7
- @config_dir=File.join(ENV["RB_HOME"],"conf")
8
- @config_file = File.join(@config_dir , "common.yaml")
9
- Dir::mkdir @config_dir if ! Dir.exists? @config_dir
10
- end
11
-
12
- before :each do
13
- end
14
-
15
- after :each do
16
- FileUtils.rm @config_file if File.exists? @config_file
17
- end
18
-
19
- after :all do
20
- end
21
-
22
- it "read config" do
23
- open( @config_file , "w" ){|f| f.write("key: value")}
24
- RBatch.init
25
- expect(RBatch.common_config["key"]).to eq "value"
26
- end
27
-
28
- it "read config. Key is Symbol" do
29
- open( @config_file , "w" ){|f| f.write(":key: value")}
30
- RBatch.init
31
- expect(RBatch.common_config[:key]).to eq "value"
32
- end
33
-
34
- it "raise error when config does not exist" do
35
- RBatch.init
36
- expect {
37
- RBatch.common_config["hoge"]
38
- }.to raise_error(RBatch::Config::Exception)
39
- expect {
40
- RBatch.common_config.to_h
41
- }.to raise_error(RBatch::Config::Exception)
42
- expect {
43
- RBatch.common_config.to_s
44
- }.to raise_error(RBatch::Config::Exception)
45
- end
46
-
47
- it "read config twice" do
48
- open( @config_file , "w" ){|f| f.write("key: value")}
49
- RBatch.init
50
- expect(RBatch.common_config["key"]).to eq "value"
51
- expect(RBatch.common_config["key"]).to eq "value"
52
- end
53
-
54
- it "raise error when read value which key does not exist" do
55
- open( @config_file , "w" ){|f| f.write("key: value")}
56
- RBatch.init
57
- expect {
58
- RBatch.common_config["not_exist"]
59
- }.to raise_error(RBatch::Config::Exception)
60
- end
61
-
62
- it "raise error when read value which key mistake String for Symbol" do
63
- open( @config_file , "w" ){|f| f.write(":key: value")}
64
- RBatch.init
65
- expect {
66
- RBatch.common_config["key"]
67
- }.to raise_error(RBatch::Config::Exception)
68
- end
69
-
70
- it "raise error when read value which key mistake Symbol for String" do
71
- open( @config_file , "w" ){|f| f.write("key: value")}
72
- RBatch.init
73
- expect {
74
- RBatch.common_config[:key]
75
- }.to raise_error(RBatch::Config::Exception)
76
- end
77
-
78
- it "success when common_conf_name changed" do
79
- conf=File.join(RBatch.ctrl.conf_dir,"global.yaml")
80
- open( conf , "w" ){|f| f.write("key4: value4")}
81
- open( RBatch.run_conf_path , "w" ){|f| f.write("common_conf_name: global.yaml")}
82
- RBatch.init
83
- expect(RBatch.common_config["key4"]).to eq "value4"
84
- end
85
- end