legato 0.0.9 → 0.0.10
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
@@ -1,7 +1,16 @@
|
|
1
1
|
# Legato: Google Analytics Model/Mapper #
|
2
|
+
[](https://travis-ci.org/tpitale/legato)
|
2
3
|
|
3
4
|
## [Check out the Wiki!](https://github.com/tpitale/legato/wiki) ##
|
4
5
|
|
6
|
+
If you've come here from Garb, welcome! There are a few changes from Garb, so you'll want to check out:
|
7
|
+
|
8
|
+
* [Model Data](https://github.com/tpitale/legato/wiki/Model-Data)
|
9
|
+
* [Query Parameters](https://github.com/tpitale/legato/wiki/Query-Parameters)
|
10
|
+
* And the biggest difference: [Filtering](https://github.com/tpitale/legato/wiki/Filtering)
|
11
|
+
|
12
|
+
If you're not able to upgrade quite yet, Garb has been maintained https://github.com/Sija/garb
|
13
|
+
|
5
14
|
## Google Analytics Management ##
|
6
15
|
|
7
16
|
1. Get an OAuth2 Access Token from Google, Read about [OAuth2](https://github.com/tpitale/legato/wiki/OAuth2-and-Google)
|
data/lib/legato/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
{"http_interactions":[{"request":{"method":"get","uri":"https://www.googleapis.com/analytics/v3/management/accounts/~all/webproperties/~all/profiles","body":"","headers":{"Authorization":["Bearer ya29.AHES6ZSw3j6NfON_gJdtG6bHrU4bh3gPsRd945judH-Umg"]}},"response":{"status":{"code":200,"message":null},"headers":{"expires":["Mon, 12 Dec 2011 01:50:58 GMT"],"date":["Mon, 12 Dec 2011 01:50:58 GMT"],"cache-control":["private, max-age=0, must-revalidate, no-transform"],"etag":["\"0EbX2LGJDld9q3PnatPaRNNGQuE/b64HzQHPH7LaksA_n9YpboKT6LI\""],"content-type":["application/json; charset=UTF-8"],"x-content-type-options":["nosniff"],"x-frame-options":["SAMEORIGIN"],"x-xss-protection":["1; mode=block"],"server":["GSE"],"connection":["close"]},"body":"{\"kind\":\"analytics#profiles\",\"username\":\"tpitale@gmail.com\",\"totalResults\":0,\"startIndex\":1,\"itemsPerPage\":1000}","http_version":null},"recorded_at":"Mon, 12 Dec 2011 01:51:14 GMT"}],"recorded_with":"VCR 2.0.0.beta2"}
|
@@ -31,4 +31,13 @@ describe "Management" do
|
|
31
31
|
profiles.map(&:id).include?("4506212").should == true
|
32
32
|
end
|
33
33
|
end
|
34
|
+
|
35
|
+
context "Management::Finder without results" do
|
36
|
+
use_vcr_cassette 'management/no_profiles'
|
37
|
+
|
38
|
+
it 'has no profiles' do
|
39
|
+
profiles = Legato::Management::Profile.all(@user)
|
40
|
+
profiles.map(&:id).should == []
|
41
|
+
end
|
42
|
+
end
|
34
43
|
end
|
@@ -1,18 +1,29 @@
|
|
1
1
|
shared_examples_for "a management finder" do
|
2
|
+
let(:response) { stub(:body => 'some json') }
|
3
|
+
let(:access_token) { access_token = stub(:get => response) }
|
4
|
+
let(:user) { stub(:access_token => access_token, :api_key => nil) }
|
5
|
+
|
6
|
+
after do
|
7
|
+
user.should have_received(:access_token)
|
8
|
+
access_token.should have_received(:get).with('https://www.googleapis.com/analytics/v3/management'+described_class.default_path)
|
9
|
+
response.should have_received(:body)
|
10
|
+
MultiJson.should have_received(:decode).with('some json')
|
11
|
+
end
|
12
|
+
|
2
13
|
it "returns an array of all #{subject_class_name} available to a user" do
|
3
14
|
MultiJson.stubs(:decode).returns({'items' => ['item1', 'item2']})
|
4
|
-
response = stub(:body => 'some json')
|
5
|
-
access_token = stub(:get => response)
|
6
|
-
user = stub(:access_token => access_token, :api_key => nil)
|
7
15
|
described_class.stubs(:new).returns('thing1', 'thing2')
|
8
16
|
|
9
17
|
described_class.all(user).should == ['thing1', 'thing2']
|
10
18
|
|
11
|
-
user.should have_received(:access_token)
|
12
|
-
access_token.should have_received(:get).with('https://www.googleapis.com/analytics/v3/management'+described_class.default_path)
|
13
|
-
response.should have_received(:body)
|
14
|
-
MultiJson.should have_received(:decode).with('some json')
|
15
19
|
described_class.should have_received(:new).with('item1', user)
|
16
20
|
described_class.should have_received(:new).with('item2', user)
|
17
21
|
end
|
18
|
-
|
22
|
+
|
23
|
+
it "returns an empty array of #{subject_class_name} when there are no results" do
|
24
|
+
MultiJson.stubs(:decode).returns({})
|
25
|
+
described_class.all(user).should == []
|
26
|
+
|
27
|
+
described_class.should have_received(:new).never
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: legato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
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
|
+
date: 2013-06-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -178,6 +178,7 @@ files:
|
|
178
178
|
- lib/legato/user.rb
|
179
179
|
- lib/legato/version.rb
|
180
180
|
- spec/cassettes/management/accounts.json
|
181
|
+
- spec/cassettes/management/no_profiles.json
|
181
182
|
- spec/cassettes/management/profiles.json
|
182
183
|
- spec/cassettes/management/web_properties.json
|
183
184
|
- spec/cassettes/model/basic.json
|
@@ -222,6 +223,7 @@ specification_version: 3
|
|
222
223
|
summary: Access the Google Analytics API with Ruby
|
223
224
|
test_files:
|
224
225
|
- spec/cassettes/management/accounts.json
|
226
|
+
- spec/cassettes/management/no_profiles.json
|
225
227
|
- spec/cassettes/management/profiles.json
|
226
228
|
- spec/cassettes/management/web_properties.json
|
227
229
|
- spec/cassettes/model/basic.json
|
@@ -240,4 +242,3 @@ test_files:
|
|
240
242
|
- spec/spec_helper.rb
|
241
243
|
- spec/support/examples/management_finder.rb
|
242
244
|
- spec/support/macros/oauth.rb
|
243
|
-
has_rdoc:
|