mixpanel_client 0.3.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -14,7 +14,7 @@ Ruby access to the [Mixpanel](http://mixpanel.com/) web analytics tool.
14
14
 
15
15
  api = Mixpanel::Client.new(config)
16
16
 
17
- data = api.request(:events, :general, {
17
+ data = api.request(:events, nil, {
18
18
  :event => '["test-event"]',
19
19
  :unit => 'hour',
20
20
  :interval => 24
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.1
@@ -15,11 +15,12 @@ require 'open-uri'
15
15
  # Ruby library for the mixpanel.com web service
16
16
  module Mixpanel
17
17
  BASE_URI = 'http://mixpanel.com/api'
18
- VERSION = '1.0'
18
+ VERSION = '2.0'
19
19
 
20
20
  # The mixpanel client can be used to easily consume data through the
21
21
  # mixpanel API.
22
22
  class Client
23
+ attr_reader :uri
23
24
  attr_accessor :api_key, :api_secret
24
25
 
25
26
  def initialize(config)
@@ -28,8 +29,8 @@ module Mixpanel
28
29
  end
29
30
 
30
31
  def request(endpoint, meth, params)
31
- uri = URI.mixpanel(endpoint, meth, normalize_params(params))
32
- response = URI.get(uri)
32
+ @uri = URI.mixpanel(endpoint, meth, normalize_params(params))
33
+ response = URI.get(@uri)
33
34
  to_hash(response)
34
35
  end
35
36
 
@@ -54,7 +55,7 @@ module Mixpanel
54
55
  # URI related helpers
55
56
  class URI
56
57
  def self.mixpanel(endpoint, meth, params)
57
- %Q(#{BASE_URI}/#{endpoint}/#{VERSION}/#{meth}?#{self.encode(params)})
58
+ File.join([BASE_URI, VERSION, endpoint.to_s, meth.to_s].reject(&:empty?)) + "?#{self.encode(params)}"
58
59
  end
59
60
 
60
61
  def self.encode(params)
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mixpanel_client}
8
- s.version = "0.3.0"
8
+ s.version = "0.4.1"
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-02-23}
12
+ s.date = %q{2010-08-04}
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 = [
@@ -35,7 +35,7 @@ Gem::Specification.new do |s|
35
35
  s.homepage = %q{http://github.com/keolo/mixpanel_client}
36
36
  s.rdoc_options = ["--charset=UTF-8"]
37
37
  s.require_paths = ["lib"]
38
- s.rubygems_version = %q{1.3.5}
38
+ s.rubygems_version = %q{1.3.6}
39
39
  s.summary = %q{Ruby Mixpanel API Client Library}
40
40
  s.test_files = [
41
41
  "spec/mixpanel_client_spec.rb",
@@ -13,7 +13,7 @@ describe Mixpanel::Client do
13
13
  # Stub Mixpanel web service
14
14
  Mixpanel::URI.stub!(:get).and_return('{"some" : "thing"}')
15
15
 
16
- data = @api.request(:events, :general, {
16
+ data = @api.request(nil, :events, {
17
17
  :event => '["test-event"]',
18
18
  :unit => 'hour',
19
19
  :interval => 24
@@ -39,9 +39,13 @@ end
39
39
 
40
40
  describe Mixpanel::URI do
41
41
  describe '.mixpanel' do
42
- it 'should return a properly formatted mixpanel uri as a string' do
43
- endpoint, meth, params = [:events, :general, {:c => 'see', :a => 'aye'}]
44
- Mixpanel::URI.mixpanel(endpoint, meth, params).should == 'http://mixpanel.com/api/events/1.0/general?a=aye&c=see'
42
+ it 'should return a properly formatted mixpanel uri as a string (without an endpoint)' do
43
+ endpoint, meth, params = [:events, nil, {:c => 'see', :a => 'aye'}]
44
+ Mixpanel::URI.mixpanel(endpoint, meth, params).should == 'http://mixpanel.com/api/2.0/events?a=aye&c=see'
45
+ end
46
+ it 'should return a properly formatted mixpanel uri as a string (with an endpoint)' do
47
+ endpoint, meth, params = [:events, :top, {:c => 'see', :a => 'aye'}]
48
+ Mixpanel::URI.mixpanel(endpoint, meth, params).should == 'http://mixpanel.com/api/2.0/events/top?a=aye&c=see'
45
49
  end
46
50
  end
47
51
 
data/test/manual.rb CHANGED
@@ -1,5 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # Notes:
4
+ # Test URI.mixpanel in browser to see response and error codes.
5
+ #
6
+
3
7
  require 'rubygems'
4
8
  require "#{File.dirname(__FILE__)}/../lib/mixpanel_client"
5
9
  #require 'mixpanel_client'
@@ -9,10 +13,18 @@ config = {:api_key => 'e81de686c96261747fdc443d4809c297', :api_secret => '201ff8
9
13
 
10
14
  api = Mixpanel::Client.new(config)
11
15
 
12
- data = api.request(:events, :general, {
16
+ data = api.request(nil, :events, {
13
17
  :event => '["test-event"]',
14
18
  :unit => 'hour',
15
- :interval => 24
19
+ :interval => 24,
20
+ })
21
+
22
+ puts api.inspect
23
+ puts data.inspect
24
+
25
+ data = api.request(:events, :top, {
26
+ :type => 'general',
27
+ #:format => :csv
16
28
  })
17
29
 
18
30
  puts api.inspect
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixpanel_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 4
8
+ - 1
9
+ version: 0.4.1
5
10
  platform: ruby
6
11
  authors:
7
12
  - Keolo Keagy
@@ -9,29 +14,35 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-23 00:00:00 -08:00
17
+ date: 2010-08-04 00:00:00 -07:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: rspec
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 2
30
+ - 9
23
31
  version: 1.2.9
24
- version:
32
+ type: :development
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: cucumber
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
30
38
  requirements:
31
39
  - - ">="
32
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
33
43
  version: "0"
34
- version:
44
+ type: :development
45
+ version_requirements: *id002
35
46
  description: Simple ruby client interface to the Mixpanel API.
36
47
  email: keolo@dreampointmedia.com
37
48
  executables: []
@@ -69,18 +80,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
80
  requirements:
70
81
  - - ">="
71
82
  - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
72
85
  version: "0"
73
- version:
74
86
  required_rubygems_version: !ruby/object:Gem::Requirement
75
87
  requirements:
76
88
  - - ">="
77
89
  - !ruby/object:Gem::Version
90
+ segments:
91
+ - 0
78
92
  version: "0"
79
- version:
80
93
  requirements: []
81
94
 
82
95
  rubyforge_project:
83
- rubygems_version: 1.3.5
96
+ rubygems_version: 1.3.6
84
97
  signing_key:
85
98
  specification_version: 3
86
99
  summary: Ruby Mixpanel API Client Library