php_process 0.0.7 → 0.0.8

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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/php_process.rb +45 -30
  3. data/php_process.gemspec +2 -2
  4. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.0.8
@@ -67,18 +67,23 @@ class Php_process
67
67
  @stderr.set_encoding("utf-8:iso-8859-1")
68
68
  @stdout.set_encoding("utf-8:iso-8859-1")
69
69
 
70
- @err_thread = Knj::Thread.new do
71
- @stderr.each_line do |str|
72
- @args[:on_err].call(str) if @args[:on_err]
73
- $stderr.print "Process error: #{str}" if @debug or @args[:debug_stderr]
74
-
75
- if str.match(/^PHP Fatal error: (.+)\s*/)
76
- @fatal = str.strip
77
- elsif str.match(/^Killed\s*$/)
78
- @fatal = "Process was killed."
70
+ @err_thread = Thread.new do
71
+ begin
72
+ @stderr.each_line do |str|
73
+ @args[:on_err].call(str) if @args[:on_err]
74
+ $stderr.print "Process error: #{str}" if @debug or @args[:debug_stderr]
75
+
76
+ if str.match(/^PHP Fatal error: (.+)\s*/)
77
+ @fatal = str.strip
78
+ elsif str.match(/^Killed\s*$/)
79
+ @fatal = "Process was killed."
80
+ end
81
+
82
+ break if (!@args and str.to_s.strip.length <= 0) or (@stderr and @stderr.closed?)
79
83
  end
80
-
81
- break if (!@args and str.to_s.strip.length <= 0) or (@stderr and @stderr.closed?)
84
+ rescue => e
85
+ $stderr.puts e.inspect
86
+ $stderr.puts e.backtrace
82
87
  end
83
88
  end
84
89
 
@@ -335,28 +340,38 @@ class Php_process
335
340
 
336
341
  #Starts the thread which reads answers from the PHP-process. This is called automatically from the constructor.
337
342
  def start_read_loop
338
- @thread = Knj::Thread.new do
339
- @stdout.lines do |line|
340
- break if line == nil or @stdout.closed?
341
-
342
- data = line.split(":")
343
- args = PHP.unserialize(Base64.strict_decode64(data[2].strip))
344
- type = data[0]
345
- id = data[1].to_i
346
- $stderr.print "Received: #{id}:#{type}:#{args}\n" if @debug
347
-
348
- if type == "answer"
349
- @responses[id] = args
350
- elsif type == "send"
351
- if args["type"] == "call_back_created_func"
352
- Knj::Thread.new do
353
- func_d = @callbacks[args["func_id"].to_i]
354
- func_d[:block].call(*args["args"])
343
+ @thread = Thread.new do
344
+ begin
345
+ @stdout.lines do |line|
346
+ break if line == nil or @stdout.closed?
347
+
348
+ data = line.split(":")
349
+ args = PHP.unserialize(Base64.strict_decode64(data[2].strip))
350
+ type = data[0]
351
+ id = data[1].to_i
352
+ $stderr.print "Received: #{id}:#{type}:#{args}\n" if @debug
353
+
354
+ if type == "answer"
355
+ @responses[id] = args
356
+ elsif type == "send"
357
+ if args["type"] == "call_back_created_func"
358
+ Thread.new do
359
+ begin
360
+ func_d = @callbacks[args["func_id"].to_i]
361
+ func_d[:block].call(*args["args"])
362
+ rescue => e
363
+ $stderr.puts e.inspect
364
+ $stderr.puts e.backtrace
365
+ end
366
+ end
355
367
  end
368
+ else
369
+ raise "Unknown type: '#{type}'."
356
370
  end
357
- else
358
- raise "Unknown type: '#{type}'."
359
371
  end
372
+ rescue => e
373
+ $stderr.puts e.inspect
374
+ $stderr.puts e.backtrace
360
375
  end
361
376
  end
362
377
  end
@@ -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.7"
8
+ s.version = "0.0.8"
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-22}
12
+ s.date = %q{2012-05-26}
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 = [
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: php_process
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.7
5
+ version: 0.0.8
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kasper Johansen
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-05-22 00:00:00 +02:00
13
+ date: 2012-05-26 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -138,7 +138,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
138
  requirements:
139
139
  - - ">="
140
140
  - !ruby/object:Gem::Version
141
- hash: 537427075948440521
141
+ hash: 4592644334405953027
142
142
  segments:
143
143
  - 0
144
144
  version: "0"