garb 0.9.7 → 0.9.9

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.
Files changed (44) hide show
  1. checksums.yaml +5 -5
  2. data/.github/dependabot.yml +17 -0
  3. data/.github/workflows/ci.yml +30 -0
  4. data/.github/workflows/codeql-analysis.yml +46 -0
  5. data/.gitignore +1 -1
  6. data/CHANGELOG.md +78 -37
  7. data/Gemfile +5 -6
  8. data/LICENSE +22 -0
  9. data/README.md +125 -92
  10. data/Rakefile +2 -4
  11. data/garb.gemspec +4 -3
  12. data/lib/garb/attributes.rb +2 -1
  13. data/lib/garb/core_ext/string.rb +6 -6
  14. data/lib/garb/core_ext/symbol.rb +30 -19
  15. data/lib/garb/destination.rb +1 -1
  16. data/lib/garb/errors.rb +5 -3
  17. data/lib/garb/filter_parameters.rb +10 -5
  18. data/lib/garb/management/feed.rb +2 -2
  19. data/lib/garb/management/goal.rb +1 -1
  20. data/lib/garb/management/segment.rb +1 -1
  21. data/lib/garb/model.rb +41 -16
  22. data/lib/garb/profile_reports.rb +9 -1
  23. data/lib/garb/report_parameter.rb +2 -3
  24. data/lib/garb/report_response.rb +3 -4
  25. data/lib/garb/reports/visits.rb +1 -1
  26. data/lib/garb/request/authentication.rb +1 -1
  27. data/lib/garb/request/data.rb +13 -10
  28. data/lib/garb/result_set.rb +9 -7
  29. data/lib/garb/support.rb +1 -1
  30. data/lib/garb/version.rb +1 -3
  31. data/lib/garb.rb +7 -7
  32. data/test/test_helper.rb +6 -6
  33. data/test/unit/garb/management/account_test.rb +1 -1
  34. data/test/unit/garb/management/feed_test.rb +2 -2
  35. data/test/unit/garb/management/goal_test.rb +1 -1
  36. data/test/unit/garb/management/profile_test.rb +1 -1
  37. data/test/unit/garb/management/segment_test.rb +1 -9
  38. data/test/unit/garb/management/web_property_test.rb +1 -1
  39. data/test/unit/garb/model_test.rb +121 -6
  40. data/test/unit/garb/report_response_test.rb +1 -1
  41. data/test/unit/garb/result_set_test.rb +29 -0
  42. data/test/unit/symbol_operator_test.rb +21 -19
  43. metadata +23 -19
  44. data/.travis.yml +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7f5abc6c78a276a4e48842d665234cf8d16ab5bc
4
- data.tar.gz: 1e2bc9ad76235027b818e4d16f53cf28a8b19ef7
2
+ SHA256:
3
+ metadata.gz: c6da63ce8a7fab26c536fba5c411f94cda0f69f20d86f35aa2024a051b872c88
4
+ data.tar.gz: e47ceda3dfa21c8e49bcd213534c8dc5ee8668af64928924feee502a40b7202f
5
5
  SHA512:
