yt 0.25.29 → 0.25.30

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8d7f0a5503a59888dd4b0d1e439162585a97544
4
- data.tar.gz: 74ac050d02d5d8f7620eaf9a1477237b713aa7d0
3
+ metadata.gz: 28a685b003b607412601a4b2c4cc2858bcc9a83d
4
+ data.tar.gz: 15134a642f1c55adef761e87e0c51cf872bad12a
5
5
  SHA512:
6
- metadata.gz: f05116b8d41cc032d0d574e7e81e39de24af901cbf349370d57171324ddf2ffc271fc18ff82d9d1cf6bdd83cbb4d5c1181269fbe222902974b3b2312f6069f94
7
- data.tar.gz: 379c55ae5fe720cc5f8169bdc20dd018a8c4b3f7aa4ed3dda7f28ef16fff64d7f7654b6b381ad6d706fbe0e5ab3eb5a41c1cc55dab8828d9df135a4c8cea79e3
6
+ metadata.gz: 9a7e2a387afa16cce3d6614df7381096d097c5e45856efdb94e1746c1f2138c6631d2fd652ac9ce2715dfeed8f9fd6bf516b24c7cbcb74b399d58ca4c8579c6f
7
+ data.tar.gz: 39e7426f7eae5d73daa453643fc145fc87608cccadfbfa693a22658849218998ca9c4934c13341b06fa52490b55922a19ee3243c1c6e83f0410c480ec71d0e94
@@ -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.25.30 - 2016-04-07
10
+
11
+ * [FEATURE] Add ability for videos to eager load claims. For example, `$content_owner.videos.includes(:claim).first.claim.id`.
12
+
9
13
  ## 0.25.29 - 2016-04-07
10
14
 
11
15
  * [BUGFIX] Previously, Yt was throttling queries for `quotaExceeded` responses from YouTube. However, matching `quotaExceeded` was too specific and would not have caught other limit exceeding responses from YouTube. This change will allow Yt to throttle other responses that contains `Exceeded` or `exceeded`.
@@ -37,7 +37,12 @@ module Yt
37
37
  end
38
38
 
39
39
  def claims_params
40
- apply_where_params! on_behalf_of_content_owner: @parent.owner_name
40
+ if @parent.respond_to? :owner_name
41
+ owner_name = @parent.owner_name
42
+ else
43
+ owner_name = @auth.owner_name
44
+ end
45
+ apply_where_params! on_behalf_of_content_owner: owner_name
41
46
  end
42
47
 
43
48
  # @private
@@ -53,4 +58,4 @@ module Yt
53
58
  end
54
59
  end
55
60
  end
56
- end
61
+ end
@@ -27,13 +27,15 @@ module Yt
27
27
  attributes[:statistics] = data['statistics']
28
28
  attributes[:video_category] = data['videoCategory']
29
29
  attributes[:auth] = @auth
30
+ attributes[:claim] = data['claim']
30
31
  end
31
32
  end
32
33
 
33
34
  def eager_load_items_from(items)
34
35
  if included_relationships.any?
35
36
  include_category = included_relationships.delete(:category)
36
- included_relationships.append(:snippet).uniq! if include_category
37
+ include_claim = included_relationships.delete(:claim)
38
+ included_relationships.append(:snippet).uniq! if include_category || include_claim
37
39
 
38
40
  ids = items.map{|item| item['id']['videoId']}
39
41
  parts = included_relationships.map{|r| r.to_s.camelize(:lower)}
@@ -52,6 +54,16 @@ module Yt
52
54
  end if video
53
55
  end
54
56
 
57
+ if include_claim
58
+ video_ids = items.map{|item| item['id']['videoId']}.uniq
59
+ conditions = { video_id: video_ids.join(',') }
60
+ claims = Collections::Claims.new(auth: @auth, parent: @parent).where conditions
61
+ items.each do |item|
62
+ claim = claims.find { |c| c.video_id == item['id']['videoId']}
63
+ item['claim'] = claim
64
+ end
65
+ end
66
+
55
67
  if include_category
56
68
  category_ids = items.map{|item| item['snippet']['categoryId']}.uniq
57
69
  conditions = {id: category_ids.join(',')}
@@ -141,4 +153,4 @@ module Yt
141
153
  end
142
154
  end
143
155
  end
144
- end
156
+ end
@@ -554,6 +554,10 @@ module Yt
554
554
  super
555
555
  end
556
556
 
557
+ ### Claim ###
558
+
559
+ has_one :claim
560
+
557
561
  ### PRIVATE API ###
558
562
 
559
563
  # @private
@@ -579,6 +583,9 @@ module Yt
579
583
  if options[:player]
580
584
  @player = Player.new data: options[:player]
581
585
  end
586
+ if options[:claim]
587
+ @claim = options[:claim]
588
+ end
582
589
  end
583
590
 
584
591
  # @private
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.25.29'
2
+ VERSION = '0.25.30'
3
3
  end
@@ -49,6 +49,16 @@ describe Yt::ContentOwner, :partner do
49
49
  expect(video.instance_variable_defined? :@content_detail).to be true
50
50
  end
51
51
  end
52
+
53
+ describe '.includes(:claim)' do
54
+ let(:video) { $content_owner.videos.includes(:claim).first }
55
+
56
+ specify 'eager-loads the claim of each video' do
57
+ expect(video.instance_variable_defined? :@claim).to be true
58
+ expect(video.claim.id).to be_a String
59
+ expect(video.claim.video_id).to eq video.id
60
+ end
61
+ end
52
62
  end
53
63
 
54
64
  describe '.video_groups' 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.25.29
4
+ version: 0.25.30
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-07 00:00:00.000000000 Z
11
+ date: 2016-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport