brainzz 0.0.9 → 0.0.10

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
  SHA1:
3
- metadata.gz: efd20c526d7209efbeeae0f353ea0ab22aaf41ce
4
- data.tar.gz: af768d8f3504b16fe18b926d3333dd8a5966626b
3
+ metadata.gz: d31efe5a7f4dfc90e786616d1e1780abaaf3d305
4
+ data.tar.gz: 306d122d776ab51eea8b9bbf86616ac0b93fabb0
5
5
  SHA512:
6
- metadata.gz: eb83f12a28b483bd2f4b4ac4c6382971b110b8c90a9a4e5dd2ddb24574d29d9c7d71e439241dc1e41cc9d19b08630a4c4105104b1d1ccd5247937c201d6d62b5
7
- data.tar.gz: 705e8be75d0921872871e8c75ee3880145315e7b36df335e278cfa20b1386c962ac2289c54fff1c4beb94dc00de8fb3ed43bd91da9318aefea6aa693409decee
6
+ metadata.gz: 77070886f824e6bfaf67e05f23dcd5379b71959f31515bb0969b5a3c6076af366c2fc0f9e93dc782e3b1fd5638165e1c7f61490403e82175c5a6b2ebadbb88b6
7
+ data.tar.gz: f93fc6c4eb0c2b475ff3e1abae3703cd8dbfe5de3ae5806952b0a6fdb47f6e48516f7cadd8992b78a07909858b5a8de9b5a0b4643e7f93f2248b39b926062dae
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Brainzz
2
2
  =======
3
3
 
