php_process 0.0.11 → 0.0.12
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/VERSION +1 -1
- data/lib/php_process.rb +26 -3
- data/lib/php_script.php +31 -0
- data/php_process.gemspec +10 -9
- data/spec/php_process_spec.rb +205 -168
- data/spec/strip_error_spec.rb +11 -0
- metadata +54 -20
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.12
|
data/lib/php_process.rb
CHANGED
@@ -287,7 +287,17 @@ class Php_process
|
|
287
287
|
end
|
288
288
|
|
289
289
|
@responses[id] = Queue.new
|
290
|
-
|
290
|
+
|
291
|
+
begin
|
292
|
+
@stdin.write("send:#{id}:#{str}\n")
|
293
|
+
rescue Errno::EPIPE => e
|
294
|
+
#Wait for fatal error and then throw it.
|
295
|
+
Thread.pass
|
296
|
+
check_alive
|
297
|
+
|
298
|
+
#Or just throw the normal error.
|
299
|
+
raise e
|
300
|
+
end
|
291
301
|
|
292
302
|
#Then return result.
|
293
303
|
return read_result(id)
|
@@ -296,7 +306,20 @@ class Php_process
|
|
296
306
|
#Searches for a result for a ID and returns it. Runs 'check_alive' to see if the process should be interrupted.
|
297
307
|
def read_result(id)
|
298
308
|
$stderr.print "Waiting for answer to ID: #{id}\n" if @debug
|
299
|
-
|
309
|
+
check_alive
|
310
|
+
|
311
|
+
begin
|
312
|
+
resp = @responses[id].pop
|
313
|
+
rescue Exception => e
|
314
|
+
if e.class.name == "fatal"
|
315
|
+
#Wait for fatal error to be registered through thread and then throw it.
|
316
|
+
Thread.pass
|
317
|
+
check_alive
|
318
|
+
end
|
319
|
+
|
320
|
+
raise e
|
321
|
+
end
|
322
|
+
|
300
323
|
@responses.delete(id)
|
301
324
|
raise "#{resp["msg"]}\n\n#{resp["bt"]}" if resp.is_a?(Hash) and resp["type"] == "error"
|
302
325
|
$stderr.print "Found answer #{id} - returning it.\n" if @debug
|
@@ -305,7 +328,7 @@ class Php_process
|
|
305
328
|
|
306
329
|
#Checks if something is wrong. Maybe stdout got closed or a fatal error appeared on stderr?
|
307
330
|
def check_alive
|
308
|
-
raise "stdout closed." if
|
331
|
+
raise "stdout closed." if !@stdout or @stdout.closed?
|
309
332
|
raise @fatal if @fatal
|
310
333
|
end
|
311
334
|
|
data/lib/php_script.php
CHANGED
@@ -329,7 +329,38 @@ class php_process{
|
|
329
329
|
"created_functions" => count($this->created_functions)
|
330
330
|
));
|
331
331
|
}
|
332
|
+
|
333
|
+
//Makes errors being thrown as exceptions instead.
|
334
|
+
function error_handler($errno, $errmsg, $filename, $linenum, $vars, $args = null){
|
335
|
+
$errortypes = array (
|
336
|
+
E_ERROR => 'Error',
|
337
|
+
E_WARNING => 'Warning',
|
338
|
+
E_PARSE => 'Parsing Error',
|
339
|
+
E_NOTICE => 'Notice',
|
340
|
+
E_CORE_ERROR => 'Core Error',
|
341
|
+
E_CORE_WARNING => 'Core Warning',
|
342
|
+
E_COMPILE_ERROR => 'Compile Error',
|
343
|
+
E_COMPILE_WARNING => 'Compile Warning',
|
344
|
+
E_USER_ERROR => 'User Error',
|
345
|
+
E_USER_WARNING => 'User Warning',
|
346
|
+
E_USER_NOTICE => 'User Notice',
|
347
|
+
E_STRICT => 'Runtime Notice'
|
348
|
+
);
|
349
|
+
|
350
|
+
if ($errno == E_STRICT or $errno == E_NOTICE){
|
351
|
+
return null;
|
352
|
+
}
|
353
|
+
|
354
|
+
throw new exception("Error " . $errortypes[$errno] . ": " . $errmsg . " in \"" . $filename . ":" . $linenum);
|
355
|
+
}
|
332
356
|
}
|
333
357
|
|
358
|
+
//Spawn the main object.
|
334
359
|
$php_process = new php_process();
|
360
|
+
|
361
|
+
//Set error-level and make warnings and errors being thrown as exceptions.
|
362
|
+
set_error_handler(array($php_process, "error_handler"));
|
363
|
+
error_reporting(E_ALL ^ E_NOTICE ^ E_STRIC);
|
364
|
+
|
365
|
+
//Start listening for instructions from host process.
|
335
366
|
$php_process->start_listening();
|
data/php_process.gemspec
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.0.
|
7
|
+
s.name = "php_process"
|
8
|
+
s.version = "0.0.12"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kasper Johansen"]
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
12
|
+
s.date = "2013-02-20"
|
13
|
+
s.description = "Spawns a PHP process and proxies calls to it, making it possible to proxy objects and more."
|
14
|
+
s.email = "k@spernj.org"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE.txt",
|
17
17
|
"README.rdoc"
|
@@ -29,13 +29,14 @@ Gem::Specification.new do |s|
|
|
29
29
|
"lib/php_script.php",
|
30
30
|
"php_process.gemspec",
|
31
31
|
"spec/php_process_spec.rb",
|
32
|
-
"spec/spec_helper.rb"
|
32
|
+
"spec/spec_helper.rb",
|
33
|
+
"spec/strip_error_spec.rb"
|
33
34
|
]
|
34
|
-
s.homepage =
|
35
|
+
s.homepage = "http://github.com/kaspernj/php_process"
|
35
36
|
s.licenses = ["MIT"]
|
36
37
|
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version =
|
38
|
-
s.summary =
|
38
|
+
s.rubygems_version = "1.8.25"
|
39
|
+
s.summary = "Ruby-to-PHP bridge"
|
39
40
|
|
40
41
|
if s.respond_to? :specification_version then
|
41
42
|
s.specification_version = 3
|
data/spec/php_process_spec.rb
CHANGED
@@ -8,185 +8,222 @@ describe "PhpProcess" do
|
|
8
8
|
|
9
9
|
|
10
10
|
#Spawn PHP-process.
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
raise "Expected const to be 5 but it wasnt: #{const}." if const != 5
|
11
|
+
Php_process.new(:debug => false, :debug_stderr => true) do |php|
|
12
|
+
#It should be able to handle constants very fast by using cache.
|
13
|
+
php.func("define", "TEST_CONSTANT", 5)
|
14
|
+
raise "Expected 'TEST_CONSTANT'-constant to exist but it didnt." if !php.func("defined", "TEST_CONSTANT")
|
15
|
+
|
16
|
+
Timeout.timeout(1) do
|
17
|
+
0.upto(10000) do
|
18
|
+
const = php.constant_val("TEST_CONSTANT")
|
19
|
+
raise "Expected const to be 5 but it wasnt: #{const}." if const != 5
|
20
|
+
end
|
22
21
|
end
|
22
|
+
|
23
|
+
|
24
|
+
#Test function calls without arguments.
|
25
|
+
pid = php.func("getmypid")
|
26
|
+
raise "Invalid PID: #{pid}" if pid.to_i <= 0
|
27
|
+
|
28
|
+
|
29
|
+
#Test encoding.
|
30
|
+
test_str = "æøå"
|
31
|
+
php.func("file_put_contents", "/tmp/php_process_test_encoding", test_str)
|
32
|
+
test_str_read = File.read("/tmp/php_process_test_encoding")
|
33
|
+
raise "Expected the two strings to be the same, but they werent: '#{test_str}', '#{test_str_read}'." if test_str != test_str_read
|
34
|
+
|
35
|
+
|
36
|
+
#Test function calls with arguments.
|
37
|
+
res = php.func("explode", ";", "1;2;4;5")
|
38
|
+
raise "Expected length of result to be 4 but it wasnt: #{res.length}" if res.length != 4
|
39
|
+
|
40
|
+
|
41
|
+
#Test eval.
|
42
|
+
resp = php.eval("return array(1 => 2)")
|
43
|
+
raise "Expected hash: '#{resp.class.name}'." if !resp.is_a?(Hash)
|
44
|
+
raise "Expected key 1 to be 2: #{resp}." if resp[1] != 2
|
45
|
+
|
46
|
+
|
47
|
+
#Test spawn object and set instance variables.
|
48
|
+
proxy_obj = php.new("stdClass")
|
49
|
+
proxy_obj.__set_var("testvar", 5)
|
50
|
+
val = proxy_obj.__get_var("testvar")
|
51
|
+
raise "Expected val to be 5 but it wasnt: #{val}" if val != 5
|
52
|
+
proxy_obj = nil
|
53
|
+
|
54
|
+
|
55
|
+
#Test spawn require and method-calling on objects.
|
56
|
+
php.func("require_once", "knj/http.php")
|
57
|
+
http = php.new("knj_httpbrowser")
|
58
|
+
http.connect("www.partyworm.dk")
|
59
|
+
resp = http.get("/?show=frontpage")
|
60
|
+
raise "Expected length of HTML to be longer than 200: #{resp.to_s.length}" if resp.to_s.length < 200
|
61
|
+
http = nil
|
62
|
+
|
63
|
+
|
64
|
+
#Test Table-Writer.
|
65
|
+
php.func("require_once", "knj/table_writer.php")
|
66
|
+
php.func("require_once", "knj/csv.php")
|
67
|
+
tw = php.new("knj_table_writer", {
|
68
|
+
"filepath" => "/tmp/php_process_test.csv",
|
69
|
+
"format" => "csv",
|
70
|
+
"expl" => ";",
|
71
|
+
"surr" => '"',
|
72
|
+
"encoding" => "utf8"
|
73
|
+
})
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
#Check garbage collection, cache and stuff.
|
78
|
+
cache_info1 = php.object_cache_info
|
79
|
+
GC.start
|
80
|
+
php.flush_unset_ids(true)
|
81
|
+
cache_info2 = php.object_cache_info
|
82
|
+
raise "Cache count should be below #{cache_info1["count"]} but it wasnt: #{cache_info2}." if cache_info2["count"] >= cache_info1["count"]
|
23
83
|
end
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
test_str = "æøå"
|
33
|
-
$php.func("file_put_contents", "/tmp/php_process_test_encoding", test_str)
|
34
|
-
test_str_read = File.read("/tmp/php_process_test_encoding")
|
35
|
-
raise "Expected the two strings to be the same, but they werent: '#{test_str}', '#{test_str_read}'." if test_str != test_str_read
|
36
|
-
|
37
|
-
|
38
|
-
#Test function calls with arguments.
|
39
|
-
res = $php.func("explode", ";", "1;2;4;5")
|
40
|
-
raise "Expected length of result to be 4 but it wasnt: #{res.length}" if res.length != 4
|
41
|
-
|
42
|
-
|
43
|
-
#Test eval.
|
44
|
-
resp = $php.eval("return array(1 => 2)")
|
45
|
-
raise "Expected hash: '#{resp.class.name}'." if !resp.is_a?(Hash)
|
46
|
-
raise "Expected key 1 to be 2: #{resp}." if resp[1] != 2
|
47
|
-
|
48
|
-
|
49
|
-
#Test spawn object and set instance variables.
|
50
|
-
proxy_obj = $php.new("stdClass")
|
51
|
-
proxy_obj.__set_var("testvar", 5)
|
52
|
-
val = proxy_obj.__get_var("testvar")
|
53
|
-
raise "Expected val to be 5 but it wasnt: #{val}" if val != 5
|
54
|
-
proxy_obj = nil
|
55
|
-
|
56
|
-
|
57
|
-
#Test spawn require and method-calling on objects.
|
58
|
-
$php.func("require_once", "knj/http.php")
|
59
|
-
http = $php.new("knj_httpbrowser")
|
60
|
-
http.connect("www.partyworm.dk")
|
61
|
-
resp = http.get("/?show=frontpage")
|
62
|
-
raise "Expected length of HTML to be longer than 200: #{resp.to_s.length}" if resp.to_s.length < 200
|
63
|
-
http = nil
|
64
|
-
|
65
|
-
|
66
|
-
#Test Table-Writer.
|
67
|
-
$php.func("require_once", "knj/table_writer.php")
|
68
|
-
$php.func("require_once", "knj/csv.php")
|
69
|
-
tw = $php.new("knj_table_writer", {
|
70
|
-
"filepath" => "/tmp/php_process_test.csv",
|
71
|
-
"format" => "csv",
|
72
|
-
"expl" => ";",
|
73
|
-
"surr" => '"',
|
74
|
-
"encoding" => "utf8"
|
75
|
-
})
|
76
|
-
|
77
|
-
|
78
|
-
#Should be able to write 1000 rows in less than 5 sec.
|
79
|
-
Timeout.timeout(5) do
|
80
|
-
0.upto(1000) do |i|
|
81
|
-
#tw.write_row(["test#{i}", i, "test#{i}", i.to_f])
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should be able to create functions and call them" do
|
87
|
+
Php_process.new(:debug => false, :debug_stderr => true) do |php|
|
88
|
+
#Test ability to create functions and do callbacks.
|
89
|
+
$callback_from_php = "test"
|
90
|
+
func = php.create_func do |arg|
|
91
|
+
$callback_from_php = arg
|
82
92
|
end
|
93
|
+
|
94
|
+
#Send argument 'kasper' which will be what "$callback_from_php" will be changed to.
|
95
|
+
func.call("kasper")
|
96
|
+
sleep 0.1
|
97
|
+
raise "Expected callback from PHP to change variable but it didnt: '#{$callback_from_php}'." if $callback_from_php != "kasper"
|
83
98
|
end
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should be able to show windows" do
|
102
|
+
Php_process.new(:debug => false, :debug_stderr => true) do |php|
|
103
|
+
#Try to play a little with GTK2-extension.
|
104
|
+
gtk_exists = true
|
105
|
+
|
106
|
+
begin
|
107
|
+
php.func("dl", "php_gtk2.so")
|
108
|
+
rescue
|
109
|
+
puts "Skipping Gtk-tests since PHP-GTK2 is not installed."
|
110
|
+
gtk_exists = false
|
111
|
+
end
|
112
|
+
|
113
|
+
if gtk_exists
|
114
|
+
win = php.new("GtkWindow")
|
115
|
+
win.set_title("Test")
|
88
116
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
#Should be able to write 1000 rows in less than 5 sec.
|
98
|
-
Timeout.timeout(5) do
|
99
|
-
0.upto(1000) do |i|
|
100
|
-
#tw.write_row(["test#{i}", i, "test#{i}", i.to_f])
|
117
|
+
button = php.new("GtkButton")
|
118
|
+
button.set_label("Weee!")
|
119
|
+
|
120
|
+
win.add(button)
|
121
|
+
win.show_all
|
122
|
+
#php.static("Gtk", "main")
|
101
123
|
end
|
102
124
|
end
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
sheet = pe.getActiveSheet
|
114
|
-
|
115
|
-
const_border_thick = $php.constant_val("PHPExcel_Style_Border::BORDER_THICK")
|
116
|
-
|
117
|
-
sheet.getStyle("A1:C1").getBorders.getTop.setBorderStyle(const_border_thick)
|
118
|
-
sheet.getStyle("A1:A5").getBorders.getLeft.setBorderStyle(const_border_thick)
|
119
|
-
sheet.getStyle("A5:C5").getBorders.getBottom.setBorderStyle(const_border_thick)
|
120
|
-
sheet.getStyle("C1:C5").getBorders.getRight.setBorderStyle(const_border_thick)
|
121
|
-
|
122
|
-
sheet.setCellValue("A1", "Kasper Johansen - æøå")
|
123
|
-
sheet.getStyle("A1").getFont.setBold(true)
|
124
|
-
|
125
|
-
writer = $php.new("PHPExcel_Writer_Excel2007", pe)
|
126
|
-
writer.save("/tmp/test_excel.xlsx")
|
127
|
-
|
128
|
-
pe = nil
|
129
|
-
sheet = nil
|
130
|
-
writer = nil
|
131
|
-
|
132
|
-
|
133
|
-
#Try to play a little with GTK2-extension.
|
134
|
-
$php.func("dl", "php_gtk2.so")
|
135
|
-
win = $php.new("GtkWindow")
|
136
|
-
win.set_title("Test")
|
137
|
-
|
138
|
-
button = $php.new("GtkButton")
|
139
|
-
button.set_label("Weee!")
|
140
|
-
|
141
|
-
win.add(button)
|
142
|
-
win.show_all
|
143
|
-
#$php.static("Gtk", "main")
|
144
|
-
|
145
|
-
|
146
|
-
#Test ability to create functions and do callbacks.
|
147
|
-
$callback_from_php = "test"
|
148
|
-
func = $php.create_func do |arg|
|
149
|
-
$callback_from_php = arg
|
150
|
-
end
|
151
|
-
|
152
|
-
#Send argument 'kasper' which will be what "$callback_from_php" will be changed to.
|
153
|
-
func.call("kasper")
|
154
|
-
sleep 0.1
|
155
|
-
raise "Expected callback from PHP to change variable but it didnt: '#{$callback_from_php}'." if $callback_from_php != "kasper"
|
156
|
-
|
157
|
-
|
158
|
-
#Check garbage collection, cache and stuff.
|
159
|
-
cache_info1 = $php.object_cache_info
|
160
|
-
GC.start
|
161
|
-
$php.flush_unset_ids(true)
|
162
|
-
cache_info2 = $php.object_cache_info
|
163
|
-
raise "Cache count should be below #{cache_info1["count"]} but it wasnt: #{cache_info2}." if cache_info2["count"] >= cache_info1["count"]
|
164
|
-
|
165
|
-
|
166
|
-
#Test thread-safety and more.
|
167
|
-
ts = []
|
168
|
-
1.upto(25) do |tcount|
|
169
|
-
ts << Thread.new do
|
170
|
-
str = $php.func("substr", "Kasper Johansen", 0, 100)
|
171
|
-
|
172
|
-
0.upto(250) do
|
173
|
-
kasper_str = $php.func("substr", str, 0, 6)
|
174
|
-
johansen_str = $php.func("substr", str, 7, 15)
|
175
|
-
|
176
|
-
raise "Expected 'Kasper' but got '#{kasper_str}'." if kasper_str != "Kasper"
|
177
|
-
raise "Expected 'Johansen' but got '#{johansen_str}'." if johansen_str != "Johansen"
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should survive a lot of threadded calls in a row" do
|
128
|
+
Php_process.new(:debug => false, :debug_stderr => true) do |php|
|
129
|
+
#Test thread-safety and more.
|
130
|
+
ts = []
|
131
|
+
1.upto(25) do |tcount|
|
132
|
+
ts << Thread.new do
|
133
|
+
str = php.func("substr", "Kasper Johansen", 0, 100)
|
178
134
|
|
179
|
-
|
135
|
+
0.upto(250) do
|
136
|
+
kasper_str = php.func("substr", str, 0, 6)
|
137
|
+
johansen_str = php.func("substr", str, 7, 15)
|
138
|
+
|
139
|
+
raise "Expected 'Kasper' but got '#{kasper_str}'." if kasper_str != "Kasper"
|
140
|
+
raise "Expected 'Johansen' but got '#{johansen_str}'." if johansen_str != "Johansen"
|
141
|
+
|
142
|
+
#STDOUT.print "."
|
143
|
+
end
|
180
144
|
end
|
181
145
|
end
|
146
|
+
|
147
|
+
ts.each do |t|
|
148
|
+
t.join
|
149
|
+
end
|
182
150
|
end
|
183
|
-
|
184
|
-
|
185
|
-
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should be able to load advanced libraries and do stuff with them (PHPExcel)" do
|
154
|
+
Php_process.new(:debug => false, :debug_stderr => true) do |php|
|
155
|
+
#Test PHPExcel.
|
156
|
+
php.func("require_once", "PHPExcel.php")
|
157
|
+
php.func("require_once", "knj/table_writer.php")
|
158
|
+
|
159
|
+
tw = php.new("knj_table_writer", {
|
160
|
+
"filepath" => "/tmp/php_process_test.xlsx",
|
161
|
+
"format" => "excel2007"
|
162
|
+
})
|
163
|
+
|
164
|
+
#Should be able to write 1000 rows in less than 5 sec.
|
165
|
+
Timeout.timeout(1.25) do
|
166
|
+
0.upto(250) do |i|
|
167
|
+
tw.write_row(["test#{i}", i, "test#{i}", i.to_f])
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
tw.close
|
172
|
+
tw = nil
|
173
|
+
|
174
|
+
tw = php.new("knj_table_writer", {
|
175
|
+
"filepath" => "/tmp/php_process_test.xlsx",
|
176
|
+
"format" => "excel2007"
|
177
|
+
})
|
178
|
+
|
179
|
+
#Should be able to write 1000 rows in less than 5 sec.
|
180
|
+
Timeout.timeout(1.25) do
|
181
|
+
0.upto(250) do |i|
|
182
|
+
tw.write_row(["test#{i}", i, "test#{i}", i.to_f])
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
tw.close
|
187
|
+
tw = nil
|
188
|
+
|
189
|
+
#Try some really advanced object-stuff.
|
190
|
+
pe = php.new("PHPExcel")
|
191
|
+
pe.getProperties.setCreator("kaspernj")
|
192
|
+
pe.setActiveSheetIndex(0)
|
193
|
+
|
194
|
+
sheet = pe.getActiveSheet
|
195
|
+
|
196
|
+
const_border_thick = php.constant_val("PHPExcel_Style_Border::BORDER_THICK")
|
197
|
+
|
198
|
+
sheet.getStyle("A1:C1").getBorders.getTop.setBorderStyle(const_border_thick)
|
199
|
+
sheet.getStyle("A1:A5").getBorders.getLeft.setBorderStyle(const_border_thick)
|
200
|
+
sheet.getStyle("A5:C5").getBorders.getBottom.setBorderStyle(const_border_thick)
|
201
|
+
sheet.getStyle("C1:C5").getBorders.getRight.setBorderStyle(const_border_thick)
|
202
|
+
|
203
|
+
sheet.setCellValue("A1", "Kasper Johansen - æøå")
|
204
|
+
sheet.getStyle("A1").getFont.setBold(true)
|
205
|
+
|
206
|
+
writer = php.new("PHPExcel_Writer_Excel2007", pe)
|
207
|
+
writer.save("/tmp/test_excel.xlsx")
|
208
|
+
|
209
|
+
pe = nil
|
210
|
+
sheet = nil
|
211
|
+
writer = nil
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
it "should catch calls to functions that does not exist" do
|
216
|
+
Php_process.new do |php|
|
217
|
+
success = false
|
218
|
+
|
219
|
+
begin
|
220
|
+
php.func("func_that_does_not_exist", "kasper")
|
221
|
+
success = true
|
222
|
+
rescue
|
223
|
+
#ignore - expected.
|
224
|
+
end
|
225
|
+
|
226
|
+
raise "Didnt expected call to go through without error." if success
|
186
227
|
end
|
187
|
-
|
188
|
-
|
189
|
-
#Destroy the object.
|
190
|
-
$php.destroy
|
191
228
|
end
|
192
229
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
4
|
+
|
5
|
+
describe "PhpProcess" do
|
6
|
+
it "should not do the strip error" do
|
7
|
+
php = Php_process.new(:debug => false)
|
8
|
+
php.func("require_once", "PHPExcel.php")
|
9
|
+
php.static("PHPExcel_IOFactory", "load", "#{File.dirname(__FILE__)}/../examples/example_phpexcel.xlsx")
|
10
|
+
end
|
11
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: php_process
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
default_executable:
|
12
|
+
date: 2013-02-20 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: php-serialize4ruby
|
17
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
18
17
|
none: false
|
19
18
|
requirements:
|
20
19
|
- - ! '>='
|
@@ -22,10 +21,15 @@ dependencies:
|
|
22
21
|
version: '0'
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
26
30
|
- !ruby/object:Gem::Dependency
|
27
31
|
name: wref
|
28
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
29
33
|
none: false
|
30
34
|
requirements:
|
31
35
|
- - ! '>='
|
@@ -33,10 +37,15 @@ dependencies:
|
|
33
37
|
version: '0'
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
37
46
|
- !ruby/object:Gem::Dependency
|
38
47
|
name: tsafe
|
39
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
40
49
|
none: false
|
41
50
|
requirements:
|
42
51
|
- - ! '>='
|
@@ -44,10 +53,15 @@ dependencies:
|
|
44
53
|
version: '0'
|
45
54
|
type: :runtime
|
46
55
|
prerelease: false
|
47
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
48
62
|
- !ruby/object:Gem::Dependency
|
49
63
|
name: rspec
|
50
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
51
65
|
none: false
|
52
66
|
requirements:
|
53
67
|
- - ~>
|
@@ -55,10 +69,15 @@ dependencies:
|
|
55
69
|
version: 2.8.0
|
56
70
|
type: :development
|
57
71
|
prerelease: false
|
58
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.8.0
|
59
78
|
- !ruby/object:Gem::Dependency
|
60
79
|
name: rdoc
|
61
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
62
81
|
none: false
|
63
82
|
requirements:
|
64
83
|
- - ~>
|
@@ -66,10 +85,15 @@ dependencies:
|
|
66
85
|
version: '3.12'
|
67
86
|
type: :development
|
68
87
|
prerelease: false
|
69
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '3.12'
|
70
94
|
- !ruby/object:Gem::Dependency
|
71
95
|
name: bundler
|
72
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
73
97
|
none: false
|
74
98
|
requirements:
|
75
99
|
- - ! '>='
|
@@ -77,10 +101,15 @@ dependencies:
|
|
77
101
|
version: 1.0.0
|
78
102
|
type: :development
|
79
103
|
prerelease: false
|
80
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.0.0
|
81
110
|
- !ruby/object:Gem::Dependency
|
82
111
|
name: jeweler
|
83
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
84
113
|
none: false
|
85
114
|
requirements:
|
86
115
|
- - ~>
|
@@ -88,7 +117,12 @@ dependencies:
|
|
88
117
|
version: 1.8.3
|
89
118
|
type: :development
|
90
119
|
prerelease: false
|
91
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 1.8.3
|
92
126
|
description: Spawns a PHP process and proxies calls to it, making it possible to proxy
|
93
127
|
objects and more.
|
94
128
|
email: k@spernj.org
|
@@ -111,7 +145,7 @@ files:
|
|
111
145
|
- php_process.gemspec
|
112
146
|
- spec/php_process_spec.rb
|
113
147
|
- spec/spec_helper.rb
|
114
|
-
|
148
|
+
- spec/strip_error_spec.rb
|
115
149
|
homepage: http://github.com/kaspernj/php_process
|
116
150
|
licenses:
|
117
151
|
- MIT
|
@@ -127,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
161
|
version: '0'
|
128
162
|
segments:
|
129
163
|
- 0
|
130
|
-
hash:
|
164
|
+
hash: 4319029056344573155
|
131
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
166
|
none: false
|
133
167
|
requirements:
|
@@ -136,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
170
|
version: '0'
|
137
171
|
requirements: []
|
138
172
|
rubyforge_project:
|
139
|
-
rubygems_version: 1.
|
173
|
+
rubygems_version: 1.8.25
|
140
174
|
signing_key:
|
141
175
|
specification_version: 3
|
142
176
|
summary: Ruby-to-PHP bridge
|