command_wrap 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of command_wrap might be problematic. Click here for more details.
- data/bin/xvfb_server.rb +4 -0
- data/lib/command_wrap.rb +5 -4
- data/lib/command_wrap/config/xvfb.rb +40 -1
- data/lib/command_wrap/xvfb.rb +9 -0
- data/lib/command_wrap/xvfb/server.rb +23 -0
- data/tests/unit/config_xvfb_test.rb +45 -0
- data/tests/unit/xvfb_server_test.rb +11 -0
- metadata +9 -4
data/bin/xvfb_server.rb
ADDED
data/lib/command_wrap.rb
CHANGED
@@ -115,9 +115,10 @@ module CommandWrap
|
|
115
115
|
''
|
116
116
|
end
|
117
117
|
|
118
|
-
autoload :Image,
|
119
|
-
autoload :OpenOffice,
|
120
|
-
autoload :Config,
|
121
|
-
autoload :Pdf,
|
118
|
+
autoload :Image, File.dirname(__FILE__) + '/command_wrap/image'
|
119
|
+
autoload :OpenOffice, File.dirname(__FILE__) + '/command_wrap/open_office'
|
120
|
+
autoload :Config, File.dirname(__FILE__) + '/command_wrap/config'
|
121
|
+
autoload :Pdf, File.dirname(__FILE__) + '/command_wrap/pdf'
|
122
|
+
autoload :Xvfb, File.dirname(__FILE__) + '/command_wrap/xvfb'
|
122
123
|
|
123
124
|
end
|
@@ -19,7 +19,46 @@ module CommandWrap::Config
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.command (subcommand)
|
22
|
-
|
22
|
+
if server_mode
|
23
|
+
"DISPLAY=:#{server_port};#{subcommand}"
|
24
|
+
else
|
25
|
+
"#{executable} #{params} #{subcommand}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.server_mode
|
30
|
+
if @server_mode.nil?
|
31
|
+
@server_mode = false
|
32
|
+
end
|
33
|
+
@server_mode
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.server_mode= (server_mode)
|
37
|
+
@server_mode = server_mode
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.server_port
|
41
|
+
@server_port ||= '35'
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.server_port= (server_port)
|
45
|
+
@server_port = server_port
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.server_command
|
49
|
+
@server_command ||= 'Xvfb :35 -screen 0 1024x768x24'
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.server_command= (server_command)
|
53
|
+
@server_command = server_command
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.stop_server_command
|
57
|
+
@server_stop ||= "killall -9 Xvfb"
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.stop_server_command= (server_stop)
|
61
|
+
@server_stop = server_stop
|
23
62
|
end
|
24
63
|
|
25
64
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module CommandWrap::Xvfb
|
2
|
+
|
3
|
+
module Server
|
4
|
+
|
5
|
+
def self.start
|
6
|
+
fork do
|
7
|
+
exec CommandWrap::Config::Xvfb.server_command
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.stop
|
12
|
+
`#{CommandWrap::Config::Xvfb.stop_server_command}`
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.restart
|
16
|
+
stop
|
17
|
+
sleep 5
|
18
|
+
start
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -30,5 +30,50 @@ class ConfigXvfbTest < Test::Unit::TestCase
|
|
30
30
|
def test_command
|
31
31
|
assert_equal 'xvfb-run --wait=0 --server-args="-screen 0, 1024x768x24" echo "test"', CommandWrap::Config::Xvfb.command('echo "test"')
|
32
32
|
end
|
33
|
+
|
34
|
+
def test_server_mode
|
35
|
+
assert_nothing_raised do
|
36
|
+
assert_equal false, CommandWrap::Config::Xvfb.server_mode
|
37
|
+
CommandWrap::Config::Xvfb.server_mode = true
|
38
|
+
assert_equal true, CommandWrap::Config::Xvfb.server_mode
|
39
|
+
CommandWrap::Config::Xvfb.server_mode = false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_server_port
|
44
|
+
assert_nothing_raised do
|
45
|
+
assert_equal '35', CommandWrap::Config::Xvfb.server_port
|
46
|
+
CommandWrap::Config::Xvfb.server_port = '15'
|
47
|
+
assert_equal '15', CommandWrap::Config::Xvfb.server_port
|
48
|
+
CommandWrap::Config::Xvfb.server_port = '35'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_server_command
|
53
|
+
assert_nothing_raised do
|
54
|
+
assert_equal 'Xvfb :35 -screen 0 1024x768x24', CommandWrap::Config::Xvfb.server_command
|
55
|
+
CommandWrap::Config::Xvfb.server_command = 'Xvfb :15 -screen 0 1024x768x24'
|
56
|
+
assert_equal 'Xvfb :15 -screen 0 1024x768x24', CommandWrap::Config::Xvfb.server_command
|
57
|
+
CommandWrap::Config::Xvfb.server_command = 'Xvfb :35 -screen 0 1024x768x24'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_stop_server_command
|
62
|
+
assert_nothing_raised do
|
63
|
+
assert_equal 'killall -9 Xvfb', CommandWrap::Config::Xvfb.stop_server_command
|
64
|
+
CommandWrap::Config::Xvfb.stop_server_command = 'dummy'
|
65
|
+
assert_equal 'dummy', CommandWrap::Config::Xvfb.stop_server_command
|
66
|
+
CommandWrap::Config::Xvfb.stop_server_command = 'killall -9 Xvfb'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_command_server_mode
|
71
|
+
begin
|
72
|
+
CommandWrap::Config::Xvfb.server_mode = true
|
73
|
+
assert_equal 'DISPLAY=:35;ksnapshot', CommandWrap::Config::Xvfb.command('ksnapshot')
|
74
|
+
ensure
|
75
|
+
CommandWrap::Config::Xvfb.server_mode = false
|
76
|
+
end
|
77
|
+
end
|
33
78
|
|
34
79
|
end
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: command_wrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: "0.
|
8
|
+
- 3
|
9
|
+
version: "0.3"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Stefaan Colman
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-03-
|
17
|
+
date: 2011-03-10 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -47,9 +47,12 @@ files:
|
|
47
47
|
- lib/command_wrap/config/open_office.rb
|
48
48
|
- lib/command_wrap/config/xvfb.rb
|
49
49
|
- lib/command_wrap/open_office/server.rb
|
50
|
+
- lib/command_wrap/xvfb/server.rb
|
51
|
+
- lib/command_wrap/xvfb.rb
|
50
52
|
- lib/command_wrap/image.rb
|
51
53
|
- lib/command_wrap/pdf.rb
|
52
54
|
- lib/command_wrap.rb
|
55
|
+
- tests/unit/xvfb_server_test.rb
|
53
56
|
- tests/unit/command_wrap_test.rb
|
54
57
|
- tests/unit/pdf_test.rb
|
55
58
|
- tests/unit/config_test.rb
|
@@ -70,6 +73,7 @@ files:
|
|
70
73
|
- tests/helpers/pdf2.pdf
|
71
74
|
- tests/test_helper.rb
|
72
75
|
- README
|
76
|
+
- bin/xvfb_server.rb
|
73
77
|
- bin/wkhtmltopdf
|
74
78
|
- bin/CutyCapt
|
75
79
|
- bin/openoffice_server.rb
|
@@ -109,6 +113,7 @@ signing_key:
|
|
109
113
|
specification_version: 3
|
110
114
|
summary: Extracting meta data from file
|
111
115
|
test_files:
|
116
|
+
- tests/unit/xvfb_server_test.rb
|
112
117
|
- tests/unit/command_wrap_test.rb
|
113
118
|
- tests/unit/pdf_test.rb
|
114
119
|
- tests/unit/config_test.rb
|