hisui 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/lib/hisui.rb +1 -0
- data/lib/hisui/filters_expression.rb +13 -0
- data/lib/hisui/model.rb +16 -0
- data/lib/hisui/request.rb +1 -0
- data/lib/hisui/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed5550e23b11889424c0bf4ec332d655989f080ab442e78954e62342b9450a65
|
4
|
+
data.tar.gz: c4d88b0d28878e96196ba088db6b6610617cbeba5e3c7dd4f2c8c013bef708df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ab1c8635dd6023ca3778c47df5940d846e89ee02e701b66cbd2252bc15bb7a0e72cf3d0a2fc5be38985680e36b0798cb81cb2a653b21ae8d12da2ef7444e7bf
|
7
|
+
data.tar.gz: 8ec50ed5bdc40a0d28f86e90052323532c61ace7c8b71eba99232978066238dad326b1747e032ec78e5451252b16f6b39cd3b13d868f40a22f5a59f29c8972b1
|
data/README.md
CHANGED
@@ -88,6 +88,23 @@ response.data?
|
|
88
88
|
#=> true
|
89
89
|
```
|
90
90
|
|
91
|
+
#### Filtering
|
92
|
+
When you set `filters_expression` method with `field_name`, `operator` and `value` params, you can filter Google Analytics Data.
|
93
|
+
|
94
|
+
For example, this is filtered by organic.
|
95
|
+
```ruby
|
96
|
+
class OrganicMedium
|
97
|
+
extend Hisui::Model
|
98
|
+
|
99
|
+
metrics :pageviews, :sessions, :users, :new_users, :bounce_rate, :pageviews_per_session, :avg_session_duration
|
100
|
+
dimensions :medium
|
101
|
+
filters_expression({ field_name: 'medium', operator: '==', value: 'organic' })
|
102
|
+
end
|
103
|
+
```
|
104
|
+
|
105
|
+
other `operator` s are [here](https://developers.google.com/analytics/devguides/reporting/core/v3/reference?hl=ja#filterOperators)
|
106
|
+
|
107
|
+
|
91
108
|
## Contributing
|
92
109
|
Fork it, fix me, and send me your pull requests.
|
93
110
|
|
data/lib/hisui.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
module Hisui
|
2
|
+
class FiltersExpression
|
3
|
+
def initialize(field_name:, value:, operator:)
|
4
|
+
@field_name = field_name
|
5
|
+
@value = value
|
6
|
+
@operator = operator
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_param
|
10
|
+
"#{Hisui.to_ga_string(@field_name)}#{@operator}#{@value}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/hisui/model.rb
CHANGED
@@ -34,6 +34,22 @@ module Hisui
|
|
34
34
|
@order_bys
|
35
35
|
end
|
36
36
|
|
37
|
+
# Adds filters_expression to the class for retrieval from GA
|
38
|
+
#
|
39
|
+
# @param field [Hash] options:
|
40
|
+
# * field_name
|
41
|
+
# * operator
|
42
|
+
# * value
|
43
|
+
#
|
44
|
+
# operators are '==', '~=' and so on. cf: https://developers.google.com/analytics/devguides/reporting/core/v3/reference?hl=ja#filters
|
45
|
+
#
|
46
|
+
# @return concatenated string
|
47
|
+
def filters_expression(field = nil)
|
48
|
+
@filters_expression ||= ''
|
49
|
+
@filters_expression = Hisui::FiltersExpression.new(field).to_param if field
|
50
|
+
@filters_expression
|
51
|
+
end
|
52
|
+
|
37
53
|
def results(profile:, **options)
|
38
54
|
Hisui::Request.new(profile: profile, model: self, **options).fetch_data
|
39
55
|
end
|
data/lib/hisui/request.rb
CHANGED
data/lib/hisui/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hisui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ikepon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -161,6 +161,7 @@ files:
|
|
161
161
|
- README.md
|
162
162
|
- Rakefile
|
163
163
|
- lib/hisui.rb
|
164
|
+
- lib/hisui/filters_expression.rb
|
164
165
|
- lib/hisui/management/account.rb
|
165
166
|
- lib/hisui/management/account_summary.rb
|
166
167
|
- lib/hisui/management/base.rb
|