mixpanel_client 2.0.0.beta1 → 2.0.0.beta2

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/README.md CHANGED
@@ -30,6 +30,9 @@ Ruby access to the [Mixpanel](http://mixpanel.com/) web analytics tool.
30
30
 
31
31
  ## Changelog
32
32
 
33
+ ### 2.0.0.beta2
34
+ * Added JSON to gemspec for ruby versions less than 1.9.
35
+
33
36
  ### 2.0.0.beta1
34
37
  * Reverted to namespacing via module name because it's a better practice.
35
38
  I.e. Use `Mixpanel::Client` instead of `MixpanelClient`.
@@ -46,6 +49,8 @@ Ruby access to the [Mixpanel](http://mixpanel.com/) web analytics tool.
46
49
 
47
50
  ## Collaborators and Maintainers
48
51
  [Keolo Keagy](http://github.com/keolo) (Author)
52
+ [Mike Ferrier](http://github.com/mferrier)
53
+ [Railwaymen](http://github.com/railwaymen)
49
54
  [Nathan Chong](http://github.com/paramaw)
50
55
  [Paul McMahon](http://github.com/pwim)
51
56
  [Chad Etzel](http://github.com/jazzychad)
data/lib/mixpanel/uri.rb CHANGED
@@ -9,18 +9,20 @@
9
9
  # http://mixpanel.com/api/docs/guides/api/
10
10
 
11
11
  # URI related helpers
12
- class Mixpanel::URI
13
- def self.mixpanel(resource, params)
14
- File.join([Mixpanel::Client::BASE_URI, Mixpanel::Client::API_VERSION, resource.to_s]) + "?#{self.encode(params)}"
15
- end
12
+ module Mixpanel
13
+ class URI
14
+ def self.mixpanel(resource, params)
15
+ File.join([Mixpanel::Client::BASE_URI, Mixpanel::Client::API_VERSION, resource.to_s]) + "?#{self.encode(params)}"
16
+ end
16
17
 
17
- def self.encode(params)
18
- params.map{|key,val| "#{key}=#{CGI.escape(val.to_s)}"}.sort.join('&')
19
- end
18
+ def self.encode(params)
19
+ params.map{|key,val| "#{key}=#{CGI.escape(val.to_s)}"}.sort.join('&')
20
+ end
20
21
 
21
- def self.get(uri)
22
- ::URI.parse(uri).read
23
- rescue OpenURI::HTTPError => error
24
- raise HTTPError, JSON.parse(error.io.read)['error']
22
+ def self.get(uri)
23
+ ::URI.parse(uri).read
24
+ rescue OpenURI::HTTPError => error
25
+ raise HTTPError, JSON.parse(error.io.read)['error']
26
+ end
25
27
  end
26
28
  end
@@ -1,6 +1,6 @@
1
1
  # Set version number for mixpanel_client
2
2
  module Mixpanel
3
3
  class Client
4
- VERSION = '2.0.0.beta1'
4
+ VERSION = '2.0.0.beta2'
5
5
  end
6
6
  end
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ['lib']
21
21
 
22
+ s.add_dependency('json', '~> 1.5.1') if RUBY_VERSION < '1.9'
22
23
  s.add_development_dependency('rspec', '>=2.5.0')
23
24
  s.add_development_dependency('webmock', '>=1.6.2')
24
25
  s.add_development_dependency('metric_fu', '>=2.1.1')
@@ -2,11 +2,16 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe Mixpanel::Client do
4
4
  before :all do
5
- config = {'api_key' => 'test', 'api_secret' => 'test'}
6
- @client = Mixpanel::Client.new(config)
5
+ @client = Mixpanel::Client.new('api_key' => 'test_key', 'api_secret' => 'test_secret')
7
6
  @uri = Regexp.escape(Mixpanel::Client::BASE_URI)
8
7
  end
9
8
 
9
+ context 'when initializing a new Mixpanel::Client' do
10
+ it 'should not raise an exception if a hash is given' do
11
+ Mixpanel::Client.new('api_key' => 'test_key', 'api_secret' => 'test_secret').should_not raise_error(ArgumentError)
12
+ end
13
+ end
14
+
10
15
  context 'when making an invalid request' do
11
16
  it 'should return an argument error "Wrong number of arguments" if using the deprecated usage' do
12
17
  # Stub Mixpanel request
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixpanel_client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196449
4
+ hash: 62196455
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
9
  - 0
10
10
  - beta
11
- - 1
12
- version: 2.0.0.beta1
11
+ - 2
12
+ version: 2.0.0.beta2
13
13
  platform: ruby
14
14
  authors:
15
15
  - Keolo Keagy
@@ -17,13 +17,29 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-05-18 00:00:00 -07:00
20
+ date: 2011-06-01 00:00:00 -07:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
- name: rspec
24
+ name: json
25
25
  prerelease: false
26
26
  requirement: &id001 !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ~>
30
+ - !ruby/object:Gem::Version
31
+ hash: 1
32
+ segments:
33
+ - 1
34
+ - 5
35
+ - 1
36
+ version: 1.5.1
37
+ type: :runtime
38
+ version_requirements: *id001
39
+ - !ruby/object:Gem::Dependency
40
+ name: rspec
41
+ prerelease: false
42
+ requirement: &id002 !ruby/object:Gem::Requirement
27
43
  none: false
28
44
  requirements:
29
45
  - - ">="
@@ -35,11 +51,11 @@ dependencies:
35
51
  - 0
36
52
  version: 2.5.0
37
53
  type: :development
38
- version_requirements: *id001
54
+ version_requirements: *id002
39
55
  - !ruby/object:Gem::Dependency
40
56
  name: webmock
41
57
  prerelease: false
42
- requirement: &id002 !ruby/object:Gem::Requirement
58
+ requirement: &id003 !ruby/object:Gem::Requirement
43
59
  none: false
44
60
  requirements:
45
61
  - - ">="
@@ -51,11 +67,11 @@ dependencies:
51
67
  - 2
52
68
  version: 1.6.2
53
69
  type: :development
54
- version_requirements: *id002
70
+ version_requirements: *id003
55
71
  - !ruby/object:Gem::Dependency
56
72
  name: metric_fu
57
73
  prerelease: false
58
- requirement: &id003 !ruby/object:Gem::Requirement
74
+ requirement: &id004 !ruby/object:Gem::Requirement
59
75
  none: false
60
76
  requirements:
61
77
  - - ">="
@@ -67,7 +83,7 @@ dependencies:
67
83
  - 1
68
84
  version: 2.1.1
69
85
  type: :development
70
- version_requirements: *id003
86
+ version_requirements: *id004
71
87
  description: Simple ruby client interface to the Mixpanel API.
72
88
  email:
73
89
  - keolo@dreampointmedia.com