Skip to content

Commit 0588bee

Browse files
authored
Merge pull request #1487 from olleolleolle/prefer-ruby-2-dir
refactor: Use Ruby 2's __dir__ where possible
2 parents 20c9cb4 + 64b059d commit 0588bee

File tree

8 files changed

+11
-10
lines changed

8 files changed

+11
-10
lines changed

CHANGELOG.rdoc

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Code Improvements:
1717
* refactor: Use Dir.glob only once in gemspec's "files" directive @olleolleolle
1818
* Configure RSpec's zero-monkey patching mode @olleolleolle
1919
* Added support for JRuby 9.4 @mikel
20+
* Prefer `__dir__` @olleolleolle
2021

2122
Bug Fixes:
2223

Rakefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
if !ENV["APPRAISAL_INITIALIZED"] && !ENV["CI"]
2-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __FILE__)
2+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('Gemfile', __dir__)
33
end
44
require 'rubygems'
55
require 'bundler/setup'

lib/mail/multibyte/unicode.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ class << self
375375

376376
# Returns the directory in which the data files are stored
377377
def self.dirname
378-
File.dirname(__FILE__) + '/../values/'
378+
__dir__ + '/../values/'
379379
end
380380

381381
# Returns the filename for the data file for this version

rakelib/corpus.rake

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ require 'benchmark'
33
namespace :corpus do
44

55
task :load_mail do
6-
require File.expand_path('../../spec/environment', __FILE__)
6+
require File.expand_path('../spec/environment', __dir__)
77
require 'mail'
88
end
99

spec/environment.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
2-
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2+
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
33

44
begin
55
require 'byebug'

spec/mail/network/delivery_methods/file_delivery_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
end
2626

2727
describe "general usage" do
28-
tmpdir = File.expand_path('../../../../tmp/mail', __FILE__)
28+
tmpdir = File.expand_path('../../../tmp/mail', __dir__)
2929

3030
it "should send an email to a file" do
3131
Mail.defaults do

spec/mail/network_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class MyRetriever; def initialize(settings); end; end
138138

139139
it "should be able to change the delivery_method and pass in settings" do
140140
mail = Mail.new
141-
tmpdir = File.expand_path('../../../tmp/mail', __FILE__)
141+
tmpdir = File.expand_path('../../tmp/mail', __dir__)
142142
mail.delivery_method :file, :location => tmpdir
143143
expect(mail.delivery_method.class).to eq Mail::FileDelivery
144144
expect(mail.delivery_method.settings).to eql({:location => tmpdir,

spec/spec_helper.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# encoding: utf-8
22
# frozen_string_literal: true
3-
require File.expand_path('../environment', __FILE__)
3+
require File.expand_path('environment', __dir__)
44

55
unless defined?(MAIL_ROOT)
66
$stderr.puts("Running Specs under Ruby Version #{RUBY_VERSION}")
7-
MAIL_ROOT = File.join(File.dirname(__FILE__), '../')
7+
MAIL_ROOT = File.join(__dir__, '../')
88
end
99

1010
unless defined?(SPEC_ROOT)
11-
SPEC_ROOT = File.join(File.dirname(__FILE__))
11+
SPEC_ROOT = __dir__
1212
end
1313

1414
unless defined?(MAIL_SPEC_SUITE_RUNNING)
@@ -17,7 +17,7 @@
1717
end
1818

1919
require 'rspec'
20-
require File.join(File.dirname(__FILE__), 'matchers', 'break_down_to')
20+
require File.join(__dir__, 'matchers', 'break_down_to')
2121

2222
require 'mail'
2323

0 commit comments

Comments
 (0)