yt 0.5.5 → 0.5.6

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: 2c609731e55cd81b71dfbc3f53f47147dac54b51
4
- data.tar.gz: 0993daf654fda172520af7d6d01e8620ff66fbf6
3
+ metadata.gz: 29f2a9daff36933af1c9fafa394009a4660697cd
4
+ data.tar.gz: b9cb80c044040fc195eac01bad264d1fb65fea69
5
5
  SHA512:
6
- metadata.gz: 60d5bf311041934ec83bd36cfff50905d04e3ef8444f90e8be39ad3249da24618ef308bdee47688785a5bdc8d8024d91dc2a253a44d3cf204d331e6209eb66cb
7
- data.tar.gz: fea7bc7fb323a51c21be93a0108e8d3350f808c8a4bb56cc956d2db5d4cf8c720fe6bdb8e492f39f65337d76d8843edf9898cd2464f9d354adc9ca089d0a834b
6
+ metadata.gz: 02a7be4f86dd4fe2801edf57ffa79f05a2b16321d3d3e5a7043893b3eb40d81bf4173049de53443bd816fe5cdf177b64f5e9150140a1b25d4f30bb5ee3523f24
7
+ data.tar.gz: d9a7005315e12337e16d89e19f8112d3b484594d984fdd7315f6fb5a3c34193f21ed1758fd9bf65487a2c849422b0763abc4b5b50406f3e733344b59c6561c5c
@@ -6,13 +6,13 @@ matrix:
6
6
  - rvm: 1.9.3
7
7
  gemfile: gemfiles/Gemfile.activesupport-3.x
8
8
  env:
9
- - secure: MRWnEbchfgv+FLXLDzkc5rqqiZ/fE/9zQVYRUlTtwHYWKRacl45RDzv0ns7avz/tGGyL/3CMQabOvRiErhN5FWoaRdQV3kBl+gAgSvV910dC+gb/dEpTxU8KGRFLBOFG5oT2WF9eTDjUOxNRiR0jEw/+wD/FltxHEuoc5EixdSI=
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: fxPlgZJcWnJZcsQYfLm5EQI4kt9Ohikwi5YugcU+daT43ZacrK0MWAnPhYBXnwNbfsot1udSFnN8DADxbL6/0DxVGVVuQUB4hT59kh8im58Rfim6uCDbgsPLeCzMrWuE2Mj+SBcwVlJ2i0zWqFv6nz4TCi007E/4BOLjjmTsOSo=
13
+ - secure: eIxGZcTZFVMxn0cxjaknhflAR78L6q+Q2G6jCXnFxqj8ARfgAS1F8v7ErkGaJ9h6dxfsH+5evhj4ZUc/gvHaqs8jcT9CVGUZsC7jpZz3gkfQ9k7Tm3sTnSfv4HbqGM8OkCJkLNOUQypmGr+mkPQskroNPhm6WT9Ml1vGq1RSTow=
14
14
  env:
15
15
  global:
16
- - secure: QEKPYkbA9ejUZTYz4p8xWMKqZ+2KpiKa2c6eu79ISQcGsp3gRvnvAzEVByVxrr+K7Igtj/jeRUE8xXMDh6d6wCcguNkTy9BVNevlo12qESpM8oP0iEmnQJL0TtYWEvqivJMg/FSXOaRj4kifB1sfTQjJLdTKVMM52r5qR9K60bs=
17
- - secure: DznIfIfJN5c0lad7FPf8TVqbMDFFajcDyWPDA55KtlDgpMrjgmLh7z1ZEhQMLvu+HAdvnxx7jEiroeMCT724hXS3ex4MsQnn9fohuM4bsjeqxgxCtdL3urFGBwGx3wMmisY3Jn+5WEQkeqrfMgnUGIyXMp8K1VvjJ6r4GrW6yEk=
18
- - secure: NeI3iyIAY3ZKAQ+AGo8+uFxdaMmf9zYkVDJMbHsXZLkHxsF1UAMnFic8EEsktfx+zobykQFarwBFeN7LtEvMjpIHeL0caKas0NiUmvnXjCh7CfK9lqY1rjZSYuNSA8uSR1Bl7GOxBjQD8xtRoUdaYAF8MLPVtEs76l0tSVwHQ6Q=
16
+ - secure: ApPj5c9h6xk+AbHHf4KXL10QnleYCWwcp2+qMFolrS6RWR5vhrnKq1UBo0h59HuvXeOQIgZ/GmocuSEZovS9c1hQP3n0PHSNEnGUNJyn6CS3BiPQSWmC3p2pONo1Xv+hVWfzDoEv80b82GX5P5x/l1BSqhpxLA9geITJprWsoLg=
17
+ - secure: CkLyqIq/yTV5h/41b0wxIhMN0LvTk51IBht1+l678YSK7zT9emo9DcwnZVQ9f9KluDD8SyUGRORD40eQs8XmqpDCx7gj7i5e3TEVBofM9YnyFMR1lsWRiMr8jf2eksuP10kEkV7S7E1KH4LI2K1ZcOVqfN0G3Vs0C5D8GwpEcQ8=
18
+ - secure: XzuEz0AV6eDeT3+VaodXRMOh+fDvtG1X/VDfnh3f3gmVsnW1d8gdZY9Gw9rkSixK0SwL58BcSu+SU9BlDAsa0asv2XF8h51Q7s3x0ld9I60ssV/4DXSXqicHYcq13Vd86JMmURUuLiJM3y5lXb0bMGXNOkgYZ19gd5X9No+Tkww=
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yt (0.5.5)
4
+ yt (0.5.6)
5
5
  activesupport
6
6
 
7
7
  GEM
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.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*)
@@ -0,0 +1,13 @@
1
+ require 'yt/errors/request_error'
2
+
3
+ module Yt
4
+ module Errors
5
+ class ServerError < RequestError
6
+ private
7
+
8
+ def explanation
9
+ 'A request to YouTube API caused an unexpected server error'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -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 Yt::Error, request_error_message
36
+ raise Errors::RequestError, request_error_message
34
37
  end
35
38
  end
36
39
 
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.5.5'
2
+ VERSION = '0.5.6'
3
3
  end
@@ -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
@@ -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(:not_found) { Net::HTTPNotFound.new nil, nil, nil }
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(:ok) { Net::HTTPOK.new nil, nil, nil }
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.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