Skip to content

Commit

Permalink
Merge pull request #178 from sparkapi/yaml_fix
Browse files Browse the repository at this point in the history
Adding ruby 3.1 support
  • Loading branch information
philreindl authored Jan 11, 2022
2 parents 5f0072a + e21a4fe commit 5b82564
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby: [ '2.5', '2.6', '2.7', '3.0' ]
ruby: [ '2.5', '2.6', '2.7', '3.0', '3.1' ]

steps:
- name: repo checkout
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v1.6.0
- Adding support for Ruby 3.1
- Add support for psych 4.0 yaml loading
- Lock Faraday down to < 2.0

v1.5.6
- Modify usage of HighLine so that it does not pollute the global namespace

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.6
1.6.0
4 changes: 2 additions & 2 deletions lib/spark_api/authentication/oauth2_impl/cli_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def filename

def load_file
yaml = {}
begin
yaml = YAML.load(File.open(filename))
begin
yaml = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(File.open(filename)) : YAML.load(File.open(filename))
yaml = {} if yaml == false
rescue => e
puts "no file: #{e.message}"
Expand Down
4 changes: 3 additions & 1 deletion lib/spark_api/configuration/yaml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ def initialize(filename=nil)
def load_file(file)
@file = file
@name = File.basename(file, ".yml")
config = YAML.load(ERB.new(File.read(file)).result)[api_env]

erb_file = ERB.new(File.read(file)).result
config = (YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(erb_file) : YAML.load(erb_file))[api_env]
config["oauth2"] == true ? load_oauth2(config) : load_api_auth(config)
rescue => e
SparkApi.logger().error("Unable to load config file #{file}[#{api_env}]")
Expand Down
2 changes: 1 addition & 1 deletion spark_api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Gem::Specification.new do |s|
s.executables = ["spark_api"]
s.require_paths = ["lib"]

s.add_dependency 'faraday', '>= 0.17.3'
s.add_dependency 'faraday', '>= 0.17.3', '< 2.0'
s.add_dependency 'multi_json', '~> 1.0'
s.add_dependency 'json', '>= 1.7'
s.add_dependency 'builder', '>= 2.1.2', '< 4.0.0'
Expand Down
21 changes: 8 additions & 13 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
require 'simplecov'
require 'simplecov-rcov'
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
SimpleCov.start do
add_filter '/vendor'
add_filter '/spec'
add_filter '/test'
unless SimpleCov.running # Hack to prevent starting SimpleCov multiple times see: https://github.com/simplecov-ruby/simplecov/issues/1003
SimpleCov.start do
add_filter '/vendor'
add_filter '/spec'
add_filter '/test'
end
end
end

Expand All @@ -21,13 +23,6 @@

require 'spark_api'

if ENV['COVERAGE'] == "on"
require 'simplecov'
require 'simplecov-rcov'
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
SimpleCov.start { add_filter %w(/vendor /spec /test) }
end

FileUtils.mkdir 'log' unless File.exists? 'log'

module SparkApi
Expand All @@ -51,7 +46,7 @@ def reset_config

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

RSpec.configure do |config|

Expand All @@ -66,6 +61,6 @@ def reset_config
config.color = true
end

def jruby?
def jruby?
RUBY_PLATFORM == "java"
end

0 comments on commit 5b82564

Please sign in to comment.