diff options
author | Bundlerbot <bot@bundler.io> | 2019-04-26 17:07:04 +0000 |
---|---|---|
committer | Bundlerbot <bot@bundler.io> | 2019-04-26 17:07:04 +0000 |
commit | 29d856f40b6b5cdbac7ef060dd0a0137e35ba0ac (patch) | |
tree | 70bb5dc915b9d0dd1f13a7402dfe6fc17057f9c4 | |
parent | 6f94959d3cc95bea616c40af7ed516b67dcbd5e0 (diff) | |
parent | 2478e3426180c4f78bafa21a0ca3f5cc4ffb7f8a (diff) | |
download | bundler-29d856f40b6b5cdbac7ef060dd0a0137e35ba0ac.tar.gz |
Merge #7137
7137: Gemspec require relative r=deivid-rodriguez a=deivid-rodriguez
### What was the end-user problem that led to this PR?
This is a follow up to #7100. Gemspec is another place where `require_relative` sounds like a win.
### What is your fix for the problem, implemented in this PR?
My fix changes bundler's gemspec to use `require_relative`, and extracts the relevant change from #4397 to also change the generated gemspec from `bundle gem`.
Co-authored-by: Miklos Fazekas <mfazekas@szemafor.com>
Co-authored-by: David RodrÃguez <deivid.rodriguez@riseup.net>
-rw-r--r-- | bundler.gemspec | 4 | ||||
-rw-r--r-- | lib/bundler/templates/newgem/newgem.gemspec.tt | 4 |
2 files changed, 3 insertions, 5 deletions
diff --git a/bundler.gemspec b/bundler.gemspec index 2711604265..7ebecb6f6f 100644 --- a/bundler.gemspec +++ b/bundler.gemspec @@ -1,10 +1,10 @@ # frozen_string_literal: true begin - require File.expand_path("../lib/bundler/version", __FILE__) + require_relative "lib/bundler/version" rescue LoadError # for Ruby core repository - require File.expand_path("../version", __FILE__) + require_relative "version" end Gem::Specification.new do |s| diff --git a/lib/bundler/templates/newgem/newgem.gemspec.tt b/lib/bundler/templates/newgem/newgem.gemspec.tt index 5505540b9e..18060942c3 100644 --- a/lib/bundler/templates/newgem/newgem.gemspec.tt +++ b/lib/bundler/templates/newgem/newgem.gemspec.tt @@ -1,6 +1,4 @@ -lib = File.expand_path("lib", __dir__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "<%= config[:namespaced_path] %>/version" +require_relative 'lib/<%=config[:namespaced_path]%>/version' Gem::Specification.new do |spec| spec.name = <%= config[:name].inspect %> |