diff --git a/Gemfile b/Gemfile index 19f70996a..1649bb593 100644 --- a/Gemfile +++ b/Gemfile @@ -64,6 +64,7 @@ gem 'sidekiq', require: nil gem 'simplecov', require: false gem 'simplecov-cobertura', require: false gem 'sucker_punch', '~> 2.0', require: nil +gem 'syck', require: nil if !defined?(JRUBY_VERSION) gem 'yard', require: nil gem 'yarjuf' @@ -125,10 +126,8 @@ if RUBY_PLATFORM == 'java' end elsif frameworks_versions['rails'] =~ /^(4|5)/ gem 'sqlite3', '~> 1.3.6' -elsif RUBY_VERSION < '2.7' - gem 'sqlite3', '~> 1.4.4' else - gem 'sqlite3' + gem 'sqlite3', '~> 1.4.4' end # sneakers main only supports >=2.5.0 diff --git a/lib/elastic_apm/config.rb b/lib/elastic_apm/config.rb index 0566936cd..275653cd3 100644 --- a/lib/elastic_apm/config.rb +++ b/lib/elastic_apm/config.rb @@ -256,7 +256,7 @@ def load_config_file read = File.read(config_file) evaled = ERB.new(read).result - YAML.safe_load(evaled) + YAML.method_defined?(:safe_load) ? YAML.safe_load(evaled) : YAML.load(evaled) end def load_env diff --git a/spec/integration/syck_spec.rb b/spec/integration/syck_spec.rb new file mode 100644 index 000000000..2110b0d26 --- /dev/null +++ b/spec/integration/syck_spec.rb @@ -0,0 +1,31 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# frozen_string_literal: true + +if !defined?(JRUBY_VERSION) + require 'integration_helper' + require 'syck' + + RSpec.describe 'Syck YAML' do + + it 'loads from config file' do + config = ElasticAPM::Config.new(config_file: 'spec/fixtures/elastic_apm.yml') + expect(config.server_url).to eq 'somewhere-config.com' + end + end +end