summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2018-04-28 06:37:55 +0000
committerColby Swandale <me@colby.fyi>2019-03-24 01:58:26 +1100
commit42192fa8b5c252803589bfeb57b6de36fc372306 (patch)
tree3b82adaef07749151f654b5433bf157c77ab8a30
parentfa150290b851d2bbf47bfef6fb1637a96098fa31 (diff)
downloadbundler-42192fa8b5c252803589bfeb57b6de36fc372306.tar.gz
Auto merge of #6503 - koic:use_dir_instead_of_file_in_newgem_template, 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 0c5d3b8c1f391aa5175321675ecd91ee6a1f231b)
-rw-r--r--lib/bundler/templates/newgem/newgem.gemspec.tt4
-rw-r--r--lib/bundler/templates/newgem/test/test_helper.rb.tt4
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/bundler/templates/newgem/newgem.gemspec.tt b/lib/bundler/templates/newgem/newgem.gemspec.tt
index faf6f7bbc5..113bf82eb2 100644
--- a/lib/bundler/templates/newgem/newgem.gemspec.tt
+++ b/lib/bundler/templates/newgem/newgem.gemspec.tt
@@ -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"
diff --git a/lib/bundler/templates/newgem/test/test_helper.rb.tt b/lib/bundler/templates/newgem/test/test_helper.rb.tt
index 725e3e4647..335c4704ec 100644
--- a/lib/bundler/templates/newgem/test/test_helper.rb.tt
+++ b/lib/bundler/templates/newgem/test/test_helper.rb.tt
@@ -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"