6
- metadata.gz: d02e72f9733c7b1d36c69020b3b4e7294290719eb3fccc38297303a4a7fa51343592df163075434d2844ed60a21d45d777e3c307e358c417ece0f61bad49640e
7
- data.tar.gz: 855bcfeaa85559b085deb284a18f6acddf5f79c7c7edf71394bfdde3ed6bb8b4d7c906395040cb7941e5a7ee71ee6c0aeb6f48707bef82af3306bca5a8cacc80
6
+ metadata.gz: 937d6c1cbb7233e6596814d0a7c432fc33fad55258e309193227149e9de9dff60ef364e80e73714efc271388d5b75eba3806beabd0fbc166cee29d07986f3acd
7
+ data.tar.gz: 88f10b343e99389102266705c61ac7cdbdf0d08bc7f0fa353f3581534df55a76bad4eef8f1778a0dc3334dba53a509e4079dddb96a8f796fa1ff963619d73421
@@ -0,0 +1,17 @@
1
+ version: 2
2
+ updates:
3
+ # Maintain dependencies for GitHub Actions
4
+ - package-ecosystem: github-actions
5
+ directory: /
6
+ schedule:
7
+ interval: daily
8
+
9
+ # Maintain dependencies for Bunder
10
+ - package-ecosystem: bundler
11
+ directory: /
12
+ schedule:
13
+ interval: daily
14
+ open-pull-requests-limit: 10
15
+ ignore:
16
+ - dependency-name: minitest
17
+ versions: ["> 4.2"]
@@ -0,0 +1,30 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ test:
14
+ runs-on: ubuntu-latest
15
+ strategy:
16
+ matrix:
17
+ ruby-version: ['3.2', '3.3', '3.4']
18
+
19
+ steps:
20
+ - name: Checkout source code
21
+ uses: actions/checkout@v7
22
+
23
+ - name: Setup Ruby
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ ruby-version: ${{ matrix.ruby-version }}
27
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
28
+
29
+ - name: Run tests
30
+ run: bundle exec rake
@@ -0,0 +1,46 @@
1
+ name: CodeQL
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ # The branches below must be a subset of the branches above
8
+ branches: [master]
9
+ schedule:
10
+ - cron: '26 21 * * 0'
11
+
12
+ jobs:
13
+ analyze:
14
+ name: Analyze
15
+ runs-on: ubuntu-latest
16
+ permissions:
17
+ actions: read
18
+ contents: read
19
+ security-events: write
20
+
21
+ strategy:
22
+ fail-fast: false
23
+ matrix:
24
+ language: [ruby]
25
+
26
+ steps:
27
+ - name: Checkout repository
28
+ uses: actions/checkout@v7
29
+
30
+ # Initializes the CodeQL tools for scanning.
31
+ - name: Initialize CodeQL
32
+ uses: github/codeql-action/init@v4
33
+ with:
34
+ languages: ${{ matrix.language }}
35
+ # If you wish to specify custom queries, you can do so here or in a config file.
36
+ # By default, queries listed here will override any specified in a config file.
37
+ # Prefix the list here with "+" to use these queries and those in the config file.
38
+
39
+ # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
40
+ # queries: security-extended,security-and-quality
41
+
42
+ - name: Autobuild
43
+ uses: github/codeql-action/autobuild@v4
44
+
45
+ - name: Perform CodeQL Analysis
46
+ uses: github/codeql-action/analyze@v4
data/.gitignore CHANGED
@@ -1,3 +1,3 @@
1
1
  *.gem
2
2
  coverage
