rubygems-update 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rubygems-update might be problematic. Click here for more details.
- data.tar.gz.sig +2 -4
- data/ChangeLog +155 -0
- data/Rakefile +20 -5
- data/doc/release_notes/rel_1_3_0.rdoc +125 -0
- data/lib/rubygems.rb +107 -15
- data/lib/rubygems/commands/contents_command.rb +1 -1
- data/lib/rubygems/commands/environment_command.rb +40 -0
- data/lib/rubygems/commands/help_command.rb +2 -2
- data/lib/rubygems/commands/install_command.rb +15 -0
- data/lib/rubygems/commands/lock_command.rb +15 -6
- data/lib/rubygems/commands/outdated_command.rb +1 -1
- data/lib/rubygems/commands/pristine_command.rb +1 -1
- data/lib/rubygems/commands/query_command.rb +14 -9
- data/lib/rubygems/commands/rdoc_command.rb +5 -1
- data/lib/rubygems/commands/specification_command.rb +2 -2
- data/lib/rubygems/commands/unpack_command.rb +1 -1
- data/lib/rubygems/commands/update_command.rb +23 -14
- data/lib/rubygems/commands/which_command.rb +4 -3
- data/lib/rubygems/config_file.rb +25 -3
- data/lib/rubygems/defaults.rb +42 -11
- data/lib/rubygems/dependency_installer.rb +19 -15
- data/lib/rubygems/doc_manager.rb +162 -115
- data/lib/rubygems/ext/builder.rb +2 -2
- data/lib/rubygems/ext/rake_builder.rb +1 -1
- data/lib/rubygems/gem_path_searcher.rb +35 -19
- data/lib/rubygems/indexer.rb +15 -6
- data/lib/rubygems/install_update_options.rb +7 -0
- data/lib/rubygems/installer.rb +85 -9
- data/lib/rubygems/local_remote_options.rb +7 -0
- data/lib/rubygems/package/tar_reader.rb +7 -7
- data/lib/rubygems/platform.rb +1 -18
- data/lib/rubygems/remote_fetcher.rb +45 -54
- data/lib/rubygems/rubygems_version.rb +1 -1
- data/lib/rubygems/source_index.rb +22 -7
- data/lib/rubygems/source_info_cache.rb +9 -0
- data/lib/rubygems/spec_fetcher.rb +18 -20
- data/lib/rubygems/specification.rb +502 -293
- data/lib/rubygems/test_utilities.rb +19 -8
- data/lib/rubygems/uninstaller.rb +60 -26
- data/setup.rb +15 -7
- data/test/gemutilities.rb +84 -0
- data/test/mockgemui.rb +22 -2
- data/test/test_gem.rb +118 -13
- data/test/test_gem_commands_dependency_command.rb +1 -1
- data/test/test_gem_commands_list_command.rb +37 -0
- data/test/test_gem_commands_lock_command.rb +69 -0
- data/test/test_gem_commands_query_command.rb +40 -1
- data/test/test_gem_commands_uninstall_command.rb +60 -0
- data/test/test_gem_config_file.rb +51 -17
- data/test/test_gem_ext_configure_builder.rb +9 -9
- data/test/test_gem_ext_rake_builder.rb +21 -12
- data/test/test_gem_gem_path_searcher.rb +15 -7
- data/test/test_gem_indexer.rb +35 -1
- data/test/test_gem_install_update_options.rb +26 -5
- data/test/test_gem_installer.rb +93 -21
- data/test/test_gem_local_remote_options.rb +12 -0
- data/test/test_gem_platform.rb +6 -13
- data/test/test_gem_remote_fetcher.rb +121 -31
- data/test/test_gem_source_index.rb +74 -21
- data/test/test_gem_source_info_cache.rb +2 -1
- data/test/test_gem_spec_fetcher.rb +13 -3
- data/test/test_gem_specification.rb +13 -7
- data/test/test_gem_uninstaller.rb +25 -2
- metadata +6 -2
- metadata.gz.sig +0 -0
@@ -30,29 +30,40 @@ class Gem::FakeFetcher
|
|
30
30
|
@paths = []
|
31
31
|
end
|
32
32
|
|
33
|
-
def fetch_path
|
33
|
+
def fetch_path path, mtime = nil
|
34
34
|
path = path.to_s
|
35
35
|
@paths << path
|
36
36
|
raise ArgumentError, 'need full URI' unless path =~ %r'^http://'
|
37
|
-
data = @data[path]
|
38
37
|
|
39
|
-
|
40
|
-
raise Gem::RemoteFetcher::FetchError.new(
|
38
|
+
unless @data.key? path then
|
39
|
+
raise Gem::RemoteFetcher::FetchError.new("no data for #{path}", path)
|
41
40
|
end
|
42
41
|
|
43
|
-
data
|
42
|
+
data = @data[path]
|
43
|
+
|
44
|
+
if data.respond_to?(:call) then
|
45
|
+
data.call
|
46
|
+
else
|
47
|
+
if path.to_s =~ /gz$/ and not data.nil? and not data.empty? then
|
48
|
+
data = Gem.gunzip data
|
49
|
+
end
|
50
|
+
|
51
|
+
data
|
52
|
+
end
|
44
53
|
end
|
45
54
|
|
46
55
|
def fetch_size(path)
|
47
56
|
path = path.to_s
|
48
57
|
@paths << path
|
58
|
+
|
49
59
|
raise ArgumentError, 'need full URI' unless path =~ %r'^http://'
|
50
|
-
data = @data[path]
|
51
60
|
|
52
|
-
|
53
|
-
raise Gem::RemoteFetcher::FetchError.new("no data for #{path}",
|
61
|
+
unless @data.key? path then
|
62
|
+
raise Gem::RemoteFetcher::FetchError.new("no data for #{path}", path)
|
54
63
|
end
|
55
64
|
|
65
|
+
data = @data[path]
|
66
|
+
|
56
67
|
data.respond_to?(:call) ? data.call : data.length
|
57
68
|
end
|
58
69
|
|
data/lib/rubygems/uninstaller.rb
CHANGED
@@ -18,9 +18,23 @@ class Gem::Uninstaller
|
|
18
18
|
include Gem::UserInteraction
|
19
19
|
|
20
20
|
##
|
21
|
-
#
|
22
|
-
|
23
|
-
|
21
|
+
# The directory a gem's executables will be installed into
|
22
|
+
|
23
|
+
attr_reader :bin_dir
|
24
|
+
|
25
|
+
##
|
26
|
+
# The gem repository the gem will be installed into
|
27
|
+
|
28
|
+
attr_reader :gem_home
|
29
|
+
|
30
|
+
##
|
31
|
+
# The Gem::Specification for the gem being uninstalled, only set during
|
32
|
+
# #uninstall_gem
|
33
|
+
|
34
|
+
attr_reader :spec
|
35
|
+
|
36
|
+
##
|
37
|
+
# Constructs an uninstaller that will uninstall +gem+
|
24
38
|
|
25
39
|
def initialize(gem, options = {})
|
26
40
|
@gem = gem
|
@@ -31,41 +45,62 @@ class Gem::Uninstaller
|
|
31
45
|
@force_all = options[:all]
|
32
46
|
@force_ignore = options[:ignore]
|
33
47
|
@bin_dir = options[:bin_dir]
|
48
|
+
|
49
|
+
spec_dir = File.join @gem_home, 'specifications'
|
50
|
+
@source_index = Gem::SourceIndex.from_gems_in spec_dir
|
34
51
|
end
|
35
52
|
|
36
53
|
##
|
37
|
-
# Performs the uninstall of the
|
38
|
-
#
|
54
|
+
# Performs the uninstall of the gem. This removes the spec, the Gem
|
55
|
+
# directory, and the cached .gem file.
|
39
56
|
|
40
57
|
def uninstall
|
41
|
-
list =
|
58
|
+
list = @source_index.find_name @gem, @version
|
42
59
|
|
43
60
|
if list.empty? then
|
44
61
|
raise Gem::InstallError, "Unknown gem #{@gem} #{@version}"
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
62
|
+
|
63
|
+
elsif list.size > 1 and @force_all then
|
64
|
+
remove_all list.dup
|
65
|
+
|
66
|
+
elsif list.size > 1 then
|
50
67
|
gem_names = list.collect {|gem| gem.full_name} + ["All versions"]
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
remove_executables(to_remove)
|
68
|
+
|
69
|
+
say
|
70
|
+
gem_name, index = choose_from_list "Select gem to uninstall:", gem_names
|
71
|
+
|
72
|
+
if index == list.size then
|
73
|
+
remove_all list.dup
|
74
|
+
elsif index >= 0 && index < list.size then
|
75
|
+
uninstall_gem list[index], list.dup
|
60
76
|
else
|
61
77
|
say "Error: must enter a number [1-#{list.size+1}]"
|
62
78
|
end
|
63
79
|
else
|
64
|
-
|
65
|
-
remove_executables(list.last)
|
80
|
+
uninstall_gem list.first, list.dup
|
66
81
|
end
|
67
82
|
end
|
68
83
|
|
84
|
+
##
|
85
|
+
# Uninstalls gem +spec+
|
86
|
+
|
87
|
+
def uninstall_gem(spec, specs)
|
88
|
+
@spec = spec
|
89
|
+
|
90
|
+
Gem.pre_uninstall_hooks.each do |hook|
|
91
|
+
hook.call self
|
92
|
+
end
|
93
|
+
|
94
|
+
specs.each { |s| remove_executables s }
|
95
|
+
remove spec, specs
|
96
|
+
|
97
|
+
Gem.post_uninstall_hooks.each do |hook|
|
98
|
+
hook.call self
|
99
|
+
end
|
100
|
+
|
101
|
+
@spec = nil
|
102
|
+
end
|
103
|
+
|
69
104
|
##
|
70
105
|
# Removes installed executables and batch files (windows only) for
|
71
106
|
# +gemspec+.
|
@@ -76,7 +111,7 @@ class Gem::Uninstaller
|
|
76
111
|
if gemspec.executables.size > 0 then
|
77
112
|
bindir = @bin_dir ? @bin_dir : (Gem.bindir @gem_home)
|
78
113
|
|
79
|
-
list =
|
114
|
+
list = @source_index.find_name(gemspec.name).delete_if { |spec|
|
80
115
|
spec.version == gemspec.version
|
81
116
|
}
|
82
117
|
|
@@ -118,7 +153,7 @@ class Gem::Uninstaller
|
|
118
153
|
# NOTE: removes uninstalled gems from +list+.
|
119
154
|
|
120
155
|
def remove_all(list)
|
121
|
-
list.dup.each { |spec|
|
156
|
+
list.dup.each { |spec| uninstall_gem spec, list }
|
122
157
|
end
|
123
158
|
|
124
159
|
##
|
@@ -185,8 +220,7 @@ class Gem::Uninstaller
|
|
185
220
|
def dependencies_ok?(spec)
|
186
221
|
return true if @force_ignore
|
187
222
|
|
188
|
-
|
189
|
-
deplist = Gem::DependencyList.from_source_index source_index
|
223
|
+
deplist = Gem::DependencyList.from_source_index @source_index
|
190
224
|
deplist.ok_to_remove?(spec.full_name) || ask_if_ok(spec)
|
191
225
|
end
|
192
226
|
|
data/setup.rb
CHANGED
@@ -90,14 +90,17 @@ HELP
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
unless install_destdir.empty? then
|
94
|
-
ENV['GEM_HOME'] ||= File.join(install_destdir,
|
95
|
-
Gem.default_dir.sub(/\A[a-z]:/i, ''))
|
96
|
-
end
|
97
|
-
|
98
93
|
require 'fileutils'
|
99
94
|
require 'rbconfig'
|
100
95
|
require 'tmpdir'
|
96
|
+
require 'pathname'
|
97
|
+
|
98
|
+
unless install_destdir.empty? then
|
99
|
+
default_dir = Pathname.new(Gem.default_dir)
|
100
|
+
top_dir = Pathname.new(RbConfig::TOPDIR)
|
101
|
+
ENV['GEM_HOME'] ||= File.join(install_destdir,
|
102
|
+
default_dir.relative_path_from(top_dir))
|
103
|
+
end
|
101
104
|
|
102
105
|
include FileUtils::Verbose
|
103
106
|
|
@@ -134,8 +137,12 @@ else
|
|
134
137
|
end
|
135
138
|
|
136
139
|
unless install_destdir.empty?
|
137
|
-
|
138
|
-
|
140
|
+
top_dir = Pathname.new(RbConfig::TOPDIR)
|
141
|
+
lib_dir_p = Pathname.new(lib_dir)
|
142
|
+
bin_dir_p = Pathname.new(bin_dir)
|
143
|
+
|
144
|
+
lib_dir = File.join install_destdir, lib_dir_p.relative_path_from(top_dir)
|
145
|
+
bin_dir = File.join install_destdir, bin_dir_p.relative_path_from(top_dir)
|
139
146
|
end
|
140
147
|
|
141
148
|
mkdir_p lib_dir
|
@@ -324,3 +331,4 @@ puts "If `gem` was installed by a previous RubyGems installation, you may need"
|
|
324
331
|
puts "to remove it by hand."
|
325
332
|
puts
|
326
333
|
|
334
|
+
|
data/test/gemutilities.rb
CHANGED
@@ -7,6 +7,8 @@
|
|
7
7
|
|
8
8
|
at_exit { $SAFE = 1 }
|
9
9
|
|
10
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
11
|
+
|
10
12
|
require 'fileutils'
|
11
13
|
require 'test/unit'
|
12
14
|
require 'tmpdir'
|
@@ -17,6 +19,10 @@ require 'rubygems/test_utilities'
|
|
17
19
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'mockgemui')
|
18
20
|
|
19
21
|
module Gem
|
22
|
+
def self.searcher=(searcher)
|
23
|
+
MUTEX.synchronize do @searcher = searcher end
|
24
|
+
end
|
25
|
+
|
20
26
|
def self.source_index=(si)
|
21
27
|
@@source_index = si
|
22
28
|
end
|
@@ -24,6 +30,10 @@ module Gem
|
|
24
30
|
def self.win_platform=(val)
|
25
31
|
@@win_platform = val
|
26
32
|
end
|
33
|
+
|
34
|
+
module DefaultUserInteraction
|
35
|
+
@ui = MockGemUi.new
|
36
|
+
end
|
27
37
|
end
|
28
38
|
|
29
39
|
class RubyGemTestCase < Test::Unit::TestCase
|
@@ -83,6 +93,27 @@ class RubyGemTestCase < Test::Unit::TestCase
|
|
83
93
|
'private_key.pem')
|
84
94
|
@public_cert = File.expand_path File.join(File.dirname(__FILE__),
|
85
95
|
'public_cert.pem')
|
96
|
+
|
97
|
+
Gem.post_install_hooks.clear
|
98
|
+
Gem.post_uninstall_hooks.clear
|
99
|
+
Gem.pre_install_hooks.clear
|
100
|
+
Gem.pre_uninstall_hooks.clear
|
101
|
+
|
102
|
+
Gem.post_install do |installer|
|
103
|
+
@post_install_hook_arg = installer
|
104
|
+
end
|
105
|
+
|
106
|
+
Gem.post_uninstall do |uninstaller|
|
107
|
+
@post_uninstall_hook_arg = uninstaller
|
108
|
+
end
|
109
|
+
|
110
|
+
Gem.pre_install do |installer|
|
111
|
+
@pre_install_hook_arg = installer
|
112
|
+
end
|
113
|
+
|
114
|
+
Gem.pre_uninstall do |uninstaller|
|
115
|
+
@pre_uninstall_hook_arg = uninstaller
|
116
|
+
end
|
86
117
|
end
|
87
118
|
|
88
119
|
def teardown
|
@@ -386,5 +417,58 @@ class RubyGemTestCase < Test::Unit::TestCase
|
|
386
417
|
self.class.process_based_port
|
387
418
|
end
|
388
419
|
|
420
|
+
def build_rake_in
|
421
|
+
gem_ruby = Gem.ruby
|
422
|
+
ruby = @@ruby
|
423
|
+
Gem.module_eval {@ruby = ruby}
|
424
|
+
env_rake = ENV["rake"]
|
425
|
+
ENV["rake"] = @@rake
|
426
|
+
yield @@rake
|
427
|
+
ensure
|
428
|
+
Gem.module_eval {@ruby = gem_ruby}
|
429
|
+
if env_rake
|
430
|
+
ENV["rake"] = env_rake
|
431
|
+
else
|
432
|
+
ENV.delete("rake")
|
433
|
+
end
|
434
|
+
end
|
435
|
+
|
436
|
+
def self.rubybin
|
437
|
+
if ruby = ENV["RUBY"]
|
438
|
+
return ruby
|
439
|
+
end
|
440
|
+
ruby = "ruby"
|
441
|
+
rubyexe = ruby+".exe"
|
442
|
+
3.times do
|
443
|
+
if File.exist? ruby and File.executable? ruby and !File.directory? ruby
|
444
|
+
return File.expand_path(ruby)
|
445
|
+
end
|
446
|
+
if File.exist? rubyexe and File.executable? rubyexe
|
447
|
+
return File.expand_path(rubyexe)
|
448
|
+
end
|
449
|
+
ruby = File.join("..", ruby)
|
450
|
+
end
|
451
|
+
begin
|
452
|
+
require "rbconfig"
|
453
|
+
File.join(
|
454
|
+
RbConfig::CONFIG["bindir"],
|
455
|
+
RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"]
|
456
|
+
)
|
457
|
+
rescue LoadError
|
458
|
+
"ruby"
|
459
|
+
end
|
460
|
+
end
|
461
|
+
|
462
|
+
@@ruby = rubybin
|
463
|
+
env_rake = ENV['rake']
|
464
|
+
ruby19_rake = @@ruby + " " + File.expand_path("../../../bin/rake", __FILE__)
|
465
|
+
@@rake = if env_rake then
|
466
|
+
ENV["rake"]
|
467
|
+
elsif File.exist? ruby19_rake then
|
468
|
+
ruby19_rake
|
469
|
+
else
|
470
|
+
'rake'
|
471
|
+
end
|
472
|
+
|
389
473
|
end
|
390
474
|
|
data/test/mockgemui.rb
CHANGED
@@ -12,8 +12,28 @@ require 'rubygems/user_interaction'
|
|
12
12
|
class MockGemUi < Gem::StreamUI
|
13
13
|
class TermError < RuntimeError; end
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
module TTY
|
16
|
+
|
17
|
+
attr_accessor :tty
|
18
|
+
|
19
|
+
def tty?()
|
20
|
+
@tty = true unless defined?(@tty)
|
21
|
+
@tty
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(input = "")
|
27
|
+
ins = StringIO.new input
|
28
|
+
outs = StringIO.new
|
29
|
+
errs = StringIO.new
|
30
|
+
|
31
|
+
ins.extend TTY
|
32
|
+
outs.extend TTY
|
33
|
+
errs.extend TTY
|
34
|
+
|
35
|
+
super ins, outs, errs
|
36
|
+
|
17
37
|
@terminated = false
|
18
38
|
end
|
19
39
|
|
data/test/test_gem.rb
CHANGED
@@ -3,6 +3,7 @@ require 'rubygems'
|
|
3
3
|
require 'rubygems/gem_openssl'
|
4
4
|
require 'rubygems/installer'
|
5
5
|
require 'pathname'
|
6
|
+
require 'tmpdir'
|
6
7
|
|
7
8
|
class TestGem < RubyGemTestCase
|
8
9
|
|
@@ -44,7 +45,12 @@ class TestGem < RubyGemTestCase
|
|
44
45
|
|
45
46
|
def test_self_bindir_default_dir
|
46
47
|
default = Gem.default_dir
|
47
|
-
bindir =
|
48
|
+
bindir = if defined?(RUBY_FRAMEWORK_VERSION) then
|
49
|
+
'/usr/bin'
|
50
|
+
else
|
51
|
+
Config::CONFIG['bindir']
|
52
|
+
end
|
53
|
+
|
48
54
|
assert_equal bindir, Gem.bindir(default)
|
49
55
|
assert_equal bindir, Gem.bindir(Pathname.new(default))
|
50
56
|
end
|
@@ -217,6 +223,36 @@ class TestGem < RubyGemTestCase
|
|
217
223
|
Gem.ssl_available = orig_Gem_ssl_available
|
218
224
|
end
|
219
225
|
|
226
|
+
def test_self_find_files
|
227
|
+
foo1 = quick_gem 'foo', '1' do |s|
|
228
|
+
s.files << 'lib/foo/discover.rb'
|
229
|
+
end
|
230
|
+
|
231
|
+
foo2 = quick_gem 'foo', '2' do |s|
|
232
|
+
s.files << 'lib/foo/discover.rb'
|
233
|
+
end
|
234
|
+
|
235
|
+
path = File.join 'gems', foo1.full_name, 'lib', 'foo', 'discover.rb'
|
236
|
+
write_file(path) { |fp| fp.puts "# #{path}" }
|
237
|
+
|
238
|
+
path = File.join 'gems', foo2.full_name, 'lib', 'foo', 'discover.rb'
|
239
|
+
write_file(path) { |fp| fp.puts "# #{path}" }
|
240
|
+
|
241
|
+
@fetcher = Gem::FakeFetcher.new
|
242
|
+
Gem::RemoteFetcher.fetcher = @fetcher
|
243
|
+
|
244
|
+
Gem.source_index = util_setup_spec_fetcher foo1, foo2
|
245
|
+
|
246
|
+
Gem.searcher = nil
|
247
|
+
|
248
|
+
expected = [
|
249
|
+
File.join(foo1.full_gem_path, 'lib', 'foo', 'discover.rb'),
|
250
|
+
File.join(foo2.full_gem_path, 'lib', 'foo', 'discover.rb'),
|
251
|
+
]
|
252
|
+
|
253
|
+
assert_equal expected, Gem.find_files('foo/discover').sort
|
254
|
+
end
|
255
|
+
|
220
256
|
def test_self_latest_load_paths
|
221
257
|
util_make_gems
|
222
258
|
|
@@ -260,36 +296,38 @@ class TestGem < RubyGemTestCase
|
|
260
296
|
unless win_platform?
|
261
297
|
def test_self_path_APPLE_GEM_HOME
|
262
298
|
Gem.clear_paths
|
263
|
-
|
264
|
-
|
265
|
-
|
299
|
+
apple_gem_home = File.join @tempdir, 'apple_gem_home'
|
300
|
+
Gem.const_set :APPLE_GEM_HOME, apple_gem_home
|
301
|
+
|
302
|
+
assert Gem.path.include?(apple_gem_home)
|
266
303
|
ensure
|
267
304
|
Gem.send :remove_const, :APPLE_GEM_HOME
|
268
305
|
end
|
269
|
-
|
306
|
+
|
270
307
|
def test_self_path_APPLE_GEM_HOME_GEM_PATH
|
271
308
|
Gem.clear_paths
|
272
309
|
ENV['GEM_PATH'] = @gemhome
|
273
|
-
|
274
|
-
|
275
|
-
|
310
|
+
apple_gem_home = File.join @tempdir, 'apple_gem_home'
|
311
|
+
Gem.const_set :APPLE_GEM_HOME, apple_gem_home
|
312
|
+
|
313
|
+
assert !Gem.path.include?(apple_gem_home)
|
276
314
|
ensure
|
277
315
|
Gem.send :remove_const, :APPLE_GEM_HOME
|
278
316
|
end
|
279
317
|
end
|
280
318
|
|
281
319
|
def test_self_path_ENV_PATH
|
282
|
-
Gem.
|
320
|
+
Gem.send :set_paths, nil
|
283
321
|
path_count = Gem.path.size
|
284
|
-
path_count -= 1 if defined? APPLE_GEM_HOME
|
285
322
|
Gem.clear_paths
|
286
|
-
util_ensure_gem_dirs
|
287
323
|
|
288
324
|
ENV['GEM_PATH'] = @additional.join(File::PATH_SEPARATOR)
|
289
325
|
|
290
326
|
assert_equal @additional, Gem.path[0,2]
|
291
|
-
|
292
|
-
|
327
|
+
|
328
|
+
assert_equal path_count + @additional.size, Gem.path.size,
|
329
|
+
"extra path components: #{Gem.path[2..-1].inspect}"
|
330
|
+
assert_equal Gem.dir, Gem.path.last
|
293
331
|
end
|
294
332
|
|
295
333
|
def test_self_path_duplicate
|
@@ -337,6 +375,7 @@ class TestGem < RubyGemTestCase
|
|
337
375
|
|
338
376
|
file_name = File.expand_path __FILE__
|
339
377
|
prefix = File.dirname File.dirname(file_name)
|
378
|
+
prefix = File.dirname prefix if File.basename(prefix) == 'test'
|
340
379
|
|
341
380
|
Gem::ConfigMap[:libdir] = prefix
|
342
381
|
|
@@ -350,6 +389,7 @@ class TestGem < RubyGemTestCase
|
|
350
389
|
|
351
390
|
file_name = File.expand_path __FILE__
|
352
391
|
prefix = File.dirname File.dirname(file_name)
|
392
|
+
prefix = File.dirname prefix if File.basename(prefix) == 'test'
|
353
393
|
|
354
394
|
Gem::ConfigMap[:sitelibdir] = prefix
|
355
395
|
|
@@ -386,6 +426,44 @@ class TestGem < RubyGemTestCase
|
|
386
426
|
Gem.required_location("a", "code.rb", "= 2")
|
387
427
|
end
|
388
428
|
|
429
|
+
def test_self_ruby_escaping_spaces_in_path
|
430
|
+
orig_ruby = Gem.ruby
|
431
|
+
orig_bindir = Gem::ConfigMap[:bindir]
|
432
|
+
orig_ruby_install_name = Gem::ConfigMap[:ruby_install_name]
|
433
|
+
orig_exe_ext = Gem::ConfigMap[:EXEEXT]
|
434
|
+
|
435
|
+
Gem::ConfigMap[:bindir] = "C:/Ruby 1.8/bin"
|
436
|
+
Gem::ConfigMap[:ruby_install_name] = "ruby"
|
437
|
+
Gem::ConfigMap[:EXEEXT] = ".exe"
|
438
|
+
Gem.instance_variable_set("@ruby", nil)
|
439
|
+
|
440
|
+
assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby
|
441
|
+
ensure
|
442
|
+
Gem.instance_variable_set("@ruby", orig_ruby)
|
443
|
+
Gem::ConfigMap[:bindir] = orig_bindir
|
444
|
+
Gem::ConfigMap[:ruby_install_name] = orig_ruby_install_name
|
445
|
+
Gem::ConfigMap[:EXEEXT] = orig_exe_ext
|
446
|
+
end
|
447
|
+
|
448
|
+
def test_self_ruby_path_without_spaces
|
449
|
+
orig_ruby = Gem.ruby
|
450
|
+
orig_bindir = Gem::ConfigMap[:bindir]
|
451
|
+
orig_ruby_install_name = Gem::ConfigMap[:ruby_install_name]
|
452
|
+
orig_exe_ext = Gem::ConfigMap[:EXEEXT]
|
453
|
+
|
454
|
+
Gem::ConfigMap[:bindir] = "C:/Ruby18/bin"
|
455
|
+
Gem::ConfigMap[:ruby_install_name] = "ruby"
|
456
|
+
Gem::ConfigMap[:EXEEXT] = ".exe"
|
457
|
+
Gem.instance_variable_set("@ruby", nil)
|
458
|
+
|
459
|
+
assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby
|
460
|
+
ensure
|
461
|
+
Gem.instance_variable_set("@ruby", orig_ruby)
|
462
|
+
Gem::ConfigMap[:bindir] = orig_bindir
|
463
|
+
Gem::ConfigMap[:ruby_install_name] = orig_ruby_install_name
|
464
|
+
Gem::ConfigMap[:EXEEXT] = orig_exe_ext
|
465
|
+
end
|
466
|
+
|
389
467
|
def test_self_ruby_version
|
390
468
|
version = RUBY_VERSION.dup
|
391
469
|
version << ".#{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
|
@@ -426,6 +504,11 @@ class TestGem < RubyGemTestCase
|
|
426
504
|
assert_equal @additional + [Gem.dir], Gem.path
|
427
505
|
end
|
428
506
|
|
507
|
+
def test_self_user_dir
|
508
|
+
assert_equal File.join(@userhome, '.gem', Gem.ruby_engine,
|
509
|
+
Gem::ConfigMap[:ruby_version]), Gem.user_dir
|
510
|
+
end
|
511
|
+
|
429
512
|
def test_self_user_home
|
430
513
|
if ENV['HOME'] then
|
431
514
|
assert_equal ENV['HOME'], Gem.user_home
|
@@ -434,6 +517,28 @@ class TestGem < RubyGemTestCase
|
|
434
517
|
end
|
435
518
|
end
|
436
519
|
|
520
|
+
def test_self_user_home_user_drive_and_path
|
521
|
+
Gem.clear_paths
|
522
|
+
|
523
|
+
# safe-keep env variables
|
524
|
+
orig_home, orig_user_profile = ENV['HOME'], ENV['USERPROFILE']
|
525
|
+
orig_user_drive, orig_user_path = ENV['HOMEDRIVE'], ENV['HOMEPATH']
|
526
|
+
|
527
|
+
# prepare the environment
|
528
|
+
ENV.delete('HOME')
|
529
|
+
ENV.delete('USERPROFILE')
|
530
|
+
ENV['HOMEDRIVE'] = 'Z:'
|
531
|
+
ENV['HOMEPATH'] = '\\Users\\RubyUser'
|
532
|
+
|
533
|
+
assert_equal "Z:\\Users\\RubyUser", Gem.user_home
|
534
|
+
|
535
|
+
ensure
|
536
|
+
ENV['HOME'] = orig_home
|
537
|
+
ENV['USERPROFILE'] = orig_user_profile
|
538
|
+
ENV['USERDRIVE'] = orig_user_drive
|
539
|
+
ENV['USERPATH'] = orig_user_path
|
540
|
+
end
|
541
|
+
|
437
542
|
def util_ensure_gem_dirs
|
438
543
|
Gem.ensure_gem_subdirectories @gemhome
|
439
544
|
@additional.each do |dir|
|