rubygems-update 0.9.0 → 0.9.1

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 (105) hide show
  1. data/.document +4 -0
  2. data/ChangeLog +458 -0
  3. data/GPL.txt +340 -0
  4. data/LICENSE.txt +53 -0
  5. data/Rakefile +26 -10
  6. data/TODO +0 -1
  7. data/bin/gem_server +2 -434
  8. data/bin/gemlock +1 -1
  9. data/bin/index_gem_repository.rb +34 -12
  10. data/examples/application/an-app.gemspec +4 -2
  11. data/examples/application/ext/Makefile +139 -0
  12. data/examples/application/ext/extconf.rb +3 -0
  13. data/examples/application/ext/foo.c +1 -0
  14. data/lib/gemconfigure.rb +2 -2
  15. data/lib/rubygems.rb +85 -46
  16. data/lib/rubygems/cmd_manager.rb +14 -11
  17. data/lib/rubygems/command.rb +18 -9
  18. data/lib/rubygems/config_file.rb +17 -16
  19. data/lib/rubygems/custom_require.rb +7 -12
  20. data/lib/rubygems/dependency_list.rb +38 -38
  21. data/lib/rubygems/gem_commands.rb +471 -242
  22. data/lib/rubygems/gem_openssl.rb +1 -1
  23. data/lib/rubygems/gem_runner.rb +2 -1
  24. data/lib/rubygems/installer.rb +189 -143
  25. data/lib/rubygems/package.rb +625 -621
  26. data/lib/rubygems/remote_fetcher.rb +142 -0
  27. data/lib/rubygems/remote_installer.rb +85 -465
  28. data/lib/rubygems/rubygems_version.rb +1 -1
  29. data/lib/rubygems/security.rb +54 -11
  30. data/lib/rubygems/server.rb +486 -0
  31. data/lib/rubygems/source_index.rb +187 -21
  32. data/lib/rubygems/source_info_cache.rb +153 -0
  33. data/lib/rubygems/source_info_cache_entry.rb +31 -0
  34. data/lib/rubygems/specification.rb +71 -30
  35. data/lib/rubygems/user_interaction.rb +22 -20
  36. data/lib/rubygems/validator.rb +8 -7
  37. data/lib/rubygems/version.rb +32 -17
  38. data/pkgs/sources/sources-0.0.1.gem +0 -0
  39. data/post-install.rb +42 -3
  40. data/scripts/gemdoc.rb +3 -3
  41. data/scripts/runtest.rb +1 -1
  42. data/scripts/upload_gemdoc.rb +11 -11
  43. data/setup.rb +14 -7
  44. data/test/brokenbuildgem.rb +35 -0
  45. data/test/data/a-0.0.1.gem +0 -0
  46. data/test/data/a-0.0.2.gem +0 -0
  47. data/test/data/b-0.0.2.gem +0 -0
  48. data/test/data/broken-1.0.0.gem +0 -0
  49. data/test/data/broken_build/broken-build.gemspec +20 -0
  50. data/test/data/broken_build/ext/extconf.rb +3 -0
  51. data/test/data/broken_build/ext/foo.c +1 -0
  52. data/test/data/c-1.2.gem +0 -0
  53. data/test/data/gemhome/cache/a-0.0.1.gem +0 -0
  54. data/test/data/gemhome/cache/a-0.0.2.gem +0 -0
  55. data/test/data/gemhome/cache/b-0.0.2.gem +0 -0
  56. data/test/data/gemhome/cache/c-1.2.gem +0 -0
  57. data/test/data/gemhome/gems/a-0.0.1/lib/code.rb +0 -6
  58. data/test/data/gemhome/gems/a-0.0.2/lib/code.rb +0 -6
  59. data/test/data/gemhome/gems/b-0.0.2/lib/code.rb +0 -6
  60. data/test/data/gemhome/gems/c-1.2/lib/code.rb +0 -6
  61. data/test/data/gemhome/specifications/a-0.0.1.gemspec +1 -1
  62. data/test/data/gemhome/specifications/a-0.0.2.gemspec +1 -1
  63. data/test/data/gemhome/specifications/b-0.0.2.gemspec +1 -1
  64. data/test/data/gemhome/specifications/c-1.2.gemspec +1 -1
  65. data/test/data/lib/code.rb +0 -6
  66. data/test/data/one/one-0.0.1.gem +0 -0
  67. data/test/functional.rb +24 -21
  68. data/test/functional_extension_gems.rb +48 -0
  69. data/test/functional_generate_yaml_index.rb +6 -3
  70. data/test/gemenvironment.rb +27 -22
  71. data/test/gemutilities.rb +95 -5
  72. data/test/insure_session.rb +2 -2
  73. data/test/io_capture.rb +33 -0
  74. data/test/test_check_command.rb +2 -2
  75. data/test/test_command.rb +16 -13
  76. data/test/test_dependency_list.rb +20 -20
  77. data/test/test_file_list.rb +10 -11
  78. data/test/test_format.rb +19 -46
  79. data/test/test_gem.rb +25 -0
  80. data/test/test_gem_ext_configure_builder.rb +88 -0
  81. data/test/test_gem_ext_ext_conf_builder.rb +122 -0
  82. data/test/test_gem_ext_rake_builder.rb +61 -0
  83. data/test/test_gem_outdated_command.rb +37 -0
  84. data/test/test_gem_source_info_cache.rb +196 -0
  85. data/test/test_gem_source_info_cache_entry.rb +44 -0
  86. data/test/test_gem_sources_command.rb +130 -0
  87. data/test/test_installer.rb +137 -9
  88. data/test/test_package.rb +521 -531
  89. data/test/test_parse_commands.rb +7 -7
  90. data/test/test_process_commands.rb +1 -1
  91. data/test/test_remote_fetcher.rb +187 -45
  92. data/test/test_remote_installer.rb +35 -52
  93. data/test/test_require_gem.rb +12 -12
  94. data/test/test_source_index.rb +194 -48
  95. data/test/test_specification.rb +154 -0
  96. data/test/test_user_interaction.rb +48 -0
  97. data/test/test_validator.rb +1 -1
  98. data/test/test_version_comparison.rb +116 -5
  99. metadata +33 -10
  100. data/lib/rubygems/incremental_fetcher.rb +0 -136
  101. data/lib/rubygems/loadpath_manager.rb +0 -114
  102. data/lib/rubygems/open-uri.rb +0 -756
  103. data/test/test_cached_fetcher.rb +0 -64
  104. data/test/test_incremental_fetcher.rb +0 -175
  105. data/test/test_local_cache.rb +0 -106
