Skip to content

Commit 2e09691

Browse files
Merge pull request #7258 from rubygems/more-cleanups
More cleanups
2 parents 5114fdc + 59a8538 commit 2e09691

File tree

10 files changed

+12
-97
lines changed

10 files changed

+12
-97
lines changed

bundler/lib/bundler/cli/common.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ def self.select_spec(name, regex_match = nil)
7979
end
8080

8181
def self.default_gem_spec(name)
82-
return unless Gem::Specification.respond_to?(:find_all_by_name)
8382
gem_spec = Gem::Specification.find_all_by_name(name).last
8483
gem_spec if gem_spec&.default_gem?
8584
end

bundler/lib/bundler/fetcher.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def fetch_spec(spec)
113113

114114
uri = Bundler::URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz")
115115
spec = if uri.scheme == "file"
116-
path = Bundler.rubygems.correct_for_windows_path(uri.path)
116+
path = Gem::Util.correct_for_windows_path(uri.path)
117117
Bundler.safe_load_marshal Bundler.rubygems.inflate(Gem.read_binary(path))
118118
elsif cached_spec_path = gemspec_cached_path(spec_file_name)
119119
Bundler.load_gemspec(cached_spec_path)

bundler/lib/bundler/installer.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def installation_parallelization(options)
214214
end
215215

216216
def load_plugins
217-
Bundler.rubygems.load_plugins
217+
Gem.load_plugins
218218

219219
requested_path_gems = @definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
220220
path_plugin_files = requested_path_gems.map do |spec|
@@ -223,8 +223,8 @@ def load_plugins
223223
error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
224224
raise Gem::InvalidSpecificationException, error_message
225225
end.flatten
226-
Bundler.rubygems.load_plugin_files(path_plugin_files)
227-
Bundler.rubygems.load_env_plugins
226+
Gem.load_plugin_files(path_plugin_files)
227+
Gem.load_env_plugins
228228
end
229229

230230
def ensure_specs_are_compatible!

bundler/lib/bundler/plugin.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def register_plugin(name, spec, optional_plugin = false)
307307
@hooks_by_event = Hash.new {|h, k| h[k] = [] }
308308

309309
load_paths = spec.load_paths
310-
Bundler.rubygems.add_to_load_path(load_paths)
310+
Gem.add_to_load_path(*load_paths)
311311
path = Pathname.new spec.full_gem_path
312312

313313
begin
@@ -342,7 +342,7 @@ def load_plugin(name)
342342
# done to avoid conflicts
343343
path = index.plugin_path(name)
344344

345-
Bundler.rubygems.add_to_load_path(index.load_paths(name))
345+
Gem.add_to_load_path(*index.load_paths(name))
346346

347347
load path.join(PLUGIN_FILE_NAME)
348348

bundler/lib/bundler/rubygems_ext.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,4 @@ def lock_name
325325
end
326326
end
327327
end
328-
329-
require "rubygems/util"
330-
331-
Util.singleton_class.module_eval do
332-
remove_method :glob_files_in_dir
333-
334-
def glob_files_in_dir(glob, base_path)
335-
Dir.glob(glob, base: base_path).map! {|f| File.expand_path(f, base_path) }
336-
end
337-
end
338328
end

bundler/lib/bundler/rubygems_integration.rb

Lines changed: 5 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@
44

55
module Bundler
66
class RubygemsIntegration
7-
if defined?(Gem::Ext::Builder::CHDIR_MONITOR)
8-
EXT_LOCK = Gem::Ext::Builder::CHDIR_MONITOR
9-
else
10-
require "monitor"
7+
require "monitor"
118

12-
EXT_LOCK = Monitor.new
13-
end
9+
EXT_LOCK = Monitor.new
1410

1511
def initialize
1612
@replaced_methods = {}
17-
backport_ext_builder_monitor
1813
end
1914

2015
def version
@@ -43,18 +38,6 @@ def loaded_specs(name)
4338
Gem.loaded_specs[name]
4439
end
4540

46-
def add_to_load_path(paths)
47-
return Gem.add_to_load_path(*paths) if Gem.respond_to?(:add_to_load_path)
48-
49-
if insert_index = Gem.load_path_insert_index
50-
# Gem directories must come after -I and ENV['RUBYLIB']
51-
$LOAD_PATH.insert(insert_index, *paths)
52-
else
53-
# We are probably testing in core, -I and RUBYLIB don't apply
54-
$LOAD_PATH.unshift(*paths)
55-
end
56-
end
57-
5841
def mark_loaded(spec)
5942
if spec.respond_to?(:activated=)
6043
current = Gem.loaded_specs[spec.name]
@@ -116,16 +99,6 @@ def inflate(obj)
11699
Gem::Util.inflate(obj)
117100
end
118101

