rubygems-update 1.7.2 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubygems-update might be problematic. Click here for more details.

Files changed (104) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +5 -1
  3. data/History.txt +101 -4
  4. data/LICENSE.txt +42 -37
  5. data/MIT.txt +20 -0
  6. data/Manifest.txt +5 -4
  7. data/Rakefile +6 -7
  8. data/lib/rubygems.rb +175 -278
  9. data/lib/rubygems/builder.rb +7 -6
  10. data/lib/rubygems/command_manager.rb +16 -2
  11. data/lib/rubygems/commands/build_command.rb +13 -11
  12. data/lib/rubygems/commands/cert_command.rb +1 -1
  13. data/lib/rubygems/commands/cleanup_command.rb +10 -19
  14. data/lib/rubygems/commands/contents_command.rb +5 -5
  15. data/lib/rubygems/commands/dependency_command.rb +17 -40
  16. data/lib/rubygems/commands/fetch_command.rb +1 -1
  17. data/lib/rubygems/commands/install_command.rb +2 -1
  18. data/lib/rubygems/commands/lock_command.rb +4 -4
  19. data/lib/rubygems/commands/outdated_command.rb +18 -6
  20. data/lib/rubygems/commands/pristine_command.rb +25 -15
  21. data/lib/rubygems/commands/query_command.rb +9 -6
  22. data/lib/rubygems/commands/setup_command.rb +1 -1
  23. data/lib/rubygems/commands/specification_command.rb +8 -23
  24. data/lib/rubygems/commands/stale_command.rb +2 -1
  25. data/lib/rubygems/commands/unpack_command.rb +7 -5
  26. data/lib/rubygems/commands/update_command.rb +2 -4
  27. data/lib/rubygems/commands/which_command.rb +5 -9
  28. data/lib/rubygems/config_file.rb +9 -7
  29. data/lib/rubygems/custom_require.rb +6 -4
  30. data/lib/rubygems/defaults.rb +30 -14
  31. data/lib/rubygems/dependency.rb +44 -1
  32. data/lib/rubygems/dependency_installer.rb +37 -41
  33. data/lib/rubygems/dependency_list.rb +20 -9
  34. data/lib/rubygems/deprecate.rb +3 -3
  35. data/lib/rubygems/doc_manager.rb +10 -11
  36. data/lib/rubygems/ext/rake_builder.rb +1 -1
  37. data/lib/rubygems/gem_path_searcher.rb +19 -4
  38. data/lib/rubygems/gem_runner.rb +1 -1
  39. data/lib/rubygems/indexer.rb +117 -123
  40. data/lib/rubygems/installer.rb +101 -94
  41. data/lib/rubygems/installer_test_case.rb +28 -30
  42. data/lib/rubygems/local_remote_options.rb +1 -1
  43. data/lib/rubygems/mock_gem_ui.rb +10 -3
  44. data/lib/rubygems/package.rb +0 -26
  45. data/lib/rubygems/package/tar_input.rb +5 -6
  46. data/lib/rubygems/package_task.rb +1 -1
  47. data/lib/rubygems/path_support.rb +72 -0
  48. data/lib/rubygems/platform.rb +12 -2
  49. data/lib/rubygems/remote_fetcher.rb +7 -6
  50. data/lib/rubygems/requirement.rb +3 -0
  51. data/lib/rubygems/security.rb +1 -1
  52. data/lib/rubygems/server.rb +67 -67
  53. data/lib/rubygems/source_index.rb +58 -29
  54. data/lib/rubygems/spec_fetcher.rb +5 -1
  55. data/lib/rubygems/specification.rb +1422 -877
  56. data/lib/rubygems/test_case.rb +114 -64
  57. data/lib/rubygems/test_utilities.rb +4 -3
  58. data/lib/rubygems/text.rb +1 -1
  59. data/lib/rubygems/uninstaller.rb +37 -44
  60. data/test/rubygems/test_gem.rb +131 -102
  61. data/test/rubygems/test_gem_builder.rb +18 -1
  62. data/test/rubygems/test_gem_command_manager.rb +2 -0
  63. data/test/rubygems/test_gem_commands_build_command.rb +31 -3
  64. data/test/rubygems/test_gem_commands_cleanup_command.rb +51 -0
  65. data/test/rubygems/test_gem_commands_dependency_command.rb +1 -10
  66. data/test/rubygems/test_gem_commands_fetch_command.rb +5 -4
  67. data/test/rubygems/test_gem_commands_help_command.rb +58 -0
  68. data/test/rubygems/test_gem_commands_install_command.rb +25 -24
  69. data/test/rubygems/test_gem_commands_list_command.rb +1 -4
  70. data/test/rubygems/test_gem_commands_outdated_command.rb +10 -9
  71. data/test/rubygems/test_gem_commands_pristine_command.rb +63 -22
  72. data/test/rubygems/test_gem_commands_push_command.rb +1 -1
  73. data/test/rubygems/test_gem_commands_query_command.rb +15 -82
  74. data/test/rubygems/test_gem_commands_sources_command.rb +8 -9
  75. data/test/rubygems/test_gem_commands_specification_command.rb +10 -6
  76. data/test/rubygems/test_gem_commands_stale_command.rb +4 -4
  77. data/test/rubygems/test_gem_commands_unpack_command.rb +20 -21
  78. data/test/rubygems/test_gem_commands_update_command.rb +19 -23
  79. data/test/rubygems/test_gem_commands_which_command.rb +7 -4
  80. data/test/rubygems/test_gem_dependency.rb +14 -8
  81. data/test/rubygems/test_gem_dependency_installer.rb +87 -33
  82. data/test/rubygems/test_gem_dependency_list.rb +7 -3
  83. data/test/rubygems/test_gem_doc_manager.rb +3 -3
  84. data/test/rubygems/test_gem_format.rb +1 -1
  85. data/test/rubygems/test_gem_gem_path_searcher.rb +45 -29
  86. data/test/rubygems/test_gem_indexer.rb +48 -47
  87. data/test/rubygems/test_gem_install_update_options.rb +6 -5
  88. data/test/rubygems/test_gem_installer.rb +61 -37
  89. data/test/rubygems/test_gem_path_support.rb +58 -0
  90. data/test/rubygems/test_gem_platform.rb +5 -5
  91. data/test/rubygems/test_gem_remote_fetcher.rb +18 -21
  92. data/test/rubygems/test_gem_server.rb +23 -15
  93. data/test/rubygems/test_gem_source_index.rb +165 -127
  94. data/test/rubygems/test_gem_spec_fetcher.rb +42 -49
  95. data/test/rubygems/test_gem_specification.rb +104 -74
  96. data/test/rubygems/test_gem_text.rb +15 -0
  97. data/test/rubygems/test_gem_uninstaller.rb +15 -26
  98. data/test/rubygems/test_kernel.rb +1 -2
  99. metadata +64 -14
  100. metadata.gz.sig +0 -0
  101. data/GPL.txt +0 -340
  102. data/pkgs/sources/lib/sources.rb +0 -3
  103. data/pkgs/sources/sources.gemspec +0 -14
  104. data/test/rubygems/functional.rb +0 -92
