brainzz 0.0.5 → 0.0.6

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: 3a7df38b3c5dbf4532513c08d8a57155167738f9
4
- data.tar.gz: 425b4f946d597db63e5e5f85a28810d36e3934d7
3
+ metadata.gz: 40016cde2e4bfde7fa826dfd41d7e5a1d2bfb87b
4
+ data.tar.gz: 2c4aa4d4abb6313926b9b1963e2ab240d84e4edf
5
5
  SHA512:
6
- metadata.gz: d06108933d0b0d71a5b09484018b999e565ce5ebfe9bfe5944c083183e7d880de8be5c27004b31d2ec9508537a9e163e0a74a7c47d281354631d00e958b35fa5
7
- data.tar.gz: 1ca881f5099f8930ec5139159abae5ecdc37100a283b8cc0d01748dbb3f526456c83d7a6bfefc6c20ea899d5feb688e2184b113e6e751914eda2bfafdc6a74dc
6
+ metadata.gz: 2f61c7b4aa8a01ec432c3b8aca5334fbebb870c274859ee12697cf98e186c4d3947f05e412c6026f6dbdf902efbb3dca983ab50ad49cf6224338181a40d85a64
7
+ data.tar.gz: 10076c54ca18e873dc0abd0a4c5d54329525b1eb8e56a28e61a473da129a24d43f3a6d2d60bf742f6022f6f615692c9ed3e07ebd91481c3eb7f5eff65c752d6e
data/README.md CHANGED
@@ -128,16 +128,17 @@ corresponding to the following YouTube referrals:
128
128
  YT_OTHER_PAGE = 11
129
129
  YT_SEARCH = 12
130
130
 
131
- The constants are defined in `Brainzz::ViewCountEnum`
131
+ The constants are defined in `Brainzz::ViewCountEnum`.
132
132
 
133
133
  ### view_totals_for
134
134
 
135
135
  #### Parameters
136
- same as views_by_day_for
136
+ Same as views_by_day_for.
137
137
 
138
138
  #### Result
139
- same as views_by_day_for except date values are nil
140
- views for date range are aggregated per source type
139
+ Same as views_by_day_for except date values are nil.
140
+
141
+ Views for date range are aggregated per source type.
141
142
 
142
143
  ### likes_by_day_for
143
144
 
@@ -154,11 +155,34 @@ An array of `Brainzz::LikeCount` objects ordered by date in ascending order.
154
155
  ### like_totals_for
155
156
 
156
157
  #### Parameters
157
- same as likes_by_day_for
158
+ Same as likes_by_day_for.
159
+
160
+ #### Result
161
+ Same as likes_by_day_for except date values are nil.
162
+
163
+ Likes for date range are aggregated.
164
+
165
+ ### shares_by_day_for
166
+
167
+ #### Parameters
168
+
169
+ * video id (String)
170
+ * start date (DateTime)
171
+ * end date (DateTime)
172
+
173
+ #### Result
174
+
175
+ An array of `Brainzz::ShareCount` objects ordered by date in ascending order.
176
+
177
+ ### share_totals_for
178
+
179
+ #### Parameters
180
+ Same as shares_by_day_for.
158
181
 
159
182
  #### Result
160
- same as likes_by_day_for except date values are nil
161
- likes for date range are aggregated
183
+ Same as shares_by_day_for except date values are nil.
184
+
185
+ Shares for date range are aggregated.
162
186
 
163
187
  Factories
164
188
  ---------
data/lib/brainzz.rb CHANGED
@@ -13,6 +13,7 @@ require_relative 'brainzz/models/video'
13
13
  require_relative 'brainzz/models/video_stat'
14
14
  require_relative 'brainzz/models/view_count'
15
15
  require_relative 'brainzz/models/like_count'
16
+ require_relative 'brainzz/models/share_count'
16
17
  require_relative 'brainzz/models/playlist_item'
17
18
  require_relative 'brainzz/models/playlist_items_wrapper'
18
19
 
@@ -29,6 +30,7 @@ require_relative 'brainzz/responses/video_details_response'
29
30
  require_relative 'brainzz/responses/video_stats_response'
30
31
  require_relative 'brainzz/responses/view_count_response'
31
32
  require_relative 'brainzz/responses/like_count_response'
33
+ require_relative 'brainzz/responses/share_count_response'
32
34
 
33
35
  require_relative 'brainzz/commands/base_command'
34
36
  require_relative 'brainzz/commands/data_command'
@@ -40,6 +42,8 @@ require_relative 'brainzz/commands/view_totals_command'
40
42
  require_relative 'brainzz/commands/view_count_by_day_command'
41
43
  require_relative 'brainzz/commands/like_totals_command'
42
44
  require_relative 'brainzz/commands/like_count_by_day_command'
45
+ require_relative 'brainzz/commands/share_totals_command'
46
+ require_relative 'brainzz/commands/share_count_by_day_command'
43
47
 
44
48
  require_relative 'brainzz/core'
45
49
 
@@ -19,7 +19,7 @@ module Brainzz
19
19
 
20
20
  def params(video_stats_params)
21
21
  super.merge({
22
- 'metrics' => 'likes',
22
+ 'metrics' => 'likes',
23
23
  })
24
24
  end
25
25
  end
@@ -0,0 +1,14 @@
1
+ module Brainzz
2
+ class ShareCountByDayCommand < ShareTotalsCommand
3
+ class << self
4
+ private
5
+
6
+ def params(video_stats_params)
7
+ super.merge({
8
+ 'dimensions' => 'day',
9
+ 'sort' => 'day',
10
+ })
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,27 @@
1
+ module Brainzz
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
17
+
18
+ private
19
+
20
+ def params(video_stats_params)
21
+ super.merge({
22
+ 'metrics' => 'shares',
23
+ })
24
+ end
25
+ end
26
+ end
27
+ end
data/lib/brainzz/core.rb CHANGED
@@ -25,5 +25,13 @@ module Brainzz
25
25
  def like_totals_for(video_id, start_date, end_date)
