yt-support 0.1.2 → 0.1.3

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: c6a662f825d0c472754909155714397c84cf600c
4
- data.tar.gz: 4999e00a754f796f8b9d5a00fed15fa538dc69bd
3
+ metadata.gz: 1d82d16731736e5ee31d63657ab86ff1dd911607
4
+ data.tar.gz: f48f9376a410f3407cabb12d4763cd14f726be38
5
5
  SHA512:
6
- metadata.gz: d91e68dea4b16beb241f28eb8808f56bd35536988c7e2565d463badf90d0568c5c4b9a64e2ee0d11dd90dc1240c1c22968e9afa8274e1189b63d26691c6c7ca1
7
- data.tar.gz: 45245e9ec74c83598d767d472df76e88c2a375ab34d92f770b5e5e7e52890d848f061cf39288bbc8b7b75c498554c5e9062fcfdb063f3812b755defdf0047dff
6
+ metadata.gz: d9e1c590dc23269d3d22a41f57b212b6594ead53761a0470a6affd963dbf08fd8d5910d64ae184c668bb2d048e1acc138d9528cd4af90e38db93375b2d8925cf
7
+ data.tar.gz: 579ab329148261c0a0d59460eca0c3b16d799ffb7ce8c6a898a961786de0e356c9749b3580d4606b28c28ba16aeb1285425cd3c737114c9b4a742f815f9df362
@@ -6,6 +6,10 @@ 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.1.3 - 2017-06-02
10
+
11
+ * [FEATURE] Add `Yt.configuration.access_token` and `.refresh_token`
12
+
9
13
  ## 0.1.2 - 2017-04-02
10
14
 
11
15
  * [FEATURE] Add Yt::ConnectionError to deal with connection/server errors
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017 Fullscreen, Inc.
3
+ Copyright (c) 2017-present Fullscreen, Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -44,6 +44,12 @@ module Yt
44
44
  # @return [String] the level of output to print for debugging purposes.
45
45
  attr_accessor :log_level
46
46
 
47
+ # @return [String] the access token to act on behalf of a YouTube account.
48
+ attr_accessor :access_token
49
+
50
+ # @return [String] the token to refresh an expired access token.
51
+ attr_accessor :refresh_token
52
+
47
53
  # Initialize the global configuration settings, using the values of
48
54
  # the specified following environment variables by default.
49
55
  def initialize
@@ -1,5 +1,11 @@
1
1
  module Yt
2
2
  # A wrapper around StandardError.
3
3
  class HTTPError < StandardError
4
+ attr_reader :response
5
+
6
+ def initialize(msg, response:)
7
+ super msg
8
+ @response = response
9
+ end
4
10
  end
5
11
  end
@@ -50,7 +50,7 @@ module Yt
50
50
  parse_response!
51
51
  end
52
52
  else
53
- raise Yt::HTTPError, error_message
53
+ raise Yt::HTTPError.new(error_message, response: response)
54
54
  end
55
55
  end
56
56
 
@@ -85,13 +85,25 @@ module Yt
85
85
  end
86
86
  end
87
87
 
88
+ def as_curl
89
+ 'curl'.tap do |curl|
90
+ curl << " -X #{http_request.method}"
91
+ http_request.each_header{|k, v| curl << %Q{ -H "#{k}: #{v}"}}
92
+ curl << %Q{ -d '#{http_request.body}'} if http_request.body
93
+ curl << %Q{ "#{uri.to_s}"}
94
+ end
95
+ end
96
+
88
97
  # Adds the request body to the request in the appropriate format.
89
98
  # if the request body is a JSON Object, transform its keys into camel-case,
90
99
  # since this is the common format for JSON APIs.
91
100
  def set_request_body!(request)
92
- if @body
93
- request.set_form_data @body
94
- end
101
+ case @request_format
102
+ when :json
103
+ request.body = @body.to_json
104
+ when :form
105
+ request.set_form_data @body
106
+ end if @body
95
107
  end
96
108
 
97
109
  # Adds the request headers to the request in the appropriate format.
@@ -110,6 +122,7 @@ module Yt
110
122
  # Run the request and memoize the response or the server error received.
111
123
  def response
112
124
  @response ||= Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
125
+ puts as_curl if Yt.configuration.developing?
113
126
  http.request http_request
114
127
  end
115
128
  rescue *server_errors => e
@@ -1,7 +1,8 @@
1
1
  module Yt
2
2
  # Provides common functionality to all Yt gems.
3
3
  module Support
4
- # current version of gem
5
- VERSION = '0.1.2'
4
+ # @return [String] the SemVer-compatible gem version.
5
+ # @see http://semver.org
6
+ VERSION = '0.1.3'
6
7
  end
7
8
  end
@@ -17,15 +17,17 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  spec.required_ruby_version = '>= 2.2.2'
19
19
 
20
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
21
+ f.match(%r{^(test|spec|features)/})
22
+ end
21
23
  spec.bindir = 'exe'
22
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
25
  spec.require_paths = ['lib']
24
26
 
25
27
  spec.add_development_dependency 'bundler', '~> 1.14'
26
28
  spec.add_development_dependency 'rspec', '~> 3.5'
27
- spec.add_development_dependency 'rake', '~> 10.0'
28
- spec.add_development_dependency 'coveralls', '~> 0.8.15'
29
+ spec.add_development_dependency 'rake', '~> 12.0'
30
+ spec.add_development_dependency 'coveralls', '~> 0.8.20'
29
31
  spec.add_development_dependency 'pry-nav', '~> 0.2.4'
30
- spec.add_development_dependency 'yard', '~> 0.9.5'
32
+ spec.add_development_dependency 'yard', '~> 0.9.8'
31
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yt-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-04-02 00:00:00.000000000 Z
12
+ date: 2017-08-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -45,28 +45,28 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '10.0'
48
+ version: '12.0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '10.0'
55
+ version: '12.0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: coveralls
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: 0.8.15
62
+ version: 0.8.20
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: 0.8.15
69
+ version: 0.8.20
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: pry-nav
72
72
  requirement: !ruby/object:Gem::Requirement
@@ -87,14 +87,14 @@ dependencies:
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: 0.9.5
90
+ version: 0.9.8
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - "~>"
96
96
  - !ruby/object:Gem::Version
97
- version: 0.9.5
97
+ version: 0.9.8
98
98
  description: |-
99
99
  Yt::Support provides common functionality to Yt,
100
100
  Yt::Auth. It is considered suitable for internal use only at this time.