yt 0.25.2 → 0.25.3

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: a06e107e7f31f7de48b0d8ff204c767c823c25eb
4
- data.tar.gz: edfd691ddfbb02206d8edde88ade590ea16054be
3
+ metadata.gz: 05e206f51ac4f37552e7061a22d0fcc7c092b539
4
+ data.tar.gz: 60cbc93e088a51afba4fc91f6d25653564065d6d
5
5
  SHA512:
6
- metadata.gz: 71703d93dc25594789d244709ef378fab971c23dd6920ea8e10e7daa2546d3087a6246d80135e3c5c01ad94b4cf05f4ade40199bff5acb91fcd3cd1065527010
7
- data.tar.gz: 874b280fabf0bc5417203724049dfe5915d9d2d6d19c79f8e3b5395f221ad324ead150cae7468bda633e78575aad364560001b2802268addd6376cbe9bae89b1
6
+ metadata.gz: aa9742e5e3b4899c4261ce280e69eab478c3cdcfcc442e9706fe19ce06cbc51802d90a801f3d6031e21aafe33076c8e3b4a3f1060defc038c44fac81bfd29c16
7
+ data.tar.gz: 328373548870b075b7cc542bb1b4736c0b7748985e912212d3f38cbe5c66431369eded41c80881e5ff7c0377a2d46bbc93a4f88f7307187eb5564ff410ff3ec7
@@ -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.3 - 2015-07-23
10
+
11
+ * [BUGFIX] Don’t run an infinite loop when calling `.playlist_items.includes(:video)` on a playlist with only private or deleted videos
12
+
9
13
  ## 0.25.2 - 2015-07-22
10
14
 
11
15
  * [FEATURE] Add .includes(:video) to .playlist_items to eager-load video data of a list of playlist items.
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.25.2'
44
+ gem 'yt', '~> 0.25.3'
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*)
@@ -76,6 +76,7 @@ module Yt
76
76
 
77
77
  def next_page
78
78
  super.tap do |items|
79
+ halt_list if use_list_endpoint? && items.empty? && @page_token.nil?
79
80
  add_offset_to(items) if !use_list_endpoint? && @page_token.nil? && videos_params[:order] == 'date'
80
81
  end
81
82
  end
@@ -91,6 +92,18 @@ module Yt
91
92
  end
92
93
  end
93
94
 
95
+ # If we ask for a list of videos matching specific IDs and no video is
96
+ # returned (e.g. they are all private/deleted), then we don’t want to
97
+ # switch from /videos to /search and keep on looking for videos, but
98
+ # simply return an empty array of items
99
+ def halt_list
100
+ @halt_list = true
101
+ end
102
+
103
+ def more_pages?
104
+ (@last_index.zero? && !@halt_list) || !@page_token.nil?
105
+ end
106
+
94
107
  def videos_params
95
108
  {}.tap do |params|
96
109
  params[:type] = :video
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.25.2'
2
+ VERSION = '0.25.3'
3
3
  end
@@ -72,7 +72,7 @@ describe Yt::Channel, :device_app do
72
72
  end
73
73
 
74
74
  describe 'when the channel has more than 500 videos' do
75
- let(:id) { 'UCsmvakQZlvGsyjyOhmhvOsw' }
75
+ let(:id) { 'UC0v-tlzsn0QZwJnkiaUSJVQ' }
76
76
 
77
77
  specify 'the estimated and actual number of videos can be retrieved' do
78
78
  # @note: in principle, the following three counters should match, but
@@ -47,6 +47,18 @@ describe Yt::Playlist, :device_app do
47
47
  end
48
48
  end
49
49
 
50
+ context 'given a playlist that only includes other people’s private or deleted videos' do
51
+ let(:id) { 'PLsnYEvcCzABOsJdehqkIDhwz8CPGWzX59' }
52
+
53
+ describe '.playlist_items.includes(:video)' do
54
+ let(:items) { playlist.playlist_items.includes(:video).map{|i| i} }
55
+
56
+ specify 'returns nil (without running an infinite loop)' do
57
+ expect(items.size).to be 2
58
+ end
59
+ end
60
+ end
61
+
50
62
  context 'given an unknown playlist' do
51
63
  let(:id) { 'not-a-playlist-id' }
52
64
 
@@ -711,7 +711,7 @@ describe Yt::Channel, :partner do
711
711
  describe 'shares can be retrieved for a single country' do
712
712
  let(:country_code) { 'US' }
713
713
  let(:shares) { channel.shares since: date, by: by, in: location }
714
- let(:date) { 4.days.ago }
714
+ let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
715
715
 
716
716
  context 'and grouped by day' do
717
717
  let(:by) { :day }
@@ -753,7 +753,7 @@ describe Yt::Channel, :partner do
753
753
  end
754
754
 
755
755
  describe 'shares can be grouped by country' do
756
- let(:range) { {since: 4.days.ago, until: 3.days.ago} }
756
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
757
757
 
758
758
  specify 'with the :by option set to :country' do
759
759
  shares = channel.shares range.merge by: :country
@@ -876,7 +876,7 @@ describe Yt::Channel, :partner do
876
876
  describe 'favorites added can be retrieved for a single country' do
877
877
  let(:country_code) { 'US' }
878
878
  let(:favorites_added) { channel.favorites_added since: date, by: by, in: location }
879
- let(:date) { 4.days.ago }
879
+ let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
880
880
 
881
881
  context 'and grouped by day' do
882
882
  let(:by) { :day }
@@ -614,7 +614,7 @@ describe Yt::Playlist, :partner do
614
614
  end
615
615
 
616
616
  describe 'playlist starts can be grouped by country' do
617
- let(:range) { {since: 4.days.ago, until: 3.days.ago} }
617
+ let(:range) { {since: ENV['YT_TEST_PARTNER_PLAYLIST_DATE']} }
618
618
 
619
619
  specify 'with the :by option set to :country' do
620
620
  starts = playlist.playlist_starts range.merge by: :country
@@ -680,7 +680,7 @@ describe Yt::Playlist, :partner do
680
680
  end
681
681
 
682
682
  describe 'average time in playlist can be grouped by country' do
683
- let(:range) { {since: 4.days.ago, until: 3.days.ago} }
683
+ let(:range) { {since: ENV['YT_TEST_PARTNER_PLAYLIST_DATE']} }
684
684
 
685
685
  specify 'with the :by option set to :country' do
686
686
  time = playlist.average_time_in_playlist range.merge by: :country
@@ -746,7 +746,7 @@ describe Yt::Playlist, :partner do
746
746
  end
747
747
 
748
748
  describe 'views per playlist start can be grouped by country' do
749
- let(:range) { {since: 4.days.ago, until: 3.days.ago} }
749
+ let(:range) { {since: ENV['YT_TEST_PARTNER_PLAYLIST_DATE']} }
750
750
 
751
751
  specify 'with the :by option set to :country' do
752
752
  views = playlist.views_per_playlist_start range.merge by: :country
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.2
4
+ version: 0.25.3
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-07-23 00:00:00.000000000 Z
11
+ date: 2015-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport