simple_ga_reporting 1.0.4 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5bdd2b6b626663dae4feb9dfb1f55c9a4cb408c00d9cac06c719e7f6127c0c9
4
- data.tar.gz: 9cedf4ac77b7eebede41f4ce90e2ce040df67c4f97d774a95d515b834a659044
3
+ metadata.gz: 93f5bda8c264e442196ebdecc2f40f062a5edb040eccd07eb583642d060e12d8
4
+ data.tar.gz: 06411f48196f37897f11e104f7afcca247e268124f7e90d6861f80a0413eb2f0
5
5
  SHA512:
6
- metadata.gz: d83595d8a9340353fbde1720c29ab48cf7fc62574b18c13e3dbd41dd1f2e0214371a355ccf92c7b34761246253f984f558aa802a23ed63e586b2b1ec514cc032
7
- data.tar.gz: 173e4cac204fdb34e7d8dddb34b36075cafcc9583afeac1a207db94331108b43bf7841045ad791eef7daf627338cad429c9c5ab92e1fc7b61ce9a0dac8dd2e90
6
+ metadata.gz: 24886998f3a4548f1a03e242adb06e6d5f227a4703d8b72227d92e22307e4c76f0cccdfe88464690079ba92eabdbdf3c76d87c7cee4cb57d8099db269a2f239e
7
+ data.tar.gz: 7dccf9f673c5970bc38ba984ba3e9411ee58a4d5f03377c054858d0d1301edb1b45909957c05d2a5f469d50b637d12ef0c9aa2a028ea81bf5bc0335d528cc23d
data/.gitignore CHANGED
@@ -54,4 +54,6 @@ build-iPhoneSimulator/
54
54
 
55
55
  Gemfile.lock
56
56
  Guardfile
57
- .idea/
57
+ .idea/
58
+ config/
59
+ sample_app.rb
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/simple_ga_reporting.svg)](https://badge.fury.io/rb/simple_ga_reporting) [![CircleCI](https://circleci.com/gh/corselia/simple-ga-reporting.svg?style=svg)](https://circleci.com/gh/corselia/simple-ga-reporting)
2
2
 
3
+ # Japanese Document
4
+ - Japanese Document (my blog's article) is following
5
+ - [Google Analytics の API を用いて簡単にデータを取得できる gem を作りました](https://obel.hatenablog.jp/entry/20180409/1523282148)
6
+
3
7
  # What's this?
4
8
  This gem helps you to obtain `Google Analytics` reporting data with ease.
5
9
 
@@ -45,7 +49,7 @@ $ gem install simple-ga-reporting
45
49
  - `SimpleGaReports.filtered_results`
46
50
  - Only three lines :-)
47
51
  - Note
48
- - If you don't use filters, use `SimpleGaReports.raw_results`
52
+ - If you don't use filters, also use `SimpleGaReports.raw_results`
49
53
  - when no filter is in configure file, `SimpleGaReports.raw_results` is the same as `SimpleGaReports.filtered_results`
50
54
 
51
55
  ```ruby
@@ -302,9 +306,8 @@ end
302
306
  ```ruby
303
307
  require 'simple_ga_reporting'
304
308
 
305
- SimpleGaReports.configure('./bar/my_ga_reporting_config.yml','./foobar/filters.rb', start_date:
306
- '2daysAgo', limit: 100)
307
- results = SimpleGaReports.filtered_results('./foo/my_key_and_email.yml')
309
+ SimpleGaReports.configure(report_config: './bar/my_ga_reporting_config.yml', filters: './foobar/filters.rb', start_date: '2daysAgo', limit: 100)
310
+ results = SimpleGaReports.filtered_results(key_and_email: './foo/my_key_and_email.yml')
308
311
 
309
312
  results.each do |result|
310
313
  puts '==================================='
@@ -410,6 +413,7 @@ HAPPY CHECK!
410
413
  - offset
411
414
  - quota_user
412
415
  - segment_id
416
+ - `segment` is the conbination of filters actually, so you can use 'filters' as alternative way
413
417
 
414
418
  # Development
415
419
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,4 +1,4 @@
1
- require $filters_file
1
+ require File.expand_path("../../../#{$filters_file}", __FILE__) # TODO: not cool...?
2
2
 
3
3
  class LegatoGaModel
4
4
  extend Legato::Model
@@ -11,15 +11,15 @@ module LegatoGaUser
11
11
  TOKEN_URL = 'https://accounts.google.com/o/oauth2/token'.freeze
12
12
 
13
13
  # private
14
- def create_ga_user(key_and_email_file='config/key_and_email.yml')
15
- signing_key = OpenSSL::PKey::RSA.new(private_key(key_and_email_file))
14
+ def create_ga_user(key_and_email)
15
+ signing_key = OpenSSL::PKey::RSA.new(private_key(key_and_email))
16
16
  auth_client = Signet::OAuth2::Client.new(
17
17
  token_credential_uri: TOKEN_CREDENTIAL_URI,
18
18
  audience: AUDIENCE,
19
19
  scope: SCOPE,
20
- issuer: client_email(key_and_email_file),
20
+ issuer: client_email(key_and_email),
21
21
  signing_key: signing_key,
22
- sub: client_email(key_and_email_file),
22
+ sub: client_email(key_and_email),
23
23
  )
24
24
  access_token = auth_client.fetch_access_token!
25
25
 
@@ -40,11 +40,11 @@ module LegatoGaUser
40
40
  ga_user
41
41
  end
42
42
 
43
- def private_key(key_and_email_file)
44
- YAML.load_file(key_and_email_file)['private_key']
43
+ def private_key(key_and_email)
44
+ YAML.load_file(key_and_email)['private_key']
45
45
  end
46
46
 
47
- def client_email(key_and_email_file)
48
- YAML.load_file(key_and_email_file)['client_email']
47
+ def client_email(key_and_email)
48
+ YAML.load_file(key_and_email)['client_email']
49
49
  end
50
50
  end
@@ -6,23 +6,23 @@ class SimpleGaReports
6
6
  end
7
7
 
8
8
  class << SimpleGaReports
9
- def configure(yaml_file, filters_file='simple_ga_reporting/config/filters.rb', **options)
9
+ def configure(report_config: 'config/ga_reporting_config.yml', filters: 'config/filters.rb', **options)
10
10
  # TODO: oh... global variable...
11
- $model_config = YAML.load_file(yaml_file)
12
- $filters_file = filters_file
11
+ $model_config = YAML.load_file(report_config)
12
+ $filters_file = filters
13
13
 
14
14
  require 'simple_ga_reporting/legato_ga_model'
15
15
  query_parameters($model_config, options)
16
16
  end
17
17
 
18
- def filtered_results(key_and_email_file)
19
- raw_results = raw_results(key_and_email_file)
18
+ def filtered_results(key_and_email: 'config/key_and_email.yml')
19
+ raw_results = raw_results(key_and_email)
20
20
  filtering(raw_results)
21
21
  end
22
22
 
23
- def raw_results(key_and_email_file)
23
+ def raw_results(key_and_email)
24
24
  # 'legato_ga_model' method is generated by Model class automatically
25
- query = ga_profile(key_and_email_file).legato_ga_model
25
+ query = ga_profile(key_and_email).legato_ga_model
26
26
 
27
27
  query.results(
28
28
  start_date: @start_date,
@@ -47,8 +47,8 @@ class << SimpleGaReports
47
47
  end
48
48
 
49
49
  # TODO: should specify by profile id, too
50
- def ga_profile(key_and_email_file)
51
- ga_user = create_ga_user(key_and_email_file)
50
+ def ga_profile(key_and_email)
51
+ ga_user = create_ga_user(key_and_email)
52
52
 
53
53
  ga_user.profiles.each do |profile|
54
54
  return profile if profile.name === @profile_name
@@ -1,3 +1,3 @@
1
1
  module SimpleGaReporting
2
- VERSION = '1.0.4'
2
+ VERSION = '1.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_ga_reporting
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Osamu Takiya
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-06 00:00:00.000000000 Z
11
+ date: 2018-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler