Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Auto merge of #6503 - koic:use_dir_instead_of_file_in_newgem_template…
Browse files Browse the repository at this point in the history
…, r=hsbt

Use `__dir__` instead of `__FILE__` in newgem.gemspec template

Since Ruby 2.0 we've had `__dir__` as well as `__FILE__`.

The initial gem codes written with `bundle gem` using Ruby 2.0 or higher is an old description using `__FILE__`.

Ruby 1.9 is EOL, so I think that there is not much Gem to start developed using it.

This PR uses `__dir__` when starting Gem development (i.e. `bundle gem`) using Ruby 2.0 or higher version.

(cherry picked from commit 0c5d3b8)
  • Loading branch information
bundlerbot authored and colby-swandale committed Mar 23, 2019
1 parent fa15029 commit 42192fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/bundler/templates/newgem/newgem.gemspec.tt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<%- if RUBY_VERSION < "2.0.0" -%>
# coding: utf-8
<%- end -%>

lib = File.expand_path("../lib", __FILE__)
<%- else -%>
lib = File.expand_path("lib", __dir__)
<%- end -%>
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "<%= config[:namespaced_path] %>/version"

Expand Down
4 changes: 4 additions & 0 deletions lib/bundler/templates/newgem/test/test_helper.rb.tt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<%- if RUBY_VERSION < "2.0.0" -%>
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
<%- else -%>
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
<%- end -%>
require "<%= config[:namespaced_path] %>"

require "minitest/autorun"

0 comments on commit 42192fa

Please sign in to comment.