3
- pkg
3
+ pkg
data/CHANGELOG.md CHANGED
@@ -1,73 +1,114 @@
1
+ Version 0.9.9
2
+
3
+ **Deprecation notice:** Google has shut down the Universal Analytics APIs (Core Reporting v3, Management v3) as well as ClientLogin, which `Garb` relies on, so it no longer works against live services. See the README for actively maintained GA4 replacement gems.
4
+
5
+ Breaking changes
6
+
7
+ * [#82](https://github.com/Sija/garb/pull/82): Require Ruby >= 3.2 (support for Ruby 1.9, Rubinius and JRuby was dropped along the way)
8
+ * [#82](https://github.com/Sija/garb/pull/82): Replaced deprecated `MultiJson` with stdlib `JSON` and dropped the `multi_json` dependency
9
+ * [#82](https://github.com/Sija/garb/pull/82): Added `ostruct` as a runtime dependency (no longer a default gem starting with Ruby 3.5)
10
+ * [#78](https://github.com/Sija/garb/pull/78), [#75](https://github.com/Sija/garb/pull/75): `Garb::Model#all_results` coerces `:limit` and `:offset` with `Integer()` and raises `ArgumentError` for non-numeric values or values lower than 1
11
+
12
+ Features
13
+
14
+ * [#47](https://github.com/Sija/garb/pull/47): Added `:sampling_level` option to `Garb::Model#results` - [@ballcheck](https://github.com/ballcheck)
15
+ * [#45](https://github.com/Sija/garb/pull/45): Defined equality (`==`, `eql?`, `hash`) of `SymbolOperator` instances, so they can be used as hash keys - [@cgunther](https://github.com/cgunther)
16
+
17
+ Fixes
18
+
19
+ * [#75](https://github.com/Sija/garb/pull/75): Fixed `Garb::Model#all_results` (`:all => true`) ignoring `:offset` after the first page - [@dblock](https://github.com/dblock)
20
+ * [#75](https://github.com/Sija/garb/pull/75): `Garb::Model#all_results` returns an empty `ResultSet` instead of `nil` when `:offset` is past the end
21
+ * [#77](https://github.com/Sija/garb/pull/77): `Garb::Model#results` no longer removes `:all` from the caller's options hash
22
+ * [#79](https://github.com/Sija/garb/pull/79): `Garb::Model#all_results` requests only as many rows as needed for `:limit` (extracted `Garb::Model::MAX_RESULTS`)
23
+ * [#80](https://github.com/Sija/garb/pull/80): Fixed `Garb::Model#all_results` raising `ArgumentError` when the response has no `totalResults`
24
+ * [#81](https://github.com/Sija/garb/pull/81): Combined `ResultSet`s are marked as sampled if any of them was sampled
25
+ * [#82](https://github.com/Sija/garb/pull/82): Fixed "method redefined" warning when the same report method is added more than once
26
+ * [#37](https://github.com/Sija/garb/pull/37): Fixed "mismatched indentations" warning - [@amatsuda](https://github.com/amatsuda)
27
+
28
+ Internal
29
+
30
+ * [#76](https://github.com/Sija/garb/pull/76): Fixed specs failing to load on modern Ruby
31
+ * Moved CI from Travis CI to GitHub Actions (Ruby 3.2, 3.3 and 3.4), added CodeQL analysis and Dependabot
32
+ * Added `LICENSE` file (MIT)
33
+
34
+ Version 0.9.8
35
+
36
+ * Switched to `Net::HTTP.new` as `Net::HTTP.start` doesn't honor timeout values (http://www.ruby-forum.com/topic/148968)
37
+ * Use `Session#api_key` for every data request (#19)
38
+ * Hack to add support for dynamic segments (props to @stevenwilkin)
39
+ * Allow alphanumeric segment ids - [@bensaunders](https://github.com/bensaunders)
40
+ * Tests are running green again
41
+
1
42
  Version 0.9.7
2
43
 
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
44
+ * Fixed bug causing `Garb::Model#all_results` to return `nil` if no limit provided
45
+ * Don't error out if goal `Destination` is missing steps
46
+ * Fixed "undefined method `map' for nil:NilClass" (#7)
47
+ * Single user requests support fibers with `Garb.use_fibers = true` (#6)
48
+ * Made `Garb::ResultSet` comparable
8
49
 
9
50
  Version 0.9.6
10
51
 
11
- * Swapped Yajl/JSON for MultiJson
52
+ * Swapped Yajl/JSON for `MultiJson`
12
53
  * Fixed "NameError: uninitialized constant Forwardable"
13
54
  * Updated README
14
55
 
15
56
  Version 0.9.5
16
57
 
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
58
+ * Moved all `Garb::*Error` classes to a separate file
59
+ * Made all `Garb::*Error` classes inherit from `Garb::Error`
60
+ * Fixed a couple of outstanding failing tests
61
+ * Replaced `CA_CERT_FILE` with `Garb.ca_cert_file`
62
+ * Added API key as an attribute of the session
22
63
  * Added `Garb.logger` module attribute
23
- * Logs responses coming from GAPI (if logger set)
24
- * Adds open_timeout support for Net::HTTP requests
64
+ * Log responses coming from GAPI (if logger is set)
65
+ * Added `open_timeout` support for `Net::HTTP` requests
25
66
  * Added Travis CI configuration file
26
67
 
27
68
  Version 0.9.4
28
69
 
29
70
  * Fixed fetching all records
30
- * Adds custom error classes inheriting from ClientError
71
+ * Added custom error classes inheriting from `ClientError`
31
72
  * 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
73
+ * Added `WebProperty#name` and `#website_url` properties
74
+ * Made `Garb` report its version with each request
75
+ * Made `FilterParameters#hash_to_params` not escape backslash (#74)
35
76
  * Code cleanup
36
77
 
37
78
  Version 0.9.3
38
79
 
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
80
+ * Added support for fetching all results to `Garb::Model`
81
+ * `ClientError` properly handles error code and message from returned JSON
82
+ * Switched to GAPI v3
42
83
 
43
84
  Version 0.9.2
44
85
 
45
- * Removed all deprecated features: Garb::Report, Garb::Resource, Garb::Profile, and Garb::Account
86
+ * Removed all deprecated features: `Garb::Report`, `Garb::Resource`, `Garb::Profile`, and `Garb::Account`
46
87
  * Moved the differing types of requests into a module, will refactor to share more code
47
- * Fixed OR'ing in :filters option for results
88
+ * Fixed OR'ing in `:filters` option for results
48
89
 
49
90
  Version 0.9.0
50
91
 
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
92
+ * New `Garb::Model` is solid. `Garb::Resource` and `Garb::Report` are deprecated.
93
+ * New GA Management API is functional and should be used in place of `Garb::Profile` and `Garb::Account`
53
94
 
54
95
  Version 0.7.4
55
96
 
56
- * Removes HappyMapper dependency in favor of Crack so we can drop libxml dependency
97
+ * Removed HappyMapper dependency in favor of Crack so we can drop libxml dependency
57
98
 
58
99
  Version 0.7.0
59
100
 
60
- * Adds multi-session support
101
+ * Added multi-session support
61
102
 
62
103
  Version 0.6.0
63
104
 
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')
105
+ * Added OAuth access token support
106
+ * Simplified `Garb` report access through a profile
107
+ * Included the start of a basic library of pre-built reports (`require 'garb/reports'`)
67
108
 
68
109
  Version 0.5.1
69
-
70
- * Brings back hash filters and symbol operators after agreed upon SymbolOperator
110
+
111
+ * Brought back hash filters and symbol operators after agreed upon `SymbolOperator`
71
112
 
72
113
  Version 0.5.0
73
114
 
@@ -75,14 +116,14 @@ Version 0.5.0
75
116
  * The method of passing a hash to filters no longer works, at all
76
117
 
77
118
  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
119
+
120
+ * Changed the API for filters and sort making it consistent with metrics/dimensions
121
+ * If you wish to clear the defaults defined on a class, you may use `clear_(filters/sort/metrics/dimensions)`
122
+ * To make a custom class using `Garb::Resource`, you must now extend instead of include the module
82
123
 
83
124
  Version 0.3.2
84
125
 
85
- * Adds Profile.first which can be used to get the first profile with a table id, or web property id (UA number)
126
+ * Added `Profile.first` which can be used to get the first profile with a table id, or web property id (UA number)
86
127
 
87
128
  Version 0.2.4
88
129
 
@@ -90,6 +131,6 @@ Version 0.2.4
90
131
 
91
132
  Version 0.2.0
92
133
 
93
- * Makes major changes (compared to 0.1.0) to the way garb is used to build reports
134
+ * Made major changes (compared to 0.1.0) to the way garb is used to build reports
94
135
  * There is now both a module that gets included for generating defined classes
95
136
  * Slight changes to the way that the Report class can be used
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in garb.gemspec
4
4
  gemspec
@@ -6,10 +6,9 @@ gemspec
6
6
  gem 'rake'
7
7
 
8
8
  group :test do
9
- gem 'shoulda'
10
9
  gem 'shoulda-context'
11
- gem 'simplecov', :require => false
12
- gem 'minitest', '4.2', :require => false
13
- gem 'jferris-mocha', :require => false
14
- gem 'json'
10
+ gem 'simplecov', '~> 0.14', require: false
11
+ gem 'minitest', '4.2', require: false
12
+ gem 'jferris-mocha', require: false
13
+ gem 'json', '>= 1.8.5'
15
14
  end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2011 Tony Pitale, Viget Labs
4
+ Copyright (c) 2012-2022 Sijawusz Pur Rahnama
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
data/README.md CHANGED
@@ -1,22 +1,43 @@
1
- Garb [![Build Status](https://secure.travis-ci.org/Sija/garb.png)](http://travis-ci.org/Sija/garb)
1
+ Garb [![Gem Version](https://badge.fury.io/rb/garb.svg)](https://badge.fury.io/rb/garb) [![CI](https://github.com/Sija/garb/actions/workflows/ci.yml/badge.svg)](https://github.com/Sija/garb/actions/workflows/ci.yml) [![License](https://img.shields.io/github/license/Sija/garb.svg)](https://github.com/Sija/garb/blob/master/LICENSE)
2
2
  ====
3
3
 
4
- http://github.com/Sija/garb
4
+ https://github.com/Sija/garb
5
5
 
6
- Legato
7
- ------
6
+ Deprecation Notice
7
+ ------------------
8
+
9
+ **This gem is no longer functional against Google's live services and is kept for historical purposes only.**
10
+
11
+ * `Garb` targets the Google Analytics **Core Reporting API v3** and **Management API v3** (Universal Analytics). Google stopped processing Universal Analytics data in July 2023 (July 2024 for Analytics 360) and has since shut both APIs down. See https://support.google.com/analytics/answer/11583528
12
+ * Username/password authentication (`Garb::Session.login`) relies on **ClientLogin**, which Google shut down on April 20th, 2015.
13
+ * Google Analytics 4 (GA4) uses a different API with a different data model (e.g. `sessions`/`screenPageViews` instead of `ga:visits`/`ga:pageviews`, properties instead of profiles), so `Garb` cannot be pointed at it.
14
+
15
+ Replacements
16
+ ------------
17
+
18
+ Use one of these actively maintained, Google-published gems instead:
19
+
20
+ | Gem | Replaces | Notes |
21
+ | --- | --- | --- |
22
+ | [`google-analytics-data`](https://rubygems.org/gems/google-analytics-data) | Reporting (`Garb::Model`, `results`) | Official GA4 Data API client (gRPC-based, recommended) |
23
+ | [`google-analytics-admin`](https://rubygems.org/gems/google-analytics-admin) | `Garb::Management::*` | Official GA4 Admin API client (accounts, properties, data streams, key events) |
24
+ | [`google-apis-analyticsdata_v1beta`](https://rubygems.org/gems/google-apis-analyticsdata_v1beta) | Reporting | REST-based GA4 Data API client, lighter alternative to the gRPC one |
25
+ | [`google-apis-analyticsadmin_v1beta`](https://rubygems.org/gems/google-apis-analyticsadmin_v1beta) | `Garb::Management::*` | REST-based GA4 Admin API client |
8
26
 
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`.
27
+ Authentication for all of the above is handled by [`googleauth`](https://rubygems.org/gems/googleauth) (service accounts, OAuth 2.0, Application Default Credentials).
28
+
29
+ [Legato](https://github.com/tpitale/legato), previously recommended here as a successor, also targets the retired Universal Analytics API and is no longer an option.
30
+
31
+ Getting started with GA4: [Data API overview](https://developers.google.com/analytics/devguides/reporting/data/v1) and [quickstart](https://developers.google.com/analytics/devguides/reporting/data/v1/quickstart)
11
32
 
12
33
  Important Changes
13
34
  -----------------
14
35
 
15
- This fork contains heavily modified version of vigetlab's `Garb` library.
36
+ This fork contains heavily modified version of vigetlab's `Garb` library.
16
37
  It works only with version 3 of Google API.
17
38
 
18
39
  Please read CHANGELOG.
19
-
40
+
20
41
  Description
21
42
  -----------
22
43
 
@@ -29,57 +50,76 @@ Basic Usage
29
50
 
30
51
  Single User Login
31
52
  -----------------
32
-
33
- > Garb::Session.api_key = api_key # required for 2-step authentication
34
- > Garb::Session.login(username, password)
35
-
53
+
54
+ **Defunct:** ClientLogin was shut down by Google in April 2015; this method no longer works.
55
+
56
+ ```ruby
57
+ Garb::Session.api_key = api_key # required for 2-step authentication
58
+ Garb::Session.login(username, password)
59
+ ```
60
+
36
61
  OAuth Access Token
37
62
  ------------------
38
63
 
39
- > Garb::Session.access_token = access_token # an instance of OAuth2::Client
64
+ The only authentication method that was still supported until the Universal Analytics APIs were retired.
65
+
66
+ ```ruby
67
+ Garb::Session.access_token = access_token # an instance of OAuth2::Client
68
+ ```
40
69
 
41
70
  Accounts, WebProperties, Profiles, and Goals
42
71
  --------------------------------------------
43
72
 
44
- > Garb::Management::Account.all
45
- > Garb::Management::WebProperty.all
46
- > Garb::Management::Profile.all
47
- > Garb::Management::Goal.all
73
+ ```ruby
74
+ Garb::Management::Account.all
75
+ Garb::Management::WebProperty.all
76
+ Garb::Management::Profile.all
77
+ Garb::Management::Goal.all
78
+ ```
48
79
 
49
80
  Profiles for a UA- Number (a WebProperty)
50
81
  -----------------------------------------
51
82
 
52
- > profile = Garb::Management::Profile.all.detect {|p| p.web_property_id == 'UA-XXXXXXX-X'}
83
+ ```ruby
84
+ profile = Garb::Management::Profile.all.detect { |p| p.web_property_id == 'UA-XXXXXXX-X' }
85
+ ```
53
86
 
54
87
  Define a Report Class
55
88
  ---------------------
56
89
 
57
- class Exits
58
- extend Garb::Model
90
+ ```ruby
91
+ class Exits
92
+ extend Garb::Model
59
93
 
60
- metrics :exits, :pageviews
61
- dimensions :page_path
62
- end
94
+ metrics :exits, :pageviews
95
+ dimensions :page_path
96
+ end
97
+ ```
63
98
 
64
99
  Get the Results
65
100
  ---------------
66
101
 
67
- > Exits.results(profile, :filters => {:page_path.eql => '/'})
102
+ ```ruby
103
+ Exits.results(profile, filters: { :page_path.eql => '/' })
104
+ ```
68
105
 
69
106
  OR shorthand
70
107
 
71
- > profile.exits(:filters => {:page_path.eql => '/'})
108
+ ```ruby
109
+ profile.exits(filters: { :page_path.eql => '/' })
110
+ ```
72
111
 
73
112
  Be forewarned, these numbers are for the last **30** days and may be slightly different from the numbers displayed in Google Analytics' dashboard for **1 month**.
74
113
 
75
114
  Other Parameters
76
115
  ----------------
77
116
 
78
- * start_date: The date of the period you would like this report to start
79
- * end_date: The date to end, inclusive
80
- * limit: The maximum number of results to be returned
81
- * offset: The starting index
82
- * all: Return all results if true (which might result in several requests to GAPI)
117
+ * __start_date__: The date of the period you would like this report to start
118
+ * __end_date__: The date to end, inclusive
119
+ * __limit__: The maximum number of results to be returned
120
+ * __offset__: The starting index
121
+ * __all__: Return all results if true (which might result in several requests to GAPI)
122
+ * __sampling_level__: Specify precision vs speed strategy (`default`, `faster`, `greater_precision`)
83
123
 
84
124
  Metrics & Dimensions
85
125
  --------------------
@@ -104,34 +144,44 @@ Filtering
104
144
 
105
145
  Operators on metrics:
106
146
 
107
- eql => '==',
108
- not_eql => '!=',
109
- gt => '>',
110
- gte => '>=',
111
- lt => '<',
112
- lte => '<='
147
+ ```ruby
148
+ :eql => '==',
149
+ :not_eql => '!=',
150
+ :gt => '>',
151
+ :gte => '>=',
152
+ :lt => '<',
153
+ :lte => '<='
154
+ ```
113
155
 
114
156
  Operators on dimensions:
115
157
 
116
- matches => '==',
117
- does_not_match => '!=',
118
- contains => '=~',
119
- does_not_contain => '!~',
120
- substring => '=@',
121
- not_substring => '!@'
122
-
158
+ ```ruby
159
+ :matches => '==',
160
+ :does_not_match => '!=',
161
+ :contains => '=~',
162
+ :does_not_contain => '!~',
163
+ :substring => '=@',
164
+ :not_substring => '!@'
165
+ ```
166
+
123
167
  Given the previous Exits example report in shorthand, we can add an option for filter:
124
168
 
125
- profile.exits(:filters => {:page_path.eql => '/extend/effectively-using-git-with-subversion/')
169
+ ```ruby
170
+ profile.exits(filters: { :page_path.eql => '/extend/effectively-using-git-with-subversion/' })
171
+ ```
126
172
 
127
173
  SSL
128
174
  ---
129
175
 
176
+ **Defunct:** this only applies to single user (ClientLogin) authentication, see above.
177
+
130
178
  Version 0.2.3 includes support for real ssl encryption for SINGLE USER authentication. First do:
131
179
 
132
- Garb::Session.login(username, password, :secure => true)
180
+ ```ruby
181
+ Garb::Session.login(username, password, secure: true)
182
+ ```
133
183
 
134
- Next, be sure to download http://curl.haxx.se/ca/cacert.pem into your application somewhere.
184
+ Next, be sure to download https://curl.haxx.se/ca/cacert.pem into your application somewhere.
135
185
  Then, point `Garb.ca_cert_file` property to that file.
136
186
 
137
187
  For whatever reason, simply creating a new certificate store and setting the defaults would
@@ -141,11 +191,13 @@ OPEN / READ TIMEOUT
141
191
  -------------------
142
192
 
143
193
  The open and read timeout values used with the network client (Net::HTTP) are configurable.
144
- Both values default to 60 seconds.
194
+ Both values default to 60 seconds.
195
+
196
+ ```ruby
197
+ Garb.open_timeout = 3
198
+ Garb.read_timeout = 3
199
+ ```
145
200
 
146
- Garb.open_timeout = 3
147
- Garb.read_timeout = 3
148
-
149
201
  TODOS
150
202
  -----
151
203
 
@@ -154,28 +206,34 @@ TODOS
154
206
  Requirements
155
207
  ------------
156
208
 
157
- * active_support >= 2.2
158
- * multi_json >= 1.3
209
+ * Ruby (tested on 3.2, 3.3 and 3.4)
210
+ * activesupport >= 2.2
211
+ * ostruct
212
+
213
+ Running Tests
214
+ -------------
159
215
 
160
- Requirements for Testing
161
- ------------------------
216
+ The test suite stubs all network calls, so no Google credentials or API keys are needed:
162
217
 
163
- * shoulda
164
- * mocha
165
- * bourne
218
+ ```sh
219
+ bundle install
220
+ bundle exec rake
221
+ ```
166
222
 
167
223
  Install
168
224
  -------
169
225
 
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`
226
+ Add this line to your application’s Gemfile:
227
+
228
+ ```ruby
229
+ gem 'garb'
230
+ ```
231
+
232
+ Then run:
233
+
234
+ ```sh
235
+ bundle install
236
+ ```
179
237
 
180
238
  Contributors
181
239
  ------------
@@ -187,29 +245,4 @@ Contributors
187
245
  * Nick Plante
188
246
  * James Cook
189
247
  * Chris Gunther
190
-
191
- License
192
- -------
193
-
194
- (The MIT License)
195
-
196
- Copyright (c) 2011 Tony Pitale, Viget Labs
197
-
198
- Permission is hereby granted, free of charge, to any person obtaining
199
- a copy of this software and associated documentation files (the
200
- 'Software'), to deal in the Software without restriction, including
201
- without limitation the rights to use, copy, modify, merge, publish,
202
- distribute, sublicense, and/or sell copies of the Software, and to
203
- permit persons to whom the Software is furnished to do so, subject to
204
- the following conditions:
205
-
206
- The above copyright notice and this permission notice shall be
207
- included in all copies or substantial portions of the Software.
208
-
209
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
210
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
211
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
212
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
213
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
214
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
215
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
248
+ * Sijawusz Pur Rahnama
data/Rakefile CHANGED
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env rake
2
2
 
3
- require 'rubygems/package_task'
3
+ require 'rubygems/package_task'
4
4
  require 'bundler/gem_tasks'
5
5
  require 'rake/testtask'
6
6
 
7
7
  $:.unshift File.expand_path('../lib', __FILE__)
8
8
  require 'garb'
9
9
 
10
- task :default => :test
10
+ task default: :test
11
11
 
12
12
  Rake::TestTask.new do |t|
13
13
  t.libs << 'test'
@@ -27,5 +27,3 @@ begin
27
27
  rescue LoadError
28
28
  nil
29
29
  end
30
-
31
- # EOF