mixpanel_client 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/mixpanel_client.rb +10 -7
- data/mixpanel_client.gemspec +2 -2
- data/spec/mixpanel_client_spec.rb +4 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
data/lib/mixpanel_client.rb
CHANGED
@@ -15,7 +15,7 @@ require 'open-uri'
|
|
15
15
|
|
16
16
|
module Mixpanel
|
17
17
|
class Client
|
18
|
-
attr_accessor :api_key, :api_secret
|
18
|
+
attr_accessor :api_key, :api_secret, :format
|
19
19
|
|
20
20
|
BASE_URI = 'http://mixpanel.com/api'
|
21
21
|
VERSION = '1.0'
|
@@ -23,12 +23,14 @@ module Mixpanel
|
|
23
23
|
def initialize(config)
|
24
24
|
@api_key = config[:api_key]
|
25
25
|
@api_secret = config[:api_secret]
|
26
|
+
@format ||= :json
|
26
27
|
end
|
27
28
|
|
28
29
|
def request(endpoint, meth, params)
|
29
|
-
params[:api_key]
|
30
|
-
params[:expire]
|
31
|
-
params[:sig]
|
30
|
+
params[:api_key] = api_key
|
31
|
+
params[:expire] = Time.now.to_i + 600 # Grant this request 10 minutes
|
32
|
+
params[:sig] = hash_args(params)
|
33
|
+
params[:format] ||= @format
|
32
34
|
|
33
35
|
@format = params[:format]
|
34
36
|
|
@@ -54,9 +56,10 @@ module Mixpanel
|
|
54
56
|
|
55
57
|
def to_hash(data)
|
56
58
|
case @format
|
57
|
-
when :
|
58
|
-
#
|
59
|
-
|
59
|
+
when :placeholder
|
60
|
+
# This is just a placeholder in case Mixpanel supports alternate
|
61
|
+
# formats. Mixpanel at this time (v1.0) only supports JSON.
|
62
|
+
else # The default response is JSON
|
60
63
|
require 'json' unless defined?(JSON)
|
61
64
|
JSON.parse(data)
|
62
65
|
end
|
data/mixpanel_client.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mixpanel_client}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Keolo Keagy"]
|
12
|
-
s.date = %q{2010-01-
|
12
|
+
s.date = %q{2010-01-19}
|
13
13
|
s.description = %q{Simple ruby client interface to the Mixpanel API.}
|
14
14
|
s.email = %q{keolo@dreampointmedia.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -8,6 +8,10 @@ describe 'Mixpanel::Client' do
|
|
8
8
|
@api = Mixpanel::Client.new(config)
|
9
9
|
end
|
10
10
|
|
11
|
+
it 'should have a format attribute that defaults to :json' do
|
12
|
+
@api.format.should == :json
|
13
|
+
end
|
14
|
+
|
11
15
|
describe '#request' do
|
12
16
|
it 'should return json and convert to a ruby hash' do
|
13
17
|
# Stub Mixpanel web service
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mixpanel_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keolo Keagy
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-19 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|