@@ -8,7 +8,7 @@ require 'time'
8
8
  require 'rubygems'
9
9
  require 'rubygems/version'
10
10
 
11
- class Time
11
+ class Time # :nodoc:
12
12
  def self.today
13
13
  Time.parse Time.now.strftime("%Y-%m-%d")
14
14
  end
@@ -152,11 +152,11 @@ module Gem
152
152
  @@default_value[name] = []
153
153
  module_eval %{
154
154
  def #{name}
155
- @#{name} ||= []
156
- end
155
+ @#{name} ||= []
156
+ end
157
157
  def #{name}=(value)
158
- @#{name} = value.to_a
159
- end
158
+ @#{name} = value.to_a
159
+ end
160
160
  }
161
161
  end
162
162
 
@@ -273,6 +273,7 @@ module Gem
273
273
 
274
274
  def test_suite_file=(val)
275
275
  warn_deprecated(:test_suite_file, :test_files)
276
+ @test_files = [] unless defined? @test_files
276
277
  @test_files << val
277
278
  end
278
279
 
@@ -320,54 +321,73 @@ module Gem
320
321
  end
321
322
 
322
323
  overwrite_accessor :summary= do |str|
323
- if str
324
- @summary = str.strip.
325
- gsub(/(\w-)\n[ \t]*(\w)/, '\1\2').
326
- gsub(/\n[ \t]*/, " ")
327
- end
324
+ @summary = if str then
325
+ str.strip.
326
+ gsub(/(\w-)\n[ \t]*(\w)/, '\1\2').
327
+ gsub(/\n[ \t]*/, " ")
328
+ end
328
329
  end
