From 8a54e3042ee79800b13211e90f096f17b5a3f3c1 Mon Sep 17 00:00:00 2001 From: Kang-Kyu Lee Date: Fri, 22 Dec 2023 06:31:20 -0800 Subject: [PATCH] Ruby version >= 2.1 because not supported anyways --- lib/yt/actions/list.rb | 2 +- lib/yt/models/iterator.rb | 16 ---------------- spec/collections/comment_threads_spec.rb | 2 +- spec/collections/videos_spec.rb | 4 ++-- .../as_content_owner/content_owner_spec.rb | 2 +- .../as_server_app/comment_threads_spec.rb | 6 +++--- spec/requests/as_server_app/videos_spec.rb | 4 ++-- spec/spec_helper.rb | 5 ----- yt.gemspec | 4 ++-- 9 files changed, 12 insertions(+), 33 deletions(-) delete mode 100644 lib/yt/models/iterator.rb diff --git a/lib/yt/actions/list.rb b/lib/yt/actions/list.rb index ff6d539a..64677de9 100644 --- a/lib/yt/actions/list.rb +++ b/lib/yt/actions/list.rb @@ -17,7 +17,7 @@ def first! def list @last_index, @page_token = 0, nil - Yt::Iterator.new(-> {total_results}) do |items| + Enumerator.new(-> {total_results}) do |items| while next_item = find_next items << next_item end diff --git a/lib/yt/models/iterator.rb b/lib/yt/models/iterator.rb deleted file mode 100644 index 6f9beb39..00000000 --- a/lib/yt/models/iterator.rb +++ /dev/null @@ -1,16 +0,0 @@ -module Yt - module Models - # @private - # If we dropped support for Ruby 1.9.3, then we could simply use Enumerator - # which takes a `size` parameter in Ruby >= 2. - class Iterator < Enumerator - def initialize(size=nil, &block) - RUBY_VERSION < '2' ? super(&block) : super(size, &block) - end - - def size - RUBY_VERSION < '2' ? count : super - end - end - end -end \ No newline at end of file diff --git a/spec/collections/comment_threads_spec.rb b/spec/collections/comment_threads_spec.rb index 0aec9d1d..ea67be48 100644 --- a/spec/collections/comment_threads_spec.rb +++ b/spec/collections/comment_threads_spec.rb @@ -6,7 +6,7 @@ describe Yt::Collections::CommentThreads do subject(:collection) { Yt::Collections::CommentThreads.new parent: parent} - describe '#size', :ruby2 do + describe '#size' do describe 'sends only one request and return the total results' do let(:total_results) { 1234 } let(:parent) { Yt::Video.new id: 'any-id' } diff --git a/spec/collections/videos_spec.rb b/spec/collections/videos_spec.rb index 332af3b4..f7f0ab54 100644 --- a/spec/collections/videos_spec.rb +++ b/spec/collections/videos_spec.rb @@ -7,7 +7,7 @@ let(:channel) { Yt::Channel.new id: 'any-id' } let(:page) { {items: [], token: 'any-token'} } - describe '#size', :ruby2 do + describe '#size' do describe 'sends only one request and return the total results' do let(:total_results) { 123456 } before do @@ -40,4 +40,4 @@ end end end -end \ No newline at end of file +end diff --git a/spec/requests/as_content_owner/content_owner_spec.rb b/spec/requests/as_content_owner/content_owner_spec.rb index fe86cfd7..7a550a03 100644 --- a/spec/requests/as_content_owner/content_owner_spec.rb +++ b/spec/requests/as_content_owner/content_owner_spec.rb @@ -10,7 +10,7 @@ expect(partnered_channels.first).to be_a Yt::Channel end - specify '.size', :ruby2 do + specify '.size' do expect(partnered_channels.size).to be > 0 end end diff --git a/spec/requests/as_server_app/comment_threads_spec.rb b/spec/requests/as_server_app/comment_threads_spec.rb index a312a4b0..5092d02f 100644 --- a/spec/requests/as_server_app/comment_threads_spec.rb +++ b/spec/requests/as_server_app/comment_threads_spec.rb @@ -5,10 +5,10 @@ require 'yt/models/channel' describe Yt::Collections::CommentThreads, :server_app, :vcr do - context "without parent association", :ruby2 do + context "without parent association" do subject(:comment_threads) { Yt::Collections::CommentThreads.new } - specify 'without given any of id, videoId, channelId or allThreadsRelatedToChannelId param, raise request error', :ruby2 do + specify 'without given any of id, videoId, channelId or allThreadsRelatedToChannelId param, raise request error' do expect{ comment_threads.size }.to raise_error(Yt::Errors::RequestError) end @@ -26,7 +26,7 @@ # end end - context "with parent association", :ruby2 do + context "with parent association" do subject(:comment_threads) { Yt::Collections::CommentThreads.new parent: parent} context "parent as video" do diff --git a/spec/requests/as_server_app/videos_spec.rb b/spec/requests/as_server_app/videos_spec.rb index bcbb4202..7b8a80d0 100644 --- a/spec/requests/as_server_app/videos_spec.rb +++ b/spec/requests/as_server_app/videos_spec.rb @@ -5,7 +5,7 @@ describe Yt::Collections::Videos, :server_app, :vcr do subject(:videos) { Yt::Collections::Videos.new } - specify 'without :where conditions, returns all YouTube videos', :ruby2 do + specify 'without :where conditions, returns all YouTube videos' do expect(videos.size).to be > 100_000 end @@ -21,7 +21,7 @@ it { expect(videos_by_id.first.id).to eq video_id } end - specify 'with a chart parameter, only returns videos of that chart', :ruby2 do + specify 'with a chart parameter, only returns videos of that chart' do expect(videos.where(chart: 'mostPopular').size).to be 200 end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1833ad25..6304ea2a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,9 +13,4 @@ RSpec.configure do |config| config.order = 'random' config.run_all_when_everything_filtered = false - # @note: Some tests might take too long to run on Ruby 1.9.3 which does not - # support "size" for Enumerator, so we are better off skipping them. - config.filter_run_excluding ruby2: true if RUBY_VERSION < '2' - # @note: See https://github.com/Fullscreen/yt/issues/103 - config.filter_run_excluding ruby21: true if RUBY_VERSION < '2.1' end diff --git a/yt.gemspec b/yt.gemspec index 96e14080..94563f15 100644 --- a/yt.gemspec +++ b/yt.gemspec @@ -13,7 +13,7 @@ Gem::Specification.new do |spec| spec.homepage = "http://github.com/Fullscreen/yt" spec.license = "MIT" - spec.required_ruby_version = '>= 1.9.3' + spec.required_ruby_version = '>= 2.1' spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } @@ -22,7 +22,7 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] - spec.add_dependency 'activesupport' # '3 (Ruby 1.9) or 4 (Ruby 2)' + spec.add_dependency 'activesupport' # For development / Code coverage / Documentation spec.add_development_dependency 'bundler'