From 6f60af08666203cdbecb600483f571691363bccf Mon Sep 17 00:00:00 2001 From: Jo Hund Date: Thu, 26 Jul 2012 13:30:40 -0700 Subject: [PATCH] Replace Oj with MultiJson for JSON handling so that neography works with jruby --- Gemfile.lock | 3 +-- lib/neography.rb | 4 ++-- lib/neography/config.rb | 4 ++-- lib/neography/multi_json_parser.rb | 9 +++++++++ lib/neography/oj_parser.rb | 8 -------- neography.gemspec | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) create mode 100644 lib/neography/multi_json_parser.rb delete mode 100644 lib/neography/oj_parser.rb diff --git a/Gemfile.lock b/Gemfile.lock index 1283996..1ad352b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,7 +4,7 @@ PATH neography (0.0.28) httparty (>= 0.8.1) json - oj + multi_json os rake (>= 0.8.7) rubyzip @@ -20,7 +20,6 @@ GEM multi_json (1.3.6) multi_xml (0.5.1) net-http-spy (0.2.1) - oj (1.2.9) os (0.9.6) rake (0.8.7) rspec (2.10.0) diff --git a/lib/neography.rb b/lib/neography.rb index 8b67800..38857a1 100644 --- a/lib/neography.rb +++ b/lib/neography.rb @@ -18,13 +18,13 @@ def find_and_require_user_defined_code require 'cgi' require 'httparty' require 'json' -require 'oj' +require 'multi_json' require 'logger' require 'ostruct' require 'os' require 'zip/zipfilesystem' -require 'neography/oj_parser' +require 'neography/multi_json_parser' require 'neography/config' require 'neography/rest' diff --git a/lib/neography/config.rb b/lib/neography/config.rb index c59c529..a97a321 100644 --- a/lib/neography/config.rb +++ b/lib/neography/config.rb @@ -15,6 +15,6 @@ class << self; attr_accessor :protocol, :server, :port, :directory, :cypher_path @authentication = {} @username = nil @password = nil - @parser = {:parser => OjParser} + @parser = {:parser => MultiJsonParser} end -end \ No newline at end of file +end diff --git a/lib/neography/multi_json_parser.rb b/lib/neography/multi_json_parser.rb new file mode 100644 index 0000000..473f09c --- /dev/null +++ b/lib/neography/multi_json_parser.rb @@ -0,0 +1,9 @@ +class MultiJsonParser < HTTParty::Parser + + protected + + def json + MultiJson.load(body) + end + +end diff --git a/lib/neography/oj_parser.rb b/lib/neography/oj_parser.rb deleted file mode 100644 index fe27953..0000000 --- a/lib/neography/oj_parser.rb +++ /dev/null @@ -1,8 +0,0 @@ -class OjParser < HTTParty::Parser - Oj.default_options = { :mode => :strict } - - protected - def json - Oj.load(body) - end -end \ No newline at end of file diff --git a/neography.gemspec b/neography.gemspec index 64344dc..868ee28 100644 --- a/neography.gemspec +++ b/neography.gemspec @@ -27,5 +27,5 @@ Gem::Specification.new do |s| s.add_dependency "json" s.add_dependency "os" s.add_dependency "rubyzip" - s.add_dependency "oj" + s.add_dependency "multi_json" end