yt 0.25.10 → 0.25.11

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: d720dbadc2626259a47ab8400a484486f88306b1
4
- data.tar.gz: f7644c90812513c80bf997b180642bb2b6d29db9
3
+ metadata.gz: e038a6da2ec69b1130e124d8c436a178a601cf4f
4
+ data.tar.gz: fd7c52d0cc6cfc3fa789d68cb99e4cce88338e9a
5
5
  SHA512:
6
- metadata.gz: be52dda90d6a38a6dc3f8fb62505ffc1168c3c3d7042aadf9575629631c3bff5db6487f86e177cc1f9e052a8ffdfe1eac060968bea1c70a89dfe57ff2d5ddaa6
7
- data.tar.gz: bd778fd7ef7bde45be00c14bd29bcdec4626eafc023e3761c8dbe32b54f5a58dae9bdea4343d5c9a7467d67cbc8676dc836741fd97dca9f88b66b4250175a727
6
+ metadata.gz: 2daaf03e57761920bafac958fb3b240efea2febdb84383c494c0629ccd7f669c01ec0cb062b52ec89e398628acaa7f661383d73386e684f53b2242ed9d200e70
7
+ data.tar.gz: 2488a4f82a7598c4abffe422a8ec2d4d97f550700b4de787b1482b008baaef2542ebdd799831e070ba9d10c4a4696d0d48e364a3dffe4d4b68f1dcd8ef8599dc
@@ -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.11 - 2015-11-05
10
+
11
+ * [ENHANCEMENT] Add "youtube.com/v/..." as possible URL for YouTube videos
12
+ * [ENHANCEMENT] Add eager loading to channel.playlists
13
+
9
14
  ## 0.25.10 - 2015-10-29
10
15
 
11
16
  * [FEATURE] Add Playlist#item_count
@@ -18,6 +18,30 @@ module Yt
18
18
  apply_where_params! params
19
19
  end
20
20
 
21
+ def attributes_for_new_item(data)
22
+ super.merge content_details: data['contentDetails']
23
+ end
24
+
25
+ def eager_load_items_from(items)
26
+ if included_relationships.any?
27
+ ids = items.map{|item| item['id']}
28
+ parts = included_relationships.map{|r| r.to_s.camelize(:lower)}
29
+ conditions = {id: ids.join(','), part: parts.join(',')}
30
+ playlists = Collections::Playlists.new(auth: @auth).where conditions
31
+
32
+ items.each do |item|
33
+ playlist = playlists.find{|playlist| playlist.id == item['id']}
34
+ parts.each do |part|
35
+ item[part] = case part
36
+ when 'snippet' then playlist.snippet.data.merge complete: true
37
+ when 'contentDetails' then playlist.content_detail.data
38
+ end
39
+ end if playlist
40
+ end
41
+ end
42
+ super
43
+ end
44
+
21
45
  def insert_parts
22
46
  snippet = {keys: [:title, :description, :tags], sanitize_brackets: true}
23
47
  status = {keys: [:privacy_status]}
@@ -184,6 +184,16 @@ module Yt
184
184
 
185
185
  ### PRIVATE API ###
186
186
 
187
+ # @private
188
+ # Override Resource's new to set content details as well
189
+ # if the response includes them
190
+ def initialize(options = {})
191
+ super options
192
+ if options[:content_details]
193
+ @content_detail = ContentDetail.new data: options[:content_details]
194
+ end
195
+ end
196
+
187
197
  # @private
188
198
  # Tells `has_reports` to retrieve the reports from YouTube Analytics API
189
199
  # either as a Channel or as a Content Owner.
@@ -72,6 +72,7 @@ module Yt
72
72
  youtube\\.com/watch\\?v=#{video_id}
73
73
  youtu\\.be/#{video_id}
74
74
  youtube\\.com/embed/#{video_id}
75
+ youtube\\.com/v/#{video_id}
75
76
  }
76
77
  end
77
78
 
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.25.10'
2
+ VERSION = '0.25.11'
3
3
  end
@@ -25,6 +25,12 @@ describe Yt::URL do
25
25
  it {expect(url.id).to eq 'MESycYJytkU' }
26
26
  end
27
27
 
28
+ context 'given a v video URL' do
29
+ let(:text) { 'https://www.youtube.com/v/MESycYJytkU' }
30
+ it {expect(url.kind).to eq :video }
31
+ it {expect(url.id).to eq 'MESycYJytkU' }
32
+ end
33
+
28
34
  context 'given a playlist-embedded video URL' do
29
35
  let(:text) { 'youtube.com/watch?v=MESycYJytkU&list=LLxO1tY8h1AhOz0T4ENwmpow' }
30
36
  it {expect(url.kind).to eq :video }
@@ -99,6 +99,16 @@ describe Yt::Channel, :device_app do
99
99
  end
100
100
  end
101
101
 
102
+ describe '.playlists' do
103
+ describe '.includes(:content_details)' do
104
+ let(:playlist) { channel.playlists.includes(:content_details).first }
105
+
106
+ specify 'eager-loads the content details of each playlist' do
107
+ expect(playlist.instance_variable_defined? :@content_detail).to be true
108
+ end
109
+ end
110
+ end
111
+
102
112
  it { expect(channel.playlists.first).to be_a Yt::Playlist }
103
113
  it { expect{channel.delete_playlists}.to raise_error Yt::Errors::RequestError }
104
114
 
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.10
4
+ version: 0.25.11
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-10-29 00:00:00.000000000 Z
11
+ date: 2015-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport