garb 0.7.4 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/garb/data_request.rb +2 -2
- data/lib/garb/report_response.rb +1 -1
- data/lib/garb/resource.rb +10 -1
- data/lib/garb/version.rb +1 -1
- data/test/unit/garb/report_response_test.rb +7 -0
- data/test/unit/garb/report_test.rb +10 -2
- metadata +3 -3
data/lib/garb/data_request.rb
CHANGED
@@ -32,11 +32,11 @@ module Garb
|
|
32
32
|
http = Net::HTTP.new(uri.host, uri.port)
|
33
33
|
http.use_ssl = true
|
34
34
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
35
|
-
http.get("#{uri.path}#{query_string}", 'Authorization' => "GoogleLogin auth=#{@session.auth_token}")
|
35
|
+
http.get("#{uri.path}#{query_string}", {'Authorization' => "GoogleLogin auth=#{@session.auth_token}", 'GData-Version' => '2'})
|
36
36
|
end
|
37
37
|
|
38
38
|
def oauth_user_request
|
39
|
-
@session.access_token.get("#{uri}#{query_string}")
|
39
|
+
@session.access_token.get("#{uri}#{query_string}", {'GData-Version' => '2'})
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
data/lib/garb/report_response.rb
CHANGED
data/lib/garb/resource.rb
CHANGED
@@ -40,6 +40,10 @@ module Garb
|
|
40
40
|
@filter_parameters = FilterParameters.new
|
41
41
|
end
|
42
42
|
|
43
|
+
def set_segment_id(id)
|
44
|
+
@segment = "gaid::#{id.to_i}"
|
45
|
+
end
|
46
|
+
|
43
47
|
def results(profile, opts = {}, &block)
|
44
48
|
@profile = profile.is_a?(Profile) ? profile : Profile.first(profile, opts.fetch(:session, Session))
|
45
49
|
|
@@ -67,13 +71,18 @@ module Garb
|
|
67
71
|
'end-date' => format_time(@end_date)}
|
68
72
|
end
|
69
73
|
|
74
|
+
def segment_params
|
75
|
+
@segment ? {'segment' => @segment} : {}
|
76
|
+
end
|
77
|
+
|
70
78
|
def params
|
71
79
|
[
|
72
80
|
metrics.to_params,
|
73
81
|
dimensions.to_params,
|
74
82
|
sort.to_params,
|
75
83
|
filters.to_params,
|
76
|
-
page_params
|
84
|
+
page_params,
|
85
|
+
segment_params
|
77
86
|
].inject(default_params) do |p, i|
|
78
87
|
p.merge(i)
|
79
88
|
end
|
data/lib/garb/version.rb
CHANGED
@@ -9,6 +9,13 @@ module Garb
|
|
9
9
|
|
10
10
|
assert_equal ['33', '2', '1'], response.results.map(&:pageviews)
|
11
11
|
end
|
12
|
+
|
13
|
+
should "return an empty array if there are no results" do
|
14
|
+
response = ReportResponse.new("result xml")
|
15
|
+
Crack::XML.stubs(:parse).with("result xml").returns({'feed' => {'entry' => nil}})
|
16
|
+
|
17
|
+
assert_equal [], response.results
|
18
|
+
end
|
12
19
|
end
|
13
20
|
end
|
14
21
|
end
|
@@ -43,6 +43,11 @@ module Garb
|
|
43
43
|
assert_equal params, @report.default_params
|
44
44
|
end
|
45
45
|
|
46
|
+
should "allow setting a segment id to the segment params" do
|
47
|
+
@report.set_segment_id 121
|
48
|
+
assert_equal({'segment' => 'gaid::121'}, @report.segment_params)
|
49
|
+
end
|
50
|
+
|
46
51
|
should "collect params from metrics, dimensions, filters, sort, and defaults" do
|
47
52
|
@report.stubs(:metrics).returns(stub(:to_params => {'metrics' => 6}))
|
48
53
|
@report.stubs(:dimensions).returns(stub(:to_params => {'dimensions' => 5}))
|
@@ -50,9 +55,12 @@ module Garb
|
|
50
55
|
@report.stubs(:sort).returns(stub(:to_params => {'sort' => 3}))
|
51
56
|
@report.stubs(:page_params).returns({'page_params' => 2})
|
52
57
|
@report.stubs(:default_params).returns({'default_params' => 1})
|
58
|
+
@report.stubs(:segment_params).returns({'segment' => 'gaid::10'})
|
53
59
|
|
54
|
-
|
55
|
-
|
60
|
+
expected_params = {'metrics' => 6,'dimensions' => 5, 'filters' => 4, 'sort' => 3,
|
61
|
+
'page_params' => 2, 'default_params' => 1, 'segment' => 'gaid::10'}
|
62
|
+
|
63
|
+
assert_equal expected_params, @report.params
|
56
64
|
end
|
57
65
|
|
58
66
|
should "format time" do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 7
|
8
|
-
-
|
9
|
-
version: 0.7.
|
8
|
+
- 5
|
9
|
+
version: 0.7.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Tony Pitale
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-05-15 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|