@@ -11,6 +11,7 @@ begin
11
11
  rescue Gem::LoadError
12
12
  end
13
13
 
14
+ require "rubygems/deprecate"
14
15
  require 'minitest/autorun'
15
16
  require 'fileutils'
16
17
  require 'tmpdir'
@@ -19,6 +20,7 @@ require 'rubygems/package'
19
20
  require 'rubygems/test_utilities'
20
21
  require 'pp'
21
22
  require 'zlib'
23
+ require 'pathname'
22
24
  Gem.load_yaml
23
25
 
24
26
  require 'rubygems/mock_gem_ui'
@@ -38,6 +40,8 @@ module Gem
38
40
  # requiring 'rubygems/test_case'
39
41
 
40
42
  def self.source_index=(si)
43
+ raise "This method is not supported"
44
+ Gem::Specification.reset if si # HACK
41
45
  @@source_index = si
42
46
  end
43
47
 
@@ -76,6 +80,18 @@ end
76
80
 
77
81
  class Gem::TestCase < MiniTest::Unit::TestCase
78
82
 
83
+ # TODO: move to minitest
84
+ def assert_path_exists path, msg = nil
85
+ msg = message(msg) { "Expected path '#{path}' to exist" }
86
+ assert File.exist?(path), msg
87
+ end
88
+
89
+ # TODO: move to minitest
90
+ def refute_path_exists path, msg = nil
91
+ msg = message(msg) { "Expected path '#{path}' to not exist" }
92
+ refute File.exist?(path), msg
93
+ end
94
+
79
95
  include Gem::DefaultUserInteraction
