mixpanel_client 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -28,8 +28,13 @@ Ruby access to the [Mixpanel](http://mixpanel.com/) web analytics tool.
28
28
 
29
29
  ## Changelog
30
30
 
31
+ ### 1.0.1
32
+ * Minor housekeeping and organizing
33
+ * Refactored specs
34
+
31
35
  ### 1.0.0
32
- * Changed "Mixpanel" class name to "MixpanelClient" to prevent naming collision in other libraries. [a710a84e8ba4b6f018b7](https://github.com/keolo/mixpanel_client/commit/a710a84e8ba4b6f018b7404ab9fabc8f08b4a4f3)
36
+ * Changed "Mixpanel" class name to "MixpanelClient" to prevent naming collision in other
37
+ libraries. [a710a84e8ba4b6f018b7](https://github.com/keolo/mixpanel_client/commit/a710a84e8ba4b6f018b7404ab9fabc8f08b4a4f3)
33
38
 
34
39
  ## Collaborators and Maintainers
35
40
  [Keolo Keagy](http://github.com/keolo) (Author)
data/Rakefile CHANGED
@@ -24,25 +24,12 @@ RSpec::Core::RakeTask.new(:rcov) do |spec|
24
24
  spec.rcov = true
25
25
  end
26
26
 
27
- task :spec #=> :check_dependencies
28
-
29
- begin
30
- require 'cucumber/rake/task'
31
- Cucumber::Rake::Task.new(:features)
32
-
33
- task :features #=> :check_dependencies
34
- rescue LoadError
35
- task :features do
36
- abort 'Cucumber is not available. In order to run features, you must: sudo gem install cucumber'
37
- end
38
- end
39
-
27
+ task :spec
40
28
  task :default => :spec
41
29
 
42
30
  require 'rake/rdoctask'
43
31
  Rake::RDocTask.new do |rdoc|
44
32
  version = File.exist?('VERSION') ? File.read('VERSION') : ''
45
-
46
33
  rdoc.rdoc_dir = 'rdoc'
47
34
  rdoc.title = "mixpanel_client #{version}"
48
35
  rdoc.rdoc_files.include('README*')
@@ -1,3 +1,3 @@
1
1
  class MixpanelClient
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -1,2 +1,2 @@
1
1
  require "#{File.dirname(__FILE__)}/mixpanel_client/mixpanel_client"
2
- require "#{File.dirname(__FILE__)}/mixpanel_client/mixpanel_client_uri"
2
+ require "#{File.dirname(__FILE__)}/mixpanel_client/uri"
@@ -19,7 +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_development_dependency('rspec')
23
- s.add_development_dependency('webmock')
24
- s.add_development_dependency('metric_fu')
22
+ s.add_development_dependency('rspec', '>=2.5.0')
23
+ s.add_development_dependency('webmock', '>=1.6.2')
24
+ s.add_development_dependency('metric_fu', '>=2.1.1')
25
25
  end
@@ -1,16 +1,15 @@
1
- require 'rubygems'
2
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
3
2
 
4
3
  WebMock.allow_net_connect!
5
4
 
6
5
  describe 'External calls to mixpanel' do
7
6
  before :all do
8
- config = YAML.load_file(File.dirname(__FILE__) + '/../config/mixpanel.yml')
7
+ config = YAML.load_file(File.dirname(__FILE__) + '/../../config/mixpanel.yml')
9
8
  config.should_not be_nil
10
9
  @client = MixpanelClient.new(config)
11
10
  end
12
11
 
13
- describe 'Events' do
12
+ context 'when requesting events' do
14
13
  it 'should raise an error for bad requests' do
15
14
  data = lambda {
16
15
  @client.request do
@@ -1,6 +1,4 @@
1
- # coding: utf-8
2
- require 'rubygems'
3
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
2
 
5
3
  describe MixpanelClient do
6
4
  before :all do
@@ -9,7 +7,7 @@ describe MixpanelClient do
9
7
  @uri = Regexp.escape(MixpanelClient::BASE_URI)
10
8
  end
11
9
 
12
- describe '#request' do
10
+ context 'when making an invalid request' do
13
11
  it 'should return an argument error "Wrong number of arguments" if using the deprecated usage' do
14
12
  # Stub Mixpanel request
15
13
  stub_request(:get, /^#{@uri}.*/).to_return(:body => '{"legend_size": 0, "data": {"series": [], "values": {}}}')
@@ -19,12 +17,11 @@ describe MixpanelClient do
19
17
  :unit => 'hour',
20
18
  :interval => 24
21
19
  })}
22
-
23
20
  data.should raise_error(ArgumentError)
24
21
  end
25
22
  end
26
23
 
27
- describe 'block form' do
24
+ context 'when making a valid request' do
28
25
  it 'should work without an endpoint' do
29
26
  # Stub Mixpanel request
30
27
  stub_request(:get, /^#{@uri}.*/).to_return(:body => '{"legend_size": 0, "data": {"series": [], "values": {}}}')
@@ -67,20 +64,20 @@ describe MixpanelClient do
67
64
 
68
65
  describe '#hash_args' do
69
66
  it 'should return a hashed string alpha sorted by key names.' do
70
- args = {:c => 'see', :a => 'aye', :d => 'dee', :b => 'bee'}
71
- args_alpha_sorted = {:a => 'aye', :b => 'bee', :c => 'see', :d => 'dee'}
67
+ args = {:c => 'see', :a => 'ey', :d => 'dee', :b => 'bee'}
68
+ args_alpha_sorted = {:a => 'ey', :b => 'bee', :c => 'see', :d => 'dee'}
72
69
  @client.generate_signature(args).should == @client.generate_signature(args_alpha_sorted)
73
70
  end
74
71
  end
75
72
 
76
73
  describe '#to_hash' do
77
74
  it 'should return a ruby hash given json as a string' do
78
- @client.to_hash('{"a" : "aye", "b" : "bee"}').should == {'a' => 'aye', 'b' => 'bee'}
75
+ @client.to_hash('{"a" : "ey", "b" : "bee"}').should == {'a' => 'ey', 'b' => 'bee'}
79
76
  end
80
77
  end
81
78
 
82
- describe 'resetting options' do
83
- it 'options should be reset before each request' do
79
+ context 'when resetting options for each request' do
80
+ it 'should reset options before each request' do
84
81
  # Stub Mixpanel request
85
82
  stub_request(:get, /^#{@uri}.*/).to_return(:body => '{"events": [], "type": "general"}')
86
83
 
@@ -111,30 +108,3 @@ describe MixpanelClient do
111
108
  end
112
109
  end
113
110
  end
114
-
115
- describe MixpanelClient::URI do
116
- describe '.mixpanel' do
117
- it 'should return a properly formatted mixpanel uri as a string (without an endpoint)' do
118
- resource, params = ['events', {:c => 'see', :a => 'aye'}]
119
- MixpanelClient::URI.mixpanel(resource, params).should == 'http://mixpanel.com/api/2.0/events?a=aye&c=see'
120
- end
121
- it 'should return a properly formatted mixpanel uri as a string (with an endpoint)' do
122
- resource, params = ['events/top', {:c => 'see', :a => 'aye'}]
123
- MixpanelClient::URI.mixpanel(resource, params).should == 'http://mixpanel.com/api/2.0/events/top?a=aye&c=see'
124
- end
125
- end
126
-
127
- describe '.encode' do
128
- it 'should return a string with url encoded values.' do
129
- params = {:hey => '!@#$%^&*()\/"Ü', :soo => "hëllö?"}
130
- MixpanelClient::URI.encode(params).should == 'hey=%21%40%23%24%25%5E%26%2A%28%29%5C%2F%22%C3%9C&soo=h%C3%ABll%C3%B6%3F'
131
- end
132
- end
133
-
134
- describe '.get' do
135
- it 'should return a string response' do
136
- stub_request(:get, 'http://example.com').to_return(:body => 'something')
137
- MixpanelClient::URI.get('http://example.com').should == 'something'
138
- end
139
- end
140
- end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
3
+
4
+ describe MixpanelClient::URI do
5
+ describe '.mixpanel' do
6
+ it 'should return a properly formatted mixpanel uri as a string (without an endpoint)' do
7
+ resource, params = ['events', {:c => 'see', :a => 'ey'}]
8
+ MixpanelClient::URI.mixpanel(resource, params).should == 'http://mixpanel.com/api/2.0/events?a=ey&c=see'
9
+ end
10
+ it 'should return a properly formatted mixpanel uri as a string (with an endpoint)' do
11
+ resource, params = ['events/top', {:c => 'see', :a => 'ey'}]
12
+ MixpanelClient::URI.mixpanel(resource, params).should == 'http://mixpanel.com/api/2.0/events/top?a=ey&c=see'
13
+ end
14
+ end
15
+
16
+ describe '.encode' do
17
+ it 'should return a string with url encoded values.' do
18
+ params = {:hey => '!@#$%^&*()\/"Ü', :soo => "hëllö?"}
19
+ MixpanelClient::URI.encode(params).should == 'hey=%21%40%23%24%25%5E%26%2A%28%29%5C%2F%22%C3%9C&soo=h%C3%ABll%C3%B6%3F'
20
+ end
21
+ end
22
+
23
+ describe '.get' do
24
+ it 'should return a string response' do
25
+ stub_request(:get, 'http://example.com').to_return(:body => 'something')
26
+ MixpanelClient::URI.get('http://example.com').should == 'something'
27
+ end
28
+ end
29
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixpanel_client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Keolo Keagy
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-12 00:00:00 -08:00
18
+ date: 2011-03-14 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,10 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 3
29
+ hash: 27
30
30
  segments:
31
+ - 2
32
+ - 5
31
33
  - 0
32
- version: "0"
34
+ version: 2.5.0
33
35
  type: :development
34
36
  version_requirements: *id001
35
37
  - !ruby/object:Gem::Dependency
@@ -40,10 +42,12 @@ dependencies:
40
42
  requirements:
41
43
  - - ">="
42
44
  - !ruby/object:Gem::Version
43
- hash: 3
45
+ hash: 11
44
46
  segments:
45
- - 0
46
- version: "0"
47
+ - 1
48
+ - 6
49
+ - 2
50
+ version: 1.6.2
47
51
  type: :development
48
52
  version_requirements: *id002
49
53
  - !ruby/object:Gem::Dependency
@@ -54,10 +58,12 @@ dependencies:
54
58
  requirements:
55
59
  - - ">="
56
60
  - !ruby/object:Gem::Version
57
- hash: 3
61
+ hash: 9
58
62
  segments:
59
- - 0
60
- version: "0"
63
+ - 2
64
+ - 1
65
+ - 1
66
+ version: 2.1.1
61
67
  type: :development
62
68
  version_requirements: *id003
63
69
  description: Simple ruby client interface to the Mixpanel API.
@@ -80,11 +86,12 @@ files:
80
86
  - config/mixpanel.template.yml
81
87
  - lib/mixpanel_client.rb
82
88
  - lib/mixpanel_client/mixpanel_client.rb
83
- - lib/mixpanel_client/mixpanel_client_uri.rb
89
+ - lib/mixpanel_client/uri.rb
84
90
  - lib/mixpanel_client/version.rb
85
91
  - mixpanel_client.gemspec
86
- - spec/events_externalspec.rb
87
- - spec/mixpanel_client_spec.rb
92
+ - spec/mixpanel_client/events_externalspec.rb
93
+ - spec/mixpanel_client/mixpanel_client_spec.rb
94
+ - spec/mixpanel_client/uri_spec.rb
88
95
  - spec/spec_helper.rb
89
96
  has_rdoc: true
90
97
  homepage: http://github.com/keolo/mixpanel_client
@@ -121,6 +128,7 @@ signing_key:
121
128
  specification_version: 3
122
129
  summary: Ruby Mixpanel API Client Library
123
130
  test_files:
124
- - spec/events_externalspec.rb
125
- - spec/mixpanel_client_spec.rb
131
+ - spec/mixpanel_client/events_externalspec.rb
132
+ - spec/mixpanel_client/mixpanel_client_spec.rb
133
+ - spec/mixpanel_client/uri_spec.rb
126
134
  - spec/spec_helper.rb