329
330
 
330
331
  overwrite_accessor :description= do |str|
331
- if str
332
- @description = str.strip.
333
- gsub(/(\w-)\n[ \t]*(\w)/, '\1\2').
334
- gsub(/\n[ \t]*/, " ")
335
- end
332
+ @description = if str then
333
+ str.strip.
334
+ gsub(/(\w-)\n[ \t]*(\w)/, '\1\2').
335
+ gsub(/\n[ \t]*/, " ")
336
+ end
336
337
  end
337
338
 
338
339
  overwrite_accessor :default_executable do
339
- return @default_executable if @default_executable
340
- # Special case: if there is only one executable specified, then
341
- # that's obviously the default one.
342
- return @executables.first if @executables.size == 1
343
- nil
340
+ begin
341
+ if defined? @default_executable and @default_executable
342
+ result = @default_executable
343
+ elsif @executables and @executables.size == 1
344
+ result = @executables.first
345
+ else
346
+ result = nil
347
+ end
348
+ result
349
+ rescue
350
+ nil
351
+ end
344
352
  end
345
353
 
346
354
  def add_bindir(executables)
347
- if(@executables.nil?)
355
+ if not defined? @executables || @executables.nil?
348
356
  return nil
349
357
  end
350
- if(@bindir)
358
+
359
+ if defined? @bindir and @bindir then
351
360
  @executables.map {|e| File.join(@bindir, e) }
352
361
  else
353
362
  @executables
354
363
  end
364
+ rescue
365
+ return nil
355
366
  end
356
367
 
357
368
  overwrite_accessor :files do
358
- (@files || []) | (@test_files || []) | (add_bindir(@executables) || []) |
359
- (@extra_rdoc_files || []) | (@extensions || [])
369
+ result = []
370
+ result |= as_array(@files) if defined?(@files)
371
+ result |= as_array(@test_files) if defined?(@test_files)
372
+ result |= as_array(add_bindir(@executables) || [])
373
+ result |= as_array(@extra_rdoc_files) if defined?(@extra_rdoc_files)
374
+ result |= as_array(@extensions) if defined?(@extensions)
375
+ result
360
376
  end
361
377
 
362
378
  overwrite_accessor :test_files do
363
379
  # Handle the possibility that we have @test_suite_file but not
364
380
  # @test_files. This will happen when an old gem is loaded via
365
381
  # YAML.
366
- if @test_suite_file
382
+ if defined? @test_suite_file then
367
383
  @test_files = [@test_suite_file].flatten
368
384
  @test_suite_file = nil
369
385
  end
370
- @test_files ||= []
386
+ if defined? @test_files and @test_files then
387
+ @test_files
388
+ else
389
+ @test_files = []
390
+ end
371
391
  end
372
392
 
373
393
  # Predicates -----------------------------------------------------
@@ -412,13 +432,14 @@ module Gem
412
432
  def Specification.from_yaml(input)
413
433
  input = normalize_yaml_input(input)
414
434
  spec = YAML.load(input)
415
- if(spec.class == FalseClass) then
435
+ if(spec && spec.class == FalseClass) then
416
436
  raise Gem::EndOfYAMLException
417
437
  end
418
438
  unless Specification === spec
419
439
  raise Gem::Exception, "YAML data doesn't evaluate to gem specification"
420
440
  end
421
- unless spec.instance_variable_get :@specification_version
441
+ unless spec.instance_variables.include? '@specification_version' and
442
+ spec.instance_variable_get :@specification_version
422
443
  spec.instance_variable_set :@specification_version,