80
96
 
81
97
  undef_method :default_test if instance_methods.include? 'default_test' or
@@ -101,12 +117,14 @@ class Gem::TestCase < MiniTest::Unit::TestCase
101
117
  @orig_gem_path = ENV['GEM_PATH']
102
118
 
103
119
  @ui = Gem::MockGemUi.new
120
+
104
121
  tmpdir = nil
105
122
  Dir.chdir Dir.tmpdir do tmpdir = Dir.pwd end # HACK OSX /private/tmp
123
+
106
124
  if ENV['KEEP_FILES'] then
107
- @tempdir = File.join tmpdir, "test_rubygems_#{$$}.#{Time.now.to_i}"
125
+ @tempdir = File.join(tmpdir, "test_rubygems_#{$$}.#{Time.now.to_i}")
108
126
  else
109
- @tempdir = File.join tmpdir, "test_rubygems_#{$$}"
127
+ @tempdir = File.join(tmpdir, "test_rubygems_#{$$}")
110
128
  end
111
129
  @tempdir.untaint
112
130
  @gemhome = File.join @tempdir, 'gemhome'
@@ -119,6 +137,9 @@ class Gem::TestCase < MiniTest::Unit::TestCase
119
137
 
120
138
  Gem.ensure_gem_subdirectories @gemhome
121
139
 
140
+ @orig_LOAD_PATH = $LOAD_PATH.dup
141
+ $LOAD_PATH.map! { |s| File.expand_path s }
142
+
122
143
  Dir.chdir @tempdir
123
144
 
124
145
  @orig_ENV_HOME = ENV['HOME']
@@ -129,6 +150,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
129
150
  FileUtils.mkdir_p @userhome
130
151
 
131
152
  Gem.use_paths(@gemhome)
153
+
132
154
  Gem.loaded_specs.clear
133
155
  Gem.unresolved_deps.clear
134
156
 
@@ -184,8 +206,6 @@ class Gem::TestCase < MiniTest::Unit::TestCase
184
206
  Gem.pre_uninstall do |uninstaller|
185
207
  @pre_uninstall_hook_arg = uninstaller
186
208
  end
187
-
188
- @orig_LOAD_PATH = $LOAD_PATH.dup
189
209
  end
190
210
 
191
211
  ##
@@ -209,8 +229,6 @@ class Gem::TestCase < MiniTest::Unit::TestCase
209
229
  ENV['GEM_HOME'] = @orig_gem_home
210
230
  ENV['GEM_PATH'] = @orig_gem_path
211
231
 
212
- Gem.clear_paths
213
-
214
232
  _ = @orig_ruby
215
233
  Gem.class_eval { @ruby = _ } if _
216
234
 
@@ -233,7 +251,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
233
251
  end
234
252
  end
235
253
 
236
- gem = File.join(@tempdir, spec.file_name).untaint
254
+ gem = File.join(@tempdir, File.basename(spec.cache_file)).untaint
237
255
 
238
256
  Gem::Installer.new(gem, :wrappers => true).install
239
257
  end
@@ -243,9 +261,19 @@ class Gem::TestCase < MiniTest::Unit::TestCase
243
261
  def uninstall_gem spec
244
262
  require 'rubygems/uninstaller'
245
263
 
246
- uninstaller = Gem::Uninstaller.new spec.name, :executables => true,
247
- :user_install => true
248
- uninstaller.uninstall
264
+ Gem::Uninstaller.new(spec.name,
265
+ :executables => true, :user_install => true).uninstall
266
+ end
267
+
268
+ ##
269
+ # creates a temporary directory with hax
270
+
271
+ def create_tmpdir
272
+ tmpdir = nil
273
+ Dir.chdir Dir.tmpdir do tmpdir = Dir.pwd end # HACK OSX /private/tmp
274
+ tmpdir = File.join tmpdir, "test_rubygems_#{$$}"
275
+ FileUtils.mkdir_p tmpdir
276
+ return tmpdir
249
277
  end
250
278
 
251
279
  ##
@@ -278,7 +306,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
278
306
  # Writes a binary file to +path+ which is relative to +@gemhome+
279
307
 
280
308
  def write_file(path)
281
- path = File.join @gemhome, path
309
+ path = File.join @gemhome, path unless Pathname.new(path).absolute?
282
310
  dir = File.dirname path
