rubygems-update 1.5.3 → 1.6.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 -1
- data/History.txt +60 -9
- data/Manifest.txt +1 -1
- data/Rakefile +0 -2
- data/lib/rubygems.rb +142 -65
- data/lib/rubygems/commands/owner_command.rb +3 -2
- data/lib/rubygems/commands/pristine_command.rb +5 -3
- data/lib/rubygems/commands/push_command.rb +8 -4
- data/lib/rubygems/commands/setup_command.rb +1 -2
- data/lib/rubygems/commands/uninstall_command.rb +5 -0
- data/lib/rubygems/commands/unpack_command.rb +10 -16
- data/lib/rubygems/config_file.rb +12 -5
- data/lib/rubygems/custom_require.rb +27 -7
- data/lib/rubygems/dependency.rb +33 -8
- data/lib/rubygems/dependency_installer.rb +21 -6
- data/lib/rubygems/dependency_list.rb +35 -3
- data/lib/rubygems/doc_manager.rb +6 -4
- data/lib/rubygems/gem_path_searcher.rb +45 -1
- data/lib/rubygems/gemcutter_utilities.rb +33 -0
- data/lib/rubygems/indexer.rb +1 -0
- data/lib/rubygems/installer.rb +11 -7
- data/lib/rubygems/installer_test_case.rb +23 -15
- data/lib/rubygems/mock_gem_ui.rb +1 -1
- data/lib/rubygems/remote_fetcher.rb +29 -10
- data/lib/rubygems/requirement.rb +1 -1
- data/lib/rubygems/security.rb +1 -0
- data/lib/rubygems/source_index.rb +3 -2
- data/lib/rubygems/spec_fetcher.rb +3 -1
- data/lib/rubygems/specification.rb +54 -12
- data/lib/rubygems/test_case.rb +99 -28
- data/lib/rubygems/test_utilities.rb +11 -1
- data/lib/rubygems/uninstaller.rb +22 -11
- data/lib/rubygems/user_interaction.rb +50 -29
- data/lib/rubygems/validator.rb +1 -1
- data/test/rubygems/fix_openssl_warnings.rb +12 -0
- data/test/rubygems/plugin/load/rubygems_plugin.rb +3 -1
- data/test/rubygems/test_gem.rb +384 -38
- data/test/rubygems/test_gem_builder.rb +1 -1
- data/test/rubygems/test_gem_command_manager.rb +2 -2
- data/test/rubygems/test_gem_commands_build_command.rb +1 -1
- data/test/rubygems/test_gem_commands_cert_command.rb +2 -1
- data/test/rubygems/test_gem_commands_dependency_command.rb +6 -5
- data/test/rubygems/test_gem_commands_fetch_command.rb +4 -4
- data/test/rubygems/test_gem_commands_install_command.rb +21 -18
- data/test/rubygems/test_gem_commands_lock_command.rb +1 -1
- data/test/rubygems/test_gem_commands_outdated_command.rb +2 -5
- data/test/rubygems/test_gem_commands_owner_command.rb +42 -0
- data/test/rubygems/test_gem_commands_pristine_command.rb +28 -8
- data/test/rubygems/test_gem_commands_push_command.rb +31 -5
- data/test/rubygems/test_gem_commands_specification_command.rb +8 -8
- data/test/rubygems/test_gem_commands_stale_command.rb +4 -2
- data/test/rubygems/test_gem_commands_uninstall_command.rb +23 -4
- data/test/rubygems/test_gem_commands_unpack_command.rb +10 -8
- data/test/rubygems/test_gem_commands_update_command.rb +16 -13
- data/test/rubygems/test_gem_commands_which_command.rb +1 -1
- data/test/rubygems/test_gem_config_file.rb +14 -0
- data/test/rubygems/test_gem_dependency.rb +39 -0
- data/test/rubygems/test_gem_dependency_installer.rb +213 -92
- data/test/rubygems/test_gem_dependency_list.rb +37 -17
- data/test/rubygems/test_gem_doc_manager.rb +5 -4
- data/test/rubygems/test_gem_format.rb +2 -2
- data/test/rubygems/test_gem_gemcutter_utilities.rb +48 -0
- data/test/rubygems/test_gem_indexer.rb +11 -10
- data/test/rubygems/test_gem_install_update_options.rb +0 -2
- data/test/rubygems/test_gem_installer.rb +151 -78
- data/test/rubygems/test_gem_package_tar_output.rb +3 -0
- data/test/rubygems/test_gem_remote_fetcher.rb +23 -14
- data/test/rubygems/test_gem_requirement.rb +4 -0
- data/test/rubygems/test_gem_security.rb +1 -0
- data/test/rubygems/test_gem_source_index.rb +17 -16
- data/test/rubygems/test_gem_spec_fetcher.rb +6 -1
- data/test/rubygems/test_gem_specification.rb +81 -31
- data/test/rubygems/test_gem_stream_ui.rb +11 -1
- data/test/rubygems/test_gem_uninstaller.rb +70 -10
- data/test/rubygems/test_gem_validator.rb +1 -1
- data/test/rubygems/test_kernel.rb +1 -1
- metadata +7 -7
- metadata.gz.sig +0 -0
- data/ChangeLog +0 -5811
data/lib/rubygems/test_case.rb
CHANGED
@@ -21,13 +21,6 @@ require 'pp'
|
|
21
21
|
require 'zlib'
|
22
22
|
Gem.load_yaml
|
23
23
|
|
24
|
-
begin
|
25
|
-
gem 'rdoc'
|
26
|
-
rescue Gem::LoadError
|
27
|
-
end
|
28
|
-
|
29
|
-
require 'rdoc/rdoc'
|
30
|
-
|
31
24
|
require 'rubygems/mock_gem_ui'
|
32
25
|
|
33
26
|
module Gem
|
@@ -88,6 +81,8 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
|
88
81
|
undef_method :default_test if instance_methods.include? 'default_test' or
|
89
82
|
instance_methods.include? :default_test
|
90
83
|
|
84
|
+
@@project_dir = Dir.pwd
|
85
|
+
|
91
86
|
##
|
92
87
|
# #setup prepares a sandboxed location to install gems. All installs are
|
93
88
|
# directed to a temporary directory. All install plugins are removed.
|
@@ -117,8 +112,6 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
|
117
112
|
@gemhome = File.join @tempdir, 'gemhome'
|
118
113
|
@userhome = File.join @tempdir, 'userhome'
|
119
114
|
|
120
|
-
Gem.ensure_gem_subdirectories @gemhome
|
121
|
-
|
122
115
|
@orig_ruby = if ruby = ENV['RUBY'] then
|
123
116
|
Gem.class_eval { ruby, @ruby = @ruby, ruby }
|
124
117
|
ruby
|
@@ -126,6 +119,8 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
|
126
119
|
|
127
120
|
Gem.ensure_gem_subdirectories @gemhome
|
128
121
|
|
122
|
+
Dir.chdir @tempdir
|
123
|
+
|
129
124
|
@orig_ENV_HOME = ENV['HOME']
|
130
125
|
ENV['HOME'] = @userhome
|
131
126
|
Gem.instance_variable_set :@user_home, nil
|
@@ -135,6 +130,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
|
135
130
|
|
136
131
|
Gem.use_paths(@gemhome)
|
137
132
|
Gem.loaded_specs.clear
|
133
|
+
Gem.unresolved_deps.clear
|
138
134
|
|
139
135
|
Gem.configuration.verbose = true
|
140
136
|
Gem.configuration.update_sources = true
|
@@ -143,6 +139,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
|
143
139
|
@uri = URI.parse @gem_repo
|
144
140
|
Gem.sources.replace [@gem_repo]
|
145
141
|
|
142
|
+
Gem.searcher = nil
|
146
143
|
Gem::SpecFetcher.fetcher = nil
|
147
144
|
|
148
145
|
@orig_BASERUBY = Gem::ConfigMap[:BASERUBY]
|
@@ -158,17 +155,14 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
|
158
155
|
|
159
156
|
@marshal_version = "#{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}"
|
160
157
|
|
161
|
-
|
162
|
-
__FILE__)
|
163
|
-
@public_cert = File.expand_path('../../../test/rubygems/public_cert.pem',
|
164
|
-
__FILE__)
|
165
|
-
|
158
|
+
# TODO: move to installer test cases
|
166
159
|
Gem.post_build_hooks.clear
|
167
160
|
Gem.post_install_hooks.clear
|
168
161
|
Gem.post_uninstall_hooks.clear
|
169
162
|
Gem.pre_install_hooks.clear
|
170
163
|
Gem.pre_uninstall_hooks.clear
|
171
164
|
|
165
|
+
# TODO: move to installer test cases
|
172
166
|
Gem.post_build do |installer|
|
173
167
|
@post_build_hook_arg = installer
|
174
168
|
true
|
@@ -208,6 +202,8 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
|
208
202
|
Gem::RemoteFetcher.fetcher = nil
|
209
203
|
end
|
210
204
|
|
205
|
+
Dir.chdir @@project_dir
|
206
|
+
|
211
207
|
FileUtils.rm_rf @tempdir unless ENV['KEEP_FILES']
|
212
208
|
|
213
209
|
ENV['GEM_HOME'] = @orig_gem_home
|
@@ -308,14 +304,14 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
|
308
304
|
require 'rubygems/specification'
|
309
305
|
|
310
306
|
spec = Gem::Specification.new do |s|
|
311
|
-
s.platform
|
312
|
-
s.name
|
313
|
-
s.version
|
314
|
-
s.author
|
315
|
-
s.email
|
316
|
-
s.homepage
|
317
|
-
s.has_rdoc
|
318
|
-
s.summary
|
307
|
+
s.platform = Gem::Platform::RUBY
|
308
|
+
s.name = name
|
309
|
+
s.version = version
|
310
|
+
s.author = 'A User'
|
311
|
+
s.email = 'example@example.com'
|
312
|
+
s.homepage = 'http://example.com'
|
313
|
+
s.has_rdoc = true
|
314
|
+
s.summary = "this is a summary"
|
319
315
|
s.description = "This is a test description"
|
320
316
|
|
321
317
|
yield(s) if block_given?
|
@@ -333,6 +329,30 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
|
333
329
|
return spec
|
334
330
|
end
|
335
331
|
|
332
|
+
def quick_spec name, version = '2'
|
333
|
+
require 'rubygems/specification'
|
334
|
+
|
335
|
+
spec = Gem::Specification.new do |s|
|
336
|
+
s.platform = Gem::Platform::RUBY
|
337
|
+
s.name = name
|
338
|
+
s.version = version
|
339
|
+
s.author = 'A User'
|
340
|
+
s.email = 'example@example.com'
|
341
|
+
s.homepage = 'http://example.com'
|
342
|
+
s.has_rdoc = true
|
343
|
+
s.summary = "this is a summary"
|
344
|
+
s.description = "This is a test description"
|
345
|
+
|
346
|
+
yield(s) if block_given?
|
347
|
+
end
|
348
|
+
|
349
|
+
spec.loaded_from = @gemhome
|
350
|
+
|
351
|
+
Gem.source_index.add_spec spec
|
352
|
+
|
353
|
+
return spec
|
354
|
+
end
|
355
|
+
|
336
356
|
##
|
337
357
|
# Builds a gem from +spec+ and places it in <tt>File.join @gemhome,
|
338
358
|
# 'cache'</tt>. Automatically creates files based on +spec.files+
|
@@ -353,7 +373,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
|
353
373
|
end
|
354
374
|
|
355
375
|
FileUtils.mv spec.file_name,
|
356
|
-
|
376
|
+
Gem.cache_gem("#{spec.original_name}.gem")
|
357
377
|
end
|
358
378
|
end
|
359
379
|
|
@@ -361,11 +381,60 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
|
361
381
|
# Removes all installed gems from +@gemhome+.
|
362
382
|
|
363
383
|
def util_clear_gems
|
364
|
-
FileUtils.
|
365
|
-
FileUtils.
|
384
|
+
FileUtils.rm_rf File.join(@gemhome, 'gems')
|
385
|
+
FileUtils.rm_rf File.join(@gemhome, 'specifications')
|
366
386
|
Gem.source_index.refresh!
|
367
387
|
end
|
368
388
|
|
389
|
+
##
|
390
|
+
# Install the provided specs
|
391
|
+
|
392
|
+
def install_specs(*specs)
|
393
|
+
specs.each do |spec|
|
394
|
+
# TODO: inverted responsibility
|
395
|
+
Gem.source_index.add_spec spec
|
396
|
+
end
|
397
|
+
Gem.searcher = nil
|
398
|
+
end
|
399
|
+
|
400
|
+
##
|
401
|
+
# Create a new spec (or gem if passed an array of files) and set it
|
402
|
+
# up properly. Use this instead of util_spec and util_gem.
|
403
|
+
|
404
|
+
def new_spec name, version, deps = nil, *files
|
405
|
+
# TODO: unfactor and deprecate util_gem and util_spec
|
406
|
+
spec, = unless files.empty? then
|
407
|
+
util_gem name, version do |s|
|
408
|
+
Array(deps).each do |n,v|
|
409
|
+
s.add_dependency n, v
|
410
|
+
end
|
411
|
+
s.files.push(*files)
|
412
|
+
end
|
413
|
+
else
|
414
|
+
util_spec name, version, deps
|
415
|
+
end
|
416
|
+
spec.loaded_from = File.join @gemhome, 'specifications', spec.spec_name
|
417
|
+
spec.loaded = false
|
418
|
+
spec
|
419
|
+
end
|
420
|
+
|
421
|
+
##
|
422
|
+
# Creates a spec with +name+, +version+ and +deps+.
|
423
|
+
|
424
|
+
def util_spec(name, version, deps = nil, &block)
|
425
|
+
raise "deps or block, not both" if deps and block
|
426
|
+
|
427
|
+
if deps then
|
428
|
+
block = proc do |s|
|
429
|
+
deps.each do |n, req|
|
430
|
+
s.add_dependency n, (req || '>= 0')
|
431
|
+
end
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
quick_spec(name, version, &block)
|
436
|
+
end
|
437
|
+
|
369
438
|
##
|
370
439
|
# Creates a gem with +name+, +version+ and +deps+. The specification will
|
371
440
|
# be yielded before gem creation for customization. The gem will be placed
|
@@ -373,6 +442,8 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
|
373
442
|
# location are returned.
|
374
443
|
|
375
444
|
def util_gem(name, version, deps = nil, &block)
|
445
|
+
raise "deps or block, not both" if deps and block
|
446
|
+
|
376
447
|
if deps then
|
377
448
|
block = proc do |s|
|
378
449
|
deps.each do |n, req|
|
@@ -386,8 +457,8 @@ class Gem::TestCase < MiniTest::Unit::TestCase
|
|
386
457
|
util_build_gem spec
|
387
458
|
|
388
459
|
cache_file = File.join @tempdir, 'gems', "#{spec.original_name}.gem"
|
389
|
-
FileUtils.
|
390
|
-
|
460
|
+
FileUtils.mkdir_p File.dirname cache_file
|
461
|
+
FileUtils.mv Gem.cache_gem("#{spec.original_name}.gem"), cache_file
|
391
462
|
FileUtils.rm File.join(@gemhome, 'specifications', spec.spec_name)
|
392
463
|
|
393
464
|
spec.loaded_from = nil
|
@@ -694,7 +765,7 @@ Also, a list:
|
|
694
765
|
|
695
766
|
@@ruby = rubybin
|
696
767
|
env_rake = ENV['rake']
|
697
|
-
ruby19_rake = File.expand_path("
|
768
|
+
ruby19_rake = File.expand_path("bin/rake", @@project_dir)
|
698
769
|
@@rake = if env_rake then
|
699
770
|
ENV["rake"]
|
700
771
|
elsif File.exist? ruby19_rake then
|
@@ -98,7 +98,7 @@ class Gem::FakeFetcher
|
|
98
98
|
|
99
99
|
def download spec, source_uri, install_dir = Gem.dir
|
100
100
|
name = spec.file_name
|
101
|
-
path =
|
101
|
+
path = Gem.cache_gem(name, install_dir)
|
102
102
|
|
103
103
|
Gem.ensure_gem_subdirectories install_dir
|
104
104
|
|
@@ -113,6 +113,16 @@ class Gem::FakeFetcher
|
|
113
113
|
path
|
114
114
|
end
|
115
115
|
|
116
|
+
def download_to_cache dependency
|
117
|
+
found = Gem::SpecFetcher.fetcher.fetch dependency
|
118
|
+
|
119
|
+
return if found.empty?
|
120
|
+
|
121
|
+
spec, source_uri = found.first
|
122
|
+
|
123
|
+
download spec, source_uri
|
124
|
+
end
|
125
|
+
|
116
126
|
end
|
117
127
|
|
118
128
|
# :stopdoc:
|
data/lib/rubygems/uninstaller.rb
CHANGED
@@ -50,6 +50,7 @@ class Gem::Uninstaller
|
|
50
50
|
@force_all = options[:all]
|
51
51
|
@force_ignore = options[:ignore]
|
52
52
|
@bin_dir = options[:bin_dir]
|
53
|
+
@format_executable = options[:format_executable]
|
53
54
|
|
54
55
|
# only add user directory if install_dir is not set
|
55
56
|
@user_install = false
|
@@ -102,6 +103,13 @@ class Gem::Uninstaller
|
|
102
103
|
def uninstall_gem(spec, specs)
|
103
104
|
@spec = spec
|
104
105
|
|
106
|
+
unless dependencies_ok? spec
|
107
|
+
unless ask_if_ok(spec)
|
108
|
+
raise Gem::DependencyRemovalException,
|
109
|
+
"Uninstallation aborted due to dependent gem(s)"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
105
113
|
Gem.pre_uninstall_hooks.each do |hook|
|
106
114
|
hook.call self
|
107
115
|
end
|
@@ -155,8 +163,8 @@ class Gem::Uninstaller
|
|
155
163
|
|
156
164
|
spec.executables.each do |exe_name|
|
157
165
|
say "Removing #{exe_name}"
|
158
|
-
FileUtils.rm_f File.join(bindir, exe_name)
|
159
|
-
FileUtils.rm_f File.join(bindir, "#{exe_name}.bat")
|
166
|
+
FileUtils.rm_f File.join(bindir, formatted_program_filename(exe_name))
|
167
|
+
FileUtils.rm_f File.join(bindir, "#{formatted_program_filename(exe_name)}.bat")
|
160
168
|
end
|
161
169
|
end
|
162
170
|
end
|
@@ -178,11 +186,6 @@ class Gem::Uninstaller
|
|
178
186
|
# uninstalled a gem, it is removed from that list.
|
179
187
|
|
180
188
|
def remove(spec, list)
|
181
|
-
unless dependencies_ok? spec then
|
182
|
-
raise Gem::DependencyRemovalException,
|
183
|
-
"Uninstallation aborted due to dependent gem(s)"
|
184
|
-
end
|
185
|
-
|
186
189
|
unless path_ok?(@gem_home, spec) or
|
187
190
|
(@user_install and path_ok?(Gem.user_dir, spec)) then
|
188
191
|
e = Gem::GemNotInHomeException.new \
|
@@ -209,11 +212,10 @@ class Gem::Uninstaller
|
|
209
212
|
|
210
213
|
FileUtils.rm_rf gemspec
|
211
214
|
|
212
|
-
|
213
|
-
gem = File.join cache_dir, spec.file_name
|
215
|
+
gem = Gem.cache_gem(spec.file_name, spec.installation_path)
|
214
216
|
|
215
217
|
unless File.exist? gem then
|
216
|
-
gem =
|
218
|
+
gem = Gem.cache_gem("#{original_platform_name}.gem", spec.installation_path)
|
217
219
|
end
|
218
220
|
|
219
221
|
FileUtils.rm_rf gem
|
@@ -240,7 +242,7 @@ class Gem::Uninstaller
|
|
240
242
|
|
241
243
|
deplist = Gem::DependencyList.from_source_index @source_index
|
242
244
|
deplist.add(*@user_index.gems.values) if @user_install
|
243
|
-
deplist.ok_to_remove?(spec.full_name)
|
245
|
+
deplist.ok_to_remove?(spec.full_name)
|
244
246
|
end
|
245
247
|
|
246
248
|
def ask_if_ok(spec)
|
@@ -257,5 +259,14 @@ class Gem::Uninstaller
|
|
257
259
|
return ask_yes_no(msg.join("\n"), true)
|
258
260
|
end
|
259
261
|
|
262
|
+
def formatted_program_filename(filename)
|
263
|
+
if @format_executable then
|
264
|
+
Gem::Installer.exec_format % File.basename(filename)
|
265
|
+
else
|
266
|
+
filename
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
|
260
271
|
end
|
261
272
|
|
@@ -132,10 +132,19 @@ class Gem::StreamUI
|
|
132
132
|
|
133
133
|
attr_reader :ins, :outs, :errs
|
134
134
|
|
135
|
-
def initialize(in_stream, out_stream, err_stream=STDERR)
|
135
|
+
def initialize(in_stream, out_stream, err_stream=STDERR, usetty=true)
|
136
136
|
@ins = in_stream
|
137
137
|
@outs = out_stream
|
138
138
|
@errs = err_stream
|
139
|
+
@usetty = usetty
|
140
|
+
end
|
141
|
+
|
142
|
+
def tty?
|
143
|
+
if RUBY_PLATFORM =~ /mingw|mswin/
|
144
|
+
@usetty
|
145
|
+
else
|
146
|
+
@usetty && @ins.tty?
|
147
|
+
end
|
139
148
|
end
|
140
149
|
|
141
150
|
##
|
@@ -167,7 +176,7 @@ class Gem::StreamUI
|
|
167
176
|
# default.
|
168
177
|
|
169
178
|
def ask_yes_no(question, default=nil)
|
170
|
-
unless
|
179
|
+
unless tty? then
|
171
180
|
if default.nil? then
|
172
181
|
raise Gem::OperationNotSupportedError,
|
173
182
|
"Not connected to a tty and no default specified"
|
@@ -176,29 +185,24 @@ class Gem::StreamUI
|
|
176
185
|
end
|
177
186
|
end
|
178
187
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
188
|
+
default_answer = case default
|
189
|
+
when nil
|
190
|
+
'yn'
|
191
|
+
when true
|
192
|
+
'Yn'
|
193
|
+
else
|
194
|
+
'yN'
|
195
|
+
end
|
187
196
|
|
188
197
|
result = nil
|
189
198
|
|
190
|
-
while result.nil?
|
191
|
-
result = ask
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
when /^$/
|
198
|
-
default
|
199
|
-
else
|
200
|
-
nil
|
201
|
-
end
|
199
|
+
while result.nil? do
|
200
|
+
result = case ask "#{question} [#{default_answer}]"
|
201
|
+
when /^y/i then true
|
202
|
+
when /^n/i then false
|
203
|
+
when /^$/ then default
|
204
|
+
else nil
|
205
|
+
end
|
202
206
|
end
|
203
207
|
|
204
208
|
return result
|
@@ -208,7 +212,7 @@ class Gem::StreamUI
|
|
208
212
|
# Ask a question. Returns an answer if connected to a tty, nil otherwise.
|
209
213
|
|
210
214
|
def ask(question)
|
211
|
-
return nil if not
|
215
|
+
return nil if not tty?
|
212
216
|
|
213
217
|
@outs.print(question + " ")
|
214
218
|
@outs.flush
|
@@ -223,7 +227,7 @@ class Gem::StreamUI
|
|
223
227
|
# Ask for a password. Does not echo response to terminal.
|
224
228
|
|
225
229
|
def ask_for_password(question)
|
226
|
-
return nil if not
|
230
|
+
return nil if not tty?
|
227
231
|
|
228
232
|
require 'io/console'
|
229
233
|
|
@@ -239,7 +243,7 @@ class Gem::StreamUI
|
|
239
243
|
# Ask for a password. Does not echo response to terminal.
|
240
244
|
|
241
245
|
def ask_for_password(question)
|
242
|
-
return nil if not
|
246
|
+
return nil if not tty?
|
243
247
|
|
244
248
|
@outs.print(question + " ")
|
245
249
|
@outs.flush
|
@@ -251,6 +255,8 @@ class Gem::StreamUI
|
|
251
255
|
# Asks for a password that works on windows. Ripped from the Heroku gem.
|
252
256
|
|
253
257
|
def ask_for_password_on_windows
|
258
|
+
return nil if not tty?
|
259
|
+
|
254
260
|
require "Win32API"
|
255
261
|
char = nil
|
256
262
|
password = ''
|
@@ -272,6 +278,8 @@ class Gem::StreamUI
|
|
272
278
|
# Asks for a password that works on unix
|
273
279
|
|
274
280
|
def ask_for_password_on_unix
|
281
|
+
return nil if not tty?
|
282
|
+
|
275
283
|
system "stty -echo"
|
276
284
|
password = @ins.gets
|
277
285
|
password.chomp! if password
|
@@ -332,6 +340,10 @@ class Gem::StreamUI
|
|
332
340
|
# Return a progress reporter object chosen from the current verbosity.
|
333
341
|
|
334
342
|
def progress_reporter(*args)
|
343
|
+
if self.kind_of?(Gem::SilentUI)
|
344
|
+
return SilentProgressReporter.new(@outs, *args)
|
345
|
+
end
|
346
|
+
|
335
347
|
case Gem.configuration.verbose
|
336
348
|
when nil, false
|
337
349
|
SilentProgressReporter.new(@outs, *args)
|
@@ -434,6 +446,10 @@ class Gem::StreamUI
|
|
434
446
|
# Return a download reporter object chosen from the current verbosity
|
435
447
|
|
436
448
|
def download_reporter(*args)
|
449
|
+
if self.kind_of?(Gem::SilentUI)
|
450
|
+
return SilentDownloadReporter.new(@outs, *args)
|
451
|
+
end
|
452
|
+
|
437
453
|
case Gem.configuration.verbose
|
438
454
|
when nil, false
|
439
455
|
SilentDownloadReporter.new(@outs, *args)
|
@@ -517,7 +533,7 @@ end
|
|
517
533
|
|
518
534
|
class Gem::ConsoleUI < Gem::StreamUI
|
519
535
|
def initialize
|
520
|
-
super STDIN, STDOUT, STDERR
|
536
|
+
super STDIN, STDOUT, STDERR, true
|
521
537
|
end
|
522
538
|
end
|
523
539
|
|
@@ -525,9 +541,7 @@ end
|
|
525
541
|
# SilentUI is a UI choice that is absolutely silent.
|
526
542
|
|
527
543
|
class Gem::SilentUI < Gem::StreamUI
|
528
|
-
|
529
544
|
def initialize
|
530
|
-
|
531
545
|
reader, writer = nil, nil
|
532
546
|
|
533
547
|
begin
|
@@ -538,8 +552,15 @@ class Gem::SilentUI < Gem::StreamUI
|
|
538
552
|
writer = File.open('nul', 'w')
|
539
553
|
end
|
540
554
|
|
541
|
-
super reader, writer, writer
|
555
|
+
super reader, writer, writer, false
|
542
556
|
end
|
543
557
|
|
558
|
+
def download_reporter(*args)
|
559
|
+
SilentDownloadReporter.new(@outs, *args)
|
560
|
+
end
|
561
|
+
|
562
|
+
def progress_reporter(*args)
|
563
|
+
SilentProgressReporter.new(@outs, *args)
|
564
|
+
end
|
544
565
|
end
|
545
566
|
|