423
444
  NONEXISTENT_SPECIFICATION_VERSION
424
445
  end
@@ -515,12 +536,26 @@ module Gem
515
536
  end
516
537
 
517
538
  # Tests specs for equality (across all attributes).
518
- def ==(other)
539
+ def ==(other) # :nodoc:
540
+ other.kind_of?(self.class) && same_attributes?(other)
541
+ end
542
+
543
+ alias eql? == # :nodoc:
544
+
545
+ def same_attributes?(other)
519
546
  @@attributes.each do |name, default|
520
547
  return false unless self.send(name) == other.send(name)
521
548
  end
522
549
  true
523
550
  end
551
+ private :same_attributes?
552
+
553
+ def hash # :nodoc:
554
+ @@attributes.inject(0) { |hash_code, (name, default_value)|
555
+ n = self.send(name).hash
556
+ hash_code + n
557
+ }
558
+ end
524
559
 
525
560
  # Export methods (YAML and Ruby code) ----------------------------
526
561
 
@@ -584,7 +619,7 @@ module Gem
584
619
  # Also, the summary and description are converted to a normal
585
620
  # format.
586
621
  def normalize
587
- if @extra_rdoc_files
622
+ if defined? @extra_rdoc_files and @extra_rdoc_files then
588
623
  @extra_rdoc_files.uniq!
589
624
  @files ||= []
590
625
  @files.concat(@extra_rdoc_files)
@@ -639,6 +674,12 @@ module Gem
639
674
  end
640
675
  end
641
676
 
677
+ def as_array(items)
678
+ items.to_ary
679
+ rescue NoMethodError => ex
680
+ [items]
681
+ end
682
+
642
683
  # Return a string containing a Ruby code representation of the
643
684
  # given object.
644
685
  def ruby_code(obj)
@@ -29,6 +29,9 @@ module Gem
29
29
 
30
30
  # The default UI is a class variable of the singleton class for
31
31
  # this module.
32
+
33
+ @ui = nil
34
+
32
35
  class << self
33
36
  def ui
34
37
  @ui ||= Gem::ConsoleUI.new
@@ -172,15 +175,15 @@ module Gem
172
175
  def progress_reporter(*args)
173
176
  case Gem.configuration.verbose
174
177
  when nil, false
175
- SilentProgressReporter.new(@outs, *args)
178
+ SilentProgressReporter.new(@outs, *args)
176
179
  when true
177
- SimpleProgressReporter.new(@outs, *args)
180
+ SimpleProgressReporter.new(@outs, *args)
178
181
  else
179
- VerboseProgressReporter.new(@outs, *args)
182
+ VerboseProgressReporter.new(@outs, *args)
180
183
  end
181
184
  end
182
185
 
183
- class SilentReporter
186
+ class SilentProgressReporter
184
187
  attr_reader :count
185
188
 
186
189
  def initialize(out_stream, size, initial_message)
@@ -199,20 +202,20 @@ module Gem
199
202
  attr_reader :count
200
203
 
201
204
  def initialize(out_stream, size, initial_message)
202
- @out = out_stream
203
- @total = size
204
- @count = 0
205
- ui.say initial_message
205
+ @out = out_stream
206
+ @total = size
207
+ @count = 0
208
+ @out.puts initial_message
206
209
  end
207
210
 
208
211
  def updated(message)
209
- @count += 1
210
- @out.print "."
211
- @out.flush
212
+ @count += 1
213
+ @out.print "."
214
+ @out.flush
212
215
  end
213
216
 
214
217
  def done
215
- @out.puts "\ncomplete"
218
+ @out.puts "\ncomplete"
216
219
  end
217
220
  end
218
221
 
@@ -222,24 +225,23 @@ module Gem
222
225
  attr_reader :count
223
226
 
224
227
  def initialize(out_stream, size, initial_message)