283
311
  FileUtils.mkdir_p dir
284
312
 
@@ -289,6 +317,10 @@ class Gem::TestCase < MiniTest::Unit::TestCase
289
317
  path
290
318
  end
291
319
 
320
+ def all_spec_names
321
+ Gem::Specification.map(&:full_name)
322
+ end
323
+
292
324
  ##
293
325
  # Creates a Gem::Specification with a minimum of extra work. +name+ and
294
326
  # +version+ are the gem's name and version, platform, author, email,
@@ -316,19 +348,21 @@ class Gem::TestCase < MiniTest::Unit::TestCase
316
348
  yield(s) if block_given?
317
349
  end
318
350
 
319
- path = File.join "specifications", spec.spec_name
320
- written_path = write_file path do |io|
351
+ Gem::Specification.map # HACK: force specs to (re-)load before we write
352
+
353
+ written_path = write_file spec.spec_file do |io|
321
354
  io.write spec.to_ruby_for_cache
322
355
  end
323
356
 
324
357
  spec.loaded_from = spec.loaded_from = written_path
325
358
 
326
- Gem.source_index.add_spec spec.for_cache
359
+ Gem::Specification.add_spec spec.for_cache
327
360
 
328
361
  return spec
329
362
  end
330
363
 
331
364
  def quick_spec name, version = '2'
365
+ # TODO: deprecate
332
366
  require 'rubygems/specification'
333
367
 
334
368
  spec = Gem::Specification.new do |s|
@@ -344,10 +378,9 @@ class Gem::TestCase < MiniTest::Unit::TestCase
344
378
  yield(s) if block_given?
345
379
  end
346
380
 
347
- path = File.join @gemhome, "specifications", spec.spec_name
348
- spec.loaded_from = path
381
+ spec.loaded_from = spec.spec_file
349
382
 
350
- Gem.source_index.add_spec spec
383
+ Gem::Specification.add_spec spec
351
384
 
352
385
  return spec
353
386
  end
@@ -357,7 +390,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
357
390
  # 'cache'</tt>. Automatically creates files based on +spec.files+
358
391
 
359
392
  def util_build_gem(spec)
360
- dir = File.join(@gemhome, 'gems', spec.full_name)
393
+ dir = spec.gem_dir
361
394
  FileUtils.mkdir_p dir
362
395
 
363
396
  Dir.chdir dir do
@@ -371,8 +404,8 @@ class Gem::TestCase < MiniTest::Unit::TestCase
371
404
  Gem::Builder.new(spec).build
372
405
  end
373
406
 
374
- FileUtils.mv spec.file_name,
375
- Gem.cache_gem("#{spec.original_name}.gem")
407
+ cache = spec.cache_file
408
+ FileUtils.mv File.basename(cache), cache
376
409
  end
377
410
  end
378
411
 
@@ -380,19 +413,16 @@ class Gem::TestCase < MiniTest::Unit::TestCase
380
413
  # Removes all installed gems from +@gemhome+.
381
414
 
382
415
  def util_clear_gems
383
- FileUtils.rm_rf File.join(@gemhome, 'gems')
384
- FileUtils.rm_rf File.join(@gemhome, 'specifications')
385
- Gem.source_index.refresh!
416
+ FileUtils.rm_rf File.join(@gemhome, "gems") # TODO: use Gem::Dirs
417
+ FileUtils.rm_rf File.join(@gemhome, "specifications")
418
+ Gem::Specification.reset
386
419
  end
387
420
 
388
421
  ##
389
422
  # Install the provided specs
390
423
 
391
424
  def install_specs(*specs)
392
- specs.each do |spec|
393
- # TODO: inverted responsibility
394
- Gem.source_index.add_spec spec
395
- end
425
+ Gem::Specification.add_specs(*specs)
396
426
  Gem.searcher = nil
397
427
  end
398
428
 
@@ -401,19 +431,42 @@ class Gem::TestCase < MiniTest::Unit::TestCase
401
431
  # up properly. Use this instead of util_spec and util_gem.
402
432
 
403
433
  def new_spec name, version, deps = nil, *files
