brainzz 0.0.7 → 0.0.8

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: 941f2f0034a79d492f3dd9fc3297d37a1353d4c8
4
- data.tar.gz: 5c9505402d65a9ec079e012591ee21056957d8a3
3
+ metadata.gz: 5abb564de2201acc9856620e5c4ca87f8d8882a7
4
+ data.tar.gz: 85deabd9d2a738dba856dbdda6197f9ae3391bb8
5
5
  SHA512:
6
- metadata.gz: e0f203efc33589c83ad5b1a71a84d4eb96f4513efd66af3ad4014f925d864aa4f26bf3ca56aed1973f422a88ba4482adec36c8bc0ae8137a19d52d42ef84bdaf
7
- data.tar.gz: 9c52a93199b8ee6597c411318ec2a5e55e723510489e5d960a2cba9a7254a51522719e84f23fdbc6f44b4c6cd9b1899e7f3270d03b5c0bea0642203eb8872868
6
+ metadata.gz: af246fac3ae9511588b11122d62f6bfa7e7f463cd6435abb707d26b850dfea0e3ddcabb7af27a36605ce4446f7a5f7faec347f53452602d7b5f5fdf839813872
7
+ data.tar.gz: bfd0284a5491991d24f556dd1fa80b2cce1b6b1ed1c3de887d5001788e6834a357005d6371e0987507387b6faf679d194a4508cdbadaa5a0f43371c129bd824b
@@ -14,6 +14,7 @@ require_relative 'brainzz/models/video_stat'
14
14
  require_relative 'brainzz/models/view_count'
15
15
  require_relative 'brainzz/models/like_count'
16
16
  require_relative 'brainzz/models/share_count'
17
+ require_relative 'brainzz/models/dislike_count'
17
18
  require_relative 'brainzz/models/playlist_item'
18
19
  require_relative 'brainzz/models/playlist_items_wrapper'
19
20
 
@@ -31,6 +32,7 @@ require_relative 'brainzz/responses/video_stats_response'
31
32
  require_relative 'brainzz/responses/view_count_response'
32
33
  require_relative 'brainzz/responses/like_count_response'
33
34
  require_relative 'brainzz/responses/share_count_response'
35
+ require_relative 'brainzz/responses/dislike_count_response'
34
36
 
35
37
  require_relative 'brainzz/commands/base_command'
36
38
  require_relative 'brainzz/commands/data_command'
@@ -44,6 +46,8 @@ require_relative 'brainzz/commands/like_totals_command'
44
46
  require_relative 'brainzz/commands/like_count_by_day_command'
45
47
  require_relative 'brainzz/commands/share_totals_command'
46
48
  require_relative 'brainzz/commands/share_count_by_day_command'
49
+ require_relative 'brainzz/commands/dislike_totals_command'
50
+ require_relative 'brainzz/commands/dislike_count_by_day_command'
47
51
 
48
52
  require_relative 'brainzz/core'
49
53
 
@@ -0,0 +1,16 @@
1
+ module Brainzz
2
+ class DislikeCountByDayCommand < DislikeTotalsCommand
3
+ make_with_response DislikeCountResponse
4
+
5
+ class << self
6
+ private
7
+
8
+ def params(video_stats_params)
9
+ super.merge({
10
+ 'dimensions' => 'day',
11
+ 'sort' => 'day',
12
+ })
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ module Brainzz
2
+ class DislikeTotalsCommand < VideoStatsCommand
3
+ make_with_response DislikeCountResponse
4
+
5
+ class << self
6
+ private
7
+
8
+ def params(video_stats_params)
9
+ super.merge({
10
+ 'metrics' => 'dislikes',
11
+ })
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,5 +1,7 @@
1
1
  module Brainzz
2
2
  class LikeCountByDayCommand < LikeTotalsCommand
3
+ make_with_response LikeCountResponse
4
+
3
5
  class << self
4
6
  private
5
7
 
@@ -1,20 +1,8 @@
1
1
  module Brainzz
2
2
  class LikeTotalsCommand < VideoStatsCommand
3
- class << self
4
- def execute(video_id, start_date, end_date)
5
- video_stats_params = VideoStatsParams.new ({
6
- :video_id => video_id,
7
- :start_date => start_date,
8
- :end_date => end_date,
9
- })
10
-
11
- if video_stats_params.valid?
12
- LikeCountResponse.new get(video_stats_params)
13
- else
14
- LikeCountResponse.new
15
- end
16
- end
3
+ make_with_response LikeCountResponse
17
4
 
5
+ class << self
18
6
  private
19
7
 
20
8
  def params(video_stats_params)
@@ -1,5 +1,7 @@
1
1
  module Brainzz
2
2
  class ShareCountByDayCommand < ShareTotalsCommand
3
+ make_with_response ShareCountResponse
4
+
3
5
  class << self
4
6
  private
5
7
 
@@ -1,20 +1,8 @@
1
1
  module Brainzz
2
2
  class ShareTotalsCommand < VideoStatsCommand
3
- class << self
4
- def execute(video_id, start_date, end_date)
5
- video_stats_params = VideoStatsParams.new ({
6
- :video_id => video_id,
7
- :start_date => start_date,
8
- :end_date => end_date,
9
- })
10
-
11
- if video_stats_params.valid?
12
- ShareCountResponse.new get(video_stats_params)
13
- else
14
- ShareCountResponse.new
15
- end
16
- end
3
+ make_with_response ShareCountResponse
17
4
 
5
+ class << self
18
6
  private
19
7
 
20
8
  def params(video_stats_params)
@@ -1,11 +1,33 @@
1
1
  module Brainzz
2
2
  class VideoStatsCommand < AnalyticsCommand
3
3
  class << self
4
+ def execute(video_id, start_date, end_date)
5
+ video_stats_params = VideoStatsParams.new ({
6
+ :video_id => video_id,
7
+ :start_date => start_date,
8
+ :end_date => end_date,
9
+ })
10
+
11
+ if video_stats_params.valid?
12
+ response.new get(video_stats_params)
13
+ else
14
+ response.new
15
+ end
16
+ end
17
+
4
18
  private
5
19
 
20
+ def response
21
+ @response
22
+ end
23
+
24
+ def make_with_response(response)
25
+ @response = response
26
+ end
27
+
6
28
  def params(video_stats_params)
7
29
  super.merge({
8
- 'filters' => "video==#{video_stats_params.video_id}",
30
+ 'filters' => "video==#{video_stats_params.video_id}",
9
31
  })
10
32
  end
11
33
  end
@@ -1,5 +1,7 @@
1
1
  module Brainzz
2
2
  class ViewCountByDayCommand < ViewTotalsCommand
3
+ make_with_response ViewCountResponse
4
+
3
5
  class << self
4
6
  private
5
7
 
@@ -1,20 +1,8 @@
1
1
  module Brainzz
2
2
  class ViewTotalsCommand < VideoStatsCommand
3
- class << self
4
- def execute(video_id, start_date, end_date)
5
- video_stats_params = VideoStatsParams.new({
6
- :video_id => video_id,
7
- :start_date => start_date,
8
- :end_date => end_date,
9
- })
10
-
11
- if video_stats_params.valid?
12
- ViewCountResponse.new get(video_stats_params)
13
- else
14
- ViewCountResponse.new
15
- end
16
- end
3
+ make_with_response ViewCountResponse
17
4
 
5
+ class << self
18
6
  private
19
7
 
20
8
  def params(video_stats_params)
@@ -33,5 +33,13 @@ module Brainzz
33
33
  def share_totals_for(video_id, start_date, end_date)
34
34
  ShareTotalsCommand.execute video_id, start_date, end_date
35
35
  end
36
+
37
+ def dislikes_by_day_for(video_id, start_date, end_date)
38
+ DislikeCountByDayCommand.execute video_id, start_date, end_date
39
+ end
40
+
41
+ def dislike_totals_for(video_id, start_date, end_date)
42
+ DislikeTotalsCommand.execute video_id, start_date, end_date
43
+ end
36
44
  end
37
45
  end
@@ -5,3 +5,4 @@ require_relative 'factories/playlist_items_wrapper'
5
5
  require_relative 'factories/view_count'
6
6
  require_relative 'factories/like_count'
7
7
  require_relative 'factories/share_count'
8
+ require_relative 'factories/dislike_count'
@@ -0,0 +1,14 @@
1
+ FactoryGirl.define do
2
+ factory :brainzz_dislike_count, :class => Brainzz::DislikeCount do
3
+ dislikes { rand(1_000_000) + 1 }
4
+ day { Time.parse (DateTime.now - rand(100)).strftime('%F') }
5
+
6
+ factory :brainzz_aggregate_dislike_count do
7
+ day nil
8
+ end
9
+
10
+ initialize_with do
11
+ Brainzz::DislikeCount.new({})
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ module Brainzz
2
+ class DislikeCount < VideoStat
3
+ attr_accessor :dislikes
4
+
5
+ def initialize(hash)
6
+ super
7
+
8
+ @dislikes = normalize_stat(dislikes_data)
9
+ end
10
+
11
+ private
12
+
13
+ def dislikes_data
14
+ data && keys['dislikes'] && data[keys['dislikes']]
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ module Brainzz
2
+ class DislikeCountResponse < VideoStatsResponse
3
+ make_with_model DislikeCount
4
+ end
5
+ end
@@ -16,12 +16,14 @@ module Brainzz
16
16
 
17
17
  def on_success
18
18
  self.data = []
19
- keys = column_headers
20
- body['rows'].each do |row|
21
- self.data << self.class.model.new({
22
- :data => row,
23
- :keys => keys,
24
- })
19
+ if body['rows']
20
+ keys = column_headers
21
+ body['rows'].each do |row|
22
+ self.data << self.class.model.new({
23
+ :data => row,
24
+ :keys => keys,
25
+ })
26
+ end
25
27
  end
26
28
  end
27
29
 
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.7
4
+ version: 0.0.8
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-04-10 00:00:00.000000000 Z
13
+ date: 2015-04-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
@@ -181,6 +181,8 @@ files:
181
181
  - lib/brainzz/commands/analytics_command.rb
182
182
  - lib/brainzz/commands/base_command.rb
183
183
  - lib/brainzz/commands/data_command.rb
184
+ - lib/brainzz/commands/dislike_count_by_day_command.rb
185
+ - lib/brainzz/commands/dislike_totals_command.rb
184
186
  - lib/brainzz/commands/like_count_by_day_command.rb
185
187
  - lib/brainzz/commands/like_totals_command.rb
186
188
  - lib/brainzz/commands/playlist_items_command.rb
@@ -193,6 +195,7 @@ files:
193
195
  - lib/brainzz/core.rb
194
196
  - lib/brainzz/enums/view_source_enum.rb
195
197
  - lib/brainzz/factories.rb
198
+ - lib/brainzz/factories/dislike_count.rb
196
199
  - lib/brainzz/factories/like_count.rb
197
200
  - lib/brainzz/factories/playlist_item.rb
198
201
  - lib/brainzz/factories/playlist_items_wrapper.rb
@@ -201,6 +204,7 @@ files:
201
204
  - lib/brainzz/factories/video.rb
202
205
  - lib/brainzz/factories/view_count.rb
203
206
  - lib/brainzz/models/base_model.rb
207
+ - lib/brainzz/models/dislike_count.rb
204
208
  - lib/brainzz/models/like_count.rb
205
209
  - lib/brainzz/models/playlist_item.rb
206
210
  - lib/brainzz/models/playlist_items_wrapper.rb
@@ -213,6 +217,7 @@ files:
213
217
  - lib/brainzz/params/playlist_items_params.rb
214
218
  - lib/brainzz/params/video_details_params.rb
215
219
  - lib/brainzz/params/video_stats_params.rb
220
+ - lib/brainzz/responses/dislike_count_response.rb
216
221
  - lib/brainzz/responses/like_count_response.rb
217
222
  - lib/brainzz/responses/playlist_items_response.rb
218
223
  - lib/brainzz/responses/share_count_response.rb