rbatch 1.13.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +15 -0
- data/README.ja.md +81 -49
- data/README.md +88 -63
- data/Rakefile +2 -31
- data/bin/rbatch-init +57 -32
- data/{rdocs → doc}/RBatch/Cmd.html +66 -59
- data/{rdocs → doc}/RBatch/CmdException.html +9 -3
- data/{rdocs → doc}/RBatch/CmdResult.html +40 -34
- data/{rdocs → doc}/RBatch/CommonConfig/Exception.html +9 -3
- data/{rdocs → doc}/RBatch/CommonConfig.html +22 -17
- data/{rdocs → doc}/RBatch/Config/Exception.html +9 -3
- data/{rdocs → doc}/RBatch/Config.html +21 -16
- data/{rdocs/RBatchException.html → doc/RBatch/DoubleRunCheckException.html} +33 -30
- data/doc/RBatch/DoubleRunChecker.html +277 -0
- data/{rdocs → doc}/RBatch/Log.html +134 -138
- data/doc/RBatch/RunConf/Exception.html +159 -0
- data/doc/RBatch/RunConf.html +557 -0
- data/doc/RBatch.html +655 -0
- data/doc/created.rid +9 -0
- data/{rdocs → doc}/index.html +46 -20
- data/{rdocs → doc}/lib/rbatch/cmd_rb.html +4 -2
- data/{rdocs → doc}/lib/rbatch/common_config_rb.html +2 -2
- data/{rdocs → doc}/lib/rbatch/config_rb.html +2 -2
- data/doc/lib/rbatch/double_run_checker_rb.html +56 -0
- data/{rdocs → doc}/lib/rbatch/log_rb.html +2 -2
- data/doc/lib/rbatch/run_conf_rb.html +56 -0
- data/{rdocs → doc}/lib/rbatch/version_rb.html +2 -2
- data/{rdocs → doc}/lib/rbatch_rb.html +7 -3
- data/lib/rbatch/cmd.rb +20 -23
- data/lib/rbatch/common_config.rb +2 -3
- data/lib/rbatch/config.rb +1 -2
- data/lib/rbatch/double_run_checker.rb +24 -0
- data/lib/rbatch/log.rb +37 -59
- data/lib/rbatch/run_conf.rb +109 -0
- data/lib/rbatch/version.rb +1 -1
- data/lib/rbatch.rb +37 -56
- data/spec/{cmd_test.spec → cmd_spec.rb} +6 -6
- data/spec/common_config_spec.rb +54 -0
- data/spec/{config_test.spec → config_spec.rb} +2 -1
- data/spec/double_run_checker_spec.rb +10 -0
- data/spec/{log_test.spec → log_spec.rb} +22 -22
- data/spec/rbatch_spec.rb +24 -0
- data/spec/run_conf_spec.rb +85 -0
- metadata +66 -65
- data/rdocs/RBatch.html +0 -713
- data/rdocs/created.rid +0 -7
- data/spec/rbatch_test.spec +0 -25
- data/test/cases/test_cmd.rb +0 -134
- data/test/cases/test_common_config.rb +0 -41
- data/test/cases/test_config.rb +0 -41
- data/test/cases/test_log.rb +0 -613
- data/test/mocks/PrintArgs.exe +0 -0
- data/test/mocks/win_cmd.exe +0 -0
- /data/{rdocs → doc}/images/brick.png +0 -0
- /data/{rdocs → doc}/images/brick_link.png +0 -0
- /data/{rdocs → doc}/images/bug.png +0 -0
- /data/{rdocs → doc}/images/bullet_black.png +0 -0
- /data/{rdocs → doc}/images/bullet_toggle_minus.png +0 -0
- /data/{rdocs → doc}/images/bullet_toggle_plus.png +0 -0
- /data/{rdocs → doc}/images/date.png +0 -0
- /data/{rdocs → doc}/images/find.png +0 -0
- /data/{rdocs → doc}/images/loadingAnimation.gif +0 -0
- /data/{rdocs → doc}/images/macFFBgHack.png +0 -0
- /data/{rdocs → doc}/images/package.png +0 -0
- /data/{rdocs → doc}/images/page_green.png +0 -0
- /data/{rdocs → doc}/images/page_white_text.png +0 -0
- /data/{rdocs → doc}/images/page_white_width.png +0 -0
- /data/{rdocs → doc}/images/plugin.png +0 -0
- /data/{rdocs → doc}/images/ruby.png +0 -0
- /data/{rdocs → doc}/images/tag_green.png +0 -0
- /data/{rdocs → doc}/images/wrench.png +0 -0
- /data/{rdocs → doc}/images/wrench_orange.png +0 -0
- /data/{rdocs → doc}/images/zoom.png +0 -0
- /data/{rdocs → doc}/js/darkfish.js +0 -0
- /data/{rdocs → doc}/js/jquery.js +0 -0
- /data/{rdocs → doc}/js/quicksearch.js +0 -0
- /data/{rdocs → doc}/js/thickbox-compressed.js +0 -0
- /data/{rdocs → doc}/rdoc.css +0 -0
data/rdocs/created.rid
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
Thu, 19 Dec 2013 01:48:51 +0900
|
2
|
-
lib/rbatch/config.rb Thu, 19 Dec 2013 01:48:36 +0900
|
3
|
-
lib/rbatch/version.rb Thu, 19 Dec 2013 01:48:36 +0900
|
4
|
-
lib/rbatch/cmd.rb Sun, 01 Dec 2013 17:31:01 +0900
|
5
|
-
lib/rbatch/common_config.rb Thu, 19 Dec 2013 01:48:36 +0900
|
6
|
-
lib/rbatch/log.rb Thu, 19 Dec 2013 01:48:36 +0900
|
7
|
-
lib/rbatch.rb Thu, 19 Dec 2013 01:48:36 +0900
|
data/spec/rbatch_test.spec
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'rbatch'
|
2
|
-
|
3
|
-
describe RBatch do
|
4
|
-
before :all do
|
5
|
-
RBatch.home_dir=Dir.tmpdir
|
6
|
-
@config_dir=File.join(RBatch.home_dir,"conf")
|
7
|
-
@config_file = File.join(@config_dir , "rbatch.yaml")
|
8
|
-
Dir::mkdir @config_dir if ! Dir.exists? @config_dir
|
9
|
-
end
|
10
|
-
|
11
|
-
before :each do
|
12
|
-
end
|
13
|
-
|
14
|
-
it "makes lock file when forbid_double_run is enable" do
|
15
|
-
open( @config_file , "w" ){|f| f.write("forbid_double_run: true")}
|
16
|
-
end
|
17
|
-
|
18
|
-
after :each do
|
19
|
-
FileUtils.rm @config_file if File.exists? @config_file
|
20
|
-
end
|
21
|
-
|
22
|
-
after :all do
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
data/test/cases/test_cmd.rb
DELETED
@@ -1,134 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'rbatch'
|
3
|
-
|
4
|
-
class RuncherTest < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
@config_dir = File.join(File.dirname(RBatch.program_name), "..", "conf")
|
7
|
-
Dir::mkdir(@config_dir) if ! Dir.exists? @config_dir
|
8
|
-
confstr = ""
|
9
|
-
open( RBatch.rbatch_config_path , "w" ){|f| f.write(confstr)}
|
10
|
-
RBatch.load_rbatch_config
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_cmd_exists
|
14
|
-
result = RBatch::cmd "ruby -e 'STDOUT.print 1; STDERR.print 2; exit 0;'"
|
15
|
-
assert_equal "1", result.stdout.chomp
|
16
|
-
assert_equal "2", result.stderr.chomp
|
17
|
-
assert_equal 0, result.status
|
18
|
-
end
|
19
|
-
def test_cmd_does_not_exist
|
20
|
-
assert_raise(Errno::ENOENT){
|
21
|
-
RBatch::cmd "not_exist_command"
|
22
|
-
}
|
23
|
-
end
|
24
|
-
def test_stdout_size_greater_than_65534
|
25
|
-
result = RBatch::cmd "ruby -e '100000.times{print 0}'"
|
26
|
-
assert_equal 100000, result.stdout.chomp.size
|
27
|
-
assert_equal "", result.stderr.chomp
|
28
|
-
assert_equal 0, result.status
|
29
|
-
end
|
30
|
-
def test_stdout_size_greater_than_65534_with_status_1
|
31
|
-
result = RBatch::cmd "ruby -e '100000.times{print 0}; exit 1'"
|
32
|
-
assert_equal 100000, result.stdout.chomp.size
|
33
|
-
assert_equal "", result.stderr.chomp
|
34
|
-
assert_equal 1, result.status
|
35
|
-
end
|
36
|
-
def test_status_code_is_1
|
37
|
-
result = RBatch::cmd "ruby -e 'STDOUT.print 1; STDERR.print 2; exit 1;'"
|
38
|
-
assert_equal "1", result.stdout.chomp
|
39
|
-
assert_equal "2", result.stderr.chomp
|
40
|
-
assert_equal 1, result.status
|
41
|
-
end
|
42
|
-
def test_status_code_is_greater_than_256
|
43
|
-
returncode = 300
|
44
|
-
result = RBatch::cmd "ruby -e 'STDOUT.print 1; STDERR.print 2; exit #{returncode};'"
|
45
|
-
assert_equal "1", result.stdout.chomp
|
46
|
-
assert_equal "2", result.stderr.chomp
|
47
|
-
case RUBY_PLATFORM
|
48
|
-
when /mswin|mingw/
|
49
|
-
assert_equal returncode, result.status
|
50
|
-
when /cygwin|linux/
|
51
|
-
assert_equal returncode % 256, result.status
|
52
|
-
end
|
53
|
-
end
|
54
|
-
def test_to_h
|
55
|
-
result = RBatch::cmd "ruby -e 'STDOUT.print 1; STDERR.print 2; exit 1;'"
|
56
|
-
assert_equal "1", result.to_h[:stdout]
|
57
|
-
assert_equal "2", result.to_h[:stderr]
|
58
|
-
assert_equal 1 , result.to_h[:status]
|
59
|
-
end
|
60
|
-
def test_to_s
|
61
|
-
result = RBatch::cmd "ruby -e 'STDOUT.print 1; STDERR.print 2; exit 1;'"
|
62
|
-
assert_equal "{:cmd_str=>\"ruby -e 'STDOUT.print 1; STDERR.print 2; exit 1;'\", :stdout=>\"1\", :stderr=>\"2\", :status=>1}", result.to_s
|
63
|
-
end
|
64
|
-
def test_nil_command
|
65
|
-
assert_raise(RBatch::CmdException){
|
66
|
-
RBatch::Cmd.new(nil)
|
67
|
-
}
|
68
|
-
end
|
69
|
-
def test_fullcmd_exists
|
70
|
-
result = RBatch::Cmd.new("ruby -e 'STDOUT.print 1; STDERR.print 2; exit 0;'").run
|
71
|
-
assert_equal "1", result.stdout.chomp
|
72
|
-
assert_equal "2", result.stderr.chomp
|
73
|
-
assert_equal 0, result.status
|
74
|
-
end
|
75
|
-
def test_opt_raise_true_status_1
|
76
|
-
cmd_str = "ruby -e 'STDOUT.print 1; STDERR.print 2; exit 1;'"
|
77
|
-
opt = {:raise => true}
|
78
|
-
assert_raise(RBatch::CmdException){
|
79
|
-
RBatch::Cmd.new(cmd_str,opt).run
|
80
|
-
}
|
81
|
-
end
|
82
|
-
def test_opt_raise_false_status_1
|
83
|
-
cmd_str = "ruby -e 'STDOUT.print 1; STDERR.print 2; exit 1;'"
|
84
|
-
opt = {:raise => false}
|
85
|
-
result = RBatch::Cmd.new(cmd_str,opt).run
|
86
|
-
assert_equal "1", result.stdout.chomp
|
87
|
-
assert_equal "2", result.stderr.chomp
|
88
|
-
assert_equal 1, result.status
|
89
|
-
end
|
90
|
-
def test_opt_raise_true_status_0
|
91
|
-
cmd_str = "ruby -e 'STDOUT.print 1; STDERR.print 2; exit 0;'"
|
92
|
-
opt = {:raise => true}
|
93
|
-
result = RBatch::Cmd.new(cmd_str,opt).run
|
94
|
-
assert_equal "1", result.stdout.chomp
|
95
|
-
assert_equal "2", result.stderr.chomp
|
96
|
-
assert_equal 0, result.status
|
97
|
-
end
|
98
|
-
def test_opt_raise_false_status_0
|
99
|
-
cmd_str = "ruby -e 'STDOUT.print 1; STDERR.print 2; exit 0;'"
|
100
|
-
opt = {:raise => false}
|
101
|
-
result = RBatch::Cmd.new(cmd_str,opt).run
|
102
|
-
assert_equal "1", result.stdout.chomp
|
103
|
-
assert_equal "2", result.stderr.chomp
|
104
|
-
assert_equal 0, result.status
|
105
|
-
end
|
106
|
-
def test_opt_raise_true_status_1_by_conf
|
107
|
-
confstr = "cmd_raise: true "
|
108
|
-
open( RBatch.rbatch_config_path , "a" ){|f| f.write(confstr)}
|
109
|
-
RBatch.load_rbatch_config
|
110
|
-
cmd_str = "ruby -e 'STDOUT.print 1; STDERR.print 2; exit 1;'"
|
111
|
-
assert_raise(RBatch::CmdException){
|
112
|
-
RBatch::Cmd.new(cmd_str).run
|
113
|
-
}
|
114
|
-
end
|
115
|
-
def test_opt_raise_true_status_1_shortcut
|
116
|
-
cmd_str = "ruby -e 'STDOUT.print 1; STDERR.print 2; exit 1;'"
|
117
|
-
opt = {:raise => true}
|
118
|
-
assert_raise(RBatch::CmdException){
|
119
|
-
RBatch::cmd(cmd_str,opt)
|
120
|
-
}
|
121
|
-
end
|
122
|
-
def test_opt_timeout
|
123
|
-
cmd_str = "ruby -e 'sleep 2'"
|
124
|
-
opt = {:timeout => 1}
|
125
|
-
assert_raise(RBatch::CmdException){
|
126
|
-
RBatch::cmd(cmd_str,opt)
|
127
|
-
}
|
128
|
-
end
|
129
|
-
def test_opt_timeout
|
130
|
-
cmd_str = "ruby -e 'sleep 1'"
|
131
|
-
opt = {:timeout => 2}
|
132
|
-
RBatch::cmd(cmd_str,opt)
|
133
|
-
end
|
134
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'rbatch'
|
3
|
-
|
4
|
-
class RuncherTest < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
@config_dir = File.join(File.dirname(RBatch.program_name), "..", "conf")
|
7
|
-
@config_file = File.join(@config_dir,"common.yaml")
|
8
|
-
Dir::mkdir(@config_dir) if ! Dir.exists? @config_dir
|
9
|
-
end
|
10
|
-
|
11
|
-
def teardown
|
12
|
-
File.delete @config_file if File.exist? @config_file
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_require
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_config
|
19
|
-
open( @config_file , "w" ){|f| f.write("key: value")}
|
20
|
-
assert_equal "value", RBatch.common_config["key"]
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_read_error
|
24
|
-
assert_raise(Errno::ENOENT){
|
25
|
-
RBatch.common_config
|
26
|
-
}
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_double_read
|
30
|
-
open( @config_file , "w" ){|f| f.write("key: value")}
|
31
|
-
assert_equal "value", RBatch.common_config["key"]
|
32
|
-
assert_equal "value", RBatch.common_config["key"]
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_not_exist_key
|
36
|
-
open( @config_file , "w" ){|f| f.write("key: value")}
|
37
|
-
assert_raise(RBatch::CommonConfig::Exception){
|
38
|
-
RBatch.common_config["not_exist"]
|
39
|
-
}
|
40
|
-
end
|
41
|
-
end
|
data/test/cases/test_config.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'rbatch'
|
3
|
-
|
4
|
-
class RuncherTest < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
@config_dir = File.join(File.dirname(RBatch.program_name), "..", "conf")
|
7
|
-
@config_file = File.join(@config_dir , "test_config.yaml")
|
8
|
-
Dir::mkdir(@config_dir) if ! Dir.exists? @config_dir
|
9
|
-
end
|
10
|
-
|
11
|
-
def teardown
|
12
|
-
File.delete @config_file if File.exist? @config_file
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_require
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_config
|
19
|
-
open( @config_file , "w" ){|f| f.write("key: value")}
|
20
|
-
assert_equal "value", RBatch.config["key"]
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_read_error
|
24
|
-
assert_raise(Errno::ENOENT){
|
25
|
-
RBatch.config
|
26
|
-
}
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_double_read
|
30
|
-
open( @config_file , "w" ){|f| f.write("key: value")}
|
31
|
-
assert_equal "value", RBatch.config["key"]
|
32
|
-
assert_equal "value", RBatch.config["key"]
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_not_exist_key
|
36
|
-
open( @config_file , "w" ){|f| f.write("key: value")}
|
37
|
-
assert_raise(RBatch::Config::Exception){
|
38
|
-
RBatch.config["not_exist"]
|
39
|
-
}
|
40
|
-
end
|
41
|
-
end
|