Skip to content

Commit

Permalink
Merge pull request #269 from cben/rest-client-2
Browse files Browse the repository at this point in the history
Require rest-client 2.x, drop 1.x support code
  • Loading branch information
simon3z committed Oct 11, 2017
2 parents 2198296 + 5357cc0 commit 2700c33
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 45 deletions.
4 changes: 1 addition & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ Metrics/ModuleLength:
Style/MethodCallWithArgsParentheses:
Enabled: true
IgnoredMethods: [require, raise, include, attr_reader, refute, assert]
Exclude: [Gemfile*, Rakefile, kubeclient.gemspec]
Style/FileName:
Exclude: [Gemfile*]
Exclude: [Gemfile, Rakefile, kubeclient.gemspec]
Security/MarshalLoad:
Exclude: [test/**/*]
8 changes: 0 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,9 @@ rvm:
- "2.2"
- "2.3.0"
- "2.4.0"
gemfile:
- Gemfile
- Gemfile-rest-client-1.8.rb
sudo: false
cache: bundler
script: bundle exec rake $TASK
env:
- TASK=test
- TASK=rubocop
matrix:
exclude:
# No point running rubocop with old rest-client
- gemfile: Gemfile-rest-client-1.8.rb
env: TASK=rubocop
11 changes: 0 additions & 11 deletions Gemfile-rest-client-1.8.rb

This file was deleted.

2 changes: 1 addition & 1 deletion kubeclient.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'webmock', '~> 3.0.1'
spec.add_development_dependency 'vcr'
spec.add_development_dependency 'rubocop', '= 0.49.1'
spec.add_dependency 'rest-client'
spec.add_dependency 'rest-client', '~> 2.0'
spec.add_dependency 'recursive-open-struct', '~> 1.0.4'
spec.add_dependency 'http', '~> 2.2.2'
end
14 changes: 1 addition & 13 deletions lib/kubeclient/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def create_rest_client(path = nil)
user: @auth_options[:username],
password: @auth_options[:password],
open_timeout: @timeouts[:open],
ClientMixin.restclient_read_timeout_option => @timeouts[:read]
read_timeout: @timeouts[:read]
}
RestClient::Resource.new(@api_endpoint.merge(path).to_s, options)
end
Expand Down Expand Up @@ -441,18 +441,6 @@ def api
JSON.parse(response)
end

def self.restclient_read_timeout_option
@restclient_read_timeout_option ||=
# RestClient silently accepts unknown options, so check accessors instead.
if RestClient::Resource.instance_methods.include?(:read_timeout) # rest-client 2.0
:read_timeout
elsif RestClient::Resource.instance_methods.include?(:timeout) # rest-client 1.x
:timeout
else
raise ArgumentError("RestClient doesn't support neither :read_timeout nor :timeout")
end
end

private

def load_entities
Expand Down
14 changes: 5 additions & 9 deletions test/test_kubeclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ def test_timeouts_defaults
)
rest_client = client.rest_client
assert_default_open_timeout(rest_client.open_timeout)
assert_equal(60, read_timeout(rest_client))
assert_equal(60, rest_client.read_timeout)
end

def test_timeouts_open
Expand All @@ -799,7 +799,7 @@ def test_timeouts_open
)
rest_client = client.rest_client
assert_equal(10, rest_client.open_timeout)
assert_equal(60, read_timeout(rest_client))
assert_equal(60, rest_client.read_timeout)
end

def test_timeouts_read
Expand All @@ -809,7 +809,7 @@ def test_timeouts_read
)
rest_client = client.rest_client
assert_default_open_timeout(rest_client.open_timeout)
assert_equal(300, read_timeout(rest_client))
assert_equal(300, rest_client.read_timeout)
end

def test_timeouts_both
Expand All @@ -819,7 +819,7 @@ def test_timeouts_both
)
rest_client = client.rest_client
assert_equal(10, rest_client.open_timeout)
assert_equal(300, read_timeout(rest_client))
assert_equal(300, rest_client.read_timeout)
end

def test_timeouts_infinite
Expand All @@ -829,11 +829,7 @@ def test_timeouts_infinite
)
rest_client = client.rest_client
assert_nil(rest_client.open_timeout)
assert_nil(read_timeout(rest_client))
end

def read_timeout(rest_client)
rest_client.send(Kubeclient::ClientMixin.restclient_read_timeout_option)
assert_nil(rest_client.read_timeout)
end

def assert_default_open_timeout(actual)
Expand Down

0 comments on commit 2700c33

Please sign in to comment.