404
- # TODO: unfactor and deprecate util_gem and util_spec
405
- spec, = unless files.empty? then
406
- util_gem name, version do |s|
407
- Array(deps).each do |n,v|
408
- s.add_dependency n, v
409
- end
410
- s.files.push(*files)
411
- end
412
- else
413
- util_spec name, version, deps
414
- end
415
- spec.loaded_from = File.join @gemhome, 'specifications', spec.spec_name
416
- spec.loaded = false
434
+ require 'rubygems/specification'
435
+
436
+ spec = Gem::Specification.new do |s|
437
+ s.platform = Gem::Platform::RUBY
438
+ s.name = name
439
+ s.version = version
440
+ s.author = 'A User'
441
+ s.email = 'example@example.com'
442
+ s.homepage = 'http://example.com'
443
+ s.summary = "this is a summary"
444
+ s.description = "This is a test description"
445
+
446
+ Array(deps).each do |n, req|
447
+ s.add_dependency n, (req || '>= 0')
448
+ end
449
+
450
+ s.files.push(*files) unless files.empty?
451
+
452
+ yield s if block_given?
453
+ end
454
+
455
+ spec.loaded_from = spec.spec_file
456
+
457
+ unless files.empty? then
458
+ write_file spec.spec_file do |io|
459
+ io.write spec.to_ruby_for_cache
460
+ end
461
+
462
+ util_build_gem spec
463
+
464
+ cache_file = File.join @tempdir, 'gems', "#{spec.full_name}.gem"
465
+ FileUtils.mkdir_p File.dirname cache_file
466
+ FileUtils.mv spec.cache_file, cache_file
467
+ FileUtils.rm spec.spec_file
468
+ end
469
+
417
470
  spec
418
471
  end
419
472
 
@@ -421,6 +474,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
421
474
  # Creates a spec with +name+, +version+ and +deps+.
422
475
 
423
476
  def util_spec(name, version, deps = nil, &block)
477
+ # TODO: deprecate
424
478
  raise "deps or block, not both" if deps and block
425
479
 
426
480
  if deps then
@@ -441,6 +495,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
441
495
  # location are returned.
442
496
 
443
497
  def util_gem(name, version, deps = nil, &block)
498
+ # TODO: deprecate
444
499
  raise "deps or block, not both" if deps and block
445
500
 
446
501
  if deps then
@@ -457,11 +512,10 @@ class Gem::TestCase < MiniTest::Unit::TestCase
457
512
 
458
513
  cache_file = File.join @tempdir, 'gems', "#{spec.original_name}.gem"
459
514
  FileUtils.mkdir_p File.dirname cache_file
460
- FileUtils.mv Gem.cache_gem("#{spec.original_name}.gem"), cache_file
461
- FileUtils.rm File.join(@gemhome, 'specifications', spec.spec_name)
515
+ FileUtils.mv spec.cache_file, cache_file
516
+ FileUtils.rm spec.spec_file
462
517
 
463
518
  spec.loaded_from = nil
464
- spec.loaded = false
465
519
 
466
520
  [spec, cache_file]
467
521
  end
@@ -509,8 +563,8 @@ class Gem::TestCase < MiniTest::Unit::TestCase
509
563
  This line is really, really long. So long, in fact, that it is more than eighty characters long! The purpose of this line is for testing wrapping behavior because sometimes people don't wrap their text to eighty characters. Without the wrapping, the text might not look good in the RSS feed.
510
564
 
511
565
  Also, a list:
512
- * An entry that's actually kind of sort
513
- * an entry that's really long, which will probably get wrapped funny. That's ok, somebody wasn't thinking straight when they made it more than eighty characters.
566
+ * An entry that\'s actually kind of sort
567
+ * an entry that\'s really long, which will probably get wrapped funny. That's ok, somebody wasn't thinking straight when they made it more than eighty characters.
514
568
  DESC
515
569
  end
516
570
 
@@ -549,9 +603,7 @@ Also, a list:
549
603
  util_build_gem spec
550
604
  end
551
605
 
552
- FileUtils.rm_r File.join(@gemhome, 'gems', @pl1.original_name)
553
-
554
- Gem.source_index = nil
606
+ FileUtils.rm_r File.join(@gemhome, "gems", @pl1.original_name)
555
607
  end
556
608
 
557
609
  ##
@@ -581,6 +633,7 @@ Also, a list:
581
633
  @fetcher = Gem::FakeFetcher.new
582
634
 
583
635
  util_make_gems(prerelease)
636
+ Gem::Specification.reset
584
637
 
