yt 0.10.5 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b514aef834131736bd47325d004cd67c38f3fcaa
4
- data.tar.gz: 1939130b4afa95148532b4f04aa97d0e09c87ef4
3
+ metadata.gz: 20c3426083692b2c9726ef4c76119e2ad252f51d
4
+ data.tar.gz: 3e03a4ab33ee8de7c5ea9e9786b05b3bc953790e
5
5
  SHA512:
6
- metadata.gz: 6ec9dbfb86d648c0b76ccc70f62bc203a76bc38ac5496c8aaaf032b00e7620e61c50d710463e9997ca3a0b13c2d414bfb05f40ae51547e86ea5929c8257c3850
7
- data.tar.gz: 88f5254c83f8c689568d8dca5b6acb21711b68cc9812b7e9631e45f8a58709694ecc3c392146de63d743e0fcc9b906fc705a76be8f25fdff50e7a2357169ba86
6
+ metadata.gz: d4f963fe983113861da21a13f2cca84011d8a717601c53f5009a6e0304354ea30d605ed31cc14ff8959107592ab6cb913387d27285ff63bf640a26fc08c8e968
7
+ data.tar.gz: 4ef695b291cb1b97884acdfc26a92130a83c6ed169319add5c9e901e8bb9067e515b992b6250750aeb71053dc1756f53e56a240c4c5fe1aa292a3f26559cf447
data/.travis.yml CHANGED
@@ -5,5 +5,30 @@ matrix:
5
5
  include:
6
6
  - rvm: 1.9.3
7
7
  gemfile: gemfiles/Gemfile.activesupport-3.x
8
+ env:
9
+ - secure: OsmWyhhYNILEb1lhqxPX+iEfbWzC3dELuxQ7JGP9iN/FhqBtlV51cu+u2cBBdql6Gzuqi4VlMEeJSX0PQUmzOsMb0vHhOJDyp4a32NE+xry8LOT8XdCwni20ZBcUeFxC5hMUVebPuhqBTFjBWbXQKwKSXIdPnNWz31d9kyGIsxk=
8
10
  - rvm: 2.0.0
