Skip to content

Commit f4f7176

Browse files
author
Phil Reindl
committed
Adding support for json 2.x and ruby 3
Ruby 3 mandated a bump to Faraday >= 0.17.3 Update specs to Rspec 3 format
1 parent c04e228 commit f4f7176

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+877
-870
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
ruby: [ '2.5', '2.6', '2.7' ]
12+
ruby: [ '2.5', '2.6', '2.7', '3.0' ]
1313

1414
steps:
1515
- name: repo checkout
1616
uses: actions/checkout@v2
1717

1818
- name: Set up Ruby ${{ matrix.ruby }}
19-
uses: actions/setup-ruby@v1
19+
# https://github.com/ruby/setup-ruby
20+
uses: ruby/setup-ruby@v1
2021
with:
2122
ruby-version: ${{ matrix.ruby }}
2223

CHANGELOG

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
v1.5.0
2+
Why upgrade?
3+
- Adding support for Ruby 3
4+
- Relaxed version requirement on json
5+
6+
Why wait?
7+
- Minimum version of Faraday brought up to v0.17.3
8+
19
v1.4.34
210
- Version update for releasing v1.4.33 as the tags were set wrong for v1.4.32 release
311

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.34
1+
1.5.0

lib/spark_api/authentication/api_auth.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def sign_token(path, params = {}, post_data="")
6262

6363
# Perform an HTTP request (no data)
6464
def request(method, path, body, options)
65-
escaped_path = URI.escape(path)
65+
escaped_path = Addressable::URI.escape(path)
6666
request_opts = {
6767
:AuthToken => @session.auth_token
6868
}

lib/spark_api/authentication/oauth2.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def authenticate
4040

4141
# Perform an HTTP request (no data)
4242
def request(method, path, body, options={})
43-
escaped_path = URI.escape(path)
43+
escaped_path = Addressable::URI.escape(path)
4444
connection = @client.connection(true) # SSL Only!
4545
connection.headers.merge!(self.auth_header)
4646

lib/spark_api/authentication/oauth2_impl/grant_type_base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def create_session(token_params)
4545
response.expires_in = provider.session_timeout if response.expires_in.nil?
4646
SparkApi.logger.debug { "[oauth2] New session created #{response}" }
4747
response
48-
rescue Faraday::Error::ConnectionFailed => e
48+
rescue Faraday::ConnectionFailed => e
4949
if @client.ssl_verify && e.message =~ /certificate verify failed/
5050
SparkApi.logger.error { SparkApi::Errors.ssl_verification_error }
5151
end

lib/spark_api/client.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module SparkApi
22
# =API Client
33
# Main class to setup and run requests on the API. A default client is accessible globally as
44
# SparkApi::client if the global configuration has been set as well. Otherwise, this class may
5-
# be instanciated separately with the configuration information.
5+
# be instantiated separately with the configuration information.
66
class Client
77
include Connection
88
include Authentication
@@ -21,7 +21,7 @@ def initialize(options={})
2121
Configuration::VALID_OPTION_KEYS.each do |key|
2222
send("#{key}=", options[key])
2323
end
24-
# Instanciate the authenication class passed in.
24+
# Instantiate the authentication class passed in.
2525
@authenticator = authentication_mode.send("new", self)
2626
end
2727

lib/spark_api/request.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def request(method, path, body, options)
9999
else
100100
return response.body
101101
end
102-
rescue Faraday::Error::ConnectionFailed => e
102+
rescue Faraday::ConnectionFailed => e
103103
if self.ssl_verify && e.message =~ /certificate verify failed/
104104
SparkApi.logger.error { SparkApi::Errors.ssl_verification_error }
105105
end

