Browse files

switch to faraday

  • Loading branch information...
1 parent e6188a9 commit 5936977f8e9d1d731068574d97d73fb189e33118 Eric Ritezel committed Mar 28, 2012
Showing with 13 additions and 4 deletions.
  1. +10 −2 lib/middleman-remote-data.rb
  2. +3 −2 middleman-remote-data.gemspec
View
12 lib/middleman-remote-data.rb
@@ -1,4 +1,5 @@
-require "httparty"
+require "faraday"
+require "faraday_middleware"
module Middleman::Features::RemoteData
class << self
@@ -17,8 +18,15 @@ module ClassMethods
#
# data.my_json
def data_source(name, url)
+ connection = Faraday.new(:url => url) do |builder|
+ builder.use Faraday::Request::UrlEncoded
+ builder.use Faraday::Adapter::NetHttp
+ builder.use FaradayMiddleware::ParseXml, :content_type => /\bxml$/
+ builder.use FaradayMiddleware::ParseJson, :content_type => /\bjson$/
+ end
+
data_callback(name) do
- HTTParty.get(url).parsed_response
+ connection.get(url).body
end
end
end
View
5 middleman-remote-data.gemspec
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
- s.add_runtime_dependency("middleman", ["~> 2.0.4"])
- s.add_runtime_dependency("httparty", ["~> 0.7.8"])
+ s.add_runtime_dependency("middleman-core", [">= 3.0.0.beta.2"])
+ s.add_runtime_dependency("faraday", ['>= 0.7.4', '< 0.9'])
+ s.add_runtime_dependency("faraday_middleware", ['>= 0.8.6'])
end

0 comments on commit 5936977

Please sign in to comment.