yt 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -5
- data/Gemfile.lock +1 -1
- data/HISTORY.md +1 -0
- data/README.md +1 -1
- data/lib/yt/errors/server_error.rb +13 -0
- data/lib/yt/models/request.rb +4 -1
- data/lib/yt/version.rb +1 -1
- data/spec/associations/device_auth/subscriptions_spec.rb +13 -3
- data/spec/models/request_spec.rb +14 -6
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29f2a9daff36933af1c9fafa394009a4660697cd
|
4
|
+
data.tar.gz: b9cb80c044040fc195eac01bad264d1fb65fea69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02a7be4f86dd4fe2801edf57ffa79f05a2b16321d3d3e5a7043893b3eb40d81bf4173049de53443bd816fe5cdf177b64f5e9150140a1b25d4f30bb5ee3523f24
|
7
|
+
data.tar.gz: d9a7005315e12337e16d89e19f8112d3b484594d984fdd7315f6fb5a3c34193f21ed1758fd9bf65487a2c849422b0763abc4b5b50406f3e733344b59c6561c5c
|
data/.travis.yml
CHANGED
@@ -6,13 +6,13 @@ matrix:
|
|
6
6
|
- rvm: 1.9.3
|
7
7
|
gemfile: gemfiles/Gemfile.activesupport-3.x
|
8
8
|
env:
|
9
|
-
- secure:
|
9
|
+
- secure: Z93M7+GBYG8A7Dsjwcsgj/8AmdJ5X2KezBk9qelw89/OtAqIp1zMNQehTEg24p/NygkNjnGycb3DQuW++31v4c+mt5/MgDDhd2jXJ4+js+3gAMAIpiMtPJfEOvmKxLbC0uMaQhXLn7dGMnn8ed7hh6Zu/8P+17qZvVeI0thI3Dg=
|
10
10
|
- rvm: 2.0.0
|
11
11
|
gemfile: gemfiles/Gemfile.activesupport-4.x
|
12
12
|
env:
|
13
|
-
- secure:
|
13
|
+
- secure: eIxGZcTZFVMxn0cxjaknhflAR78L6q+Q2G6jCXnFxqj8ARfgAS1F8v7ErkGaJ9h6dxfsH+5evhj4ZUc/gvHaqs8jcT9CVGUZsC7jpZz3gkfQ9k7Tm3sTnSfv4HbqGM8OkCJkLNOUQypmGr+mkPQskroNPhm6WT9Ml1vGq1RSTow=
|
14
14
|
env:
|
15
15
|
global:
|
16
|
-
- secure:
|
17
|
-
- secure:
|
18
|
-
- secure:
|
16
|
+
- secure: ApPj5c9h6xk+AbHHf4KXL10QnleYCWwcp2+qMFolrS6RWR5vhrnKq1UBo0h59HuvXeOQIgZ/GmocuSEZovS9c1hQP3n0PHSNEnGUNJyn6CS3BiPQSWmC3p2pONo1Xv+hVWfzDoEv80b82GX5P5x/l1BSqhpxLA9geITJprWsoLg=
|
17
|
+
- secure: CkLyqIq/yTV5h/41b0wxIhMN0LvTk51IBht1+l678YSK7zT9emo9DcwnZVQ9f9KluDD8SyUGRORD40eQs8XmqpDCx7gj7i5e3TEVBofM9YnyFMR1lsWRiMr8jf2eksuP10kEkV7S7E1KH4LI2K1ZcOVqfN0G3Vs0C5D8GwpEcQ8=
|
18
|
+
- secure: XzuEz0AV6eDeT3+VaodXRMOh+fDvtG1X/VDfnh3f3gmVsnW1d8gdZY9Gw9rkSixK0SwL58BcSu+SU9BlDAsa0asv2XF8h51Q7s3x0ld9I60ssV/4DXSXqicHYcq13Vd86JMmURUuLiJM3y5lXb0bMGXNOkgYZ19gd5X9No+Tkww=
|
data/Gemfile.lock
CHANGED
data/HISTORY.md
CHANGED
@@ -10,6 +10,7 @@ v0.5 - 2014/05/16
|
|
10
10
|
* Move models in Yt::Models but still auto-include them in the main namespace
|
11
11
|
* New Authentication model to separate `access_token` and `refresh_token` from Account
|
12
12
|
* New types of Errors that render more verbose errors and the failing request in cURL syntax
|
13
|
+
* Separate Error class for 500 error, so they can be easily found in app logs
|
13
14
|
|
14
15
|
v0.4 - 2014/05/09
|
15
16
|
--------------------
|
data/README.md
CHANGED
@@ -300,7 +300,7 @@ To install on your system, run
|
|
300
300
|
|
301
301
|
To use inside a bundled Ruby project, add this line to the Gemfile:
|
302
302
|
|
303
|
-
gem 'yt', '~> 0.5.
|
303
|
+
gem 'yt', '~> 0.5.6'
|
304
304
|
|
305
305
|
Since the gem follows [Semantic Versioning](http://semver.org),
|
306
306
|
indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
|
data/lib/yt/models/request.rb
CHANGED
@@ -6,6 +6,7 @@ require 'active_support/core_ext' # for Hash.from_xml, Hash.to_param
|
|
6
6
|
require 'yt/config'
|
7
7
|
require 'yt/errors/missing_auth'
|
8
8
|
require 'yt/errors/request_error'
|
9
|
+
require 'yt/errors/server_error'
|
9
10
|
|
10
11
|
module Yt
|
11
12
|
module Models
|
@@ -27,10 +28,12 @@ module Yt
|
|
27
28
|
case response
|
28
29
|
when @expected_response
|
29
30
|
response.tap{|response| response.body = parse_format response.body}
|
31
|
+
when Net::HTTPServerError
|
32
|
+
raise Errors::ServerError, request_error_message
|
30
33
|
when Net::HTTPUnauthorized
|
31
34
|
raise Errors::MissingAuth, request_error_message
|
32
35
|
else
|
33
|
-
raise
|
36
|
+
raise Errors::RequestError, request_error_message
|
34
37
|
end
|
35
38
|
end
|
36
39
|
|
data/lib/yt/version.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'yt/models/channel'
|
3
3
|
|
4
|
-
# NOTE: This test is slow because we *must* wait for some seconds between
|
5
|
-
# subscribing and unsubscribing to a channel, otherwise YouTube will show
|
6
|
-
# wrong (cached) data, such as a user is subscribed when he is not.
|
7
4
|
describe Yt::Associations::Subscriptions, :device_app do
|
8
5
|
describe '#subscription' do
|
6
|
+
# NOTE: These tests are slow because we *must* wait some seconds between
|
7
|
+
# subscribing and unsubscribing to a channel, otherwise YouTube will show
|
8
|
+
# wrong (cached) data, such as a user is subscribed when he is not.
|
9
9
|
context 'given an existing channel' do
|
10
10
|
let(:channel) { Yt::Channel.new id: 'UCxO1tY8h1AhOz0T4ENwmpow', auth: $account }
|
11
11
|
|
@@ -21,5 +21,15 @@ describe Yt::Associations::Subscriptions, :device_app do
|
|
21
21
|
it { expect(channel.unsubscribe!).to be_true }
|
22
22
|
end
|
23
23
|
end
|
24
|
+
|
25
|
+
# NOTE: This test is just a reflection of YouTube irrational behavior of
|
26
|
+
# raising a 500 error when you try to subscribe to your own channel, rather
|
27
|
+
# than a more logical 4xx error. Hopefully this will get fixed and this
|
28
|
+
# test removed.
|
29
|
+
context 'given my own channel' do
|
30
|
+
let(:channel) { Yt::Channel.new id: $account.channel.id, auth: $account }
|
31
|
+
|
32
|
+
it { expect{channel.subscribe}.to raise_error Yt::Errors::ServerError }
|
33
|
+
end
|
24
34
|
end
|
25
35
|
end
|
data/spec/models/request_spec.rb
CHANGED
@@ -4,19 +4,27 @@ require 'yt/models/request'
|
|
4
4
|
describe Yt::Request do
|
5
5
|
subject(:request) { Yt::Request.new attrs }
|
6
6
|
let(:attrs) { {host: 'example.com'} }
|
7
|
+
before { Net::HTTP.stub(:start).and_return response }
|
8
|
+
before { response.stub(:body) }
|
7
9
|
|
8
10
|
describe '#run' do
|
11
|
+
context 'given a request that returns a 500 code' do
|
12
|
+
let(:response) { Net::HTTPServerError.new nil, nil, nil }
|
13
|
+
it { expect{request.run}.to fail }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'given a request that returns a 401 code' do
|
17
|
+
let(:response) { Net::HTTPUnauthorized.new nil, nil, nil }
|
18
|
+
it { expect{request.run}.to fail }
|
19
|
+
end
|
20
|
+
|
9
21
|
context 'given a request that returns a non-2XX code' do
|
10
|
-
let(:
|
11
|
-
before { Net::HTTP.stub(:start).and_return not_found }
|
12
|
-
before { not_found.stub(:body) }
|
22
|
+
let(:response) { Net::HTTPNotFound.new nil, nil, nil }
|
13
23
|
it { expect{request.run}.to fail }
|
14
24
|
end
|
15
25
|
|
16
26
|
context 'given a request that returns a 2XX code' do
|
17
|
-
let(:
|
18
|
-
before { Net::HTTP.stub(:start).and_return ok }
|
19
|
-
before { ok.stub(:body) }
|
27
|
+
let(:response) { Net::HTTPOK.new nil, nil, nil }
|
20
28
|
it { expect{request.run}.not_to fail }
|
21
29
|
end
|
22
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claudio Baccigalupo
|
@@ -153,6 +153,7 @@ files:
|
|
153
153
|
- lib/yt/errors/missing_auth.rb
|
154
154
|
- lib/yt/errors/no_items.rb
|
155
155
|
- lib/yt/errors/request_error.rb
|
156
|
+
- lib/yt/errors/server_error.rb
|
156
157
|
- lib/yt/models/account.rb
|
157
158
|
- lib/yt/models/annotation.rb
|
158
159
|
- lib/yt/models/authentication.rb
|