garb 0.9.1 → 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -0
  3. data/.travis.yml +7 -0
  4. data/CHANGELOG.md +95 -0
  5. data/Gemfile +15 -0
  6. data/README.md +47 -25
  7. data/Rakefile +8 -34
  8. data/garb.gemspec +22 -0
  9. data/lib/garb.rb +71 -48
  10. data/lib/garb/attributes.rb +35 -0
  11. data/lib/garb/core_ext/array.rb +13 -0
  12. data/lib/garb/core_ext/string.rb +48 -0
  13. data/lib/garb/core_ext/symbol.rb +59 -0
  14. data/lib/garb/destination.rb +5 -6
  15. data/lib/garb/errors.rb +20 -0
  16. data/lib/garb/filter_parameters.rb +20 -29
  17. data/lib/garb/management/account.rb +10 -16
  18. data/lib/garb/management/feed.rb +4 -5
  19. data/lib/garb/management/goal.rb +10 -15
  20. data/lib/garb/management/profile.rb +11 -20
  21. data/lib/garb/management/segment.rb +9 -15
  22. data/lib/garb/management/web_property.rb +11 -16
  23. data/lib/garb/model.rb +37 -13
  24. data/lib/garb/path_attribute.rb +7 -0
  25. data/lib/garb/report_parameter.rb +5 -5
  26. data/lib/garb/report_response.rb +29 -28
  27. data/lib/garb/reports/bounces.rb +1 -1
  28. data/lib/garb/reports/exits.rb +1 -1
  29. data/lib/garb/reports/pageviews.rb +1 -1
  30. data/lib/garb/reports/unique_pageviews.rb +1 -1
  31. data/lib/garb/reports/visits.rb +1 -1
  32. data/lib/garb/request/authentication.rb +54 -0
  33. data/lib/garb/request/data.rb +98 -0
  34. data/lib/garb/result_set.rb +23 -9
  35. data/lib/garb/session.rb +3 -3
  36. data/lib/garb/step.rb +4 -4
  37. data/lib/garb/support.rb +6 -0
  38. data/lib/garb/version.rb +3 -3
  39. data/test/fixtures/account_management.json +1 -0
  40. data/test/fixtures/ga_profile_management.json +1 -0
  41. data/test/fixtures/ga_segment_management.json +1 -0
  42. data/test/fixtures/ga_webproperty_management.json +1 -0
  43. data/test/fixtures/goal_management.json +1 -0
  44. data/test/fixtures/profile_feed.json +1 -0
  45. data/test/fixtures/report_feed.json +75 -0
  46. data/test/test_helper.rb +6 -10
  47. data/test/unit/garb/filter_parameters_test.rb +15 -46
  48. data/test/unit/garb/management/account_test.rb +8 -16
  49. data/test/unit/garb/management/feed_test.rb +5 -10
  50. data/test/unit/garb/management/goal_test.rb +7 -21
  51. data/test/unit/garb/management/profile_test.rb +11 -26
  52. data/test/unit/garb/management/segment_test.rb +7 -6
  53. data/test/unit/garb/management/web_property_test.rb +10 -12
  54. data/test/unit/garb/model_test.rb +70 -32
  55. data/test/unit/garb/report_parameter_test.rb +6 -6
  56. data/test/unit/garb/report_response_test.rb +23 -13
  57. data/test/unit/garb/request/authentication_test.rb +152 -0
  58. data/test/unit/garb/request/data_test.rb +157 -0
  59. data/test/unit/garb/session_test.rb +13 -13
  60. data/test/unit/garb_test.rb +4 -11
  61. data/test/unit/symbol_operator_test.rb +3 -3
  62. metadata +90 -292
  63. data/lib/garb/account.rb +0 -22
  64. data/lib/garb/account_feed_request.rb +0 -25
  65. data/lib/garb/authentication_request.rb +0 -53
  66. data/lib/garb/data_request.rb +0 -42
  67. data/lib/garb/goal.rb +0 -20
  68. data/lib/garb/profile.rb +0 -33
  69. data/lib/garb/report.rb +0 -28
  70. data/lib/garb/resource.rb +0 -115
  71. data/lib/support.rb +0 -40
  72. data/test/unit/garb/account_feed_request_test.rb +0 -42
  73. data/test/unit/garb/account_test.rb +0 -53
  74. data/test/unit/garb/authentication_request_test.rb +0 -121
  75. data/test/unit/garb/coverage/assets/0.3.9/app.js +0 -66
  76. data/test/unit/garb/coverage/assets/0.3.9/fancybox/blank.gif +0 -0
  77. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_close.png +0 -0
  78. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_loading.png +0 -0
  79. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_nav_left.png +0 -0
  80. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_nav_right.png +0 -0
  81. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_e.png +0 -0
  82. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_n.png +0 -0
  83. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_ne.png +0 -0
  84. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_nw.png +0 -0
  85. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_s.png +0 -0
  86. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_se.png +0 -0
  87. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_sw.png +0 -0
  88. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_w.png +0 -0
  89. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_title_left.png +0 -0
  90. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_title_main.png +0 -0
  91. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_title_over.png +0 -0
  92. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_title_right.png +0 -0
  93. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancybox-x.png +0 -0
  94. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancybox-y.png +0 -0
  95. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancybox.png +0 -0
  96. data/test/unit/garb/coverage/assets/0.3.9/fancybox/jquery.fancybox-1.3.1.css +0 -363
  97. data/test/unit/garb/coverage/assets/0.3.9/fancybox/jquery.fancybox-1.3.1.pack.js +0 -44
  98. data/test/unit/garb/coverage/assets/0.3.9/favicon.png +0 -0
  99. data/test/unit/garb/coverage/assets/0.3.9/jquery-1.4.2.min.js +0 -155
  100. data/test/unit/garb/coverage/assets/0.3.9/jquery.dataTables.min.js +0 -152
  101. data/test/unit/garb/coverage/assets/0.3.9/jquery.timeago.js +0 -141
  102. data/test/unit/garb/coverage/assets/0.3.9/jquery.url.js +0 -174
  103. data/test/unit/garb/coverage/assets/0.3.9/loading.gif +0 -0
  104. data/test/unit/garb/coverage/assets/0.3.9/magnify.png +0 -0
  105. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  106. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  107. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  108. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  109. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  110. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  111. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  112. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  113. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-icons_222222_256x240.png +0 -0
  114. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  115. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-icons_454545_256x240.png +0 -0
  116. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-icons_888888_256x240.png +0 -0
  117. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  118. data/test/unit/garb/coverage/assets/0.3.9/smoothness/jquery-ui-1.8.4.custom.css +0 -295
  119. data/test/unit/garb/coverage/assets/0.3.9/stylesheet.css +0 -341
  120. data/test/unit/garb/coverage/index.html +0 -100
  121. data/test/unit/garb/coverage/resultset.yml +0 -5
  122. data/test/unit/garb/data_request_test.rb +0 -107
  123. data/test/unit/garb/destination_test.rb +0 -28
  124. data/test/unit/garb/goal_test.rb +0 -24
  125. data/test/unit/garb/management/coverage/assets/0.3.9/app.js +0 -66
  126. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/blank.gif +0 -0
  127. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_close.png +0 -0
  128. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_loading.png +0 -0
  129. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_nav_left.png +0 -0
  130. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_nav_right.png +0 -0
  131. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_e.png +0 -0
  132. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_n.png +0 -0
  133. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_ne.png +0 -0
  134. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_nw.png +0 -0
  135. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_s.png +0 -0
  136. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_se.png +0 -0
  137. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_sw.png +0 -0
  138. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_w.png +0 -0
  139. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_title_left.png +0 -0
  140. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_title_main.png +0 -0
  141. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_title_over.png +0 -0
  142. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_title_right.png +0 -0
  143. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancybox-x.png +0 -0
  144. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancybox-y.png +0 -0
  145. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancybox.png +0 -0
  146. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/jquery.fancybox-1.3.1.css +0 -363
  147. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/jquery.fancybox-1.3.1.pack.js +0 -44
  148. data/test/unit/garb/management/coverage/assets/0.3.9/favicon.png +0 -0
  149. data/test/unit/garb/management/coverage/assets/0.3.9/jquery-1.4.2.min.js +0 -155
  150. data/test/unit/garb/management/coverage/assets/0.3.9/jquery.dataTables.min.js +0 -152
  151. data/test/unit/garb/management/coverage/assets/0.3.9/jquery.timeago.js +0 -141
  152. data/test/unit/garb/management/coverage/assets/0.3.9/jquery.url.js +0 -174
  153. data/test/unit/garb/management/coverage/assets/0.3.9/loading.gif +0 -0
  154. data/test/unit/garb/management/coverage/assets/0.3.9/magnify.png +0 -0
  155. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  156. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  157. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  158. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  159. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  160. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  161. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  162. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  163. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-icons_222222_256x240.png +0 -0
  164. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  165. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-icons_454545_256x240.png +0 -0
  166. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-icons_888888_256x240.png +0 -0
  167. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  168. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/jquery-ui-1.8.4.custom.css +0 -295
  169. data/test/unit/garb/management/coverage/assets/0.3.9/stylesheet.css +0 -341
  170. data/test/unit/garb/management/coverage/index.html +0 -100
  171. data/test/unit/garb/management/coverage/resultset.yml +0 -5
  172. data/test/unit/garb/profile_test.rb +0 -77
  173. data/test/unit/garb/report_test.rb +0 -99
  174. data/test/unit/garb/resource_test.rb +0 -50
  175. data/test/unit/garb/step_test.rb +0 -15
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7f5abc6c78a276a4e48842d665234cf8d16ab5bc
4
+ data.tar.gz: 1e2bc9ad76235027b818e4d16f53cf28a8b19ef7
5
+ SHA512:
6
+ metadata.gz: d02e72f9733c7b1d36c69020b3b4e7294290719eb3fccc38297303a4a7fa51343592df163075434d2844ed60a21d45d777e3c307e358c417ece0f61bad49640e
7
+ data.tar.gz: 855bcfeaa85559b085deb284a18f6acddf5f79c7c7edf71394bfdde3ed6bb8b4d7c906395040cb7941e5a7ee71ee6c0aeb6f48707bef82af3306bca5a8cacc80
@@ -0,0 +1,3 @@
1
+ *.gem
2
+ coverage
3
+ pkg
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - rbx-19mode
6
+ - jruby-19mode
7
+
@@ -0,0 +1,95 @@
1
+ Version 0.9.7
2
+
3
+ * Fixed bug causing Garb::Model#all_results to return nil if no limit provided
4
+ * Don't error out if goal Destination is missing steps
5
+ * Fixed "undefined method `map' for nil:NilClass" [#7]
6
+ * Single user requests supports fibers with `Garb.use_fibers = true` [#6]
7
+ * Made Garb::ResultSet comparable
8
+
9
+ Version 0.9.6
10
+
11
+ * Swapped Yajl/JSON for MultiJson
12
+ * Fixed "NameError: uninitialized constant Forwardable"
13
+ * Updated README
14
+
15
+ Version 0.9.5
16
+
17
+ * Moved all Garb::*Error classes to separate file
18
+ * Made all Garb::*Error classes inherit from Garb::Error
19
+ * Fixed couple of outstanding failing tests
20
+ * CA_CERT_FILE -> Garb.ca_cert_file
21
+ * API key as an element of the session
22
+ * Added `Garb.logger` module attribute
23
+ * Logs responses coming from GAPI (if logger set)
24
+ * Adds open_timeout support for Net::HTTP requests
25
+ * Added Travis CI configuration file
26
+
27
+ Version 0.9.4
28
+
29
+ * Fixed fetching all records
30
+ * Adds custom error classes inheriting from ClientError
31
+ * Made error messages a bit more descriptive
32
+ * Adds WebsiteProperty#name and #website_url properties
33
+ * Made Garb report its version with each request
34
+ * Made FilterParameter#hash_to_params do not escape backslash. Fixes #74
35
+ * Code cleanup
36
+
37
+ Version 0.9.3
38
+
39
+ * Adds support for fetching all results to Garb::Model
40
+ * ClientError handles properly error code and message from returned JSON
41
+ * Switches to GAPI v3
42
+
43
+ Version 0.9.2
44
+
45
+ * Removed all deprecated features: Garb::Report, Garb::Resource, Garb::Profile, and Garb::Account
46
+ * Moved the differing types of requests into a module, will refactor to share more code
47
+ * Fixed OR'ing in :filters option for results
48
+
49
+ Version 0.9.0
50
+
51
+ * New Garb::Model is solid. Garb::Resource and Garb::Report are deprecated.
52
+ * New GA Management API is functional and should be used in place of Garb::Profile and Garb::Account
53
+
54
+ Version 0.7.4
55
+
56
+ * Removes HappyMapper dependency in favor of Crack so we can drop libxml dependency
57
+
58
+ Version 0.7.0
59
+
60
+ * Adds multi-session support
61
+
62
+ Version 0.6.0
63
+
64
+ * Adds OAuth access token support
65
+ * Simplifies Garb report access through a profile
66
+ * Includes the start of a basic library of pre-built reports (require 'garb/reports')
67
+
68
+ Version 0.5.1
69
+
70
+ * Brings back hash filters and symbol operators after agreed upon SymbolOperator
71
+
72
+ Version 0.5.0
73
+
74
+ * Filters now have a new DSL so that I could toss Symbol operators (which conflict with DataMapper and MongoMapper)
75
+ * The method of passing a hash to filters no longer works, at all
76
+
77
+ Version 0.4.0
78
+
79
+ * Changes the api for filters and sort making it consistent with metrics/dimensions
80
+ * If you wish to clear the defaults defined on a class, you may use clear_(filters/sort/metrics/dimensions)
81
+ * To make a custom class using Garb::Resource, you must now extend instead of include the module
82
+
83
+ Version 0.3.2
84
+
85
+ * Adds Profile.first which can be used to get the first profile with a table id, or web property id (UA number)
86
+
87
+ Version 0.2.4
88
+
89
+ * Requires happymapper from rubygems, version 0.2.5. Be sure to update
90
+
91
+ Version 0.2.0
92
+
93
+ * Makes major changes (compared to 0.1.0) to the way garb is used to build reports
94
+ * There is now both a module that gets included for generating defined classes
95
+ * Slight changes to the way that the Report class can be used
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in garb.gemspec
4
+ gemspec
5
+
6
+ gem 'rake'
7
+
8
+ group :test do
9
+ gem 'shoulda'
10
+ gem 'shoulda-context'
11
+ gem 'simplecov', :require => false
12
+ gem 'minitest', '4.2', :require => false
13
+ gem 'jferris-mocha', :require => false
14
+ gem 'json'
15
+ end
data/README.md CHANGED
@@ -1,28 +1,28 @@
1
- Garb
1
+ Garb [![Build Status](https://secure.travis-ci.org/Sija/garb.png)](http://travis-ci.org/Sija/garb)
2
2
  ====
3
3
 
4
- http://github.com/vigetlabs/garb
4
+ http://github.com/Sija/garb
5
5
 
6
- Important Changes
7
- =================
6
+ Legato
7
+ ------
8
8
 
9
- With The release of version 0.9.0 I have officially deprecated Garb::Report, Garb::Resource,
10
- Garb::Profile, and Garb::Account. Garb::Report and Garb::Resource should be replaced by Garb::Model.
11
- Garb::Profile and Garb::Account are supplanted by their Garb::Management::* counterparts.
12
-
13
- I'll be working hard to update the documentation over the next day or so to highlight all of the
14
- old features in the new classes, as well as any new features brought by the new classes. If you
15
- are looking for something in particular, please open an issue and I will try to prioritize these
16
- requests.
9
+ There's rewritten and (moar) actively maintained version of the library in the form of [Legato](https://github.com/tpitale/legato).
10
+ You might want to check it out as it's mostly compatible with `Garb`.
11
+
12
+ Important Changes
13
+ -----------------
17
14
 
18
- Please read CHANGELOG
15
+ This fork contains heavily modified version of vigetlab's `Garb` library.
16
+ It works only with version 3 of Google API.
19
17
 
18
+ Please read CHANGELOG.
19
+
20
20
  Description
21
21
  -----------
22
22
 
23
23
  Provides a Ruby API to the Google Analytics API.
24
24
 
25
- http://code.google.com/apis/analytics/docs/gdata/gdataDeveloperGuide.html
25
+ https://developers.google.com/analytics/devguides/reporting/core/v3/coreDevguide
26
26
 
27
27
  Basic Usage
28
28
  ===========
@@ -30,15 +30,16 @@ Basic Usage
30
30
  Single User Login
31
31
  -----------------
32
32
 
33
+ > Garb::Session.api_key = api_key # required for 2-step authentication
33
34
  > Garb::Session.login(username, password)
34
35
 
35
36
  OAuth Access Token
36
37
  ------------------
37
38
 
38
- > Garb::Session.access_token = access_token # assign from oauth gem
39
+ > Garb::Session.access_token = access_token # an instance of OAuth2::Client
39
40
 
40
41
  Accounts, WebProperties, Profiles, and Goals
41
- --------
42
+ --------------------------------------------
42
43
 
43
44
  > Garb::Management::Account.all
44
45
  > Garb::Management::WebProperty.all
@@ -46,7 +47,7 @@ Accounts, WebProperties, Profiles, and Goals
46
47
  > Garb::Management::Goal.all
47
48
 
48
49
  Profiles for a UA- Number (a WebProperty)
49
- --------
50
+ -----------------------------------------
50
51
 
51
52
  > profile = Garb::Management::Profile.all.detect {|p| p.web_property_id == 'UA-XXXXXXX-X'}
52
53
 
@@ -78,6 +79,7 @@ Other Parameters
78
79
  * end_date: The date to end, inclusive
79
80
  * limit: The maximum number of results to be returned
80
81
  * offset: The starting index
82
+ * all: Return all results if true (which might result in several requests to GAPI)
81
83
 
82
84
  Metrics & Dimensions
83
85
  --------------------
@@ -86,7 +88,7 @@ Metrics & Dimensions
86
88
 
87
89
  I suggest reading the google documentation to familiarize yourself with this.
88
90
 
89
- http://code.google.com/apis/analytics/docs/gdata/gdataReferenceDimensionsMetrics.html#bounceRate
91
+ https://developers.google.com/analytics/devguides/reporting/core/dimsmets#q=bouncerate
90
92
 
91
93
  When you've returned, you can pass the appropriate combinations to Garb, as symbols.
92
94
 
@@ -95,7 +97,7 @@ Filtering
95
97
 
96
98
  Google Analytics supports a significant number of filtering options.
97
99
 
98
- http://code.google.com/apis/analytics/docs/gdata/gdataReference.html#filtering
100
+ https://developers.google.com/analytics/devguides/reporting/core/v3/reference#filters
99
101
 
100
102
  Here is what we can do currently:
101
103
  (the operator is a method on a symbol for the appropriate metric or dimension)
@@ -130,11 +132,20 @@ SSL
130
132
  Garb::Session.login(username, password, :secure => true)
131
133
 
132
134
  Next, be sure to download http://curl.haxx.se/ca/cacert.pem into your application somewhere.
133
- Then, define a constant CA_CERT_FILE and point to that file.
135
+ Then, point `Garb.ca_cert_file` property to that file.
134
136
 
135
137
  For whatever reason, simply creating a new certificate store and setting the defaults would
136
138
  not validate the google ssl certificate as authentic.
137
139
 
140
+ OPEN / READ TIMEOUT
141
+ -------------------
142
+
143
+ The open and read timeout values used with the network client (Net::HTTP) are configurable.
144
+ Both values default to 60 seconds.
145
+
146
+ Garb.open_timeout = 3
147
+ Garb.read_timeout = 3
148
+
138
149
  TODOS
139
150
  -----
140
151
 
@@ -143,19 +154,28 @@ TODOS
143
154
  Requirements
144
155
  ------------
145
156
 
146
- * crack >= 0.1.6
147
- * active_support >= 2.2.0
157
+ * active_support >= 2.2
158
+ * multi_json >= 1.3
148
159
 
149
160
  Requirements for Testing
150
161
  ------------------------
151
162
 
152
163
  * shoulda
153
- * jferris-mocha
164
+ * mocha
165
+ * bourne
154
166
 
155
167
  Install
156
168
  -------
157
169
 
158
- gem install garb
170
+ From git:
171
+
172
+ `git clone git://github.com/Sija/garb.git`
173
+ `cd garb && rake install`
174
+
175
+ OR with bundler:
176
+
177
+ gem 'garb', :git => 'git://github.com/Sija/garb.git'
178
+ `bundle install`
159
179
 
160
180
  Contributors
161
181
  ------------
@@ -165,13 +185,15 @@ Contributors
165
185
  * Patrick Reagan
166
186
  * Justin Marney
167
187
  * Nick Plante
188
+ * James Cook
189
+ * Chris Gunther
168
190
 
169
191
  License
170
192
  -------
171
193
 
172
194
  (The MIT License)
173
195
 
174
- Copyright (c) 2010 Viget Labs
196
+ Copyright (c) 2011 Tony Pitale, Viget Labs
175
197
 
176
198
  Permission is hereby granted, free of charge, to any person obtaining
177
199
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -1,4 +1,7 @@
1
- require 'rake/gempackagetask'
1
+ #!/usr/bin/env rake
2
+
3
+ require 'rubygems/package_task'
4
+ require 'bundler/gem_tasks'
2
5
  require 'rake/testtask'
3
6
 
4
7
  $:.unshift File.expand_path('../lib', __FILE__)
@@ -6,52 +9,23 @@ require 'garb'
6
9
 
7
10
  task :default => :test
8
11
 
9
- spec = Gem::Specification.new do |s|
10
- s.name = 'garb'
11
- s.version = Garb::Version.to_s
12
- s.has_rdoc = false
13
- s.rubyforge_project = 'viget'
14
- s.summary = "Google Analytics API Ruby Wrapper"
15
- s.authors = ['Tony Pitale']
16
- s.email = 'tony.pitale@viget.com'
17
- s.homepage = 'http://github.com/vigetlabs/garb'
18
- s.files = %w(README.md Rakefile) + Dir.glob("lib/**/*")
19
- s.test_files = Dir.glob("test/**/*")
20
-
21
- s.add_dependency("crack", [">= 0.1.6"])
22
- s.add_dependency("activesupport", [">= 2.2.0"])
23
- end
24
-
25
- Rake::GemPackageTask.new(spec) do |pkg|
26
- pkg.gem_spec = spec
27
- end
28
-
29
12
  Rake::TestTask.new do |t|
30
13
  t.libs << 'test'
31
- t.test_files = FileList["test/**/*_test.rb"]
14
+ t.test_files = FileList['test/**/*_test.rb']
32
15
  t.verbose = true
33
16
  end
34
17
 
35
- desc 'Generate the gemspec to serve this Gem from Github'
36
- task :github do
37
- file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
38
- File.open(file, 'w') {|f| f << spec.to_ruby }
39
- puts "Created gemspec: #{file}"
40
- end
41
-
42
18
  begin
43
19
  require 'rcov/rcovtask'
44
20
 
45
- desc "Generate RCov coverage report"
21
+ desc 'Generate RCov coverage report'
46
22
  Rcov::RcovTask.new(:rcov) do |t|
47
- t.libs << "test"
23
+ t.libs << 'test'
48
24
  t.test_files = FileList['test/**/*_test.rb']
49
- t.rcov_opts << "-x \"test/*,gems/*,/Library/Ruby/*,config/*\" -x lib/garb.rb -x lib/garb/version.rb --rails"
25
+ t.rcov_opts << '-x "test/*,gems/*,/Library/Ruby/*,config/*" -x lib/garb.rb -x lib/garb/version.rb --rails'
50
26
  end
51
27
  rescue LoadError
52
28
  nil
53
29
  end
54
30
 
55
- task :default => 'test'
56
-
57
31
  # EOF
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/garb/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ['Tony Pitale', 'Sijawusz Pur Rahnama']
6
+ gem.email = ['tony.pitale@viget.com', 'sija@sija.pl']
7
+ gem.homepage = 'http://github.com/Sija/garb'
8
+ gem.license = 'MIT'
9
+
10
+ gem.summary = 'Google Analytics API Ruby Wrapper'
11
+ gem.description = ''
12
+
13
+ gem.files = `git ls-files`.split $\
14
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
15
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
+ gem.name = 'garb'
17
+ gem.require_paths = ['lib']
18
+ gem.version = Garb::VERSION
19
+
20
+ gem.add_dependency 'activesupport', '>= 2.2'
21
+ gem.add_dependency 'multi_json', '>= 1.3'
22
+ end
@@ -1,56 +1,84 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+
1
3
  require 'net/http'
2
4
  require 'net/https'
3
5
 
4
6
  require 'cgi'
5
7
  require 'ostruct'
6
- require 'crack'
7
-
8
- begin
9
- require 'active_support/inflector'
10
- require 'active_support/deprecation'
11
- rescue LoadError
12
- require 'active_support'
13
- end
14
8
 
15
- require 'garb/version'
16
- require 'garb/authentication_request'
17
- require 'garb/data_request'
18
- require 'garb/account_feed_request'
19
- require 'garb/session'
20
- require 'garb/profile_reports'
21
- require 'garb/step'
22
- require 'garb/destination'
23
- require 'garb/goal'
24
- require 'garb/profile'
25
- require 'garb/account'
26
- require 'garb/filter_parameters'
27
- require 'garb/report_parameter'
28
- require 'garb/result_set'
29
- require 'garb/report_response'
30
- require 'garb/resource'
31
- require 'garb/report'
32
-
33
- require 'garb/model'
34
-
35
- # management
36
- require 'garb/management/feed'
37
- require 'garb/management/segment'
38
- require 'garb/management/account'
39
- require 'garb/management/web_property'
40
- require 'garb/management/profile'
41
- require 'garb/management/goal'
42
-
43
- require 'support'
9
+ require 'multi_json'
44
10
 
45
11
  module Garb
46
- GA = "http://schemas.google.com/analytics/2008"
12
+ autoload :VERSION, 'garb/version'
13
+
14
+ autoload :Attributes, 'garb/attributes'
15
+ autoload :PathAttribute, 'garb/path_attribute'
16
+ autoload :Destination, 'garb/destination'
17
+ autoload :FilterParameters, 'garb/filter_parameters'
18
+ autoload :Model, 'garb/model'
19
+ autoload :ProfileReports, 'garb/profile_reports'
20
+ autoload :ReportParameter, 'garb/report_parameter'
21
+ autoload :ReportResponse, 'garb/report_response'
22
+ autoload :ResultSet, 'garb/result_set'
23
+ autoload :Session, 'garb/session'
24
+ autoload :Step, 'garb/step'
25
+
26
+ module Management
27
+ autoload :Account, 'garb/management/account'
28
+ autoload :Feed, 'garb/management/feed'
29
+ autoload :Goal, 'garb/management/goal'
30
+ autoload :Profile, 'garb/management/profile'
31
+ autoload :Segment, 'garb/management/segment'
32
+ autoload :WebProperty, 'garb/management/web_property'
33
+ end
34
+
35
+ module Request
36
+ autoload :Authentication, 'garb/request/authentication'
37
+ autoload :Data, 'garb/request/data'
38
+ end
39
+ end
47
40
 
41
+ module Garb
48
42
  extend self
49
43
 
44
+ class << self
45
+ attr_accessor :proxy_address, :proxy_port, :proxy_user, :proxy_password, :logger
46
+ attr_writer :open_timeout, :read_timeout, :ca_cert_file
47
+ end
48
+
49
+ def use_fibers=(val)
50
+ if val and (!defined?(EM) || !defined?(Fiber))
51
+ raise ArgumentError, 'Eventmachine and Fibers required (Ruby 1.9+ only)'
52
+ end
53
+ require 'em-net-http' if val
54
+ @use_fibers = val
55
+ end
56
+
57
+ def use_fibers
58
+ @use_fibers || false
59
+ end
60
+
61
+ def open_timeout
62
+ @open_timeout || 60
63
+ end
64
+
65
+ def read_timeout
66
+ @read_timeout || 60
67
+ end
68
+
69
+ def ca_cert_file
70
+ @ca_cert_file || raise(MissingCertFileError)
71
+ end
72
+
73
+ def log(str, level = :debug)
74
+ level, str = str, level if str.is_a? Symbol
75
+ logger.send level, str unless logger.nil?
76
+ end
77
+
50
78
  def to_google_analytics(thing)
51
- return thing.to_google_analytics if thing.respond_to?(:to_google_analytics)
79
+ return thing.to_google_analytics if thing.respond_to? :to_google_analytics
52
80
 
53
- "ga:#{thing.to_s.camelize(:lower)}"
81
+ "#{$1}ga:#{$2}" if "#{thing.to_s.camelize(:lower)}" =~ /^(-)?(.*)$/
54
82
  end
55
83
  alias :to_ga :to_google_analytics
56
84
 
@@ -58,12 +86,7 @@ module Garb
58
86
  thing.to_s.gsub(/^ga\:/, '').underscore
59
87
  end
60
88
  alias :from_ga :from_google_analytics
61
-
62
- def parse_properties(entry)
63
- Hash[entry['dxp:property'].map {|p| [Garb.from_ga(p['name']),p['value']]}]
64
- end
65
-
66
- def parse_link(entry, rel)
67
- entry['link'].detect {|link| link["rel"] == rel}['href']
68
- end
69
89
  end
90
+
91
+ require 'garb/support'
92
+ require 'garb/errors'