225
- @out = out_stream
226
- @total = size
227
- @count = 0
228
- @out.puts initial_message
228
+ @out = out_stream
229
+ @total = size
230
+ @count = 0
231
+ @out.puts initial_message
229
232
  end
230
233
 
231
234
  def updated(message)
232
- @count += 1
233
- @out.puts "#{@count}/#{@total}: #{message}"
235
+ @count += 1
236
+ @out.puts "#{@count}/#{@total}: #{message}"
234
237
  end
235
238
 
236
239
  def done
237
- @out.puts "complete"
240
+ @out.puts "complete"
238
241
  end
239
242
  end
240
243
  end
241
244
 
242
-
243
245
  ####################################################################
244
246
  # Subclass of StreamUI that instantiates the user interaction using
245
247
  # standard in, out and error.
@@ -23,8 +23,8 @@ module Gem
23
23
  require 'md5'
24
24
  unless(gem_data =~ /MD5SUM/m)
25
25
  return # Don't worry about it...this sucks. Need to fix MD5 stuff for
26
- # new format
27
- # FIXME
26
+ # new format
27
+ # FIXME
28
28
  end
29
29
  unless (MD5.md5(gem_data.gsub(/MD5SUM = "([a-z0-9]+)"/, "MD5SUM = \"" + ("F" * 32) + "\"")) == $1.to_s)
30
30
  raise VerificationError.new("Invalid checksum for Gem file")
@@ -95,10 +95,10 @@ module Gem
95
95
  format = Gem::Format.from_file_by_path(gem_path)
96
96
  format.file_entries.each do |entry, data|
97
97
  # Found this file. Delete it from list
98
- installed_files.delete remove_leading_dot_dir(entry['path'])
98
+ installed_files.delete remove_leading_dot_dir(entry['path'])
99
99
  File.open(File.join(gem_directory, entry['path']), 'rb') do |f|
100
100
  unless MD5.md5(f.read).to_s == MD5.md5(data).to_s
101
- errors[gem_name] << ErrorData.new(entry['path'], "installed file doesn't match original from gem")
101
+ errors[gem_name] << ErrorData.new(entry['path'], "installed file doesn't match original from gem")
102
102
  end
103
103
  end
104
104
  end
@@ -108,7 +108,7 @@ module Gem
108
108
  end
109
109
  # Clean out directories that weren't explicitly included in the gemspec
110
110
  # FIXME: This still allows arbitrary incorrect directories.
