From 7b8bc771522a43e43e687da3e80e1ba4b2ce47a5 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Tue, 7 Jun 2022 15:52:31 +0200 Subject: [PATCH] refactor: Prefer __dir__ --- lib/sepa_king/message.rb | 2 +- sepa_king.gemspec | 2 +- spec/spec_helper.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sepa_king/message.rb b/lib/sepa_king/message.rb index 98e80c7..bdd3084 100644 --- a/lib/sepa_king/message.rb +++ b/lib/sepa_king/message.rb @@ -161,7 +161,7 @@ def transaction_group(transaction) end def validate_final_document!(document, schema_name) - xsd = Nokogiri::XML::Schema(File.read(File.expand_path("../../../lib/schema/#{schema_name}.xsd", __FILE__))) + xsd = Nokogiri::XML::Schema(File.read(File.expand_path("../../lib/schema/#{schema_name}.xsd", __dir__))) errors = xsd.validate(document).map { |error| error.message } raise SEPA::Error.new("Incompatible with schema #{schema_name}: #{errors.join(', ')}") if errors.any? end diff --git a/sepa_king.gemspec b/sepa_king.gemspec index bab196a..cfb147f 100644 --- a/sepa_king.gemspec +++ b/sepa_king.gemspec @@ -1,5 +1,5 @@ # coding: utf-8 -lib = File.expand_path('../lib', __FILE__) +lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'sepa_king/version' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9939da8..403fe2e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -18,7 +18,7 @@ # 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(__dir__, 'support', '**', '*.rb'))].each {|f| require f} # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config|