Skip to content

Commit 45dd287

Browse files
authored
Refactor and cleanup bundle wrapper (heroku#1602)
* Refactor report to kwarg * Refactor gemfile_path to kwarg * Refactor bundler_path to kwarg * Remove unused options * Remove unused code * Remove unused code
1 parent ae8bb3d commit 45dd287

4 files changed

Lines changed: 10 additions & 30 deletions

File tree

hatchet.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"rails_versions": [
2424
"sharpstone/rails_lts_23_default_ruby",
2525
"sharpstone/rails3_default_ruby",
26-
"sharpstone/rails4_windows_mri193",
2726
"sharpstone/rails42_default_ruby",
2827
"sharpstone/rails61",
2928
"sharpstone/rails-jsbundling",

hatchet.lock

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
- 984b6d02353519251c2d1e885bf8914a2584f26a
2222
- - "./repos/rails_versions/rails42_default_ruby"
2323
- fbdaf031823f09d1514ec1d55dcb04ca2f4264ca
24-
- - "./repos/rails_versions/rails4_windows_mri193"
25-
- f4c7b6209835050468bbb87827acf652b8f4d8ce
2624
- - "./repos/rails_versions/rails61"
2725
- 47828a3e8c79b7869ca0d9a3afa4be065fa46e96
2826
- - "./repos/rails_versions/rails_8_ruby_schema"

lib/language_pack/helpers/bundler_wrapper.rb

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,15 @@ def initialize(version_hash, major_minor)
101101

102102
attr_reader :bundler_path
103103

104-
def initialize(options = {})
105-
@report = options[:report] || HerokuBuildReport::GLOBAL
104+
def initialize(
105+
bundler_path: nil,
106+
gemfile_path: Pathname.new("./Gemfile"),
107+
report: HerokuBuildReport::GLOBAL
108+
)
109+
@report = report
106110
@bundler_tmp = Pathname.new(Dir.mktmpdir)
107-
@fetcher = options[:fetcher] || LanguagePack::Fetcher.new(LanguagePack::Base::VENDOR_URL) # coupling
108-
@gemfile_path = options[:gemfile_path] || Pathname.new("./Gemfile")
111+
@fetcher = LanguagePack::Fetcher.new(LanguagePack::Base::VENDOR_URL) # coupling
112+
@gemfile_path = gemfile_path
109113
@gemfile_lock_path = Pathname.new("#{@gemfile_path}.lock")
110114

111115
contents = @gemfile_lock_path.read(mode: "rt")
@@ -132,8 +136,8 @@ def initialize(options = {})
132136
)
133137
@dir_name = "bundler-#{@version}"
134138

135-
@bundler_path = options[:bundler_path] || @bundler_tmp.join(@dir_name)
136-
@bundler_tar = options[:bundler_tar] || "bundler/#{@dir_name}.tgz"
139+
@bundler_path = bundler_path || @bundler_tmp.join(@dir_name)
140+
@bundler_tar = "bundler/#{@dir_name}.tgz"
137141
@orig_bundle_gemfile = ENV['BUNDLE_GEMFILE']
138142
@path = Pathname.new("#{@bundler_path}/gems/#{@dir_name}/lib")
139143
end
@@ -162,22 +166,10 @@ def gem_version(name)
162166
end
163167
end
164168

165-
# detects whether the Gemfile.lock contains the Windows platform
166-
# @return [Boolean] true if the Gemfile.lock was created on Windows
167-
def windows_gemfile_lock?
168-
platforms.detect do |platform|
169-
/mingw|mswin/.match(platform.os) if platform.is_a?(Gem::Platform)
170-
end
171-
end
172-
173169
def specs
174170
@specs ||= lockfile_parser.specs.each_with_object({}) {|spec, hash| hash[spec.name] = spec }
175171
end
176172

177-
def platforms
178-
@platforms ||= lockfile_parser.platforms
179-
end
180-
181173
def version
182174
@version
183175
end

spec/helpers/bundler_wrapper_spec.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,6 @@ def wrapper.topic(*args); end # Silence output in tests
110110
end
111111
end
112112

113-
it "detects windows gemfiles" do
114-
Hatchet::App.new("rails4_windows_mri193").in_directory_fork do |dir|
115-
require "bundler"
116-
Bundler.with_unbundled_env do
117-
expect(@bundler.install.windows_gemfile_lock?).to be_truthy
118-
end
119-
end
120-
end
121-
122113
describe "when executing bundler" do
123114
it "handles JRuby pre gemfiles" do
124115
Hatchet::App.new("jruby-minimal").in_directory_fork do |dir|

0 commit comments

Comments
 (0)