Skip to content

Commit

Permalink
Merge pull request #22 from edave/master
Browse files Browse the repository at this point in the history
Workaround for HTTParty 0.8.1
  • Loading branch information
maxdemarzi committed Apr 4, 2012
2 parents 24a1c6c + ebda23d commit fddb7cb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
13 changes: 9 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
PATH
remote: .
specs:
neography (0.0.19)
httparty (= 0.7.8)
neography (0.0.20)
crack (= 0.1.8)
httparty (= 0.8.1)
json
os
rake (>= 0.8.7)
rubyzip

GEM
remote: http://rubygems.org/
specs:
crack (0.1.8)
diff-lcs (1.1.3)
httparty (0.7.8)
crack (= 0.1.8)
httparty (0.8.1)
multi_json
multi_xml
json (1.6.4)
multi_json (1.0.4)
multi_xml (0.4.1)
net-http-spy (0.2.1)
os (0.9.5)
rake (0.8.7)
Expand Down
22 changes: 17 additions & 5 deletions lib/neography/rest.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
module Neography

class Rest
include HTTParty

class CrackParser < HTTParty::Parser
require 'crack'

protected
def json
Crack::JSON.parse(body)
end
end

attr_accessor :protocol, :server, :port, :directory, :cypher_path, :gremlin_path, :log_file, :log_enabled, :logger, :max_threads, :authentication, :username, :password

Expand All @@ -16,7 +26,8 @@ def initialize(options=ENV['NEO4J_URL'] || {})
:max_threads => Neography::Config.max_threads,
:authentication => Neography::Config.authentication,
:username => Neography::Config.username,
:password => Neography::Config.password}
:password => Neography::Config.password,
}

unless options.respond_to?(:each_pair)
url = URI.parse(options)
Expand Down Expand Up @@ -44,6 +55,7 @@ def initialize(options=ENV['NEO4J_URL'] || {})
@max_threads = init[:max_threads]
@authentication = Hash.new
@authentication = {"#{init[:authentication]}_auth".to_sym => {:username => init[:username], :password => init[:password]}} unless init[:authentication].empty?
@parser = {:parser => CrackParser}
end

def configure(protocol, server, port, directory)
Expand Down Expand Up @@ -459,19 +471,19 @@ def evaluate_response(response)
end

def get(path,options={})
evaluate_response(HTTParty.get(configuration + URI.encode(path), options.merge!(@authentication)))
evaluate_response(HTTParty.get(configuration + URI.encode(path), options.merge!(@authentication).merge!(@parser)))
end

def post(path,options={})
evaluate_response(HTTParty.post(configuration + URI.encode(path), options.merge!(@authentication)))
evaluate_response(HTTParty.post(configuration + URI.encode(path), options.merge!(@authentication).merge!(@parser)))
end

def put(path,options={})
evaluate_response(HTTParty.put(configuration + URI.encode(path), options.merge!(@authentication)))
evaluate_response(HTTParty.put(configuration + URI.encode(path), options.merge!(@authentication).merge!(@parser)))
end

def delete(path,options={})
evaluate_response(HTTParty.delete(configuration + URI.encode(path), options.merge!(@authentication)))
evaluate_response(HTTParty.delete(configuration + URI.encode(path), options.merge!(@authentication).merge!(@parser)))
end

def get_id(id)
Expand Down
4 changes: 3 additions & 1 deletion neography.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ Gem::Specification.new do |s|

s.add_development_dependency "rspec"
s.add_development_dependency "net-http-spy", "0.2.1"
s.add_development_dependency "rake", "~> 0.8.7"
s.add_dependency "crack", "0.1.8"
s.add_dependency "httparty", "0.8.1"
s.add_dependency "rake", ">= 0.8.7"
s.add_dependency "httparty", "~> 0.7.8"
s.add_dependency "json"
s.add_dependency "os"
s.add_dependency "rubyzip"
Expand Down

0 comments on commit fddb7cb

Please sign in to comment.