9
- gemfile: gemfiles/Gemfile.activesupport-4.x
11
+ gemfile: gemfiles/Gemfile.activesupport-4.x
12
+ env:
13
+ - secure: FrmFA2BE0FYyuKsf0FEO0EAXY+h048HbD1p3lu5XPo9/lxpAl7wM5m12HsnJQuNY6UlUmZ5bp9f8upCBZpz7cLZK5e/FWLWSvkv3Fts+NVsbAcVtFgvBKOCgTznZi/qgUtqbWBevkM3gyXyylzdB+c4wWjoOO/xSDVR227m8nMA=
14
+ env:
15
+ global:
16
+ - secure: MKvaid8oW+io0vtzTUL6jNDBrgoxBe9RLEiFh/gKyVw8cj6bvRPBmYXrZfsNGZfns1i75/GaLCLNMl60ZJkfaN4twdPsh2ju6OnsrKW684G7Ha8Jv6GuaEYEwURBAGULW9EHylW5BlYE7H8SNRjtT8RLyIdjpFphuuiOuUO0/tE=
17
+ - secure: K3f1RUzLByFOH44M50U02+hDNxFXNts6jWTI6PIP6DAn+j1QyQdvlm55kQ1/otf8L/ypH6GqxF/OQhEOK2xr72MVgFBh0wn4iF7U93Q6xX1ZBNwIGJ6lFWaJ6AP3M0y/Y4Qj3xVQpE6Ofq9TflqeGbuIplQv81z8FV+euq6l+XI=
18
+ - secure: HyjaCM/coZiZJuIhIBSI+/1Uprs4NvcWAPcCAKtLClZtKLuqNQtKP+pF6aYabOQNFNFyLvcaooygx1VEESx0Hxb6V7OloJlrdt87xc0DxswNBxsZUUJifDW42HXLu5Mkq37fUvNAOKalRpn2mp0y87qJJGyYzo6KKDEvO9fH6HI=
19
+ - secure: TIhkYLhm8jWq5syGQXknXq1UmBGqQr9BbQwr97ZMAZDHh9GR4WZ27r8R4h+P6a98NfUcl8B72c2TgNpV8Ix8IpAUPrysVmhnSu7LSskevRiEYUsKRKGRK3kgSzawjrxosclEOn4RbWcO/BUjN/2kvT1WZUyRgI8/eZ0WcMjvsP0=
20
+ - secure: cY0QRvVWriQDvCN1+ntGme1YJfR+LlfXlaXOd7kGSw+JHXUMK49FAcdYXrN+lDA0lY8K2nBvHLvk62oWGvGbYmvqzXrNjljsHQWqtbiuI7AlGjcGDAqyrRcWRQhu+MppLTfduxGrgx+wqZZ9i+3bLiHod8HLa2tyO8P09A7groc=
21
+ - secure: OeA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 - secure: V3cOMG0aPefKiuKAlrfZb6cMJLMAv8A538qf0Ouw1MN6ngL6uqDaQqissp+/sGp4wUfTJdjVtQn/j4IA1gmk9vdRydILhOryL4X0w2uV1Ip33PEawi+EOOZO2W1vxNrLQO4LvOZmz376sifXwPN3d0aethnHhZ4DiuJrZRT/BUA=
28
+ - secure: CFmPvFamKLdyaTEAHbtNAOStc4nIjbHcF2g2fyH/s4kxBWCwUlUdEN9/K7Fa9SX6orf/PUA4R08t6o3NLyt/S1dC9DKezZmfTYKuhRNzTOHCiSjeIoDpgdY/lglnTHvr7kuT9ceGAgWk/hmEw7/wQ6ASK4g6G+zRaYi4KDlcM94=
29
+ - secure: DjWReu3fGGGlk0B2k3sfM5HwRkxNqKo9QNaXYAZa8mJuZs990U7LjfvFEPKHaYTsxPCv1ANEiBGHQYjmlFnKh6B+FmAz5JCtrxRbSARzQ9DBjxyWGNIK064fcFHqYb309OYH8NhCc8WYxr/gn7FJjDb5NCoCIGQ2sYrk4pSormM=
30
+ - secure: BCr8OowszYHLieino4Zr/E/I8rJujRFFmsY12WovoQiILIbEBonBoTHV1duVcCZyh4MFsdH8rH7NFNCYpeNuETwcU5DPbr3hsALS/4FzBe4J1WixI7jN1wyVWPtSbwfSje8rGMjQmwlML1dgm1QtmI/5MD6mpybwHFrQB9RSV/k=
31
+ - secure: FwxY5FMyWDyNkHbiZf3odst2kC5iIb00n0lRFU97Ywj8jioqjzKr/x4JCXjKbqFUz4a32mM72fBoj3hqhKnL6/cdnTdhigt3yegR3ozzidcu2SFeZTEDqsHGN0hhqjQIzMI6oKHyqWafSeYtgE18FtxsNpeefZWnRWcQytIMxAI=
32
+ - secure: CFkNT5WI2ATF3TKehTSuCwzG4EENnoVXaddL0PqpuH4Ss82k0k0xcJBhKbmD3Qkf7nw8y0g4s3jCepHssB2ZwzqQinKcYvamzIbsNPuhsuvlc9rMvT9ZosT5CHsiRJANl+OeZ8l2SqGu6kCMDx45h+fL7YZEtn3jjVZYEAXQSig=
33
+ - secure: WWuYLNKcTM+fjgFrRT4qa3y4IlwO6xeSkM16jbDG05FUIThMfWRVQHhs5JThw/M3SByWGWySmz74sNpGV6V/yt9jw8o1u6F81j0ec2oeHDCwkZ8xK8ubPv3Pmg14PGr1Awu04zfhTEY9KzJt6HrFSYzek/MpV5Prg4J1l6SgqyU=
34
+ - secure: YuWrOwaqBT0tLVe90OkfCLX/7tzrLhsOBn7LnqH0Ifw6T+EddNDmQLriWLRny8uNQSg7j/AhPOuEvR/ImOibK3a003LyxQZUx9KrEOkgIa5c82OlOLdcvmXw/8wnQ/SEdTDs8r2l1aZ2NxiieCA3fl7oxR1Lt/O+lS/vgqQY+uM=
data/CHANGELOG.md CHANGED
@@ -6,6 +6,26 @@ 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.11.0 - 2014-08-17
10
+
11
+ **How to upgrade**
12
+
13
+ When a request to YouTube fails, Yt used to print out a verbose error message,
14
+ including the response body and the request that caused the error (in curl
15
+ format). This output could include sensitive data (such as the authentication
16
+ token). For security reasons, Yt will not print it out anymore by default.
17
+
18
+ If this is acceptable, then you are good to go.
19
+ If you want the old behavior, set the `log_level` of Yt to `:debug`:
20
+
21
+ ```ruby
22
+ Yt.configure do |config|
23
+ config.log_level = :debug
24
+ end
25
+ ```
26
+
27
+ * [ENHANCEMENT] Add `log_level` to Yt.configuration
28
+
9
29
  ## 0.10.5 - 2014-08-17