585
638
  @all_gems = [@a1, @a2, @a3a, @a_evil9, @b2, @c1_2].sort
586
639
  @all_gem_names = @all_gems.map { |gem| gem.full_name }
@@ -588,14 +641,6 @@ Also, a list:
588
641
  gem_names = [@a1.full_name, @a2.full_name, @a3a.full_name, @b2.full_name]
589
642
  @gem_names = gem_names.sort.join("\n")
590
643
 
591
- @source_index = Gem::SourceIndex.new
592
- @source_index.add_spec @a1
593
- @source_index.add_spec @a2
594
- @source_index.add_spec @a3a
595
- @source_index.add_spec @a_evil9
596
- @source_index.add_spec @c1_2
597
- @source_index.add_spec @a2_pre if prerelease
598
-
599
644
  Gem::RemoteFetcher.fetcher = @fetcher
600
645
  end
601
646
 
@@ -604,37 +649,42 @@ Also, a list:
604
649
  # Best used with +@all_gems+ from #util_setup_fake_fetcher.
605
650
 
606
651
  def util_setup_spec_fetcher(*specs)
607
- si = Gem::SourceIndex.new
608
- si.add_specs(*specs)
652
+ specs -= Gem::Specification._all
653
+ Gem::Specification.add_specs(*specs)
609
654
 
610
655
  spec_fetcher = Gem::SpecFetcher.fetcher
611
656
 
657
+ prerelease, _ = Gem::Specification.partition { |spec|
658
+ spec.version.prerelease?
659
+ }
660
+
612
661
  spec_fetcher.specs[@uri] = []
613
- si.gems.sort_by { |_, spec| spec }.each do |_, spec|
662
+ Gem::Specification.each do |spec|
614
663
  spec_tuple = [spec.name, spec.version, spec.original_platform]
615
664
  spec_fetcher.specs[@uri] << spec_tuple
616
665
  end
617
666
 
618
667
  spec_fetcher.latest_specs[@uri] = []
619
- si.latest_specs.sort.each do |spec|
668
+ Gem::Specification.latest_specs.each do |spec|
620
669
  spec_tuple = [spec.name, spec.version, spec.original_platform]
621
670
  spec_fetcher.latest_specs[@uri] << spec_tuple
622
671
  end
623
672
 
624
673
  spec_fetcher.prerelease_specs[@uri] = []
625
- si.prerelease_specs.sort.each do |spec|
674
+ prerelease.each do |spec|
626
675
  spec_tuple = [spec.name, spec.version, spec.original_platform]
627
676
  spec_fetcher.prerelease_specs[@uri] << spec_tuple
628
677
  end
629
678
 
630
- (si.gems.merge si.prerelease_gems).sort_by { |_,spec| spec }.each do |_, spec|
631
- path = "#{@gem_repo}quick/Marshal.#{Gem.marshal_version}/#{spec.original_name}.gemspec.rz"
679
+ v = Gem.marshal_version
680
+ Gem::Specification.each do |spec|
681
+ path = "#{@gem_repo}quick/Marshal.#{v}/#{spec.original_name}.gemspec.rz"
632
682
  data = Marshal.dump spec
633
683
  data_deflate = Zlib::Deflate.deflate data
634
684
  @fetcher.data[path] = data_deflate
635
685
  end
636
686
 
637
- si
687
+ nil # force errors
638
688
  end
639
689
 
640
690
  ##
@@ -97,8 +97,8 @@ class Gem::FakeFetcher
97
97
  end
98
98
 
99
99
  def download spec, source_uri, install_dir = Gem.dir
100
- name = spec.file_name
101
- path = Gem.cache_gem(name, install_dir)
100
+ name = File.basename spec.cache_file
101
+ path = File.join install_dir, "cache", name
102
102
 
103
103
  Gem.ensure_gem_subdirectories install_dir
104
104
 
@@ -114,7 +114,8 @@ class Gem::FakeFetcher
114
114
  end
115
115
 
116
116
  def download_to_cache dependency
117
- found = Gem::SpecFetcher.fetcher.fetch dependency
117
+ found = Gem::SpecFetcher.fetcher.fetch dependency, true, true,
118
+ dependency.prerelease?
118
119
 
119
120
  return if found.empty?
120
121
 
@@ -15,7 +15,7 @@ module Gem::Text
15
15
 
16
16
  while work.length > wrap do
