Permalink
Browse files

Adding json to wrap multi_json

  • Loading branch information...
1 parent 0aeeaa6 commit 737bb369f20fc3dd14c0dd58079f302e51e8cdab @calvinfo calvinfo committed Feb 11, 2013
View
@@ -1,3 +1,8 @@
+0.1.1 / 2013-2-11
+===========
+* Updating dependencies
+* Adding actual support for MultiJson 1.0
+
0.1.0 / 2013-1-22
===========
* Updated docs to point at segment.io
View
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
spec.email = 'friends@segment.io'
spec.homepage = 'https://github.com/segmentio/analytics-ruby'
- spec.add_dependency 'faraday', ['~> 0.8', '< 0.10']
+ spec.add_dependency 'faraday', ['>= 0.8', '< 0.10']
spec.add_dependency 'faraday_middleware', ['~> 0.9.0']
spec.add_dependency 'multi_json', ['~> 1.0']
View
@@ -0,0 +1,28 @@
+require 'multi_json'
+
+module AnalyticsRuby
+
+ # JSON Wrapper module adapted from
+ # https://github.com/stripe/stripe-ruby/blob/master/lib/stripe/json.rb
+ #
+ # .dump was added in MultiJson 1.3
+ module JSON
+ if MultiJson.respond_to?(:dump)
+ def self.dump(*args)
+ MultiJson.dump(*args)
+ end
+
+ def self.load(*args)
+ MultiJson.load(*args)
+ end
+ else
+ def self.dump(*args)
+ MultiJson.encode(*args)
+ end
+
+ def self.load(*args)
+ MultiJson.decode(*args)
+ end
+ end
+ end
+end
@@ -1,7 +1,7 @@
require 'analytics-ruby/defaults'
require 'analytics-ruby/response'
-require 'multi_json'
+require 'analytics-ruby/json'
require 'faraday'
require 'faraday_middleware'
@@ -35,7 +35,7 @@ def post(secret, batch)
begin
res = @conn.post do |req|
req.url(@path)
- req.body = MultiJson.dump(secret: secret, batch: batch)
+ req.body = AnalyticsRuby::JSON::dump(secret: secret, batch: batch)
end
status = res.status
error = res.body["error"]
@@ -1,3 +1,3 @@
module AnalyticsRuby
- VERSION = '0.1.0'
+ VERSION = '0.1.1'
end
View
@@ -23,6 +23,7 @@
it 'should not error with the required options' do
Analytics.track AnalyticsHelpers::Queued::TRACK
+ sleep(1)
end
end
@@ -34,6 +35,7 @@
it 'should not error with the required options' do
Analytics.identify AnalyticsHelpers::Queued::IDENTIFY
+ sleep(1)
end
end
end
View
@@ -3,7 +3,7 @@ module AnalyticsHelpers
SECRET = 'testsecret'
- TRACK = { event: 'Baked a cake',
+ TRACK = { event: 'Ruby Library test event',
properties: {
type: 'Chocolate',
is_a_lie: true,

0 comments on commit 737bb36

Please sign in to comment.