10
30
 
11
31
  * [ENHANCEMENT] Use PATCH rather than PUT to partially update a MatchPolicy
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yt (0.10.5)
4
+ yt (0.11.0)
5
5
  activesupport
6
6
 
7
7
  GEM
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.10.5'
44
+ gem 'yt', '~> 0.11.0'
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*)
@@ -1,3 +1,5 @@
1
+ require 'yt/config'
2
+
1
3
  module Yt
2
4
  module Errors
3
5
  class RequestError < StandardError
@@ -9,11 +11,7 @@ module Yt
9
11
  def message
10
12
  <<-MSG.gsub(/^ {8}/, '')
11
13
  #{explanation}:
12
- #{response_body}
13
-
14
- You can retry the same request manually by running:
15
- #{request_curl}
16
- #{more_details}
14
+ #{Yt.configuration.debugging? ? details : no_details }
17
15
  MSG
18
16
  end
19
17
 
@@ -31,6 +29,27 @@ module Yt
31
29
  'A request to YouTube API failed'
32
30
  end
33
31
 
32
+
33
+ def details
34
+ <<-MSG.gsub(/^ {8}/, '')
35
+ #{response_body}
36
+
37
+ You can retry the same request manually by running:
38
+ #{request_curl}
39
+ #{more_details}
40
+ MSG
41
+ end
42
+
43
+ def no_details
44
+ <<-MSG.gsub(/^ {8}/, '')
45
+ To display more verbose errors, change the configuration of Yt with:
46
+
47
+ Yt.configure do |config|
48
+ config.log_level = :debug
49
+ end
50
+ MSG
51
+ end
52
+
34
53
  def more_details
35
54
  end
36
55
 
@@ -20,6 +20,7 @@ module Yt
20
20
  # * +YT_CLIENT_ID+ to store the Client ID for web/device apps
21
21
  # * +YT_CLIENT_SECRET+ to store the Client Secret for web/device apps
22
22
  # * +YT_API_KEY+ to store the API key for server/browser apps
23
+ # * +YT_LOG_LEVEL+ to store the verbosity level of the logs
23
24
  #
24
25
  # In case both methods are used together,
25
26
  # {Yt::Config#configure Yt.configure} takes precedence.
@@ -41,12 +42,28 @@ module Yt
41
42
  # @see https://console.developers.google.com Google Developers Console
42
43
  attr_accessor :api_key
43
44
 
45
+ # @return [String] the level of output to print for debugging purposes.
46
+ attr_accessor :log_level
47
+
44
48
  # Initialize the global configuration settings, using the values of
45
49
  # the specified following environment variables by default.
46
50
  def initialize
47
51
  @client_id = ENV['YT_CLIENT_ID']
48
52
  @client_secret = ENV['YT_CLIENT_SECRET']