spark_api.gemspec

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,26 @@ Gem::Specification.new do |s|
2828
s.files = Dir["{History.txt,LICENSE,Rakefile,README.md,VERSION}", "{bin,lib,script}/**/*"]
2929
s.test_files = Dir["spec/{fixtures,unit}/**/*", "spec/*.rb"]
3030
s.executables = ["spark_api"]
31-
s.default_executable = %q{spark_api}
3231
s.require_paths = ["lib"]
33-
34-
s.add_dependency 'faraday', '~> 0.9.0'
32+
33+
s.add_dependency 'faraday', '>= 0.17.3'
3534
s.add_dependency 'multi_json', '~> 1.0'
36-
s.add_dependency 'json', '~> 1.7'
35+
s.add_dependency 'json', '>= 1.7'
3736
s.add_dependency 'builder', '>= 2.1.2', '< 4.0.0'
3837
s.add_dependency 'will_paginate', '>= 3.0.pre2', '< 4.0.0'
3938
s.add_dependency 'highline', '>= 1.0'
4039

41-
# spark_api doesn't use public_suffix directly. spark_api uses Webmock, which
42-
# uses addressable, which uses public_suffix. Bundler has suddenly started
43-
# trying to install public_suffix 2.0.4, which requires Ruby 2. When spark_api
44-
# starts to require Ruby 2, this dependency can be removed.
45-
s.add_development_dependency 'public_suffix', '~> 1.4.6'
46-
4740
# TEST GEMS
48-
s.add_development_dependency 'rake', '~> 0.9.2'
49-
s.add_development_dependency 'rspec', '~> 2.14.0'
50-
s.add_development_dependency 'webmock', '~> 1.9'
51-
s.add_development_dependency 'typhoeus', '~> 0.3'
52-
s.add_development_dependency 'ci_reporter', '~> 1.7.0'
53-
s.add_development_dependency 'rb-readline'
54-
s.add_development_dependency 'rb-fsevent'
55-
s.add_development_dependency 'simplecov'
41+
s.add_development_dependency 'rake'
42+
s.add_development_dependency 'rspec'
43+
s.add_development_dependency 'webmock'
44+
s.add_development_dependency 'rexml' #needed for ruby 3
45+
s.add_development_dependency 'typhoeus'
46+
s.add_development_dependency 'ci_reporter_rspec'
47+
# s.add_development_dependency 'rb-readline'
48+
# s.add_development_dependency 'rb-fsevent'
49+
# s.add_development_dependency 'simplecov'
5650
s.add_development_dependency 'simplecov-rcov'
57-
s.add_development_dependency 'listen', '~> 3.0.8' # for guard-rspec with ruby 1.9.3
58-
s.add_development_dependency 'guard-rspec'
51+
# s.add_development_dependency 'guard-rspec'
5952
end
6053

spec/spec_helper.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
require "rubygems"
1313
require "rspec"
14-
require 'rspec/autorun'
1514
require 'webmock/rspec'
1615
require "json"
1716
require 'multi_json'
@@ -22,6 +21,13 @@
2221

2322
require 'spark_api'
2423

24+
if ENV['COVERAGE'] == "on"
25+
require 'simplecov'
26+
require 'simplecov-rcov'
27+
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
28+
SimpleCov.start { add_filter %w(/vendor /spec /test) }
29+
end
30+
2531
FileUtils.mkdir 'log' unless File.exists? 'log'
2632

2733
module SparkApi
@@ -48,17 +54,16 @@ def reset_config
4854
Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
4955

5056
RSpec.configure do |config|
51-
57+
5258
config.include WebMock::API
5359
config.include StubApiRequests
5460

55-
config.treat_symbols_as_metadata_keys_with_true_values = true
5661
config.alias_example_to :on_get_it, :method => 'GET'
5762
config.alias_example_to :on_put_it, :method => 'PUT'
5863
config.alias_example_to :on_post_it, :method => 'POST'
5964
config.alias_example_to :on_delete_it, :method => 'DELETE'
6065
config.before(:all) { reset_config }
61-
config.color_enabled = true
66+
config.color = true
6267
end
6368

6469
def jruby?

0 commit comments

Comments
 (0)