Skip to content

Commit

Permalink
JSON why do you kill my performance? Oh yeah...
Browse files Browse the repository at this point in the history
  • Loading branch information
deadprogram committed Apr 6, 2011
1 parent f0e2ed1 commit 9a25d2d
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 12 deletions.
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ source "http://rubygems.org"

gem "qtbindings"
gem 'htmlentities'
gem 'rest-client'

# only needed for testing
gem 'mocha'
gem 'json_pure'
gem 'rest-client'
2 changes: 0 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ GEM
remote: http://rubygems.org/
specs:
htmlentities (4.2.3)
json_pure (1.5.1)
mime-types (1.16)
mocha (0.9.10)
rake
Expand All @@ -16,7 +15,6 @@ PLATFORMS

DEPENDENCIES
htmlentities
json_pure
mocha
qtbindings
rest-client
4 changes: 1 addition & 3 deletions app/widgets/server.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'uri'
require 'json/pure'

# http server listening on port 8080 to do the inter-process communication
class KidsRubyServer < Qt::TcpServer
Expand Down Expand Up @@ -86,8 +85,7 @@ def connection
@parent.append(param)
connection.write validResponse("OK")
elsif command == "appendError"
body.each_line {|l| @parent.appendError( JSON.parse(l)['error'] )}
#@parent.appendError(body)
@parent.appendError(body)
connection.write validResponse("OK")
elsif command == "gets"
connection.write validResponse(@parent.gets)
Expand Down
3 changes: 1 addition & 2 deletions lib/kidsruby/interface.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require "uri"
require "rest_client"
require 'json/pure'

class InterfaceHelper
def connect!
Expand Down Expand Up @@ -34,7 +33,7 @@ def call(method, param = nil)
loc = loc + "?#{URI.escape(param)}"
return Reply.new(RestClient.get(loc))
elsif param && param.is_a?(Hash)
return Reply.new(RestClient.post(loc, JSON.generate(param), :content_type => :json, :accept => :json))
return Reply.new(RestClient.post(loc, param['data'], :content_type => 'text/plain'))
else
return Reply.new(RestClient.get(loc))
end
Expand Down
4 changes: 1 addition & 3 deletions lib/kidsruby/stdio.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ def write(data)

class StdErr < KidsRubyStdIo
def write(data)
#t = data.gsub(/\n/,"<br/>")
@payload = {'error' => data}
@iface.call("appendError", @payload)
@iface.call("appendError", {'data' => data})
end
alias_method :puts, :write
end
Expand Down

0 comments on commit 9a25d2d

Please sign in to comment.