Skip to content

Commit

Permalink
Prefer __dir__ over File.dirname(__FILE__) (#104)
Browse files Browse the repository at this point in the history
It is shorter and looks a whole lot cleaner
  • Loading branch information
herwinw authored and lfittl committed Oct 2, 2018
1 parent 9836396 commit feec888
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ task test: :spec
task lint: :rubocop

task :clean do
FileUtils.rm_rf File.join(File.dirname(__FILE__), 'tmp/')
FileUtils.rm_f Dir.glob(File.join(File.dirname(__FILE__), 'ext/pg_query/*.o'))
FileUtils.rm_f File.join(File.dirname(__FILE__), 'lib/pg_query/pg_query.bundle')
FileUtils.rm_rf File.join(__dir__, 'tmp/')
FileUtils.rm_f Dir.glob(File.join(__dir__, 'ext/pg_query/*.o'))
FileUtils.rm_f File.join(__dir__, 'lib/pg_query/pg_query.bundle')
end
4 changes: 2 additions & 2 deletions ext/pg_query/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

workdir = Dir.pwd
libdir = File.join(workdir, 'libpg_query-' + LIB_PG_QUERY_TAG)
gemdir = File.join(File.dirname(__FILE__), '../..')
gemdir = File.join(__dir__, '../..')
libfile = libdir + '/libpg_query.a'

unless File.exist?("#{workdir}/libpg_query.tar.gz")
Expand Down Expand Up @@ -36,7 +36,7 @@
$LIBPATH << libdir
$CFLAGS << " -I #{libdir} -O3 -Wall -fno-strict-aliasing -fwrapv -g"

SYMFILE = File.join(File.dirname(__FILE__), 'pg_query_ruby.sym')
SYMFILE = File.join(__dir__, 'pg_query_ruby.sym')
if RUBY_PLATFORM =~ /darwin/
$DLDFLAGS << " -Wl,-exported_symbols_list #{SYMFILE}" unless defined?(::Rubinius)
else
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/fingerprint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def fingerprint_parts(qstr)
end

def fingerprint_defs
@fingerprint_defs ||= JSON.parse File.read(File.join(File.dirname(__FILE__), '../files/fingerprint.json'))
@fingerprint_defs ||= JSON.parse File.read(File.join(__dir__, '../files/fingerprint.json'))
end

describe PgQuery, "#fingerprint" do
Expand Down

0 comments on commit feec888

Please sign in to comment.