Skip to content

Commit

Permalink
yt as dependency, for use in an app already has yt (not yt-core)
Browse files Browse the repository at this point in the history
  • Loading branch information
kangkyu committed Mar 12, 2019
1 parent 4167842 commit 4539c89
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions lib/yt/url.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'yt/core'
require 'yt'

# An object-oriented Ruby client for YouTube.
# @see http://www.rubydoc.info/gems/yt/
Expand Down Expand Up @@ -35,7 +35,7 @@ def resource(options = {})
when :channel then Yt::Channel
when :video then Yt::Video
when :playlist then Yt::Playlist
else raise Yt::NoItemsError
else raise Yt::Errors::NoItems
end.new options.merge(id: id)
end

Expand Down Expand Up @@ -94,7 +94,7 @@ def fetch_id
if data = response.body.match(regex)
data[:id]
else
raise Yt::NoItemsError
raise Yt::Errors::NoItems
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/id_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

describe 'fails with unknown channels' do
let(:name) { 'not-an-actual-channel' }
it {expect{url.id}.to raise_error Yt::NoItemsError }
it {expect{url.id}.to raise_error Yt::Errors::NoItems }
end
end

Expand All @@ -46,7 +46,7 @@

describe 'fails with unknown channels' do
let(:name) { 'not-an-actual-channel' }
it {expect{url.id}.to raise_error Yt::NoItemsError }
it {expect{url.id}.to raise_error Yt::Errors::NoItems }
end
end

Expand All @@ -60,7 +60,7 @@

describe 'fails with unknown channels' do
let(:name) { 'not-an-actual-channel' }
it {expect{url.id}.to raise_error Yt::NoItemsError }
it {expect{url.id}.to raise_error Yt::Errors::NoItems }
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
let(:text) { "youtu.be/#{$unknown_video_id}" }

it {expect(url.resource).to be_a Yt::Video }
it {expect{url.resource.title}.to raise_error Yt::NoItemsError }
it {expect{url.resource.title}.to raise_error Yt::Errors::NoItems }
end

context 'given an existing YouTube playlist URL' do
Expand All @@ -35,12 +35,12 @@
let(:text) { "https://www.youtube.com/playlist?list=#{$unknown_playlist_id}" }

it {expect(url.resource).to be_a Yt::Playlist }
it {expect{url.resource.title}.to raise_error Yt::NoItemsError }
it {expect{url.resource.title}.to raise_error Yt::Errors::NoItems }
end

context 'given an unknown text' do
let(:text) { $unknown_text }

it {expect{url.resource}.to raise_error Yt::NoItemsError }
it {expect{url.resource}.to raise_error Yt::Errors::NoItems }
end
end
4 changes: 2 additions & 2 deletions yt-url.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']

spec.add_dependency 'yt-core', '>= 0.1.0'
spec.add_dependency 'yt', '>= 0.29'

spec.add_development_dependency 'bundler', '~> 1.14'
spec.add_development_dependency 'rspec', '~> 3.5'
spec.add_development_dependency 'rake', '~> 12.0'
spec.add_development_dependency 'coveralls', '~> 0.8.20'
spec.add_development_dependency 'pry-nav', '~> 0.2.4'
spec.add_development_dependency 'yard', '~> 0.9.8'
end
end

0 comments on commit 4539c89

Please sign in to comment.