26
26
  LikeTotalsCommand.execute video_id, start_date, end_date
27
27
  end
28
+
29
+ def shares_by_day_for(video_id, start_date, end_date)
30
+ ShareCountByDayCommand.execute video_id, start_date, end_date
31
+ end
32
+
33
+ def share_totals_for(video_id, start_date, end_date)
34
+ ShareTotalsCommand.execute video_id, start_date, end_date
35
+ end
28
36
  end
29
37
  end
@@ -4,3 +4,4 @@ require_relative 'factories/playlist_item'
4
4
  require_relative 'factories/playlist_items_wrapper'
5
5
  require_relative 'factories/view_count'
6
6
  require_relative 'factories/like_count'
7
+ require_relative 'factories/share_count'
@@ -0,0 +1,14 @@
1
+ FactoryGirl.define do
2
+ factory :brainzz_share_count, :class => Brainzz::ShareCount do
3
+ shares { rand(1_000_000) + 1 }
4
+ day { DateTime.parse((DateTime.now - rand(100)).strftime('%F')) }
5
+
6
+ factory :brainzz_aggregate_share_count do
7
+ day nil
8
+ end
9
+
10
+ initialize_with do
11
+ Brainzz::ShareCount.new({})
12
+ end
13
+ end
14
+ end
@@ -19,7 +19,7 @@ module Brainzz
19
19
  def transform_date(value)
20
20
  value = transform(value)
21
21
  return nil unless value.is_a?(String)
22
- DateTime.parse value
22
+ Time.parse value
23
23
  end
24
24
  end
25
25
  end
@@ -5,8 +5,6 @@ module Brainzz
5
5
  def initialize(hash)
6
6
  super
7
7
 
8
- @hash = hash
9
-
10
8
  @likes = normalize_stat(likes_data)
11
9
  end
12
10
 
@@ -0,0 +1,17 @@
1
+ module Brainzz
2
+ class ShareCount < VideoStat
3
+ attr_accessor :shares
4
+
5
+ def initialize(hash)
6
+ super
7
+
8
+ @shares = normalize_stat(shares_data)
9
+ end
10
+
11
+ private
12
+
13
+ def shares_data
14
+ data && keys['shares'] && data[keys['shares']]
15
+ end
16
+ end
17
+ end
@@ -5,8 +5,6 @@ module Brainzz
5
5
  def initialize(hash)
6
6
  super
7
7
 
8
- @hash = hash
9
-
10
8
  @views = normalize_stat(views_data)
11
9
  @source = source_value(source_data)
12
10
  end
@@ -0,0 +1,5 @@
1
+ module Brainzz
2
+ class ShareCountResponse < VideoStatsResponse
3
+ make_with_model ShareCount
4
+ end
5
+ end
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.5
4
+ version: 0.0.6
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-08 00:00:00.000000000 Z
13
+ date: 2015-04-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
@@ -144,14 +144,14 @@ dependencies:
144
144
  requirements:
145
145
  - - "~>"
146
146
  - !ruby/object:Gem::Version
147
- version: '1'
147
+ version: '2'
148
148
  type: :development
149
149
  prerelease: false
150
150
  version_requirements: !ruby/object:Gem::Requirement
151
151
  requirements:
152
152
  - - "~>"
153
153
  - !ruby/object:Gem::Version
154
- version: '1'
154
+ version: '2'
155
155
  - !ruby/object:Gem::Dependency
156
156
  name: factory_girl
157
157
  requirement: !ruby/object:Gem::Requirement
@@ -184,6 +184,8 @@ files:
184
184
  - lib/brainzz/commands/like_count_by_day_command.rb
185
185
  - lib/brainzz/commands/like_totals_command.rb
186
186
  - lib/brainzz/commands/playlist_items_command.rb
187
+ - lib/brainzz/commands/share_count_by_day_command.rb
188
+ - lib/brainzz/commands/share_totals_command.rb
187
189
  - lib/brainzz/commands/video_details_command.rb
188
190
  - lib/brainzz/commands/video_stats_command.rb
189
191
  - lib/brainzz/commands/view_count_by_day_command.rb
@@ -195,12 +197,14 @@ files:
195
197
  - lib/brainzz/factories/playlist_item.rb
196
198
  - lib/brainzz/factories/playlist_items_wrapper.rb
197
199
  - lib/brainzz/factories/sequences.rb
200
+ - lib/brainzz/factories/share_count.rb
198
201
  - lib/brainzz/factories/video.rb
199
202
  - lib/brainzz/factories/view_count.rb
200
203
  - lib/brainzz/models/base_model.rb
201
204
  - lib/brainzz/models/like_count.rb
202
205
  - lib/brainzz/models/playlist_item.rb
203
206
  - lib/brainzz/models/playlist_items_wrapper.rb
207
+ - lib/brainzz/models/share_count.rb
204
208
  - lib/brainzz/models/video.rb
205
209
  - lib/brainzz/models/video_stat.rb
206
210
  - lib/brainzz/models/view_count.rb
@@ -211,6 +215,7 @@ files:
211
215
  - lib/brainzz/params/video_stats_params.rb
212
216
  - lib/brainzz/responses/like_count_response.rb
213
217
  - lib/brainzz/responses/playlist_items_response.rb
218
+ - lib/brainzz/responses/share_count_response.rb
214
219
  - lib/brainzz/responses/video_details_response.rb
215
220
  - lib/brainzz/responses/video_stats_response.rb
216
221
  - lib/brainzz/responses/view_count_response.rb