yt 0.25.18 → 0.25.19

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: 326f3adf4a4e1e7bbf64930125f77a404276d391
4
- data.tar.gz: 26c77d99c92fc26b67b085bb1a453dc297f95a90
3
+ metadata.gz: 027f85007663e5e62a0cfae07c66e09078ce0391
4
+ data.tar.gz: e1d99207ce02b83a05d60e3fe83d181cf2d20fbd
5
5
  SHA512:
6
- metadata.gz: c07e83a315d72de93ec39e4c24b953b7aa65f96cfa7fda272d0f6bc7f18819ba065a407374aef07571b811c5baed4c4bd993c3895c19d39c3d54a0c9eb6c7291
7
- data.tar.gz: 17cab126cf09804f07a3025f4daab542ae0a5cbb54ee6026953ec9e67e53784b972560fefd74cb66e5c629808c28114adf9080379e820bba7bf8c51cdac9ce8b
6
+ metadata.gz: b2acbbbaf56554ff7e5b6334faefcd0f486513c1423c0ec30e77cd71f6172b1d3222144384f48396f2adcf985ca83a265f77d5cc60ef5ee36030f69d572b914a
7
+ data.tar.gz: 63960c6908b3ffe0d3ffc433734c68e8b94e13ee8f7bbdb1aab112b59cfbcbe578fd87646b24e1b16b8bd17817ba3f50fa036944bfd0c7f76b8f0a0c0d7df910
data/CHANGELOG.md CHANGED
@@ -6,6 +6,11 @@ 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.25.19 - 2016-01-15
10
+
11
+ * [FEATURE] Add `:group_items` to Yt::VideoGroup (list items of a group)
12
+ * [FEATURE] Add `:includes(:video)` to `Yt::VideoGroup#group_items` (eagerly loads all the videos)
13
+
9
14
  ## 0.25.18 - 2016-01-08
10
15
 
11
16
  * [FEATURE] Add Yt::COUNTRIES and Yt::US_STATES
@@ -0,0 +1,44 @@
1
+ require 'yt/collections/base'
2
+ require 'yt/models/group_item'
3
+
4
+ module Yt
5
+ module Collections
6
+ # @private
7
+ class GroupItems < Base
8
+
9
+ private
10
+
11
+ def attributes_for_new_item(data)
12
+ super(data).tap do |attributes|
13
+ attributes[:video] = data['video']
14
+ end
15
+ end
16
+
17
+ def list_params
18
+ super.tap do |params|
19
+ params[:path] = "/youtube/analytics/v1/groupItems"
20
+ params[:params] = {group_id: @parent.id}
21
+ if @auth.owner_name
22
+ params[:params][:on_behalf_of_content_owner] = @auth.owner_name
23
+ end
24
+ end
25
+ end
26
+
27
+ def eager_load_items_from(items)
28
+ if included_relationships.include?(:video)
29
+ all_video_ids = items.map{|item| item['resource']['id']}.uniq
30
+ all_video_ids.each_slice(50) do |video_ids|
31
+ conditions = {id: video_ids.join(',')}
32
+ conditions[:part] = 'snippet,status,statistics,contentDetails'
33
+ videos = Collections::Videos.new(auth: @auth).where conditions
34
+ items.each do |item|
35
+ video = videos.find{|v| v.id == item['resource']['id']}
36
+ item['video'] = video if video
37
+ end
38
+ end
39
+ end
40
+ super
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,15 @@
1
+ require 'yt/models/video'
2
+
3
+ module Yt
4
+ module Models
5
+ class GroupItem < Base
6
+ attr_reader :auth, :data, :video
7
+
8
+ def initialize(options = {})
9
+ @data = options[:data]
10
+ @auth = options[:auth]
11
+ @video = options[:video] if options[:video]
12
+ end
13
+ end
14
+ end
15
+ end
@@ -24,6 +24,12 @@ module Yt
24
24
  # @return [Time] the date and time when the group was created.
25
25
  delegate :published_at, to: :group_info
26
26
 
27
+ ### ASSOCIATIONS ###
28
+
29
+ # @!attribute [r] group_items
30
+ # @return [Yt::Collections::GroupItems] the group’s items.
31
+ has_many :group_items
32
+
27
33
  ### ANALYTICS ###
28
34
 
29
35
  # @macro reports
data/lib/yt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.25.18'
2
+ VERSION = '0.25.19'
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require 'spec_helper'
2
2
  require 'yt/models/video_group'
3
+ require 'yt/models/group_item'
3
4
 
4
5
  describe Yt::VideoGroup, :partner do
5
6
  subject(:video_group) { Yt::VideoGroup.new id: id, auth: $content_owner }
@@ -18,6 +19,18 @@ describe Yt::VideoGroup, :partner do
18
19
  expect(video_group.item_count).not_to be_zero
19
20
  end
20
21
 
22
+ specify '.group_items retrieves the group items' do
23
+ expect(video_group.group_items.count).to be_an(Integer)
24
+ expect(video_group.group_items.map{|g| g}).to all(be_a Yt::GroupItem)
25
+ end
26
+
27
+ specify '.group_items.includes(:video) eager-loads each video' do
28
+ item = video_group.group_items.includes(:video).first
29
+ expect(item.video.instance_variable_defined? :@snippet).to be true
30
+ expect(item.video.instance_variable_defined? :@status).to be true
31
+ expect(item.video.instance_variable_defined? :@statistics_set).to be true
32
+ end
33
+
21
34
  describe 'multiple reports can be retrieved at once' do
22
35
  metrics = {views: Integer, uniques: Integer,
23
36
  estimated_minutes_watched: Integer, comments: Integer, likes: Integer,
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.25.18
4
+ version: 0.25.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-09 00:00:00.000000000 Z
11
+ date: 2016-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -143,6 +143,7 @@ files:
143
143
  - lib/yt/collections/device_flows.rb
144
144
  - lib/yt/collections/file_details.rb
145
145
  - lib/yt/collections/group_infos.rb
146
+ - lib/yt/collections/group_items.rb
146
147
  - lib/yt/collections/ids.rb
147
148
  - lib/yt/collections/live_streaming_details.rb
148
149
  - lib/yt/collections/ownerships.rb
@@ -196,6 +197,7 @@ files:
196
197
  - lib/yt/models/device_flow.rb
197
198
  - lib/yt/models/file_detail.rb
198
199
  - lib/yt/models/group_info.rb
200
+ - lib/yt/models/group_item.rb
199
201
  - lib/yt/models/id.rb
200
202
  - lib/yt/models/iterator.rb
201
203
  - lib/yt/models/live_streaming_detail.rb