analytics-rb 0.0.10 → 0.0.11

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/.coveralls.yml CHANGED
@@ -1,3 +1,2 @@
1
- service_name: travis-pro
2
1
  repo_token: oGPYHZPw9CvkHSCdoSy4faX4Be7zMGKEB
3
2
 
data/README.md CHANGED
@@ -1,8 +1,4 @@
1
- # Analytics
2
-
3
- [![Build Status](https://travis-ci.org/AlexisMontagne/analytics.png?branch=master)](https://travis-ci.org/AlexisMontagne/analytics)
4
- [![Code Climate](https://codeclimate.com/repos/528d2778c7f3a335fa013259/badges/c4c17ae9f5591d5b5509/gpa.png)](https://codeclimate.com/repos/528d2778c7f3a335fa013259/feed)
5
- [![githalytics.com alpha](https://cruel-carlota.pagodabox.com/b9b735f530731e985ae3f291b84c4e63 "githalytics.com")](http://githalytics.com/AlexisMontagne/analytics)
1
+ # Analytics [![Build Status](https://travis-ci.org/AlexisMontagne/analytics.png?branch=master)](https://travis-ci.org/AlexisMontagne/analytics) [![Code Climate](https://codeclimate.com/repos/528d2778c7f3a335fa013259/badges/c4c17ae9f5591d5b5509/gpa.png)](https://codeclimate.com/repos/528d2778c7f3a335fa013259/feed) [![Gem Version](https://badge.fury.io/rb/analytics-rb.png)](http://badge.fury.io/rb/analytics-rb) [![Dependency Status](https://gemnasium.com/AlexisMontagne/analytics.png)](https://gemnasium.com/AlexisMontagne/analytics) [![githalytics.com alpha](https://cruel-carlota.pagodabox.com/b9b735f530731e985ae3f291b84c4e63 "githalytics.com")](http://githalytics.com/AlexisMontagne/analytics)
6
2
 
7
3
  A Ruby interface to the Google Analytics API.
8
4
 
@@ -26,41 +22,50 @@ Or install it yourself as:
26
22
 
27
23
  To make calls to the Google Analytics API, you have to authenticate via an API key (which you can get from the Google [APIs Console](https://code.google.com/apis/console#access). To set your API key and get started, use:
28
24
 
29
- Analytics.consumer_key = 'your key'
30
- Analytics.consumer_secret = 'your secret'
25
+ ```ruby
26
+ Analytics.consumer_key = 'your key'
27
+ Analytics.consumer_secret = 'your secret'
28
+ ```
31
29
 
32
30
  Then you have to provide an access token ( OAuth or OAuth2 ) to manage or visualize statistics.
33
-
34
- client = Analytics::Client.new(Analytics::OAuth.access_token('my token', 'my secret')) # With OAuth 1.x
35
- client = Analytics::Client.new(Analytics::OAuth.access_token('my token')) # With OAuth 2.x
36
-
31
+
32
+ ```ruby
33
+ client = Analytics::Client.new(Analytics::OAuth.access_token('my token', 'my secret')) # With OAuth 1.x
34
+ client = Analytics::Client.new(Analytics::OAuth.access_token('my token')) # With OAuth 2.x
35
+ ```
36
+
37
37
  ### Management
38
38
 
39
- ** You can access to the accounts, web properties and profile from a `Analytics::Client`
40
-
41
- client.accounts # returns an array of Analytics::Account
42
- client.web_properties # returns an array of Analytics::WebProperty
43
- client.profiles # returns an array of Analytics::Profile
39
+ You can access to the accounts, web properties and profile from an `Analytics::Client`
40
+
41
+ ```ruby
42
+ client.accounts # returns an array of Analytics::Account
43
+ client.web_properties # returns an array of Analytics::WebProperty
44
+ client.profiles # returns an array of Analytics::Profile
45
+ ```
44
46
 
45
47
  ### Reporting
46
48
 
47
- From a `Analyics::Profile` you can access to the report object
49
+ You can access the report object from an `Analytics::Profile`
48
50
 
49
- profile.report
50
- # or
51
- Analyics::Report.new('profile_id', access_token) # access_token is a OAuth::AccessToken or OAuth2::AccessToken
51
+ ```ruby
52
+ profile.report
53
+ # or
54
+ Analytics::Report.new('profile_id', access_token) # access_token is a OAuth::AccessToken or OAuth2::AccessToken
55
+ ```
52
56
 
53
- You can grab datas with a simple DSL
57
+ You can grab data with a simple DSL
54
58
 
55
- report.visits(0, Time.now) # it should grab all visits from Jan 1st 1970 to now
56
- # you can provide all metrics from google analytics ( visitors, new_visits, percent_new_visits, ... )
59
+ ```ruby
60
+ report.visits(0, Time.now) # it should grab all visits from Jan 1st 1970 to now
61
+ # you can provide all metrics from google analytics ( visitors, new_visits, percent_new_visits, ... )
57
62
 
58
- # you can provide a metric and a dimension
59
- report.visits_by_month(0, Time.now)
60
-
61
- # you can provide multiple metrics and dimensions as well
62
- report.visists_and_visitors_by_month_and_city(0, Time.now)
63
+ # you can provide a metric and a dimension
64
+ report.visits_by_month(0, Time.now)
63
65
 
66
+ # you can provide multiple metrics and dimensions as well
67
+ report.visists_and_visitors_by_month_and_city(0, Time.now)
68
+ ```
64
69
 
65
70
  ## Contributing
66
71
 
@@ -7,9 +7,18 @@ module Analytics
7
7
  end
8
8
 
9
9
  def request
10
- access_token.get(full_path).body
11
- rescue ::OAuth2::Error
12
- raise Analytics::Error::PermissionInsufficient
10
+ retried = false
11
+ begin
12
+ access_token.get(full_path).body
13
+ rescue ::OAuth2::Error => e
14
+ # One of the 403 error code means that you already did 10 requests for a second
15
+ if e.code["error"] == 403 && !retried
16
+ sleep 1
17
+ retried = true
18
+ retry
19
+ end
20
+ raise Analytics::Error::PermissionInsufficient
21
+ end
13
22
  end
14
23
 
15
24
  def response
@@ -1,3 +1,3 @@
1
1
  module Analytics
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
@@ -3,10 +3,10 @@ require "spec_helper"
3
3
  describe Analytics::Request do
4
4
  let(:incorrect_token) { ::OAuth2::AccessToken.new(::OAuth2::Client.new('1','1'),'123') }
5
5
  let(:sample_request) { Analytics::Request.new('http://assets.up-fluence.com', 'test.json', incorrect_token) }
6
-
6
+
7
7
  context ".full_path" do
8
8
  it "should render the normal fullpath" do
9
- sample_request.full_path.should == 'http://assets.up-fluence.com/test.json'
9
+ sample_request.full_path.should == 'http://assets.up-fluence.com/test.json'
10
10
  end
11
11
  end
12
12
 
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,7 @@
1
- require 'analytics-rb'
2
1
  require 'coveralls'
3
2
  Coveralls.wear!
4
3
 
4
+ require 'analytics-rb'
5
5
  require 'vcr'
6
6
 
7
7
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: analytics-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-14 00:00:00.000000000 Z
12
+ date: 2014-01-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -199,12 +199,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
199
199
  - - ! '>='
200
200
  - !ruby/object:Gem::Version
201
201
  version: '0'
202
+ segments:
203
+ - 0
204
+ hash: -2642488278583136719
202
205
  required_rubygems_version: !ruby/object:Gem::Requirement
203
206
  none: false
204
207
  requirements:
205
208
  - - ! '>='
206
209
  - !ruby/object:Gem::Version
207
210
  version: '0'
211
+ segments:
212
+ - 0
213
+ hash: -2642488278583136719
208
214
  requirements: []
209
215
  rubyforge_project:
210
216
  rubygems_version: 1.8.23