17
17
  if work =~ /^(.{0,#{wrap}})[ \n]/ then
18
- result << $1
18
+ result << $1.rstrip
19
19
  work.slice!(0, $&.length)
20
20
  else
21
21
  result << work.slice!(0, wrap)
@@ -42,26 +42,23 @@ class Gem::Uninstaller
42
42
  # Constructs an uninstaller that will uninstall +gem+
43
43
 
44
44
  def initialize(gem, options = {})
45
- @gem = gem
46
- @version = options[:version] || Gem::Requirement.default
47
- gem_home = options[:install_dir] || Gem.dir
48
- @gem_home = File.expand_path gem_home
45
+ @gem = gem
46
+ @version = options[:version] || Gem::Requirement.default
47
+ @gem_home = File.expand_path(options[:install_dir] || Gem.dir)
49
48
  @force_executables = options[:executables]
50
- @force_all = options[:all]
51
- @force_ignore = options[:ignore]
52
- @bin_dir = options[:bin_dir]
49
+ @force_all = options[:all]
50
+ @force_ignore = options[:ignore]
51
+ @bin_dir = options[:bin_dir]
53
52
  @format_executable = options[:format_executable]
54
53
 
55
54
  # only add user directory if install_dir is not set
56
55
  @user_install = false
57
56
  @user_install = options[:user_install] unless options[:install_dir]
58
57
 
59
- spec_dir = File.join @gem_home, 'specifications'
60
- @source_index = Gem::SourceIndex.new [spec_dir]
61
-
62
58
  if @user_install then
63
- user_dir = File.join Gem.user_dir, 'specifications'
64
- @user_index = Gem::SourceIndex.new [user_dir]
59
+ Gem.use_paths Gem.user_dir, @gem_home
60
+ else
61
+ Gem.use_paths @gem_home
65
62
  end
66
63
  end
67
64
 
@@ -70,8 +67,7 @@ class Gem::Uninstaller
70
67
  # directory, and the cached .gem file.
71
68
 
72
69
  def uninstall
73
- list = @source_index.find_name @gem, @version
74
- list += @user_index.find_name @gem, @version if @user_install
70
+ list = Gem::Specification.find_all_by_name(@gem, @version)
75
71
 
76
72
  if list.empty? then
77
73
  raise Gem::InstallError, "cannot uninstall, check `gem list -d #{@gem}`"
@@ -93,14 +89,14 @@ class Gem::Uninstaller
93
89
  say "Error: must enter a number [1-#{list.size+1}]"
94
90
  end
95
91
  else
96
- uninstall_gem list.first, list.dup
92
+ uninstall_gem list.first
97
93
  end
98
94
  end
99
95
 
100
96
  ##
101
97
  # Uninstalls gem +spec+
102
98
 
103
- def uninstall_gem(spec, specs)
99
+ def uninstall_gem(spec)
104
100
  @spec = spec
105
101
 
106
102
  unless dependencies_ok? spec
@@ -115,7 +111,7 @@ class Gem::Uninstaller
115
111
  end
116
112
 
117
113
  remove_executables @spec
118
- remove @spec, specs
114
+ remove @spec
119
115
 
120
116
  Gem.post_uninstall_hooks.each do |hook|
121
117
  hook.call self
@@ -131,10 +127,8 @@ class Gem::Uninstaller
131
127
  def remove_executables(spec)
132
128
  return if spec.nil? or spec.executables.empty?
133
129
 
134
- bindir = @bin_dir ? @bin_dir : Gem.bindir(spec.installation_path)
135
-
136
- list = @source_index.find_name(spec.name).delete_if { |s|
137
- s.version == spec.version
130
+ list = Gem::Specification.find_all { |s|
131
+ s.name == spec.name && s.version != spec.version
138
132
  }
139
133
 
140
134
  executables = spec.executables.clone
@@ -159,6 +153,8 @@ class Gem::Uninstaller
159
153
  unless remove then
160
154
  say "Executables and scripts will remain installed."
161
155
  else
156
+ bindir = @bin_dir || Gem.bindir(spec.base_dir)
157
+
162
158
  raise Gem::FilePermissionError, bindir unless File.writable? bindir
163
159
 
164
160
  spec.executables.each do |exe_name|
@@ -185,7 +181,7 @@ class Gem::Uninstaller
185
181
  # Warning: this method modifies the +list+ parameter. Once it has
186
182
  # uninstalled a gem, it is removed from that list.
187
183
 
188
- def remove(spec, list)
184
+ def remove(spec)
189
185
  unless path_ok?(@gem_home, spec) or
190
186
  (@user_install and path_ok?(Gem.user_dir, spec)) then
191
187
  e = Gem::GemNotInHomeException.new \
@@ -195,28 +191,27 @@ class Gem::Uninstaller
195
191
  raise e
196
192
  end
197
193
 
198
- raise Gem::FilePermissionError, spec.installation_path unless
199
- File.writable?(spec.installation_path)
194
+ raise Gem::FilePermissionError, spec.base_dir unless
195
+ File.writable?(spec.base_dir)
200
196
 
201
197
  FileUtils.rm_rf spec.full_gem_path
202
198
 
203
- original_platform_name = [
204
- spec.name, spec.version, spec.original_platform].join '-'
199
+ # TODO: should this be moved to spec?... I vote eww (also exists in docmgr)
200
+ old_platform_name = [spec.name,
201
+ spec.version,
202
+ spec.original_platform].join '-'
205
203
 
206
- spec_dir = File.join spec.installation_path, 'specifications'
207
- gemspec = File.join spec_dir, spec.spec_name
204
+ gemspec = spec.spec_file
208
205
 
209
206
  unless File.exist? gemspec then
210
- gemspec = File.join spec_dir, "#{original_platform_name}.gemspec"
207
+ gemspec = File.join(File.dirname(gemspec), "#{old_platform_name}.gemspec")
211
208
  end
212
209
 
213
210
  FileUtils.rm_rf gemspec
214
211
 
215
- gem = Gem.cache_gem(spec.file_name, spec.installation_path)
216
-
217
- unless File.exist? gem then
218
- gem = Gem.cache_gem("#{original_platform_name}.gem", spec.installation_path)
219
- end
212
+ gem = spec.cache_file
213
+ gem = File.join(spec.cache_dir, "#{old_platform_name}.gem") unless
214
+ File.exist? gem
220
215
 
221
216
  FileUtils.rm_rf gem
222
217
 
@@ -224,14 +219,14 @@ class Gem::Uninstaller
224
219
 
225
220
  say "Successfully uninstalled #{spec.full_name}"
226
221
 
227
- list.delete spec
222
+ Gem::Specification.remove_spec spec
228
223
  end
229
224
 
230
225
  ##
231
226
  # Is +spec+ in +gem_dir+?
232
227
 
233
228
  def path_ok?(gem_dir, spec)
234
- full_path = File.join gem_dir, 'gems', spec.full_name
229
+ full_path = File.join gem_dir, 'gems', spec.full_name
235
230
  original_path = File.join gem_dir, 'gems', spec.original_name
236
231
 
237
232
  full_path == spec.full_gem_path || original_path == spec.full_gem_path
@@ -240,8 +235,7 @@ class Gem::Uninstaller
240
235
  def dependencies_ok?(spec)
241
236
  return true if @force_ignore
242
237
 
243
- deplist = Gem::DependencyList.from_source_index @source_index
244
- deplist.add(*@user_index.gems.values) if @user_install
238
+ deplist = Gem::DependencyList.from_specs
245
239
  deplist.ok_to_remove?(spec.full_name)
246
240
  end
247
241
 
@@ -249,11 +243,13 @@ class Gem::Uninstaller
249
243
  msg = ['']
250
244
  msg << 'You have requested to uninstall the gem:'
251
245
  msg << "\t#{spec.full_name}"
252
- spec.dependent_gems.each do |gem,dep,satlist|
246
+
247
+ spec.dependent_gems.each do |dep_spec, dep, satlist|
253
248
  msg <<
254
- ("#{gem.name}-#{gem.version} depends on " +
255
- "[#{dep.name} (#{dep.requirement})]")
249
+ ("#{dep_spec.name}-#{dep_spec.version} depends on " +
250
+ "[#{dep.name} (#{dep.requirement})]")
256
251
  end
252
+
257
253
  msg << 'If you remove this gems, one or more dependencies will not be met.'
258
254
  msg << 'Continue with Uninstall?'
259
255
  return ask_yes_no(msg.join("\n"), true)
@@ -266,7 +262,4 @@ class Gem::Uninstaller
266
262
  filename
267
263
  end
268
264
  end
269
-
270
-
271
265
  end
272
-