garb 0.9.1 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +95 -0
- data/Gemfile +15 -0
- data/README.md +47 -25
- data/Rakefile +8 -34
- data/garb.gemspec +22 -0
- data/lib/garb.rb +71 -48
- data/lib/garb/attributes.rb +35 -0
- data/lib/garb/core_ext/array.rb +13 -0
- data/lib/garb/core_ext/string.rb +48 -0
- data/lib/garb/core_ext/symbol.rb +59 -0
- data/lib/garb/destination.rb +5 -6
- data/lib/garb/errors.rb +20 -0
- data/lib/garb/filter_parameters.rb +20 -29
- data/lib/garb/management/account.rb +10 -16
- data/lib/garb/management/feed.rb +4 -5
- data/lib/garb/management/goal.rb +10 -15
- data/lib/garb/management/profile.rb +11 -20
- data/lib/garb/management/segment.rb +9 -15
- data/lib/garb/management/web_property.rb +11 -16
- data/lib/garb/model.rb +37 -13
- data/lib/garb/path_attribute.rb +7 -0
- data/lib/garb/report_parameter.rb +5 -5
- data/lib/garb/report_response.rb +29 -28
- data/lib/garb/reports/bounces.rb +1 -1
- data/lib/garb/reports/exits.rb +1 -1
- data/lib/garb/reports/pageviews.rb +1 -1
- data/lib/garb/reports/unique_pageviews.rb +1 -1
- data/lib/garb/reports/visits.rb +1 -1
- data/lib/garb/request/authentication.rb +54 -0
- data/lib/garb/request/data.rb +98 -0
- data/lib/garb/result_set.rb +23 -9
- data/lib/garb/session.rb +3 -3
- data/lib/garb/step.rb +4 -4
- data/lib/garb/support.rb +6 -0
- data/lib/garb/version.rb +3 -3
- data/test/fixtures/account_management.json +1 -0
- data/test/fixtures/ga_profile_management.json +1 -0
- data/test/fixtures/ga_segment_management.json +1 -0
- data/test/fixtures/ga_webproperty_management.json +1 -0
- data/test/fixtures/goal_management.json +1 -0
- data/test/fixtures/profile_feed.json +1 -0
- data/test/fixtures/report_feed.json +75 -0
- data/test/test_helper.rb +6 -10
- data/test/unit/garb/filter_parameters_test.rb +15 -46
- data/test/unit/garb/management/account_test.rb +8 -16
- data/test/unit/garb/management/feed_test.rb +5 -10
- data/test/unit/garb/management/goal_test.rb +7 -21
- data/test/unit/garb/management/profile_test.rb +11 -26
- data/test/unit/garb/management/segment_test.rb +7 -6
- data/test/unit/garb/management/web_property_test.rb +10 -12
- data/test/unit/garb/model_test.rb +70 -32
- data/test/unit/garb/report_parameter_test.rb +6 -6
- data/test/unit/garb/report_response_test.rb +23 -13
- data/test/unit/garb/request/authentication_test.rb +152 -0
- data/test/unit/garb/request/data_test.rb +157 -0
- data/test/unit/garb/session_test.rb +13 -13
- data/test/unit/garb_test.rb +4 -11
- data/test/unit/symbol_operator_test.rb +3 -3
- metadata +90 -292
- data/lib/garb/account.rb +0 -22
- data/lib/garb/account_feed_request.rb +0 -25
- data/lib/garb/authentication_request.rb +0 -53
- data/lib/garb/data_request.rb +0 -42
- data/lib/garb/goal.rb +0 -20
- data/lib/garb/profile.rb +0 -33
- data/lib/garb/report.rb +0 -28
- data/lib/garb/resource.rb +0 -115
- data/lib/support.rb +0 -40
- data/test/unit/garb/account_feed_request_test.rb +0 -42
- data/test/unit/garb/account_test.rb +0 -53
- data/test/unit/garb/authentication_request_test.rb +0 -121
- data/test/unit/garb/coverage/assets/0.3.9/app.js +0 -66
- data/test/unit/garb/coverage/assets/0.3.9/fancybox/blank.gif +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_close.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_loading.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_nav_left.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_nav_right.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_e.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_n.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_ne.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_nw.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_s.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_se.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_sw.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_w.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_title_left.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_title_main.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_title_over.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_title_right.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancybox-x.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancybox-y.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancybox.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/fancybox/jquery.fancybox-1.3.1.css +0 -363
- data/test/unit/garb/coverage/assets/0.3.9/fancybox/jquery.fancybox-1.3.1.pack.js +0 -44
- data/test/unit/garb/coverage/assets/0.3.9/favicon.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/jquery-1.4.2.min.js +0 -155
- data/test/unit/garb/coverage/assets/0.3.9/jquery.dataTables.min.js +0 -152
- data/test/unit/garb/coverage/assets/0.3.9/jquery.timeago.js +0 -141
- data/test/unit/garb/coverage/assets/0.3.9/jquery.url.js +0 -174
- data/test/unit/garb/coverage/assets/0.3.9/loading.gif +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/magnify.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/test/unit/garb/coverage/assets/0.3.9/smoothness/jquery-ui-1.8.4.custom.css +0 -295
- data/test/unit/garb/coverage/assets/0.3.9/stylesheet.css +0 -341
- data/test/unit/garb/coverage/index.html +0 -100
- data/test/unit/garb/coverage/resultset.yml +0 -5
- data/test/unit/garb/data_request_test.rb +0 -107
- data/test/unit/garb/destination_test.rb +0 -28
- data/test/unit/garb/goal_test.rb +0 -24
- data/test/unit/garb/management/coverage/assets/0.3.9/app.js +0 -66
- data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/blank.gif +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_close.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_loading.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_nav_left.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_nav_right.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_e.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_n.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_ne.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_nw.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_s.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_se.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_sw.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_w.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_title_left.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_title_main.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_title_over.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_title_right.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancybox-x.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancybox-y.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancybox.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/jquery.fancybox-1.3.1.css +0 -363
- data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/jquery.fancybox-1.3.1.pack.js +0 -44
- data/test/unit/garb/management/coverage/assets/0.3.9/favicon.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/jquery-1.4.2.min.js +0 -155
- data/test/unit/garb/management/coverage/assets/0.3.9/jquery.dataTables.min.js +0 -152
- data/test/unit/garb/management/coverage/assets/0.3.9/jquery.timeago.js +0 -141
- data/test/unit/garb/management/coverage/assets/0.3.9/jquery.url.js +0 -174
- data/test/unit/garb/management/coverage/assets/0.3.9/loading.gif +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/magnify.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/jquery-ui-1.8.4.custom.css +0 -295
- data/test/unit/garb/management/coverage/assets/0.3.9/stylesheet.css +0 -341
- data/test/unit/garb/management/coverage/index.html +0 -100
- data/test/unit/garb/management/coverage/resultset.yml +0 -5
- data/test/unit/garb/profile_test.rb +0 -77
- data/test/unit/garb/report_test.rb +0 -99
- data/test/unit/garb/resource_test.rb +0 -50
- data/test/unit/garb/step_test.rb +0 -15
@@ -1,99 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Garb
|
4
|
-
# Also tests Garb::Resource, which is the basis for Garb::Report
|
5
|
-
class ReportTest < MiniTest::Unit::TestCase
|
6
|
-
context "An instance of the Report class" do
|
7
|
-
setup do
|
8
|
-
@now = Time.now
|
9
|
-
Time.stubs(:now).returns(@now)
|
10
|
-
@profile = stub(:table_id => 'ga:1234', :session => Session)
|
11
|
-
@report = Report.new(@profile)
|
12
|
-
end
|
13
|
-
|
14
|
-
%w(metrics dimensions sort).each do |param|
|
15
|
-
should "have parameters for #{param}" do
|
16
|
-
assert @report.send(:"#{param}").is_a?(ReportParameter)
|
17
|
-
end
|
18
|
-
|
19
|
-
should "clear parameters for #{param}" do
|
20
|
-
assert_equal({}, @report.send(:"clear_#{param}").to_params)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
should "have filter parameters for filters" do
|
25
|
-
assert @report.filters.is_a?(FilterParameters)
|
26
|
-
end
|
27
|
-
|
28
|
-
should "add new filters to filter parameters" do
|
29
|
-
@report.clear_filters
|
30
|
-
hash = {:thing.gt => 'val'}
|
31
|
-
@report.filters hash
|
32
|
-
|
33
|
-
assert_equal hash, @report.filters.parameters.first
|
34
|
-
end
|
35
|
-
|
36
|
-
should "clear filter parameters for filters" do
|
37
|
-
assert_equal({}, @report.clear_filters.to_params)
|
38
|
-
end
|
39
|
-
|
40
|
-
should "have default parameters" do
|
41
|
-
@report.stubs(:format_time).returns('2009-08-01')
|
42
|
-
params = {'ids' => 'ga:1234', 'start-date' => '2009-08-01', 'end-date' => '2009-08-01'}
|
43
|
-
assert_equal params, @report.default_params
|
44
|
-
end
|
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
|
-
|
51
|
-
should "collect params from metrics, dimensions, filters, sort, and defaults" do
|
52
|
-
@report.stubs(:metrics).returns(stub(:to_params => {'metrics' => 6}))
|
53
|
-
@report.stubs(:dimensions).returns(stub(:to_params => {'dimensions' => 5}))
|
54
|
-
@report.stubs(:filters).returns(stub(:to_params => {'filters' => 4}))
|
55
|
-
@report.stubs(:sort).returns(stub(:to_params => {'sort' => 3}))
|
56
|
-
@report.stubs(:page_params).returns({'page_params' => 2})
|
57
|
-
@report.stubs(:default_params).returns({'default_params' => 1})
|
58
|
-
@report.stubs(:segment_params).returns({'segment' => 'gaid::10'})
|
59
|
-
|
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
|
64
|
-
end
|
65
|
-
|
66
|
-
should "format time" do
|
67
|
-
assert_equal @now.strftime('%Y-%m-%d'), @report.format_time(@now)
|
68
|
-
end
|
69
|
-
|
70
|
-
should "send a data request to GA" do
|
71
|
-
response = mock {|m| m.expects(:body).returns('response body') }
|
72
|
-
request = mock {|m| m.expects(:send_request).returns(response) }
|
73
|
-
@report.expects(:params).returns('params')
|
74
|
-
|
75
|
-
DataRequest.expects(:new).with(Session, Garb::Report::URL, 'params').returns(request)
|
76
|
-
assert_equal 'response body', @report.send_request_for_body
|
77
|
-
end
|
78
|
-
|
79
|
-
should "fetch and parse results from GA" do
|
80
|
-
@report.expects(:send_request_for_body).with().returns('xml')
|
81
|
-
ReportResponse.expects(:new).with('xml').returns(mock(:results => ['entry']))
|
82
|
-
assert_equal ['entry'], @report.results
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
context "An instance of the Report class with initial options" do
|
87
|
-
setup do
|
88
|
-
@profile = stub(:table_id => 'ga:1234')
|
89
|
-
@report = Report.new(@profile, :limit => 10, :offset => 20)
|
90
|
-
end
|
91
|
-
|
92
|
-
should "have page paramaters" do
|
93
|
-
params = {'max-results' => 10, 'start-index' => 20}
|
94
|
-
assert_equal params, @report.page_params
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
end
|
99
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
# Most of the resource testing is done as a part of ReportTest
|
4
|
-
class ResourceTest < MiniTest::Unit::TestCase
|
5
|
-
|
6
|
-
context "A class with Garb::Resource mixed in" do
|
7
|
-
setup do
|
8
|
-
@test_report = Class.new
|
9
|
-
@test_report.extend(Garb::Resource)
|
10
|
-
end
|
11
|
-
|
12
|
-
should "get results from GA" do
|
13
|
-
profile = stub(:is_a? => true)
|
14
|
-
@test_report.expects(:send_request_for_body).returns('xml')
|
15
|
-
Garb::ReportResponse.expects(:new).with('xml', OpenStruct).returns(mock(:results => 'analytics'))
|
16
|
-
|
17
|
-
assert_equal 'analytics', @test_report.results(profile)
|
18
|
-
end
|
19
|
-
|
20
|
-
should "get results from GA using a specific user session" do
|
21
|
-
profile = '123'
|
22
|
-
session = Garb::Session.new
|
23
|
-
@test_report.expects(:send_request_for_body).returns('xml')
|
24
|
-
Garb::ReportResponse.expects(:new).with('xml', OpenStruct).returns(mock(:results => 'analytics'))
|
25
|
-
Garb::Profile.expects(:first).with(profile, session).returns(mock('Garb::Profile'))
|
26
|
-
|
27
|
-
assert_equal 'analytics', @test_report.results(profile, :session => session)
|
28
|
-
end
|
29
|
-
|
30
|
-
should "permit setting a segment id" do
|
31
|
-
@test_report.set_segment_id 1
|
32
|
-
assert_equal "gaid::1", @test_report.segment
|
33
|
-
end
|
34
|
-
|
35
|
-
should "permit setting a klass used for instantiation of results" do
|
36
|
-
TestKlass = Class.new(OpenStruct)
|
37
|
-
@test_report.set_instance_klass TestKlass
|
38
|
-
assert_equal TestKlass, @test_report.instance_klass
|
39
|
-
end
|
40
|
-
|
41
|
-
should "return an empty result set if profile is invalid" do
|
42
|
-
profile = '123'
|
43
|
-
@test_report.expects(:send_request_for_body).never
|
44
|
-
Garb::ReportResponse.expects(:new).never
|
45
|
-
|
46
|
-
Garb::Profile.expects(:first).returns(nil)
|
47
|
-
assert_equal [], @test_report.results(profile)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
data/test/unit/garb/step_test.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Garb
|
4
|
-
class StepTest < MiniTest::Unit::TestCase
|
5
|
-
context "A Step" do
|
6
|
-
should "have a name, number, and path" do
|
7
|
-
step = Step.new({'name' => 'Contact Form Page', 'number' => '1', 'path' => '/contact.html'})
|
8
|
-
|
9
|
-
assert_equal 'Contact Form Page', step.name
|
10
|
-
assert_equal 1, step.number
|
11
|
-
assert_equal '/contact.html', step.path
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|