49
53
  @api_key = ENV['YT_API_KEY']
54
+ @log_level = ENV['YT_LOG_LEVEL']
55
+ end
56
+
57
+ # @return [Boolean] whether the logging output is extra-verbose.
58
+ # Useful when developing (e.g., to print the curl of every request).
59
+ def developing?
60
+ log_level.to_s.in? %w(devel)
61
+ end
62
+
63
+ # @return [Boolean] whether the logging output is verbose.
64
+ # Useful when debugging (e.g., to print the curl of failing requests).
65
+ def debugging?
66
+ log_level.to_s.in? %w(devel debug)
50
67
  end
51
68
  end
52
69
  end
@@ -28,6 +28,8 @@ module Yt
28
28
  end
29
29
 
30
30
  def run
31
+ p as_curl if Yt.configuration.developing?
32
+
31
33
  if response.is_a? @expected_response
32
34
  response.tap{|response| response.body = parse_format response.body}
33
35
  else
data/lib/yt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.10.5'
2
+ VERSION = '0.11.0'
3
3
  end
@@ -2,10 +2,36 @@ require 'spec_helper'
2
2
  require 'yt/errors/request_error'
3
3
 
4
4
  describe Yt::Errors::RequestError do
5
+ subject(:error) { raise Yt::Errors::RequestError, params }
6
+ let(:params) { {} }
5
7
  let(:msg) { %r{^A request to YouTube API failed} }
6
8
 
7
9
  describe '#exception' do
8
- it { expect{raise Yt::Errors::RequestError}.to raise_error msg }
10
+ it { expect{error}.to raise_error msg }
11
+
12
+ context 'given the exception includes sensitive data' do
13
+ let(:body) { 'some secret token' }
14
+ let(:curl) { 'curl -H "Authorization: secret-token"' }
15
+ let(:params) { {response_body: body, request_curl: curl}.to_json }
16
+
17
+ describe 'given a log level of :debug or :devel' do
18
+ before(:all) { Yt.configuration.log_level = :debug }
19
+ specify 'exposes sensitive data' do
20
+ expect{error}.to raise_error do |error|
21
+ expect(error.message).to include 'secret'
22
+ end
23
+ end
24
+ end
25
+
26
+ describe 'given a different log level' do
27
+ before(:all) { Yt.configuration.log_level = :info }
28
+ specify 'hides sensitive data' do
29
+ expect{error}.to raise_error do |error|
30
+ expect(error.message).not_to include 'secret'
31
+ end
32
+ end
33
+ end
34
+ end
9
35
  end
10
36
  end
11
37
 
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  require 'spec_helper'
2
3
  require 'yt/models/account'
3
4
 
@@ -23,12 +23,14 @@ RSpec.configure do |config|
23
23
  Yt.configure do |config|
24
24
  config.client_id = ENV['YT_TEST_DEVICE_CLIENT_ID']
25
25
  config.client_secret = ENV['YT_TEST_DEVICE_CLIENT_SECRET']
26
+ config.log_level = ENV['YT_LOG_LEVEL']
26
27
  end
27
28
  end
28
29
 
29
30
  config.before :all, server_app: true do
30
31
  Yt.configure do |config|
31
32
  config.api_key = ENV['YT_TEST_SERVER_API_KEY']
33
+ config.log_level = ENV['YT_LOG_LEVEL']
32
34
  end
33
35
  end
34
36
 
@@ -36,6 +38,7 @@ RSpec.configure do |config|
36
38
  Yt.configure do |config|
37
39
  config.client_id = ENV['YT_TEST_PARTNER_CLIENT_ID']
38
40
  config.client_secret = ENV['YT_TEST_PARTNER_CLIENT_SECRET']
41
+ config.log_level = ENV['YT_LOG_LEVEL']
39
42
  end
40
43
  # Create one Youtube Partner channel, authenticated as the content owner
41
44
  attrs = {refresh_token: ENV['YT_TEST_CONTENT_OWNER_REFRESH_TOKEN']}
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.10.5
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo