droplet_kit 2.7.0 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +5 -0
- data/README.md +13 -0
- data/droplet_kit.gemspec +1 -2
- data/lib/droplet_kit/client.rb +8 -2
- data/lib/droplet_kit/version.rb +1 -1
- data/spec/lib/droplet_kit/client_spec.rb +38 -0
- metadata +4 -19
- data/test.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e0cf3b3acb6383c2bb59033a01b8d3d14e14c4387db6f921ba0d06530d0d5a13
|
4
|
+
data.tar.gz: b9c37f5787739cb2f6256ac3d4654bda66c4ca34179152c9243aa327079e7083
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d69f2d18487aa8f742f3fe7973367dc183976ca0ffdf7853fc4577f572e09ebaa8e880ca4231214517cefb48d98f6a2f4fd914974aa75c47935c7718b6a4c41
|
7
|
+
data.tar.gz: 992888c5e18630c67ed28e584e81775e65c4787aacfad5bcce037cc681c6a5ce69c5dc526e282e8d51257750409acc731adc71d8c68001fa7e5799c433f5a3d6
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
### [2.8.0] - 2018-12-11
|
2
|
+
* #144 Adds the ability to set timeout options for Faraday - @tgturner
|
3
|
+
* #145 Bump Faraday version to 0.15 - @petems
|
4
|
+
* #170 Remove test rb file - @scottcrawford03
|
5
|
+
|
1
6
|
### Version 2.7.0
|
2
7
|
* Added KubernetesCluster resource
|
3
8
|
* Added KubernetesOptions resource
|
data/README.md
CHANGED
@@ -29,6 +29,19 @@ require 'droplet_kit'
|
|
29
29
|
client = DropletKit::Client.new(access_token: 'YOUR_TOKEN')
|
30
30
|
```
|
31
31
|
|
32
|
+
### Timeout
|
33
|
+
|
34
|
+
You may also set timeout and time to first byte options on the client.
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
require 'droplet_kit'
|
38
|
+
client = DropletKit::Client.new(
|
39
|
+
access_token: 'YOUR_TOKEN',
|
40
|
+
open_timeout: 60, # time to first byte in seconds
|
41
|
+
timeout: 120, # response timeout in seconds
|
42
|
+
)
|
43
|
+
```
|
44
|
+
|
32
45
|
### Custom User-Agent
|
33
46
|
|
34
47
|
If you would like to include a custom User-Agent header beyond what DropletKit
|
data/droplet_kit.gemspec
CHANGED
@@ -24,12 +24,11 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_dependency "resource_kit", '~> 0.1.5'
|
25
25
|
spec.add_dependency "kartograph", '~> 0.2.3'
|
26
26
|
spec.add_dependency "activesupport", '> 3.0', '< 6'
|
27
|
-
spec.add_dependency "faraday", '~> 0.
|
27
|
+
spec.add_dependency "faraday", '~> 0.15'
|
28
28
|
|
29
29
|
spec.add_development_dependency "bundler", ">= 1.11.0"
|
30
30
|
spec.add_development_dependency "rake"
|
31
31
|
spec.add_development_dependency "rspec", "~> 3.0.0"
|
32
|
-
spec.add_development_dependency "pry"
|
33
32
|
spec.add_development_dependency "rb-readline"
|
34
33
|
|
35
34
|
# FakeServe
|
data/lib/droplet_kit/client.rb
CHANGED
@@ -2,18 +2,24 @@ require 'faraday'
|
|
2
2
|
|
3
3
|
module DropletKit
|
4
4
|
class Client
|
5
|
+
DEFAULT_OPEN_TIMEOUT = 60
|
6
|
+
DEFAULT_TIMEOUT = 120
|
5
7
|
DIGITALOCEAN_API = 'https://api.digitalocean.com'
|
6
8
|
|
7
|
-
attr_reader :access_token, :user_agent
|
9
|
+
attr_reader :access_token, :timeout, :open_timeout, :user_agent
|
8
10
|
|
9
11
|
def initialize(options = {})
|
10
12
|
@access_token = options.with_indifferent_access[:access_token]
|
11
|
-
@
|
13
|
+
@open_timeout = options.with_indifferent_access[:open_timeout] || DEFAULT_OPEN_TIMEOUT
|
14
|
+
@timeout = options.with_indifferent_access[:timeout] || DEFAULT_TIMEOUT
|
15
|
+
@user_agent = options.with_indifferent_access[:user_agent]
|
12
16
|
end
|
13
17
|
|
14
18
|
def connection
|
15
19
|
@faraday ||= Faraday.new connection_options do |req|
|
16
20
|
req.adapter :net_http
|
21
|
+
req.options.open_timeout = open_timeout
|
22
|
+
req.options.timeout = timeout
|
17
23
|
end
|
18
24
|
end
|
19
25
|
|
data/lib/droplet_kit/version.rb
CHANGED
@@ -13,6 +13,36 @@ RSpec.describe DropletKit::Client do
|
|
13
13
|
client = DropletKit::Client.new('access_token' => 'my-token')
|
14
14
|
expect(client.access_token).to eq('my-token')
|
15
15
|
end
|
16
|
+
|
17
|
+
it 'has default open_timeout for faraday' do
|
18
|
+
client = DropletKit::Client.new('access_token' => 'my-token')
|
19
|
+
expect(client.open_timeout).to eq(DropletKit::Client::DEFAULT_OPEN_TIMEOUT)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'allows open_timeout to be set' do
|
23
|
+
open_timeout = 10
|
24
|
+
client = DropletKit::Client.new(
|
25
|
+
'access_token' => 'my-token',
|
26
|
+
'open_timeout' => open_timeout
|
27
|
+
)
|
28
|
+
|
29
|
+
expect(client.open_timeout).to eq(open_timeout)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'has default timeout' do
|
33
|
+
client = DropletKit::Client.new('access_token' => 'my-token')
|
34
|
+
expect(client.timeout).to eq(DropletKit::Client::DEFAULT_TIMEOUT)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'allows timeout to be set' do
|
38
|
+
timeout = 10
|
39
|
+
client = DropletKit::Client.new(
|
40
|
+
'access_token' => 'my-token',
|
41
|
+
'timeout' => timeout
|
42
|
+
)
|
43
|
+
|
44
|
+
expect(client.timeout).to eq(timeout)
|
45
|
+
end
|
16
46
|
end
|
17
47
|
|
18
48
|
describe "#method_missing" do
|
@@ -58,6 +88,14 @@ RSpec.describe DropletKit::Client do
|
|
58
88
|
client.connection.use AcmeApp::CustomLogger
|
59
89
|
expect(client.connection.builder.handlers).to include(AcmeApp::CustomLogger)
|
60
90
|
end
|
91
|
+
|
92
|
+
it 'has open_timeout set' do
|
93
|
+
expect(client.connection.options.open_timeout).to eq(DropletKit::Client::DEFAULT_OPEN_TIMEOUT)
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'has timeout set' do
|
97
|
+
expect(client.connection.options.timeout).to eq(DropletKit::Client::DEFAULT_TIMEOUT)
|
98
|
+
end
|
61
99
|
end
|
62
100
|
|
63
101
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: droplet_kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Ross
|
@@ -78,14 +78,14 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: '0.
|
81
|
+
version: '0.15'
|
82
82
|
type: :runtime
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: '0.
|
88
|
+
version: '0.15'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: bundler
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,20 +128,6 @@ dependencies:
|
|
128
128
|
- - "~>"
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: 3.0.0
|
131
|
-
- !ruby/object:Gem::Dependency
|
132
|
-
name: pry
|
133
|
-
requirement: !ruby/object:Gem::Requirement
|
134
|
-
requirements:
|
135
|
-
- - ">="
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
version: '0'
|
138
|
-
type: :development
|
139
|
-
prerelease: false
|
140
|
-
version_requirements: !ruby/object:Gem::Requirement
|
141
|
-
requirements:
|
142
|
-
- - ">="
|
143
|
-
- !ruby/object:Gem::Version
|
144
|
-
version: '0'
|
145
131
|
- !ruby/object:Gem::Dependency
|
146
132
|
name: rb-readline
|
147
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -450,7 +436,6 @@ files:
|
|
450
436
|
- spec/support/shared_examples/common_errors.rb
|
451
437
|
- spec/support/shared_examples/paginated_endpoint.rb
|
452
438
|
- spec/support/shared_examples/unprocessable_entity.rb
|
453
|
-
- test.rb
|
454
439
|
homepage: https://github.com/digitalocean/droplet_kit
|
455
440
|
licenses:
|
456
441
|
- MIT
|
@@ -471,7 +456,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
471
456
|
version: '0'
|
472
457
|
requirements: []
|
473
458
|
rubyforge_project:
|
474
|
-
rubygems_version: 2.6
|
459
|
+
rubygems_version: 2.7.6
|
475
460
|
signing_key:
|
476
461
|
specification_version: 4
|
477
462
|
summary: Droplet Kit is the official Ruby library for DigitalOcean's API
|