Skip to content

Commit 5b82564

Browse files
authored
Merge pull request #178 from sparkapi/yaml_fix
Adding ruby 3.1 support
2 parents 5f0072a + e21a4fe commit 5b82564

File tree

7 files changed

+21
-19
lines changed

7 files changed

+21
-19
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
ruby: [ '2.5', '2.6', '2.7', '3.0' ]
12+
ruby: [ '2.5', '2.6', '2.7', '3.0', '3.1' ]
1313

1414
steps:
1515
- name: repo checkout

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
v1.6.0
2+
- Adding support for Ruby 3.1
3+
- Add support for psych 4.0 yaml loading
4+
- Lock Faraday down to < 2.0
5+
16
v1.5.6
27
- Modify usage of HighLine so that it does not pollute the global namespace
38

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.5.6
1+
1.6.0

lib/spark_api/authentication/oauth2_impl/cli_provider.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ def filename
8282

8383
def load_file
8484
yaml = {}
85-
begin
86-
yaml = YAML.load(File.open(filename))
85+
begin
86+
yaml = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(File.open(filename)) : YAML.load(File.open(filename))
8787
yaml = {} if yaml == false
8888
rescue => e
8989
puts "no file: #{e.message}"

lib/spark_api/configuration/yaml.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ def initialize(filename=nil)
1616
def load_file(file)
1717
@file = file
1818
@name = File.basename(file, ".yml")
19-
config = YAML.load(ERB.new(File.read(file)).result)[api_env]
19+
20+
erb_file = ERB.new(File.read(file)).result
21+
config = (YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(erb_file) : YAML.load(erb_file))[api_env]
2022
config["oauth2"] == true ? load_oauth2(config) : load_api_auth(config)
2123
rescue => e
2224
SparkApi.logger().error("Unable to load config file #{file}[#{api_env}]")

spark_api.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Gem::Specification.new do |s|
3030
s.executables = ["spark_api"]
3131
s.require_paths = ["lib"]
3232

33-
s.add_dependency 'faraday', '>= 0.17.3'
33+
s.add_dependency 'faraday', '>= 0.17.3', '< 2.0'
3434
s.add_dependency 'multi_json', '~> 1.0'
3535
s.add_dependency 'json', '>= 1.7'
3636
s.add_dependency 'builder', '>= 2.1.2', '< 4.0.0'

spec/spec_helper.rb

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
require 'simplecov'
33
require 'simplecov-rcov'
44
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
5-
SimpleCov.start do
6-
add_filter '/vendor'
7-
add_filter '/spec'
8-
add_filter '/test'
5+
unless SimpleCov.running # Hack to prevent starting SimpleCov multiple times see: https://github.com/simplecov-ruby/simplecov/issues/1003
6+
SimpleCov.start do
7+
add_filter '/vendor'
8+
add_filter '/spec'
9+
add_filter '/test'
10+
end
911
end
1012
end
1113

@@ -21,13 +23,6 @@
2123

2224
require 'spark_api'
2325

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-
3126
FileUtils.mkdir 'log' unless File.exists? 'log'
3227

3328
module SparkApi
@@ -51,7 +46,7 @@ def reset_config
5146

5247
# Requires supporting ruby files with custom matchers and macros, etc,
5348
# # in spec/support/ and its subdirectories.
54-
Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
49+
Dir[File.expand_path(File.join(File.dirname(__FILE__), 'support', '**', '*.rb'))].each { |f| require f }
5550

5651
RSpec.configure do |config|
5752

@@ -66,6 +61,6 @@ def reset_config
6661
config.color = true
6762
end
6863

69-
def jruby?
64+
def jruby?
7065
RUBY_PLATFORM == "java"
7166
end

0 commit comments

Comments
 (0)