php_process 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -2
- data/VERSION +1 -1
- data/lib/php_process.rb +66 -24
- data/lib/php_script.php +58 -35
- data/php_process.gemspec +8 -8
- data/spec/php_process_spec.rb +10 -1
- metadata +73 -68
data/Gemfile
CHANGED
@@ -2,8 +2,8 @@ source "http://rubygems.org"
|
|
2
2
|
# Add dependencies required to use your gem here.
|
3
3
|
# Example:
|
4
4
|
# gem "activesupport", ">= 2.3.5"
|
5
|
-
gem "knjrbfw"
|
6
|
-
gem "php-
|
5
|
+
gem "knjrbfw", ">= 0.0.31"
|
6
|
+
gem "php-serialize4ruby"
|
7
7
|
|
8
8
|
# Add dependencies to develop your gem here.
|
9
9
|
# Include everything needed to run rake, tests, features, etc.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/lib/php_process.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "knjrbfw"
|
2
|
+
require "knj/wref"
|
2
3
|
require "base64"
|
3
|
-
require "
|
4
|
+
require "php-serialize4ruby"
|
4
5
|
|
5
6
|
#This class starts a PHP-process and proxies various calls to it. It also spawns proxy-objects, which can you can call like they were normal Ruby-objects.
|
6
7
|
#===Examples
|
@@ -13,7 +14,12 @@ class Php_process
|
|
13
14
|
|
14
15
|
#This object controls which IDs should be unset on the PHP-side by being a destructor on the Ruby-side.
|
15
16
|
def objects_unsetter(id)
|
16
|
-
|
17
|
+
obj_count_id = @object_ids[id]
|
18
|
+
|
19
|
+
if @object_unset_ids.index(obj_count_id) == nil
|
20
|
+
@object_unset_ids << obj_count_id
|
21
|
+
end
|
22
|
+
|
17
23
|
@object_ids.delete(id)
|
18
24
|
end
|
19
25
|
|
@@ -28,6 +34,7 @@ class Php_process
|
|
28
34
|
@responses = Knj::Threadsafe::Synced_hash.new
|
29
35
|
@object_ids = Knj::Threadsafe::Synced_hash.new
|
30
36
|
@object_unset_ids = Knj::Threadsafe::Synced_array.new
|
37
|
+
@objects = Knj::Wref_map.new
|
31
38
|
|
32
39
|
#Used for 'create_func'.
|
33
40
|
@callbacks = {}
|
@@ -45,17 +52,18 @@ class Php_process
|
|
45
52
|
@stdout.sync = true
|
46
53
|
@stdin.sync = true
|
47
54
|
|
48
|
-
@
|
49
|
-
@
|
55
|
+
@stdin.set_encoding("iso-8859-1:utf-8")
|
56
|
+
@stderr.set_encoding("utf-8:iso-8859-1")
|
57
|
+
@stdout.set_encoding("utf-8:iso-8859-1")
|
50
58
|
|
51
59
|
@err_thread = Knj::Thread.new do
|
52
60
|
@stderr.each_line do |str|
|
61
|
+
@args[:on_err].call(str) if @args[:on_err]
|
62
|
+
$stderr.print "Process error: #{str}" if @debug or @args[:debug_stderr]
|
63
|
+
|
53
64
|
if str.match(/^PHP Fatal error: (.+)\s+/)
|
54
65
|
@fatal = str.strip
|
55
66
|
end
|
56
|
-
|
57
|
-
@args[:on_err].call(str) if @args[:on_err]
|
58
|
-
$stderr.print "Process error: #{str}" if @debug or @args[:debug_stderr]
|
59
67
|
end
|
60
68
|
end
|
61
69
|
|
@@ -75,6 +83,14 @@ class Php_process
|
|
75
83
|
|
76
84
|
$stderr.print "PHP-script ready.\n" if @debug
|
77
85
|
start_read_loop
|
86
|
+
|
87
|
+
if block_given?
|
88
|
+
begin
|
89
|
+
yield(self)
|
90
|
+
ensure
|
91
|
+
self.destroy
|
92
|
+
end
|
93
|
+
end
|
78
94
|
end
|
79
95
|
|
80
96
|
#Returns various info in a hash about the object-cache on the PHP-side.
|
@@ -124,7 +140,7 @@ class Php_process
|
|
124
140
|
# pe = php.new("PHPExcel")
|
125
141
|
# pe.getProperties.setCreator("kaspernj")
|
126
142
|
def new(classname, *args)
|
127
|
-
return self.send(:type => :new, :class => classname, :args => parse_data(args))
|
143
|
+
return self.send(:type => :new, :class => classname, :args => parse_data(args))
|
128
144
|
end
|
129
145
|
|
130
146
|
#Call a function in PHP.
|
@@ -133,14 +149,14 @@ class Php_process
|
|
133
149
|
# pid_of_php_process = php.func("getmypid")
|
134
150
|
# php.func("require_once", "PHPExcel.php")
|
135
151
|
def func(func_name, *args)
|
136
|
-
return self.send(:type => :func, :func_name => func_name, :args => parse_data(args))
|
152
|
+
return self.send(:type => :func, :func_name => func_name, :args => parse_data(args))
|
137
153
|
end
|
138
154
|
|
139
155
|
#Sends a call to a static method on a class with given arguments.
|
140
156
|
#===Examples
|
141
157
|
# php.static("Gtk", "main_quit")
|
142
158
|
def static(class_name, method_name, *args)
|
143
|
-
return self.send(:type => :static_method_call, :class_name => class_name, :method_name => method_name, :args => parse_data(args))
|
159
|
+
return self.send(:type => :static_method_call, :class_name => class_name, :method_name => method_name, :args => parse_data(args))
|
144
160
|
end
|
145
161
|
|
146
162
|
#Creates a function on the PHP-side. When the function is called, it callbacks to the Ruby-side which then can execute stuff back to PHP.
|
@@ -175,14 +191,17 @@ class Php_process
|
|
175
191
|
$stderr.print "Sending unsets: #{elements}\n" if @debug
|
176
192
|
send_real("type" => "unset_ids", "ids" => elements)
|
177
193
|
end
|
194
|
+
|
195
|
+
#Clean wref-map.
|
196
|
+
@objects.clean
|
178
197
|
end
|
179
198
|
|
180
199
|
#Parses argument-data into special hashes that can be used on the PHP-side. It is public because the proxy-objects uses it. Normally you would never use it.
|
181
200
|
def parse_data(data)
|
182
201
|
if data.is_a?(Php_process::Proxy_obj)
|
183
|
-
return {:type =>
|
202
|
+
return {:type => :proxyobj, :id => data.args[:id]}
|
184
203
|
elsif data.is_a?(Php_process::Created_function)
|
185
|
-
return {:type =>
|
204
|
+
return {:type => :php_process_created_function, :id => data.args[:id]}
|
186
205
|
elsif data.is_a?(Hash)
|
187
206
|
newhash = {}
|
188
207
|
data.each do |key, val|
|
@@ -204,14 +223,27 @@ class Php_process
|
|
204
223
|
|
205
224
|
#Returns the value of a constant on the PHP-side.
|
206
225
|
def constant_val(name)
|
207
|
-
return self.send(:type => :constant_val, :name => name)
|
226
|
+
return self.send(:type => :constant_val, :name => name)
|
227
|
+
end
|
228
|
+
|
229
|
+
#Returns various informations about boths sides memory in a hash.
|
230
|
+
def memory_info
|
231
|
+
return {
|
232
|
+
:php_info => self.send(:type => :memory_info),
|
233
|
+
:ruby_info => {
|
234
|
+
:responses => @responses.length,
|
235
|
+
:objects_ids => @object_ids.length,
|
236
|
+
:object_unset_ids => @object_unset_ids.length,
|
237
|
+
:objects => @objects.length
|
238
|
+
}
|
239
|
+
}
|
208
240
|
end
|
209
241
|
|
210
242
|
private
|
211
243
|
|
212
244
|
#Generates the command from the given object and sends it to the PHP-process. Then returns the parsed result.
|
213
245
|
def send_real(hash)
|
214
|
-
$stderr.print "Sending: #{hash}\n" if @debug
|
246
|
+
$stderr.print "Sending: #{hash[:args]}\n" if @debug and hash[:args]
|
215
247
|
str = Base64.strict_encode64(PHP.serialize(hash))
|
216
248
|
@stdin.write("send:#{@send_count}:#{str}\n")
|
217
249
|
id = @send_count
|
@@ -235,11 +267,12 @@ class Php_process
|
|
235
267
|
raise "#{resp["msg"]}\n\n#{resp["bt"]}"
|
236
268
|
end
|
237
269
|
|
270
|
+
$stderr.print "Found answer #{id} - returning it.\n" if @debug
|
238
271
|
return read_parsed_data(resp)
|
239
272
|
end
|
240
273
|
|
241
274
|
check_alive
|
242
|
-
sleep 0.
|
275
|
+
sleep 0.01
|
243
276
|
$stderr.print "Waiting for answer to ID: #{id}\n" if @debug
|
244
277
|
end
|
245
278
|
end
|
@@ -252,12 +285,21 @@ class Php_process
|
|
252
285
|
|
253
286
|
#Parses special hashes to proxy-objects and leaves the rest. This is used automatically.
|
254
287
|
def read_parsed_data(data)
|
255
|
-
if data.is_a?(
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
288
|
+
if data.is_a?(Array) and data.length == 2 and data[0] == "proxyobj"
|
289
|
+
id = data[1].to_i
|
290
|
+
|
291
|
+
if proxy_obj = @objects.get!(id)
|
292
|
+
$stderr.print "Reuse proxy-obj!\n" if @debug
|
293
|
+
return proxy_obj
|
294
|
+
else
|
295
|
+
$stderr.print "Spawn new proxy-obj!\n" if @debug
|
296
|
+
proxy_obj = Proxy_obj.new(
|
297
|
+
:php => self,
|
298
|
+
:id => id
|
299
|
+
)
|
300
|
+
@objects[id] = proxy_obj
|
301
|
+
return proxy_obj
|
302
|
+
end
|
261
303
|
elsif data.is_a?(Hash)
|
262
304
|
newdata = {}
|
263
305
|
data.each do |key, val|
|
@@ -319,7 +361,7 @@ class Php_process::Proxy_obj
|
|
319
361
|
#===Examples
|
320
362
|
# proxy_obj.__phpclass #=> :PHPExcel
|
321
363
|
def __phpclass
|
322
|
-
return @args[:
|
364
|
+
return @args[:php].func("get_class", self)
|
323
365
|
end
|
324
366
|
|
325
367
|
#Sets an instance-variable on the object.
|
@@ -338,12 +380,12 @@ class Php_process::Proxy_obj
|
|
338
380
|
# proxy_obj.__set_var("testvar", 5)
|
339
381
|
# proxy_obj.__get_var("testvar") #=> 5
|
340
382
|
def __get_var(name)
|
341
|
-
return @args[:php].send(:type => "get_var", :id => @args[:id], :name => name)
|
383
|
+
return @args[:php].send(:type => "get_var", :id => @args[:id], :name => name)
|
342
384
|
end
|
343
385
|
|
344
386
|
#Uses 'method_missing' to proxy all other calls onto the PHP-process and the PHP-object. Then returns the parsed result.
|
345
387
|
def method_missing(method_name, *args)
|
346
|
-
return @args[:php].send(:type => :object_call, :method => method_name, :args => @args[:php].parse_data(args), :id => @args[:id])
|
388
|
+
return @args[:php].send(:type => :object_call, :method => method_name, :args => @args[:php].parse_data(args), :id => @args[:id])
|
347
389
|
end
|
348
390
|
end
|
349
391
|
|
data/lib/php_script.php
CHANGED
@@ -6,9 +6,10 @@ class php_process{
|
|
6
6
|
$this->sock_stdin = fopen("php://stdin", "r");
|
7
7
|
$this->sock_stdout = fopen("php://stdout", "w");
|
8
8
|
$this->objects = array();
|
9
|
+
$this->objects_spl = array();
|
9
10
|
$this->objects_count = 0;
|
10
11
|
$this->created_functions = array();
|
11
|
-
$this->proxy_to_func = array("call_created_func", "constant_val", "create_func", "func", "get_var", "object_cache_info", "object_call", "require_once_path", "set_var", "static_method_call", "unset_ids");
|
12
|
+
$this->proxy_to_func = array("call_created_func", "constant_val", "create_func", "func", "get_var", "memory_info", "object_cache_info", "object_call", "require_once_path", "set_var", "static_method_call", "unset_ids");
|
12
13
|
$this->send_count = 0;
|
13
14
|
|
14
15
|
print "php_script_ready:" . getmypid() . "\n";
|
@@ -37,6 +38,9 @@ class php_process{
|
|
37
38
|
$type = $data[0];
|
38
39
|
$id = intval($data[1]);
|
39
40
|
$args = unserialize(base64_decode($data[2]));
|
41
|
+
if ($args === false){
|
42
|
+
throw new exception("The args-data was not unserializeable: " . utf8_encode(base64_decode($data[2])));
|
43
|
+
}
|
40
44
|
|
41
45
|
try{
|
42
46
|
if ($type == "send"){
|
@@ -48,7 +52,7 @@ class php_process{
|
|
48
52
|
}elseif(in_array($args["type"], $this->proxy_to_func)){
|
49
53
|
$this->$args["type"]($id, $args);
|
50
54
|
}else{
|
51
|
-
throw new exception("Unknown send-type: " . $args["type"]);
|
55
|
+
throw new exception("Unknown send-type: " . $args["type"] . " (" . implode(", ", array_keys($args)) . ") (" . base64_decode($data[2]) . ")");
|
52
56
|
}
|
53
57
|
}else{
|
54
58
|
throw new exception("Invalid type: " . $type);
|
@@ -62,17 +66,29 @@ class php_process{
|
|
62
66
|
if (is_array($data)){
|
63
67
|
foreach($data as $key => $val){
|
64
68
|
if (is_object($val)){
|
65
|
-
$
|
66
|
-
$data[$key] = array("type" => "php_process_proxy", "id" => $this->objects_count, "class" => get_class($val));
|
67
|
-
$this->objects_count++;
|
69
|
+
$data[$key] = $this->parse_data($val);
|
68
70
|
}
|
69
71
|
}
|
70
72
|
|
71
73
|
return $data;
|
72
74
|
}elseif(is_object($data)){
|
73
|
-
$
|
74
|
-
|
75
|
-
$this->
|
75
|
+
$spl = spl_object_hash($data);
|
76
|
+
|
77
|
+
if (array_key_exists($spl, $this->objects_spl)){
|
78
|
+
$id = $this->objects_spl[$spl];
|
79
|
+
}else{
|
80
|
+
$id = $this->objects_count;
|
81
|
+
$this->objects_count++;
|
82
|
+
|
83
|
+
if (array_key_exists($id, $this->objects)){
|
84
|
+
throw new exception("Object with that ID already exists: " . $id);
|
85
|
+
}
|
86
|
+
|
87
|
+
$this->objects[$id] = array("obj" => $data, "spl" => $spl);
|
88
|
+
$this->objects_spl[$spl] = $id;
|
89
|
+
}
|
90
|
+
|
91
|
+
$ret = array("proxyobj", $id);
|
76
92
|
return $ret;
|
77
93
|
}else{
|
78
94
|
return $data;
|
@@ -80,14 +96,14 @@ class php_process{
|
|
80
96
|
}
|
81
97
|
|
82
98
|
function read_parsed_data($data){
|
83
|
-
if (is_array($data) and array_key_exists("type", $data) and $data["type"] == "
|
84
|
-
$object = $this->objects[$data["id"]];
|
99
|
+
if (is_array($data) and array_key_exists("type", $data) and $data["type"] == "proxyobj" and array_key_exists("id", $data)){
|
100
|
+
$object = $this->objects[$data["id"]]["obj"];
|
85
101
|
if (!$object){
|
86
102
|
throw new exception("No object by that ID: " . $data["id"]);
|
87
103
|
}
|
88
104
|
|
89
105
|
return $object;
|
90
|
-
}elseif(is_array($data) and array_key_exists("type", $data) and $data["type"] == "php_process_created_function" and array_key_exists("id", $data)
|
106
|
+
}elseif(is_array($data) and array_key_exists("type", $data) and $data["type"] == "php_process_created_function" and array_key_exists("id", $data)){
|
91
107
|
$func = $this->created_functions[$data["id"]]["func"];
|
92
108
|
return $func;
|
93
109
|
}elseif(is_array($data)){
|
@@ -114,13 +130,11 @@ class php_process{
|
|
114
130
|
$klass = new ReflectionClass($class);
|
115
131
|
$object = $klass->newInstanceArgs($new_args);
|
116
132
|
|
117
|
-
$this->answer($id,
|
118
|
-
"object" => $object
|
119
|
-
));
|
133
|
+
$this->answer($id, $object);
|
120
134
|
}
|
121
135
|
|
122
136
|
function set_var($id, $args){
|
123
|
-
$object = $this->objects[$args["id"]];
|
137
|
+
$object = $this->objects[$args["id"]]["obj"];
|
124
138
|
if (!$object){
|
125
139
|
throw new exception("No object by that ID: " . $args["id"]);
|
126
140
|
}
|
@@ -130,23 +144,20 @@ class php_process{
|
|
130
144
|
}
|
131
145
|
|
132
146
|
function get_var($id, $args){
|
133
|
-
$object = $this->objects[$args["id"]];
|
147
|
+
$object = $this->objects[$args["id"]]["obj"];
|
134
148
|
if (!$object){
|
135
149
|
throw new exception("No object by that ID: " . $args["id"]);
|
136
150
|
}
|
137
151
|
|
138
|
-
$this->answer($id,
|
139
|
-
"result" => $object->$args["name"]
|
140
|
-
));
|
141
|
-
}
|
142
|
-
|
143
|
-
function require_once_path($id, $args){
|
144
|
-
require_once $args["filepath"];
|
145
|
-
$this->answer($id, true);
|
152
|
+
$this->answer($id, $object->$args["name"]);
|
146
153
|
}
|
147
154
|
|
148
155
|
function object_call($id, $args){
|
149
|
-
|
156
|
+
if (!array_key_exists($args["id"], $this->objects)){
|
157
|
+
throw new exception("No object by that ID: " . $args["id"]);
|
158
|
+
}
|
159
|
+
|
160
|
+
$object = $this->objects[$args["id"]]["obj"];
|
150
161
|
$call_arr = array($object, $args["method"]);
|
151
162
|
|
152
163
|
//Error handeling.
|
@@ -159,9 +170,7 @@ class php_process{
|
|
159
170
|
}
|
160
171
|
|
161
172
|
$res = call_user_func_array($call_arr, $this->read_parsed_data($args["args"]));
|
162
|
-
$this->answer($id,
|
163
|
-
"result" => $res
|
164
|
-
));
|
173
|
+
$this->answer($id, $res);
|
165
174
|
}
|
166
175
|
|
167
176
|
function func($id, $args){
|
@@ -191,11 +200,22 @@ class php_process{
|
|
191
200
|
$res = call_user_func_array($args["func_name"], $newargs);
|
192
201
|
}
|
193
202
|
|
194
|
-
$this->answer($id,
|
203
|
+
$this->answer($id, $res);
|
195
204
|
}
|
196
205
|
|
197
206
|
function unset_ids($id, $args){
|
198
207
|
foreach($args["ids"] as $obj_id){
|
208
|
+
if (!array_key_exists($obj_id, $this->objects)){
|
209
|
+
continue;
|
210
|
+
}
|
211
|
+
|
212
|
+
$spl = $this->objects[$obj_id]["spl"];
|
213
|
+
|
214
|
+
if (!array_key_exists($spl, $this->objects_spl)){
|
215
|
+
throw new exception("SPL could not be found: " . $spl);
|
216
|
+
}
|
217
|
+
|
218
|
+
unset($this->objects_spl[$spl]);
|
199
219
|
unset($this->objects[$obj_id]);
|
200
220
|
}
|
201
221
|
|
@@ -230,12 +250,9 @@ class php_process{
|
|
230
250
|
}
|
231
251
|
|
232
252
|
$newargs = $this->read_parsed_data($args["args"]);
|
233
|
-
error_log("Args: " . print_r($newargs, true));
|
234
253
|
$res = call_user_func_array($call_arr, $newargs);
|
235
254
|
|
236
|
-
$this->answer($id,
|
237
|
-
"result" => $res
|
238
|
-
));
|
255
|
+
$this->answer($id, $res);
|
239
256
|
}
|
240
257
|
|
241
258
|
function create_func($id, $args){
|
@@ -277,12 +294,18 @@ class php_process{
|
|
277
294
|
|
278
295
|
$eval_str .= ");";
|
279
296
|
$res = eval($eval_str);
|
280
|
-
$this->answer($id,
|
297
|
+
$this->answer($id, $res);
|
281
298
|
}
|
282
299
|
|
283
300
|
function constant_val($id, $args){
|
301
|
+
$this->answer($id, constant($args["name"]));
|
302
|
+
}
|
303
|
+
|
304
|
+
function memory_info($id, $args){
|
284
305
|
$this->answer($id, array(
|
285
|
-
"
|
306
|
+
"objects" => count($this->objects),
|
307
|
+
"objects_spl" => count($this->objects_spl),
|
308
|
+
"created_functions" => count($this->created_functions)
|
286
309
|
));
|
287
310
|
}
|
288
311
|
}
|
data/php_process.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{php_process}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.3"
|
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 = %q{2012-05-
|
12
|
+
s.date = %q{2012-05-06}
|
13
13
|
s.description = %q{Spawns a PHP process and proxies calls to it, making it possible to proxy objects and more.}
|
14
14
|
s.email = %q{k@spernj.org}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -40,16 +40,16 @@ Gem::Specification.new do |s|
|
|
40
40
|
s.specification_version = 3
|
41
41
|
|
42
42
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
43
|
-
s.add_runtime_dependency(%q<knjrbfw>, [">= 0"])
|
44
|
-
s.add_runtime_dependency(%q<php-
|
43
|
+
s.add_runtime_dependency(%q<knjrbfw>, [">= 0.0.31"])
|
44
|
+
s.add_runtime_dependency(%q<php-serialize4ruby>, [">= 0"])
|
45
45
|
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
46
46
|
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
47
47
|
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
48
48
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
49
49
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
50
50
|
else
|
51
|
-
s.add_dependency(%q<knjrbfw>, [">= 0"])
|
52
|
-
s.add_dependency(%q<php-
|
51
|
+
s.add_dependency(%q<knjrbfw>, [">= 0.0.31"])
|
52
|
+
s.add_dependency(%q<php-serialize4ruby>, [">= 0"])
|
53
53
|
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
54
54
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
55
55
|
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
@@ -57,8 +57,8 @@ Gem::Specification.new do |s|
|
|
57
57
|
s.add_dependency(%q<rcov>, [">= 0"])
|
58
58
|
end
|
59
59
|
else
|
60
|
-
s.add_dependency(%q<knjrbfw>, [">= 0"])
|
61
|
-
s.add_dependency(%q<php-
|
60
|
+
s.add_dependency(%q<knjrbfw>, [">= 0.0.31"])
|
61
|
+
s.add_dependency(%q<php-serialize4ruby>, [">= 0"])
|
62
62
|
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
63
63
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
64
64
|
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
data/spec/php_process_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
1
3
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
4
|
|
3
5
|
describe "PhpProcess" do
|
@@ -14,6 +16,13 @@ describe "PhpProcess" do
|
|
14
16
|
raise "Invalid PID: #{pid}" if pid.to_i <= 0
|
15
17
|
|
16
18
|
|
19
|
+
#Test encoding.
|
20
|
+
test_str = "æøå"
|
21
|
+
$php.func("file_put_contents", "/tmp/php_process_test_encoding", test_str)
|
22
|
+
test_str_read = File.read("/tmp/php_process_test_encoding")
|
23
|
+
raise "Expected the two strings to be the same, but they werent: '#{test_str}', '#{test_str_read}'." if test_str != test_str_read
|
24
|
+
|
25
|
+
|
17
26
|
#Test function calls with arguments.
|
18
27
|
res = $php.func("explode", ";", "1;2;4;5")
|
19
28
|
raise "Expected length of result to be 4 but it wasnt: #{res.length}" if res.length != 4
|
@@ -99,7 +108,7 @@ describe "PhpProcess" do
|
|
99
108
|
sheet.getStyle("A5:C5").getBorders.getBottom.setBorderStyle(const_border_thick)
|
100
109
|
sheet.getStyle("C1:C5").getBorders.getRight.setBorderStyle(const_border_thick)
|
101
110
|
|
102
|
-
sheet.setCellValue("A1", "Kasper Johansen")
|
111
|
+
sheet.setCellValue("A1", "Kasper Johansen - æøå")
|
103
112
|
sheet.getStyle("A1").getFont.setBold(true)
|
104
113
|
|
105
114
|
writer = $php.new("PHPExcel_Writer_Excel2007", pe)
|
metadata
CHANGED
@@ -1,103 +1,105 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: php_process
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.2
|
3
|
+
version: !ruby/object:Gem::Version
|
5
4
|
prerelease:
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Kasper Johansen
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
12
|
+
|
13
|
+
date: 2012-05-06 00:00:00 +02:00
|
13
14
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
16
17
|
name: knjrbfw
|
17
|
-
requirement: &
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
19
|
none: false
|
19
|
-
requirements:
|
20
|
-
- -
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version:
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.31
|
23
24
|
type: :runtime
|
24
25
|
prerelease: false
|
25
|
-
version_requirements: *
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
-
name: php-
|
28
|
-
requirement: &
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: php-serialize4ruby
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
29
30
|
none: false
|
30
|
-
requirements:
|
31
|
-
- -
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version:
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
34
35
|
type: :runtime
|
35
36
|
prerelease: false
|
36
|
-
version_requirements: *
|
37
|
-
- !ruby/object:Gem::Dependency
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
38
39
|
name: rspec
|
39
|
-
requirement: &
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
41
|
none: false
|
41
|
-
requirements:
|
42
|
+
requirements:
|
42
43
|
- - ~>
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
+
- !ruby/object:Gem::Version
|
44
45
|
version: 2.8.0
|
45
46
|
type: :development
|
46
47
|
prerelease: false
|
47
|
-
version_requirements: *
|
48
|
-
- !ruby/object:Gem::Dependency
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
49
50
|
name: rdoc
|
50
|
-
requirement: &
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
51
52
|
none: false
|
52
|
-
requirements:
|
53
|
+
requirements:
|
53
54
|
- - ~>
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version:
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "3.12"
|
56
57
|
type: :development
|
57
58
|
prerelease: false
|
58
|
-
version_requirements: *
|
59
|
-
- !ruby/object:Gem::Dependency
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
60
61
|
name: bundler
|
61
|
-
requirement: &
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
62
63
|
none: false
|
63
|
-
requirements:
|
64
|
-
- -
|
65
|
-
- !ruby/object:Gem::Version
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
66
67
|
version: 1.0.0
|
67
68
|
type: :development
|
68
69
|
prerelease: false
|
69
|
-
version_requirements: *
|
70
|
-
- !ruby/object:Gem::Dependency
|
70
|
+
version_requirements: *id005
|
71
|
+
- !ruby/object:Gem::Dependency
|
71
72
|
name: jeweler
|
72
|
-
requirement: &
|
73
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
73
74
|
none: false
|
74
|
-
requirements:
|
75
|
+
requirements:
|
75
76
|
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
+
- !ruby/object:Gem::Version
|
77
78
|
version: 1.8.3
|
78
79
|
type: :development
|
79
80
|
prerelease: false
|
80
|
-
version_requirements: *
|
81
|
-
- !ruby/object:Gem::Dependency
|
81
|
+
version_requirements: *id006
|
82
|
+
- !ruby/object:Gem::Dependency
|
82
83
|
name: rcov
|
83
|
-
requirement: &
|
84
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
84
85
|
none: false
|
85
|
-
requirements:
|
86
|
-
- -
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version:
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: "0"
|
89
90
|
type: :development
|
90
91
|
prerelease: false
|
91
|
-
version_requirements: *
|
92
|
-
description: Spawns a PHP process and proxies calls to it, making it possible to proxy
|
93
|
-
objects and more.
|
92
|
+
version_requirements: *id007
|
93
|
+
description: Spawns a PHP process and proxies calls to it, making it possible to proxy objects and more.
|
94
94
|
email: k@spernj.org
|
95
95
|
executables: []
|
96
|
+
|
96
97
|
extensions: []
|
97
|
-
|
98
|
+
|
99
|
+
extra_rdoc_files:
|
98
100
|
- LICENSE.txt
|
99
101
|
- README.rdoc
|
100
|
-
files:
|
102
|
+
files:
|
101
103
|
- .document
|
102
104
|
- .rspec
|
103
105
|
- Gemfile
|
@@ -112,31 +114,34 @@ files:
|
|
112
114
|
- spec/spec_helper.rb
|
113
115
|
has_rdoc: true
|
114
116
|
homepage: http://github.com/kaspernj/php_process
|
115
|
-
licenses:
|
117
|
+
licenses:
|
116
118
|
- MIT
|
117
119
|
post_install_message:
|
118
120
|
rdoc_options: []
|
119
|
-
|
121
|
+
|
122
|
+
require_paths:
|
120
123
|
- lib
|
121
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
125
|
none: false
|
123
|
-
requirements:
|
124
|
-
- -
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
|
127
|
-
segments:
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
hash: -690325750737638364
|
130
|
+
segments:
|
128
131
|
- 0
|
129
|
-
|
130
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
version: "0"
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
134
|
none: false
|
132
|
-
requirements:
|
133
|
-
- -
|
134
|
-
- !ruby/object:Gem::Version
|
135
|
-
version:
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: "0"
|
136
139
|
requirements: []
|
140
|
+
|
137
141
|
rubyforge_project:
|
138
142
|
rubygems_version: 1.6.2
|
139
143
|
signing_key:
|
140
144
|
specification_version: 3
|
141
145
|
summary: Ruby-to-PHP bridge
|
142
146
|
test_files: []
|
147
|
+
|