Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for HTTParty 0.8.1 #22

Merged
merged 2 commits into from
Apr 4, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, :log_file, :log_enabled, :logger, :max_threads, :authentication, :username, :password

Expand All @@ -14,7 +24,8 @@ def initialize(options={})
: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 All @@ -40,6 +51,7 @@ def initialize(options={})
@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 @@ -419,19 +431,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