4
- [![Build Status](https://semaphoreci.com/api/v1/projects/6bcf66fa-7d8c-4027-93ae-13b6bb75325f/346455/badge.png)](https://semaphoreci.com/awesomenesstv/brainzz)
4
+ [![Build Status](https://semaphoreci.com/api/v1/projects/576d44ff-f19c-4430-a40e-11423e7cd69d/460069/badge.svg)](https://semaphoreci.com/awesomenesstv/brainzz)
5
5
 
6
6
  Brainzz explains why youtoobers' brainzz are turned to mush.
7
7
  ... by extracting data from the YouTube API.
@@ -1,6 +1,13 @@
1
1
  module Brainzz
2
2
  class AnalyticsCommand < BaseCommand
3
3
  class << self
4
+ def execute(*args)
5
+ local_token = access_token
6
+ response = super
7
+ response.scrub local_token, 'ACCESS_TOKEN'
8
+ response
9
+ end
10
+
4
11
  private
5
12
 
6
13
  def base_url
@@ -18,11 +25,7 @@ module Brainzz
18
25
  end
19
26
 
20
27
  def access_token
21
- AccessTokenService.retrieve_token refresh_token
22
- end
23
-
24
- def refresh_token
25
- ENV['BRAINZZ_REFRESH_TOKEN']
28
+ AccessTokenService.retrieve_token
26
29
  end
27
30
 
28
31
  def params(analytics_params)
@@ -36,6 +39,11 @@ module Brainzz
36
39
  def content_owner
37
40
  ENV['BRAINZZ_CONTENT_OWNER']
38
41
  end
42
+
43
+ def scrub(response)
44
+ response.scrub access_token, 'ACCESS_TOKEN'
45
+ response.scrub content_owner, 'CONTENT_OWNER'
46
+ end
39
47
  end
40
48
  end
41
49
  end
@@ -1,6 +1,12 @@
1
1
  module Brainzz
2
2
  class BaseCommand
3
3
  class << self
4
+ def execute(*args)
5
+ response = on_execute(*args)
6
+ scrub response
7
+ response
8
+ end
9
+
4
10
  private
5
11
 
6
12
  def get(parameters)
@@ -1,9 +1,11 @@
1
1
  module Brainzz
2
2
  class DataCommand < BaseCommand
3
3
  class << self
4
+ private
5
+
4
6
  def params(parameters = nil)
5
7
  super.merge({
6
- :key => api_key,
8
+ :key => google_api_key,
7
9
  })
8
10
  end
9
11
 
@@ -11,9 +13,13 @@ module Brainzz
11
13
  'https://www.googleapis.com/youtube/v3'
12
14
  end
13
15
 
14
- def api_key
16
+ def google_api_key
15
17
  ENV['BRAINZZ_GOOGLE_API_KEY']
16
18
  end
19
+
20
+ def scrub(response)
21
+ response.scrub google_api_key, 'GOOGLE_API_KEY'
22
+ end
17
23
  end
18
24
  end
19
25
  end
@@ -1,7 +1,9 @@
1
1
  module Brainzz
2
2
  class PlaylistItemsCommand < DataCommand
3
3
  class << self
4
- def execute(playlist_id, response)
4
+ private
5
+
6
+ def on_execute(playlist_id, response)
5
7
  playlist_items_params = PlaylistItemsParams.new(playlist_id, response)
6
8
 
7
9
  if playlist_items_params.valid?
@@ -12,8 +14,6 @@ module Brainzz
12
14
  end
13
15
  end
14
16
 
15
- private
16
-
17
17
  def endpoint
18
18
  'playlistItems'
19
19
  end
@@ -1,7 +1,9 @@
1
1
  module Brainzz
2
2
  class VideoDetailsCommand < DataCommand
3
3
  class << self
4
- def execute(video_ids)
4
+ private
5
+
6
+ def on_execute(video_ids)
5
7
  video_details_params = VideoDetailsParams.new(video_ids)
6
8
 
7
9
  if video_details_params.valid?
@@ -12,8 +14,6 @@ module Brainzz
12
14
  end
13
15
  end
14
16
 
15
- private
16
-
17
17
  def endpoint
18
18
  'videos'
19
19
  end
@@ -1,7 +1,9 @@
1
1
  module Brainzz
2
2
  class VideoStatsCommand < AnalyticsCommand
3
3
  class << self
4
- def execute(video_id, start_date, end_date)
4
+ private
5
+
6
+ def on_execute(video_id, start_date, end_date)
5
7
  video_stats_params = VideoStatsParams.new ({
6
8
  :video_id => video_id,
7
9
  :start_date => start_date,
@@ -9,20 +11,14 @@ module Brainzz
9
11
  })
10
12
 
11
13
  if video_stats_params.valid?
12
- response.new get(video_stats_params)
14
+ @response_class.new get(video_stats_params)
13
15
  else
14
- response.new
16
+ @response_class.new
15
17
  end
16
18
  end
17
19
 
18
- private
19
-
20
- def response
21
- @response
22
- end
23
-
24
20
  def make_with_response(response)
25
- @response = response
21
+ @response_class = response
26
22
  end
27
23
 
28
24
  def params(video_stats_params)
@@ -4,10 +4,10 @@ module Brainzz
4
4
 
5
5
  @@mutex = Mutex.new
6
6
 
7
- def retrieve_token(refresh_token)
7
+ def retrieve_token
8
8
  @@mutex.synchronize do
9
9
  if !defined?(@token) or @token.expired?
10
- response = Toke.retrieve_token(params(refresh_token))
10
+ response = Toke.retrieve_token(params)
11
11
  @token = response.data if response.success?
12
12
  end
13
13
 
@@ -17,9 +17,9 @@ module Brainzz
17
17
 
18
18
  private
19
19
 
20
- def params(refresh_token)
20
+ def params
21
21
  {
22
- :refresh_token => refresh_token,
22
+ :refresh_token => ENV['BRAINZZ_REFRESH_TOKEN'],
23
23
  :client_id => ENV['BRAINZZ_CLIENT_ID'],
24
24
  :client_secret => ENV['BRAINZZ_CLIENT_SECRET'],
25
25
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brainzz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Herrick
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-05-29 00:00:00.000000000 Z
13
+ date: 2015-06-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
@@ -32,28 +32,28 @@ dependencies:
32
32
  requirements:
33
33
  - - "~>"
34
34
  - !ruby/object:Gem::Version
35
- version: '0'
35
+ version: 0.0.4
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: '0'
42
+ version: 0.0.4
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: toke
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: '0'
49
+ version: 0.0.3
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: '0'
56
+ version: 0.0.3
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: gems
59
59
  requirement: !ruby/object:Gem::Requirement
@@ -74,14 +74,14 @@ dependencies:
74
74
  requirements:
75
75
  - - "~>"
76
76
  - !ruby/object:Gem::Version
77
- version: '4'
77
+ version: '4.1'
78
78
  type: :development
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - "~>"
83
83
  - !ruby/object:Gem::Version
84
- version: '4'
84
+ version: '4.1'
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: cane
87
87
  requirement: !ruby/object:Gem::Requirement
@@ -284,7 +284,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
284
284
  version: '0'
285
285
  requirements: []
286
286
  rubyforge_project:
287
- rubygems_version: 2.4.6
287
+ rubygems_version: 2.4.8
288
288
  signing_key:
289
289
  specification_version: 4
290
290
  summary: YouTube API interface