119-
def correct_for_windows_path(path)
120-
if Gem::Util.respond_to?(:correct_for_windows_path)
121-
Gem::Util.correct_for_windows_path(path)
122-
elsif path[0].chr == "/" && path[1].chr =~ /[a-z]/i && path[2].chr == ":"
123-
path[1..-1]
124-
else
125-
path
126-
end
127-
end
128-
129102
def gem_dir
130103
Gem.dir
131104
end
@@ -161,7 +134,7 @@ def gem_cache
161134
def spec_cache_dirs
162135
@spec_cache_dirs ||= begin
163136
dirs = gem_path.map {|dir| File.join(dir, "specifications") }
164-
dirs << Gem.spec_cache_dir if Gem.respond_to?(:spec_cache_dir) # Not in RubyGems 2.0.3 or earlier
137+
dirs << Gem.spec_cache_dir
165138
dirs.uniq.select {|dir| File.directory? dir }
166139
end
167140
end
@@ -183,18 +156,6 @@ def loaded_gem_paths
183156
loaded_gem_paths.flatten
184157
end
185158

186-
def load_plugins
187-
Gem.load_plugins if Gem.respond_to?(:load_plugins)
188-
end
189-
190-
def load_plugin_files(files)
191-
Gem.load_plugin_files(files) if Gem.respond_to?(:load_plugin_files)
192-
end
193-
194-
def load_env_plugins
195-
Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins)
196-
end
197-
198159
def ui=(obj)
199160
Gem::DefaultUserInteraction.ui = obj
200161
end
@@ -480,7 +441,6 @@ def download_gem(spec, uri, cache_dir, fetcher)
480441

481442
begin
482443
remote_gem_path = uri + "gems/#{gem_file_name}"
483-
remote_gem_path = remote_gem_path.to_s if provides?("< 3.2.0.rc.1")
484444

485445
SharedHelpers.filesystem_access(local_gem_path) do
486446
fetcher.cache_update_path remote_gem_path, local_gem_path
@@ -514,25 +474,6 @@ def all_specs
514474
end
515475
end
516476

517-
def backport_ext_builder_monitor
518-
# So we can avoid requiring "rubygems/ext" in its entirety
519-
Gem.module_eval <<-RUBY, __FILE__, __LINE__ + 1
520-
module Ext
521-
end
522-
RUBY
523-
524-
require "rubygems/ext/builder"
525-
526-
Gem::Ext::Builder.class_eval do
527-
unless const_defined?(:CHDIR_MONITOR)
528-
const_set(:CHDIR_MONITOR, EXT_LOCK)
529-
end
530-
531-
remove_const(:CHDIR_MUTEX) if const_defined?(:CHDIR_MUTEX)
532-
const_set(:CHDIR_MUTEX, const_get(:CHDIR_MONITOR))
533-
end
534-
end
535-
536477
def find_bundler(version)
537478
find_name("bundler").find {|s| s.version.to_s == version }
538479
end
@@ -541,14 +482,8 @@ def find_name(name)
541482
Gem::Specification.stubs_for(name).map(&:to_spec)
542483
end
543484

544-
if Gem::Specification.respond_to?(:default_stubs)
545-
def default_stubs
546-
Gem::Specification.default_stubs("*.gemspec")
547-
end
548-
else
549-
def default_stubs
550-
Gem::Specification.send(:default_stubs, "*.gemspec")
551-
end
485+
def default_stubs
486+
Gem::Specification.default_stubs("*.gemspec")
552487
end
553488
end
554489

bundler/lib/bundler/runtime.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def setup(*groups)
2828
spec.load_paths.reject {|path| $LOAD_PATH.include?(path) }
2929
end.reverse.flatten
3030

31-
Bundler.rubygems.add_to_load_path(load_paths)
31+
Gem.add_to_load_path(*load_paths)
3232

3333
setup_manpath
3434

bundler/spec/bundler/plugin/installer_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
describe "cli install" do
77
it "uses Gem.sources when non of the source is provided" do
88
sources = double(:sources)
9-
Bundler.settings # initialize it before we have to touch rubygems.ext_lock
109
allow(Gem).to receive(:sources) { sources }
1110

1211
allow(installer).to receive(:install_rubygems).

bundler/spec/bundler/rubygems_integration_spec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# frozen_string_literal: true
22

33
RSpec.describe Bundler::RubygemsIntegration do
4-
it "uses the same chdir lock as rubygems" do
5-
expect(Bundler.rubygems.ext_lock).to eq(Gem::Ext::Builder::CHDIR_MONITOR)
6-
end
7-
84
context "#validate" do
95
let(:spec) do
106
Gem::Specification.new do |s|

bundler/spec/bundler/shared_helpers_spec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
# frozen_string_literal: true
22

33
RSpec.describe Bundler::SharedHelpers do
4-
let(:ext_lock_double) { double(:ext_lock) }
5-
64
before do
75
pwd_stub
8-
allow(Bundler.rubygems).to receive(:ext_lock).and_return(ext_lock_double)
9-
allow(ext_lock_double).to receive(:synchronize) {|&block| block.call }
106
end
117

128
let(:pwd_stub) { allow(subject).to receive(:pwd).and_return(bundled_app) }

0 commit comments

Comments
 (0)