yt 0.25.32 → 0.25.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/yt/collections/claims.rb +21 -0
- data/lib/yt/collections/videos.rb +5 -2
- data/lib/yt/models/claim.rb +12 -1
- data/lib/yt/version.rb +1 -1
- data/spec/models/claim_spec.rb +13 -1
- data/spec/requests/as_content_owner/content_owner_spec.rb +3 -1
- 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: 6e07affd7b6d4df0e69e0ab16d65a959be125294
|
4
|
+
data.tar.gz: f29044dea895dfce5e8dee70f81e7583b84cb5ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9c7378a1167c85d6329d8477eead541168cfeeece66cbafbe75eceea23740b3c5ec3b927d95fab7eebe51e70adfcc020a150c67e289e7dbdd720323a244fb4a
|
7
|
+
data.tar.gz: c71329c0e58166f21c494028c5da4659a3d2c5dc75e3458d6fc7c7dccbcd8e821998454f1365eda0a68ad02f7952740eca42944582d8603f5b4c8ae70f7159ff
|
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.33 - 2016-04-15
|
10
|
+
|
11
|
+
* [FEATURE] Eager-loading claims from videos will also eager-load assets.
|
12
|
+
* [FEATURE] New method - `Claim#source` will return the source of the claim.
|
13
|
+
|
9
14
|
## 0.25.32 - 2016-04-12
|
10
15
|
|
11
16
|
* [BUGFIX] Fix where videos did not eager load claims or categories in subsequent requests.
|
@@ -17,6 +17,27 @@ module Yt
|
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
+
def attributes_for_new_item(data)
|
21
|
+
{}.tap do |attributes|
|
22
|
+
attributes[:id] = data['id']
|
23
|
+
attributes[:auth] = @auth
|
24
|
+
attributes[:data] = data
|
25
|
+
attributes[:asset] = data['asset']
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def eager_load_items_from(items)
|
30
|
+
if included_relationships.include? :asset
|
31
|
+
asset_ids = items.map { |item| item['assetId'] }.uniq
|
32
|
+
conditions = { id: asset_ids.join(','), fetch_metadata: 'effective' }
|
33
|
+
assets = @parent.assets.where conditions
|
34
|
+
items.each do |item|
|
35
|
+
item['asset'] = assets.find { |a| a.id == item['assetId'] }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
super
|
39
|
+
end
|
40
|
+
|
20
41
|
# @return [Hash] the parameters to submit to YouTube to list claims
|
21
42
|
# administered by the content owner.
|
22
43
|
# @see https://developers.google.com/youtube/partner/docs/v1/claims/list
|
@@ -59,8 +59,11 @@ module Yt
|
|
59
59
|
|
60
60
|
if included_relationships.include? :claim
|
61
61
|
video_ids = items.map{|item| item['id']['videoId']}.uniq
|
62
|
-
conditions = {
|
63
|
-
|
62
|
+
conditions = {
|
63
|
+
video_id: video_ids.join(','),
|
64
|
+
include_third_party_claims: false
|
65
|
+
}
|
66
|
+
claims = @parent.claims.includes(:asset).where conditions
|
64
67
|
items.each do |item|
|
65
68
|
claim = claims.find { |c| c.video_id == item['id']['videoId']}
|
66
69
|
item['claim'] = claim
|
data/lib/yt/models/claim.rb
CHANGED
@@ -11,6 +11,7 @@ module Yt
|
|
11
11
|
@data = options[:data]
|
12
12
|
@id = options[:id]
|
13
13
|
@auth = options[:auth]
|
14
|
+
@asset = options[:asset] if options[:asset]
|
14
15
|
end
|
15
16
|
|
16
17
|
# @!attribute [r] claim_history
|
@@ -113,6 +114,16 @@ module Yt
|
|
113
114
|
content_type == 'audiovisual'
|
114
115
|
end
|
115
116
|
|
117
|
+
# @return [String] the source of the claim
|
118
|
+
def source
|
119
|
+
@data.fetch('origin', {})['source']
|
120
|
+
end
|
121
|
+
|
122
|
+
# @return [Yt::Models::Asset] the asset of the claim
|
123
|
+
def asset
|
124
|
+
@asset
|
125
|
+
end
|
126
|
+
|
116
127
|
# @return [Time] the date and time that the claim was created.
|
117
128
|
has_attribute :created_at, type: Time, from: :time_created
|
118
129
|
|
@@ -153,4 +164,4 @@ module Yt
|
|
153
164
|
end
|
154
165
|
end
|
155
166
|
end
|
156
|
-
end
|
167
|
+
end
|
data/lib/yt/version.rb
CHANGED
data/spec/models/claim_spec.rb
CHANGED
@@ -208,4 +208,16 @@ describe Yt::Claim do
|
|
208
208
|
it { expect(claim.third_party?).to be false }
|
209
209
|
end
|
210
210
|
end
|
211
|
-
|
211
|
+
|
212
|
+
describe '#source' do
|
213
|
+
context 'given fetching a claim returns a source' do
|
214
|
+
let(:data) { {"origin"=>{"source"=>"webUpload"}} }
|
215
|
+
it { expect(claim.source).to eq 'webUpload' }
|
216
|
+
end
|
217
|
+
|
218
|
+
context 'given fetching a claim does not return a source' do
|
219
|
+
let(:data) { {"origin"=>{}} }
|
220
|
+
it { expect(claim.source).to eq nil }
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
@@ -54,10 +54,12 @@ describe Yt::ContentOwner, :partner do
|
|
54
54
|
let(:videos) { $content_owner.videos.includes(:claim) }
|
55
55
|
let(:video_with_claim) { videos.find{|v| v.claim.present?} }
|
56
56
|
|
57
|
-
specify 'eager-loads the claim of each video' do
|
57
|
+
specify 'eager-loads the claim of each video and its asset' do
|
58
58
|
expect(video_with_claim.claim).to be_a Yt::Claim
|
59
59
|
expect(video_with_claim.claim.id).to be_a String
|
60
60
|
expect(video_with_claim.claim.video_id).to eq video_with_claim.id
|
61
|
+
expect(video_with_claim.claim.asset).to be_a Yt::Asset
|
62
|
+
expect(video_with_claim.claim.asset.id).to be_a String
|
61
63
|
end
|
62
64
|
end
|
63
65
|
end
|
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.
|
4
|
+
version: 0.25.33
|
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-04-
|
11
|
+
date: 2016-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|