111
- installed_files.delete_if {|potential_directory|
111
+ installed_files.delete_if {|potential_directory|
112
112
  File.directory?(File.join(gem_directory, potential_directory))
113
113
  }
114
114
  if(installed_files.size > 0) then
@@ -130,7 +130,7 @@ module Gem
130
130
  say "There are no unit tests to run for #{gem_spec.name}-#{gem_spec.version}"
131
131
  return
132
132
  end
133
- require_gem gem_spec.name, "= #{gem_spec.version.version}"
133
+ gem gem_spec.name, "= #{gem_spec.version.version}"
134
134
  test_files.each do |f| require f end
135
135
  require 'test/unit/ui/console/testrunner'
136
136
  suite = Test::Unit::TestSuite.new("#{gem_spec.name}-#{gem_spec.version}")
@@ -144,8 +144,9 @@ module Gem
144
144
  #Gem::Uninstaller.new(gem_spec.name, gem_spec.version.version).uninstall
145
145
  #end
146
146
  end
147
- Dir.chdir(start_dir)
148
147
  result
148
+ ensure
149
+ Dir.chdir(start_dir)
149
150
  end
150
151
 
151
152
  def remove_leading_dot_dir(path)
@@ -10,7 +10,9 @@ module Gem
10
10
  # The Dependency class holds a Gem name and Version::Requirement
11
11
  #
12
12
  class Dependency
13
- attr_accessor :name, :version_requirements
13
+ attr_accessor :name
14
+
15
+ attr_writer :version_requirements
14
16
 
15
17
  def <=>(other)
16
18
  [@name] <=> [other.name]
@@ -28,9 +30,8 @@ module Gem
28
30
  @version_requirement = nil # Avoid warnings.
29
31
  end
30
32
 
31
- undef version_requirements
32
33
  def version_requirements
33
- normalize if @version_requirement
34
+ normalize if defined? @version_requirement and @version_requirement
34
35
  @version_requirements
35
36
  end
36
37
 
@@ -51,9 +52,15 @@ module Gem
51
52
  end
52
53
 
53
54
  def ==(other)
54
- self.name = other.name and
55
+ other.kind_of?(self.class) &&
56
+ self.name == other.name &&
55
57
  self.version_requirements == other.version_requirements
56
58
  end
59
+
60
+ def hash
61
+ name.hash + version_requirements.hash
62
+ end
63
+
57
64
  end
58
65
 
59
66
  ####################################################################
@@ -150,6 +157,10 @@ module Gem
150
157
  return r <=> v
151
158
  end
152
159
 
160
+ def hash
161
+ to_ints.inject { |hash_code, n| hash_code + n }
162
+ end
163
+
153
164
  # Return a new version object where the next to the last revision
154
165
  # number is one greater. (e.g. 5.3.1 => 5.4)
155
166
  def bump
@@ -200,13 +211,13 @@ module Gem
200
211
  #
201
212
  def self.create(input)
202
213
  if input.kind_of?(Requirement)
203
- return input
214
+ return input
204
215
  elsif input.kind_of?(Array)
205
- return self.new(input)
216
+ return self.new(input)
206
217
  elsif input.respond_to? :to_str
207
- return self.new([input.to_str])
218
+ return self.new([input.to_str])
208
219
  else
209
- return self.default
220
+ return self.default
210
221
  end
211
222
  end
212
223
 
@@ -224,8 +235,8 @@ module Gem
224
235
  #
225
236
  def initialize(reqs)
226
237
  @requirements = reqs.collect do |rq|
227
- op, version_string = parse(rq)
228
- [op, Version.new(version_string)]
238
+ op, version_string = parse(rq)
239
+ [op, Version.new(version_string)]
229
240
  end
230
241
  @version = nil # Avoid warnings.
231
242
  end
@@ -248,12 +259,12 @@ module Gem
248
259
  def as_list
249
260
  normalize
250
261
  @requirements.collect { |req|
251
- "#{req[0]} #{req[1]}"
262
+ "#{req[0]} #{req[1]}"
252
263
  }
253
264
  end
254
265
 
255
266
  def normalize
256
- return if @version.nil?
267
+ return if not defined? @version or @version.nil?
257
268
  @requirements = [parse(@version)]
258
269
  @nums = nil
259
270
  @version = nil
@@ -287,20 +298,24 @@ module Gem
287
298
  #
288
299
  def parse(str)
289
300
  if md = /^\s*(#{OP_RE})\s*([0-9.]+)\s*$/.match(str)
290
- [md[1], md[2]]
301
+ [md[1], md[2]]
291
302
  elsif md = /^\s*([0-9.]+)\s*$/.match(str)
292
- ["=", md[1]]
303
+ ["=", md[1]]
293
304
  elsif md = /^\s*(#{OP_RE})\s*$/.match(str)
294
- [md[1], "0"]
305
+ [md[1], "0"]
295
306
  else
296
- fail ArgumentError, "Illformed requirement [#{str}]"
307
+ fail ArgumentError, "Illformed requirement [#{str}]"
297
308
  end
298
309
  end
299
310
 
300
311
  def <=>(other)
301
312
  to_s <=> other.to_s
302
313
  end
303
-
314
+
315
+ def hash
316
+ to_s.hash
317
+ end
318
+ public :hash
304
319
  end
305
320
 
306
321
  end