faraday 0.9.1 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE.md +1 -1
- data/README.md +189 -28
- data/lib/faraday/adapter/em_http.rb +8 -2
- data/lib/faraday/adapter/em_http_ssl_patch.rb +1 -1
- data/lib/faraday/adapter/em_synchrony.rb +16 -2
- data/lib/faraday/adapter/excon.rb +7 -8
- data/lib/faraday/adapter/httpclient.rb +27 -5
- data/lib/faraday/adapter/net_http.rb +16 -9
- data/lib/faraday/adapter/net_http_persistent.rb +24 -9
- data/lib/faraday/adapter/patron.rb +40 -12
- data/lib/faraday/adapter/test.rb +79 -28
- data/lib/faraday/adapter/typhoeus.rb +4 -115
- data/lib/faraday/adapter.rb +10 -1
- data/lib/faraday/autoload.rb +1 -1
- data/lib/faraday/connection.rb +72 -20
- data/lib/faraday/error.rb +18 -5
- data/lib/faraday/options.rb +40 -18
- data/lib/faraday/parameters.rb +54 -38
- data/lib/faraday/rack_builder.rb +27 -2
- data/lib/faraday/request/authorization.rb +1 -2
- data/lib/faraday/request/multipart.rb +7 -2
- data/lib/faraday/request/retry.rb +80 -17
- data/lib/faraday/request.rb +2 -0
- data/lib/faraday/response/logger.rb +28 -7
- data/lib/faraday/response.rb +6 -2
- data/lib/faraday/utils.rb +32 -3
- data/lib/faraday.rb +14 -34
- metadata +7 -93
- data/.document +0 -6
- data/CHANGELOG.md +0 -20
- data/CONTRIBUTING.md +0 -36
- data/Gemfile +0 -25
- data/Rakefile +0 -71
- data/faraday.gemspec +0 -34
- data/script/cached-bundle +0 -46
- data/script/console +0 -7
- data/script/generate_certs +0 -42
- data/script/package +0 -7
- data/script/proxy-server +0 -42
- data/script/release +0 -17
- data/script/s3-put +0 -71
- data/script/server +0 -36
- data/script/test +0 -172
- data/test/adapters/default_test.rb +0 -14
- data/test/adapters/em_http_test.rb +0 -20
- data/test/adapters/em_synchrony_test.rb +0 -20
- data/test/adapters/excon_test.rb +0 -20
- data/test/adapters/httpclient_test.rb +0 -21
- data/test/adapters/integration.rb +0 -254
- data/test/adapters/logger_test.rb +0 -82
- data/test/adapters/net_http_persistent_test.rb +0 -20
- data/test/adapters/net_http_test.rb +0 -14
- data/test/adapters/patron_test.rb +0 -20
- data/test/adapters/rack_test.rb +0 -31
- data/test/adapters/test_middleware_test.rb +0 -114
- data/test/adapters/typhoeus_test.rb +0 -28
- data/test/authentication_middleware_test.rb +0 -65
- data/test/composite_read_io_test.rb +0 -111
- data/test/connection_test.rb +0 -522
- data/test/env_test.rb +0 -218
- data/test/helper.rb +0 -81
- data/test/live_server.rb +0 -67
- data/test/middleware/instrumentation_test.rb +0 -88
- data/test/middleware/retry_test.rb +0 -177
- data/test/middleware_stack_test.rb +0 -173
- data/test/multibyte.txt +0 -1
- data/test/options_test.rb +0 -252
- data/test/parameters_test.rb +0 -64
- data/test/request_middleware_test.rb +0 -142
- data/test/response_middleware_test.rb +0 -72
- data/test/strawberry.rb +0 -2
- data/test/utils_test.rb +0 -58
data/lib/faraday.rb
CHANGED
@@ -14,7 +14,7 @@ require 'forwardable'
|
|
14
14
|
# conn.get '/'
|
15
15
|
#
|
16
16
|
module Faraday
|
17
|
-
VERSION = "0.
|
17
|
+
VERSION = "0.15.0"
|
18
18
|
|
19
19
|
class << self
|
20
20
|
# Public: Gets or sets the root path that Faraday is being loaded from.
|
@@ -34,8 +34,8 @@ module Faraday
|
|
34
34
|
# Faraday.get "https://faraday.com"
|
35
35
|
attr_writer :default_connection
|
36
36
|
|
37
|
-
# Public:
|
38
|
-
|
37
|
+
# Public: Tells faraday to ignore the environment proxy (http_proxy).
|
38
|
+
attr_accessor :ignore_env_proxy
|
39
39
|
|
40
40
|
# Public: Initializes a new Faraday::Connection.
|
41
41
|
#
|
@@ -66,7 +66,7 @@ module Faraday
|
|
66
66
|
# Returns a Faraday::Connection.
|
67
67
|
def new(url = nil, options = nil)
|
68
68
|
block = block_given? ? Proc.new : nil
|
69
|
-
options = options ? default_connection_options.merge(options) : default_connection_options
|
69
|
+
options = options ? default_connection_options.merge(options) : default_connection_options
|
70
70
|
Faraday::Connection.new(url, options, &block)
|
71
71
|
end
|
72
72
|
|
@@ -92,6 +92,10 @@ module Faraday
|
|
92
92
|
|
93
93
|
alias require_lib require_libs
|
94
94
|
|
95
|
+
def respond_to?(symbol, include_private = false)
|
96
|
+
default_connection.respond_to?(symbol, include_private) || super
|
97
|
+
end
|
98
|
+
|
95
99
|
private
|
96
100
|
# Internal: Proxies method calls on the Faraday constant to
|
97
101
|
# #default_connection.
|
@@ -100,6 +104,7 @@ module Faraday
|
|
100
104
|
end
|
101
105
|
end
|
102
106
|
|
107
|
+
self.ignore_env_proxy = false
|
103
108
|
self.root_path = File.expand_path "..", __FILE__
|
104
109
|
self.lib_path = File.expand_path "../faraday", __FILE__
|
105
110
|
self.default_adapter = :net_http
|
@@ -108,7 +113,7 @@ module Faraday
|
|
108
113
|
#
|
109
114
|
# Returns a Faraday::Connection, configured with the #default_adapter.
|
110
115
|
def self.default_connection
|
111
|
-
@default_connection ||= Connection.new
|
116
|
+
@default_connection ||= Connection.new(default_connection_options)
|
112
117
|
end
|
113
118
|
|
114
119
|
# Gets the default connection options used when calling Faraday#new.
|
@@ -118,13 +123,10 @@ module Faraday
|
|
118
123
|
@default_connection_options ||= ConnectionOptions.new
|
119
124
|
end
|
120
125
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
rescue LoadError
|
126
|
-
warn "Faraday: you may want to install system_timer for reliable timeouts"
|
127
|
-
end
|
126
|
+
# Public: Sets the default options used when calling Faraday#new.
|
127
|
+
def self.default_connection_options=(options)
|
128
|
+
@default_connection = nil
|
129
|
+
@default_connection_options = ConnectionOptions.from(options)
|
128
130
|
end
|
129
131
|
|
130
132
|
unless const_defined? :Timer
|
@@ -244,25 +246,3 @@ module Faraday
|
|
244
246
|
require_lib 'autoload'
|
245
247
|
end
|
246
248
|
end
|
247
|
-
|
248
|
-
# not pulling in active-support JUST for this method. And I love this method.
|
249
|
-
class Object
|
250
|
-
# The primary purpose of this method is to "tap into" a method chain,
|
251
|
-
# in order to perform operations on intermediate results within the chain.
|
252
|
-
#
|
253
|
-
# Examples
|
254
|
-
#
|
255
|
-
# (1..10).tap { |x| puts "original: #{x.inspect}" }.to_a.
|
256
|
-
# tap { |x| puts "array: #{x.inspect}" }.
|
257
|
-
# select { |x| x%2 == 0 }.
|
258
|
-
# tap { |x| puts "evens: #{x.inspect}" }.
|
259
|
-
# map { |x| x*x }.
|
260
|
-
# tap { |x| puts "squares: #{x.inspect}" }
|
261
|
-
#
|
262
|
-
# Yields self.
|
263
|
-
# Returns self.
|
264
|
-
def tap
|
265
|
-
yield(self)
|
266
|
-
self
|
267
|
-
end unless Object.respond_to?(:tap)
|
268
|
-
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faraday
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rick Olson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multipart-post
|
@@ -30,34 +30,14 @@ dependencies:
|
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '3'
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: bundler
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '1.0'
|
40
|
-
type: :development
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - "~>"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '1.0'
|
47
33
|
description:
|
48
34
|
email: technoweenie@gmail.com
|
49
35
|
executables: []
|
50
36
|
extensions: []
|
51
37
|
extra_rdoc_files: []
|
52
38
|
files:
|
53
|
-
- ".document"
|
54
|
-
- CHANGELOG.md
|
55
|
-
- CONTRIBUTING.md
|
56
|
-
- Gemfile
|
57
39
|
- LICENSE.md
|
58
40
|
- README.md
|
59
|
-
- Rakefile
|
60
|
-
- faraday.gemspec
|
61
41
|
- lib/faraday.rb
|
62
42
|
- lib/faraday/adapter.rb
|
63
43
|
- lib/faraday/adapter/em_http.rb
|
@@ -92,44 +72,6 @@ files:
|
|
92
72
|
- lib/faraday/response/raise_error.rb
|
93
73
|
- lib/faraday/upload_io.rb
|
94
74
|
- lib/faraday/utils.rb
|
95
|
-
- script/cached-bundle
|
96
|
-
- script/console
|
97
|
-
- script/generate_certs
|
98
|
-
- script/package
|
99
|
-
- script/proxy-server
|
100
|
-
- script/release
|
101
|
-
- script/s3-put
|
102
|
-
- script/server
|
103
|
-
- script/test
|
104
|
-
- test/adapters/default_test.rb
|
105
|
-
- test/adapters/em_http_test.rb
|
106
|
-
- test/adapters/em_synchrony_test.rb
|
107
|
-
- test/adapters/excon_test.rb
|
108
|
-
- test/adapters/httpclient_test.rb
|
109
|
-
- test/adapters/integration.rb
|
110
|
-
- test/adapters/logger_test.rb
|
111
|
-
- test/adapters/net_http_persistent_test.rb
|
112
|
-
- test/adapters/net_http_test.rb
|
113
|
-
- test/adapters/patron_test.rb
|
114
|
-
- test/adapters/rack_test.rb
|
115
|
-
- test/adapters/test_middleware_test.rb
|
116
|
-
- test/adapters/typhoeus_test.rb
|
117
|
-
- test/authentication_middleware_test.rb
|
118
|
-
- test/composite_read_io_test.rb
|
119
|
-
- test/connection_test.rb
|
120
|
-
- test/env_test.rb
|
121
|
-
- test/helper.rb
|
122
|
-
- test/live_server.rb
|
123
|
-
- test/middleware/instrumentation_test.rb
|
124
|
-
- test/middleware/retry_test.rb
|
125
|
-
- test/middleware_stack_test.rb
|
126
|
-
- test/multibyte.txt
|
127
|
-
- test/options_test.rb
|
128
|
-
- test/parameters_test.rb
|
129
|
-
- test/request_middleware_test.rb
|
130
|
-
- test/response_middleware_test.rb
|
131
|
-
- test/strawberry.rb
|
132
|
-
- test/utils_test.rb
|
133
75
|
homepage: https://github.com/lostisland/faraday
|
134
76
|
licenses:
|
135
77
|
- MIT
|
@@ -142,44 +84,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
84
|
requirements:
|
143
85
|
- - ">="
|
144
86
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
87
|
+
version: '1.9'
|
146
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
89
|
requirements:
|
148
90
|
- - ">="
|
149
91
|
- !ruby/object:Gem::Version
|
150
|
-
version:
|
92
|
+
version: '0'
|
151
93
|
requirements: []
|
152
94
|
rubyforge_project:
|
153
|
-
rubygems_version: 2.
|
95
|
+
rubygems_version: 2.7.6
|
154
96
|
signing_key:
|
155
|
-
specification_version:
|
97
|
+
specification_version: 4
|
156
98
|
summary: HTTP/REST API client library.
|
157
|
-
test_files:
|
158
|
-
- test/adapters/default_test.rb
|
159
|
-
- test/adapters/em_http_test.rb
|
160
|
-
- test/adapters/em_synchrony_test.rb
|
161
|
-
- test/adapters/excon_test.rb
|
162
|
-
- test/adapters/httpclient_test.rb
|
163
|
-
- test/adapters/integration.rb
|
164
|
-
- test/adapters/logger_test.rb
|
165
|
-
- test/adapters/net_http_persistent_test.rb
|
166
|
-
- test/adapters/net_http_test.rb
|
167
|
-
- test/adapters/patron_test.rb
|
168
|
-
- test/adapters/rack_test.rb
|
169
|
-
- test/adapters/test_middleware_test.rb
|
170
|
-
- test/adapters/typhoeus_test.rb
|
171
|
-
- test/authentication_middleware_test.rb
|
172
|
-
- test/composite_read_io_test.rb
|
173
|
-
- test/connection_test.rb
|
174
|
-
- test/env_test.rb
|
175
|
-
- test/helper.rb
|
176
|
-
- test/live_server.rb
|
177
|
-
- test/middleware/instrumentation_test.rb
|
178
|
-
- test/middleware/retry_test.rb
|
179
|
-
- test/middleware_stack_test.rb
|
180
|
-
- test/options_test.rb
|
181
|
-
- test/parameters_test.rb
|
182
|
-
- test/request_middleware_test.rb
|
183
|
-
- test/response_middleware_test.rb
|
184
|
-
- test/strawberry.rb
|
185
|
-
- test/utils_test.rb
|
99
|
+
test_files: []
|
data/.document
DELETED
data/CHANGELOG.md
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# Faraday Changelog
|
2
|
-
|
3
|
-
## v0.9.1
|
4
|
-
|
5
|
-
* Refactor Net:HTTP adapter so that with_net_http_connection can be overridden to allow pooled connections. (@Ben-M)
|
6
|
-
* Add configurable methods that bypass `retry_if` in the Retry request middleware. (@mike-bourgeous)
|
7
|
-
|
8
|
-
## v0.9.0
|
9
|
-
|
10
|
-
* Add HTTPClient adapter (@hakanensari)
|
11
|
-
* Improve Retry handler (@mislav)
|
12
|
-
* Remove autoloading by default (@technoweenie)
|
13
|
-
* Improve internal docs (@technoweenie, @mislav)
|
14
|
-
* Respect user/password in http proxy string (@mislav)
|
15
|
-
* Adapter options are structs. Reinforces consistent options across adapters
|
16
|
-
(@technoweenie)
|
17
|
-
* Stop stripping trailing / off base URLs in a Faraday::Connection. (@technoweenie)
|
18
|
-
* Add a configurable URI parser. (@technoweenie)
|
19
|
-
* Remove need to manually autoload when using the authorization header helpers on `Faraday::Connection`. (@technoweenie)
|
20
|
-
* `Faraday::Adapter::Test` respects the `Faraday::RequestOptions#params_encoder` option. (@technoweenie)
|
data/CONTRIBUTING.md
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
## Contributing
|
2
|
-
|
3
|
-
You can run the test suite against a live server by running `script/test`. It
|
4
|
-
automatically starts a test server in background. Only tests in
|
5
|
-
`test/adapters/*_test.rb` require a server, though.
|
6
|
-
|
7
|
-
``` sh
|
8
|
-
# run the whole suite
|
9
|
-
$ script/test
|
10
|
-
|
11
|
-
# run only specific files
|
12
|
-
$ script/test excon typhoeus
|
13
|
-
|
14
|
-
# run tests using SSL
|
15
|
-
$ SSL=yes script/test
|
16
|
-
```
|
17
|
-
|
18
|
-
We will accept middleware that:
|
19
|
-
|
20
|
-
1. is useful to a broader audience, but can be implemented relatively
|
21
|
-
simple; and
|
22
|
-
2. which isn't already present in [faraday_middleware][] project.
|
23
|
-
|
24
|
-
We will accept adapters that:
|
25
|
-
|
26
|
-
1. support SSL & streaming;
|
27
|
-
1. are proven and may have better performance than existing ones; or
|
28
|
-
2. if they have features not present in included adapters.
|
29
|
-
|
30
|
-
We are pushing towards a 1.0 release, when we will have to follow [Semantic
|
31
|
-
Versioning][semver]. If your patch includes changes to break compatibility,
|
32
|
-
note that so we can add it to the [Changelog][].
|
33
|
-
|
34
|
-
[semver]: http://semver.org/
|
35
|
-
[changelog]: https://github.com/lostisland/faraday/wiki/Changelog
|
36
|
-
[faraday_middleware]: https://github.com/lostisland/faraday_middleware/wiki
|
data/Gemfile
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gem 'ffi-ncurses', '~> 0.3', :platforms => :jruby
|
4
|
-
gem 'jruby-openssl', '~> 0.8.8', :platforms => :jruby
|
5
|
-
gem 'rake'
|
6
|
-
|
7
|
-
group :test do
|
8
|
-
gem 'coveralls', :require => false
|
9
|
-
gem 'em-http-request', '>= 1.1', :require => 'em-http'
|
10
|
-
gem 'em-synchrony', '>= 1.0.3', :require => ['em-synchrony', 'em-synchrony/em-http']
|
11
|
-
gem 'excon', '>= 0.27.4'
|
12
|
-
gem 'httpclient', '>= 2.2'
|
13
|
-
gem 'leftright', '>= 0.9', :require => false
|
14
|
-
gem 'mime-types', '~> 1.25', :platforms => [:jruby, :ruby_18]
|
15
|
-
gem 'minitest', '>= 5.0.5'
|
16
|
-
gem 'net-http-persistent', '>= 2.9.4'
|
17
|
-
gem 'patron', '>= 0.4.2', :platforms => :ruby
|
18
|
-
gem 'rack-test', '>= 0.6', :require => 'rack/test'
|
19
|
-
gem 'rest-client', '~> 1.6.0', :platforms => [:jruby, :ruby_18]
|
20
|
-
gem 'simplecov'
|
21
|
-
gem 'sinatra', '~> 1.3'
|
22
|
-
gem 'typhoeus', '~> 0.3.3', :platforms => :ruby
|
23
|
-
end
|
24
|
-
|
25
|
-
gemspec
|
data/Rakefile
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'date'
|
2
|
-
require 'fileutils'
|
3
|
-
require 'openssl'
|
4
|
-
require 'rake/testtask'
|
5
|
-
require 'bundler'
|
6
|
-
Bundler::GemHelper.install_tasks
|
7
|
-
|
8
|
-
task :default => :test
|
9
|
-
|
10
|
-
## helper functions
|
11
|
-
|
12
|
-
def name
|
13
|
-
@name ||= Dir['*.gemspec'].first.split('.').first
|
14
|
-
end
|
15
|
-
|
16
|
-
def version
|
17
|
-
line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
|
18
|
-
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
19
|
-
end
|
20
|
-
|
21
|
-
def gemspec_file
|
22
|
-
"#{name}.gemspec"
|
23
|
-
end
|
24
|
-
|
25
|
-
def gem_file
|
26
|
-
"#{name}-#{version}.gem"
|
27
|
-
end
|
28
|
-
|
29
|
-
def replace_header(head, header_name)
|
30
|
-
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
|
31
|
-
end
|
32
|
-
|
33
|
-
# Adapted from WEBrick::Utils. Skips cert extensions so it
|
34
|
-
# can be used as a CA bundle
|
35
|
-
def create_self_signed_cert(bits, cn, comment)
|
36
|
-
rsa = OpenSSL::PKey::RSA.new(bits)
|
37
|
-
cert = OpenSSL::X509::Certificate.new
|
38
|
-
cert.version = 2
|
39
|
-
cert.serial = 1
|
40
|
-
name = OpenSSL::X509::Name.new(cn)
|
41
|
-
cert.subject = name
|
42
|
-
cert.issuer = name
|
43
|
-
cert.not_before = Time.now
|
44
|
-
cert.not_after = Time.now + (365*24*60*60)
|
45
|
-
cert.public_key = rsa.public_key
|
46
|
-
cert.sign(rsa, OpenSSL::Digest::SHA1.new)
|
47
|
-
return [cert, rsa]
|
48
|
-
end
|
49
|
-
|
50
|
-
## standard tasks
|
51
|
-
|
52
|
-
desc "Run all tests"
|
53
|
-
task :test do
|
54
|
-
exec 'script/test'
|
55
|
-
end
|
56
|
-
|
57
|
-
desc "Generate certificates for SSL tests"
|
58
|
-
task :'test:generate_certs' do
|
59
|
-
cert, key = create_self_signed_cert(1024, [['CN', 'localhost']], 'Faraday Test CA')
|
60
|
-
FileUtils.mkdir_p 'tmp'
|
61
|
-
File.open('tmp/faraday-cert.key', 'w') {|f| f.puts(key) }
|
62
|
-
File.open('tmp/faraday-cert.crt', 'w') {|f| f.puts(cert.to_s) }
|
63
|
-
end
|
64
|
-
|
65
|
-
file 'tmp/faraday-cert.key' => :'test:generate_certs'
|
66
|
-
file 'tmp/faraday-cert.crt' => :'test:generate_certs'
|
67
|
-
|
68
|
-
desc "Open an irb session preloaded with this library"
|
69
|
-
task :console do
|
70
|
-
sh "irb -rubygems -r ./lib/#{name}.rb"
|
71
|
-
end
|
data/faraday.gemspec
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
lib = "faraday"
|
2
|
-
lib_file = File.expand_path("../lib/#{lib}.rb", __FILE__)
|
3
|
-
File.read(lib_file) =~ /\bVERSION\s*=\s*["'](.+?)["']/
|
4
|
-
version = $1
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.specification_version = 2 if spec.respond_to? :specification_version=
|
8
|
-
spec.required_rubygems_version = '>= 1.3.5'
|
9
|
-
|
10
|
-
spec.name = lib
|
11
|
-
spec.version = version
|
12
|
-
|
13
|
-
spec.summary = "HTTP/REST API client library."
|
14
|
-
|
15
|
-
spec.authors = ["Rick Olson"]
|
16
|
-
spec.email = 'technoweenie@gmail.com'
|
17
|
-
spec.homepage = 'https://github.com/lostisland/faraday'
|
18
|
-
spec.licenses = ['MIT']
|
19
|
-
|
20
|
-
spec.add_dependency 'multipart-post', '>= 1.2', '< 3'
|
21
|
-
spec.add_development_dependency 'bundler', '~> 1.0'
|
22
|
-
|
23
|
-
spec.files = %w(.document CHANGELOG.md CONTRIBUTING.md Gemfile LICENSE.md README.md Rakefile)
|
24
|
-
spec.files << "#{lib}.gemspec"
|
25
|
-
spec.files += Dir.glob("lib/**/*.rb")
|
26
|
-
spec.files += Dir.glob("test/**/*.{rb,txt}")
|
27
|
-
spec.files += Dir.glob("script/*")
|
28
|
-
|
29
|
-
dev_null = File.exist?('/dev/null') ? '/dev/null' : 'NUL'
|
30
|
-
git_files = `git ls-files -z 2>#{dev_null}`
|
31
|
-
spec.files &= git_files.split("\0") if $?.success?
|
32
|
-
|
33
|
-
spec.test_files = Dir.glob("test/**/*.rb")
|
34
|
-
end
|
data/script/cached-bundle
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
# Usage: cached-bundle install --deployment
|
3
|
-
#
|
4
|
-
# After running `bundle`, caches the `./bundle` directory to S3.
|
5
|
-
# On the next run, restores the cached directory before running `bundle`.
|
6
|
-
# When `Gemfile` changes, the cache gets rebuilt.
|
7
|
-
#
|
8
|
-
# Requirements:
|
9
|
-
# - Gemfile
|
10
|
-
# - TRAVIS_REPO_SLUG
|
11
|
-
# - TRAVIS_RUBY_VERSION
|
12
|
-
# - AMAZON_S3_BUCKET
|
13
|
-
# - script/s3-put
|
14
|
-
# - bundle
|
15
|
-
# - curl
|
16
|
-
#
|
17
|
-
# Author: Mislav Marohnić
|
18
|
-
|
19
|
-
set -e
|
20
|
-
|
21
|
-
compute_md5() {
|
22
|
-
local output="$(openssl md5)"
|
23
|
-
echo "${output##* }"
|
24
|
-
}
|
25
|
-
|
26
|
-
download() {
|
27
|
-
curl --tcp-nodelay -qsfL "$1" -o "$2"
|
28
|
-
}
|
29
|
-
|
30
|
-
bundle_path="bundle"
|
31
|
-
gemfile_hash="$(compute_md5 <"${BUNDLE_GEMFILE:-Gemfile}")"
|
32
|
-
cache_name="${TRAVIS_RUBY_VERSION}-${gemfile_hash}.tgz"
|
33
|
-
fetch_url="http://${AMAZON_S3_BUCKET}.s3.amazonaws.com/${TRAVIS_REPO_SLUG}/${cache_name}"
|
34
|
-
|
35
|
-
if download "$fetch_url" "$cache_name"; then
|
36
|
-
echo "Reusing cached bundle ${cache_name}"
|
37
|
-
tar xzf "$cache_name"
|
38
|
-
fi
|
39
|
-
|
40
|
-
bundle "$@"
|
41
|
-
|
42
|
-
if [ ! -f "$cache_name" ] && [ -n "$AMAZON_SECRET_ACCESS_KEY" ]; then
|
43
|
-
echo "Caching \`${bundle_path}' to S3"
|
44
|
-
tar czf "$cache_name" "$bundle_path"
|
45
|
-
script/s3-put "$cache_name" "${AMAZON_S3_BUCKET}:${TRAVIS_REPO_SLUG}/${cache_name}"
|
46
|
-
fi
|
data/script/console
DELETED
data/script/generate_certs
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# Usage: generate_certs
|
3
|
-
# Generate test certs for testing Faraday with SSL
|
4
|
-
|
5
|
-
require 'openssl'
|
6
|
-
require 'fileutils'
|
7
|
-
|
8
|
-
$shell = ARGV.include? '-s'
|
9
|
-
|
10
|
-
# Adapted from WEBrick::Utils. Skips cert extensions so it
|
11
|
-
# can be used as a CA bundle
|
12
|
-
def create_self_signed_cert(bits, cn, comment)
|
13
|
-
rsa = OpenSSL::PKey::RSA.new(bits)
|
14
|
-
cert = OpenSSL::X509::Certificate.new
|
15
|
-
cert.version = 2
|
16
|
-
cert.serial = 1
|
17
|
-
name = OpenSSL::X509::Name.new(cn)
|
18
|
-
cert.subject = name
|
19
|
-
cert.issuer = name
|
20
|
-
cert.not_before = Time.now
|
21
|
-
cert.not_after = Time.now + (365*24*60*60)
|
22
|
-
cert.public_key = rsa.public_key
|
23
|
-
cert.sign(rsa, OpenSSL::Digest::SHA1.new)
|
24
|
-
return [cert, rsa]
|
25
|
-
end
|
26
|
-
|
27
|
-
def write(file, contents, env_var)
|
28
|
-
FileUtils.mkdir_p(File.dirname(file))
|
29
|
-
File.open(file, 'w') {|f| f.puts(contents) }
|
30
|
-
puts %(export #{env_var}="#{file}") if $shell
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
# One cert / CA for ease of testing when ignoring verification
|
35
|
-
cert, key = create_self_signed_cert(1024, [['CN', 'localhost']], 'Faraday Test CA')
|
36
|
-
write 'tmp/faraday-cert.key', key, 'SSL_KEY'
|
37
|
-
write 'tmp/faraday-cert.crt', cert, 'SSL_FILE'
|
38
|
-
|
39
|
-
# And a second CA to prove that verification can fail
|
40
|
-
cert, key = create_self_signed_cert(1024, [['CN', 'real-ca.com']], 'A different CA')
|
41
|
-
write 'tmp/faraday-different-ca-cert.key', key, 'SSL_KEY_ALT'
|
42
|
-
write 'tmp/faraday-different-ca-cert.crt', cert, 'SSL_FILE_ALT'
|
data/script/package
DELETED
data/script/proxy-server
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# Usage: script/proxy-server [-p PORT] [-u USER:PASSWORD]
|
3
|
-
require 'webrick'
|
4
|
-
require 'webrick/httpproxy'
|
5
|
-
|
6
|
-
port = 4001
|
7
|
-
|
8
|
-
if found = ARGV.index('-p')
|
9
|
-
port = ARGV[found + 1].to_i
|
10
|
-
end
|
11
|
-
if found = ARGV.index('-u')
|
12
|
-
username, password = ARGV[found + 1].split(':', 2)
|
13
|
-
end
|
14
|
-
|
15
|
-
match_credentials = lambda { |credentials|
|
16
|
-
got_username, got_password = credentials.to_s.unpack("m*")[0].split(":", 2)
|
17
|
-
got_username == username && got_password == password
|
18
|
-
}
|
19
|
-
|
20
|
-
log_io = $stdout
|
21
|
-
log_io.sync = true
|
22
|
-
|
23
|
-
webrick_opts = {
|
24
|
-
:Port => port, :Logger => WEBrick::Log::new(log_io),
|
25
|
-
:AccessLog => [[log_io, "[%{X-Faraday-Adapter}i] %m %U -> %s %b"]],
|
26
|
-
:ProxyAuthProc => lambda { |req, res|
|
27
|
-
if username
|
28
|
-
type, credentials = req.header['proxy-authorization'].first.to_s.split(/\s+/, 2)
|
29
|
-
unless "Basic" == type && match_credentials.call(credentials)
|
30
|
-
res['proxy-authenticate'] = %{Basic realm="testing"}
|
31
|
-
raise WEBrick::HTTPStatus::ProxyAuthenticationRequired
|
32
|
-
end
|
33
|
-
end
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
proxy = WEBrick::HTTPProxyServer.new(webrick_opts)
|
38
|
-
|
39
|
-
trap(:TERM) { proxy.shutdown }
|
40
|
-
trap(:INT) { proxy.shutdown }
|
41
|
-
|
42
|
-
proxy.start
|
data/script/release
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
# Usage: script/release
|
3
|
-
# Build the package, tag a commit, push it to origin, and then release the
|
4
|
-
# package publicly.
|
5
|
-
|
6
|
-
set -e
|
7
|
-
|
8
|
-
version="$(script/package | grep Version: | awk '{print $2}')"
|
9
|
-
[ -n "$version" ] || exit 1
|
10
|
-
|
11
|
-
git commit --allow-empty -a -m "Release $version"
|
12
|
-
git tag "v$version"
|
13
|
-
git push origin
|
14
|
-
git push origin "v$version"
|
15
|
-
git push legacy
|
16
|
-
git push legacy "v$version"
|
17
|
-
gem push pkg/*-${version}.gem
|
data/script/s3-put
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
# Usage: s3-put <FILE> <S3_BUCKET>[:<PATH>] [<CONTENT_TYPE>]
|
3
|
-
#
|
4
|
-
# Uploads a file to the Amazon S3 service.
|
5
|
-
# Outputs the URL for the newly uploaded file.
|
6
|
-
#
|
7
|
-
# Requirements:
|
8
|
-
# - AMAZON_ACCESS_KEY_ID
|
9
|
-
# - AMAZON_SECRET_ACCESS_KEY
|
10
|
-
# - openssl
|
11
|
-
# - curl
|
12
|
-
#
|
13
|
-
# Author: Mislav Marohnić
|
14
|
-
|
15
|
-
set -e
|
16
|
-
|
17
|
-
authorization() {
|
18
|
-
local signature="$(string_to_sign | hmac_sha1 | base64)"
|
19
|
-
echo "AWS ${AMAZON_ACCESS_KEY_ID?}:${signature}"
|
20
|
-
}
|
21
|
-
|
22
|
-
hmac_sha1() {
|
23
|
-
openssl dgst -binary -sha1 -hmac "${AMAZON_SECRET_ACCESS_KEY?}"
|
24
|
-
}
|
25
|
-
|
26
|
-
base64() {
|
27
|
-
openssl enc -base64
|
28
|
-
}
|
29
|
-
|
30
|
-
bin_md5() {
|
31
|
-
openssl dgst -binary -md5
|
32
|
-
}
|
33
|
-
|
34
|
-
string_to_sign() {
|
35
|
-
echo "$http_method"
|
36
|
-
echo "$content_md5"
|
37
|
-
echo "$content_type"
|
38
|
-
echo "$date"
|
39
|
-
echo "x-amz-acl:$acl"
|
40
|
-
printf "/$bucket/$remote_path"
|
41
|
-
}
|
42
|
-
|
43
|
-
date_string() {
|
44
|
-
LC_TIME=C date "+%a, %d %h %Y %T %z"
|
45
|
-
}
|
46
|
-
|
47
|
-
file="$1"
|
48
|
-
bucket="${2%%:*}"
|
49
|
-
remote_path="${2#*:}"
|
50
|
-
content_type="$3"
|
51
|
-
|
52
|
-
if [ -z "$remote_path" ] || [ "$remote_path" = "$bucket" ]; then
|
53
|
-
remote_path="${file##*/}"
|
54
|
-
fi
|
55
|
-
|
56
|
-
http_method=PUT
|
57
|
-
acl="public-read"
|
58
|
-
content_md5="$(bin_md5 < "$file" | base64)"
|
59
|
-
date="$(date_string)"
|
60
|
-
|
61
|
-
url="https://$bucket.s3.amazonaws.com/$remote_path"
|
62
|
-
|
63
|
-
curl -qsSf -T "$file" \
|
64
|
-
-H "Authorization: $(authorization)" \
|
65
|
-
-H "x-amz-acl: $acl" \
|
66
|
-
-H "Date: $date" \
|
67
|
-
-H "Content-MD5: $content_md5" \
|
68
|
-
-H "Content-Type: $content_type" \
|
69
|
-
"$url"
|
70
|
-
|
71
|
-
echo "$url"
|