yt 0.23.1 → 0.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/yt/associations/has_reports.rb +28 -9
- data/lib/yt/collections/playlists.rb +3 -1
- data/lib/yt/collections/reports.rb +3 -3
- data/lib/yt/version.rb +1 -1
- data/spec/requests/as_content_owner/channel_spec.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa3a856cfe1b488850e6af5bf28d463fda5b1dde
|
4
|
+
data.tar.gz: 65d075b87a03e753b232d923966fb12b0a947d7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aeee94c2369c21e724f251f013b049c300350b476f884deffde9252f422af8764670137bc52439993cf8d36c7203e4b75e1f7e9eaaba6227a0309a8befc5561b
|
7
|
+
data.tar.gz: a95ae747c8b4dc774a7e6c498355bb0019806360ab85bbef9da91fffc56c2e9afa4a7c81fece144a21504db5ec1e5e59686bf6b38ff796de39cbee31829f3339
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,10 @@ For more information about changelogs, check
|
|
6
6
|
[Keep a Changelog](http://keepachangelog.com) and
|
7
7
|
[Vandamme](http://tech-angels.github.io/vandamme).
|
8
8
|
|
9
|
+
## 0.23.2 - 2015-05-20
|
10
|
+
|
11
|
+
* [FEATURE] Accept `:includes` in reports by video, related video and playlist to preload parts.
|
12
|
+
|
9
13
|
## 0.23.1 - 2015-05-19
|
10
14
|
|
11
15
|
* [FEATURE] New `by: :month` option for reports.
|
data/README.md
CHANGED
@@ -41,7 +41,7 @@ To install on your system, run
|
|
41
41
|
|
42
42
|
To use inside a bundled Ruby project, add this line to the Gemfile:
|
43
43
|
|
44
|
-
gem 'yt', '~> 0.23.
|
44
|
+
gem 'yt', '~> 0.23.2'
|
45
45
|
|
46
46
|
Since the gem follows [Semantic Versioning](http://semver.org),
|
47
47
|
indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
|
@@ -95,10 +95,10 @@ module Yt
|
|
95
95
|
# # => {embedded: 53.0, watch: 467.0, …}
|
96
96
|
# @return [Hash<Yt::Video, $2>] if grouped by related video, the
|
97
97
|
# $1 for each related video.
|
98
|
-
# @example Get yesterday’s $1 by related video
|
99
|
-
# resource.$1 since: 1.day.ago, until: 1.day.ago, by: :related_video
|
98
|
+
# @example Get yesterday’s $1 by related video, eager-loading the snippet of each video::
|
99
|
+
# resource.$1 since: 1.day.ago, until: 1.day.ago, by: :related_video, includes: [:snippet]
|
100
100
|
# # => {#<Yt::Video @id=…> => 33.0, #<Yt::Video @id=…> => 12.0, …}
|
101
|
-
# @return [Hash<
|
101
|
+
# @return [Hash<Symbol, $2>] if grouped by device type, the
|
102
102
|
# $1 for each device type.
|
103
103
|
# @example Get yesterday’s $1 by search term:
|
104
104
|
# resource.$1 since: 1.day.ago, until: 1.day.ago, by: :search_term
|
@@ -108,7 +108,7 @@ module Yt
|
|
108
108
|
# @example Get yesterday’s $1 by device type:
|
109
109
|
# resource.$1 since: 1.day.ago, until: 1.day.ago, by: :device_type
|
110
110
|
# # => {mobile: 133.0, tv: 412.0, …}
|
111
|
-
# @return [Hash<
|
111
|
+
# @return [Hash<Symbol, $2>] if grouped by traffic source, the
|
112
112
|
# $1 for each traffic source.
|
113
113
|
# @example Get yesterday’s $1 by traffic source:
|
114
114
|
# resource.$1 since: 1.day.ago, until: 1.day.ago, by: :traffic_source
|
@@ -121,6 +121,10 @@ module Yt
|
|
121
121
|
# Accepted values are: +:day+, +:month+, +:range+, +:traffic_source+,
|
122
122
|
# +:search_term+, +:playback_location+, +:related_video+,
|
123
123
|
# +:embedded_player_location+.
|
124
|
+
# @option options [Array<Symbol>] :includes ([:id]) if grouped by
|
125
|
+
# related video, the parts of each video to eager-load. Accepted
|
126
|
+
# values are: +:id+, +:snippet+, +:status+, +:statistics+,
|
127
|
+
# +:content_details+.
|
124
128
|
# @return [Hash<Symbol, $2>] if grouped by embedded player location,
|
125
129
|
# the $1 for each embedded player location.
|
126
130
|
# @example Get yesterday’s $1 by embedded player location:
|
@@ -130,16 +134,20 @@ module Yt
|
|
130
134
|
# @macro report_with_country_and_state
|
131
135
|
|
132
136
|
# @!macro [new] report_with_channel_dimensions
|
137
|
+
# @option options [Array<Symbol>] :includes ([:id]) if grouped by
|
138
|
+
# video, related video, or playlist, the parts of each video or
|
139
|
+
# playlist to eager-load. Accepted values are: +:id+, +:snippet+,
|
140
|
+
# +:status+, +:statistics+, +:content_details+.
|
133
141
|
# @return [Hash<Yt::Video, $2>] if grouped by video, the
|
134
142
|
# $1 for each video.
|
135
|
-
# @example Get yesterday’s $1 by video:
|
136
|
-
# resource.$1 since: 1.day.ago, until: 1.day.ago, by: :video
|
143
|
+
# @example Get yesterday’s $1 by video, eager-loading the status and statistics of each video:
|
144
|
+
# resource.$1 since: 1.day.ago, until: 1.day.ago, by: :video, includes: [:status, :statistics]
|
137
145
|
# # => {#<Yt::Video @id=…> => 33.0, #<Yt::Video @id=…> => 12.0, …}
|
138
|
-
# @return [Hash<Yt::
|
146
|
+
# @return [Hash<Yt::Playlist, $2>] if grouped by playlist, the
|
139
147
|
# $1 for each playlist.
|
140
148
|
# @example Get yesterday’s $1 by playlist:
|
141
149
|
# resource.$1 since: 1.day.ago, until: 1.day.ago, by: :playlist
|
142
|
-
# # => {#<Yt::
|
150
|
+
# # => {#<Yt::Playlist @id=…> => 33.0, #<Yt::Playlist @id=…> => 12.0, …}
|
143
151
|
# @macro report_with_video_dimensions
|
144
152
|
|
145
153
|
# @!macro [new] report_by_channel_dimensions
|
@@ -253,7 +261,7 @@ module Yt
|
|
253
261
|
|
254
262
|
ivar = instance_variable_get "@#{metric}_#{dimension}_#{country}_#{state}"
|
255
263
|
instance_variable_set "@#{metric}_#{dimension}_#{country}_#{state}", ivar || {}
|
256
|
-
case dimension
|
264
|
+
results = case dimension
|
257
265
|
when :day
|
258
266
|
Hash[*range.flat_map do |date|
|
259
267
|
[date, instance_variable_get("@#{metric}_#{dimension}_#{country}_#{state}")[date] ||= send("range_#{metric}", range, dimension, country, state)[date]]
|
@@ -261,6 +269,17 @@ module Yt
|
|
261
269
|
else
|
262
270
|
instance_variable_get("@#{metric}_#{dimension}_#{country}_#{state}")[range] ||= send("range_#{metric}", range, dimension, country, state)
|
263
271
|
end
|
272
|
+
lookup_class = case options[:by]
|
273
|
+
when :video, :related_video then Yt::Collections::Videos
|
274
|
+
when :playlist then Yt::Collections::Playlists
|
275
|
+
end
|
276
|
+
if lookup_class
|
277
|
+
includes = options.fetch(:includes, [:id]).join(',').camelize(:lower)
|
278
|
+
items = lookup_class.new(auth: auth).where(part: includes, id: results.keys.join(','))
|
279
|
+
results.transform_keys{|id| items.find{|item| item.id == id}}.reject{|k, _| k.nil?}
|
280
|
+
else
|
281
|
+
results
|
282
|
+
end
|
264
283
|
end
|
265
284
|
end
|
266
285
|
|
@@ -10,10 +10,10 @@ module Yt
|
|
10
10
|
hash[:traffic_source] = {name: 'insightTrafficSourceType', parse: ->(source, *values) { @metrics.keys.zip(values.map{|v| {TRAFFIC_SOURCES.key(source) => v}}).to_h} }
|
11
11
|
hash[:playback_location] = {name: 'insightPlaybackLocationType', parse: ->(location, *values) { @metrics.keys.zip(values.map{|v| {PLAYBACK_LOCATIONS.key(location) => v}}).to_h} }
|
12
12
|
hash[:embedded_player_location] = {name: 'insightPlaybackLocationDetail', parse: ->(url, *values) {@metrics.keys.zip(values.map{|v| {url => v}}).to_h} }
|
13
|
-
hash[:related_video] = {name: 'insightTrafficSourceDetail', parse: ->(video_id, *values) { @metrics.keys.zip(values.map{|v| {
|
13
|
+
hash[:related_video] = {name: 'insightTrafficSourceDetail', parse: ->(video_id, *values) { @metrics.keys.zip(values.map{|v| {video_id => v}}).to_h} }
|
14
14
|
hash[:search_term] = {name: 'insightTrafficSourceDetail', parse: ->(search_term, *values) {@metrics.keys.zip(values.map{|v| {search_term => v}}).to_h} }
|
15
|
-
hash[:video] = {name: 'video', parse: ->(video_id, *values) { @metrics.keys.zip(values.map{|v| {
|
16
|
-
hash[:playlist] = {name: 'playlist', parse: ->(playlist_id, *values) { @metrics.keys.zip(values.map{|v| {
|
15
|
+
hash[:video] = {name: 'video', parse: ->(video_id, *values) { @metrics.keys.zip(values.map{|v| {video_id => v}}).to_h} }
|
16
|
+
hash[:playlist] = {name: 'playlist', parse: ->(playlist_id, *values) { @metrics.keys.zip(values.map{|v| {playlist_id => v}}).to_h} }
|
17
17
|
hash[:device_type] = {name: 'deviceType', parse: ->(type, *values) {@metrics.keys.zip(values.map{|v| {type.downcase.to_sym => v}}).to_h} }
|
18
18
|
hash[:country] = {name: 'country', parse: ->(country_code, *values) { @metrics.keys.zip(values.map{|v| {country_code => v}}).to_h} }
|
19
19
|
hash[:state] = {name: 'province', parse: ->(country_and_state_code, *values) { @metrics.keys.zip(values.map{|v| {country_and_state_code[3..-1] => v}}).to_h} }
|
data/lib/yt/version.rb
CHANGED
@@ -330,6 +330,12 @@ describe Yt::Channel, :partner do
|
|
330
330
|
views = channel.views range.merge by: :related_video
|
331
331
|
expect(views.keys).to all(be_instance_of Yt::Video)
|
332
332
|
end
|
333
|
+
|
334
|
+
specify 'and provided with an :includes option to preload parts' do
|
335
|
+
views = channel.views range.merge by: :related_video, includes: [:statistics]
|
336
|
+
expect(views.keys.map{|v| v.instance_variable_defined? :@status}).to all(be false)
|
337
|
+
expect(views.keys.map{|v| v.instance_variable_defined? :@statistics_set}).to all(be true)
|
338
|
+
end
|
333
339
|
end
|
334
340
|
|
335
341
|
describe 'views can be grouped by search term' do
|
@@ -348,6 +354,12 @@ describe Yt::Channel, :partner do
|
|
348
354
|
views = channel.views range.merge by: :video
|
349
355
|
expect(views.keys).to all(be_instance_of Yt::Video)
|
350
356
|
end
|
357
|
+
|
358
|
+
specify 'and provided with an :includes option to preload parts' do
|
359
|
+
views = channel.views range.merge by: :video, includes: [:statistics]
|
360
|
+
expect(views.keys.map{|v| v.instance_variable_defined? :@status}).to all(be false)
|
361
|
+
expect(views.keys.map{|v| v.instance_variable_defined? :@statistics_set}).to all(be true)
|
362
|
+
end
|
351
363
|
end
|
352
364
|
|
353
365
|
describe 'views can be grouped by playlist' do
|
@@ -357,6 +369,12 @@ describe Yt::Channel, :partner do
|
|
357
369
|
views = channel.views range.merge by: :playlist
|
358
370
|
expect(views.keys).to all(be_instance_of Yt::Playlist)
|
359
371
|
end
|
372
|
+
|
373
|
+
specify 'and provided with an :includes option to preload parts' do
|
374
|
+
views = channel.views range.merge by: :playlist, includes: [:status]
|
375
|
+
expect(views.keys.map{|playlist| playlist.instance_variable_defined? :@content_details}).to all(be false)
|
376
|
+
expect(views.keys.map{|playlist| playlist.instance_variable_defined? :@status}).to all(be true)
|
377
|
+
end
|
360
378
|
end
|
361
379
|
|
362
380
|
describe 'views can be grouped by device type' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.23.
|
4
|
+
version: 0.23.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claudio Baccigalupo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|