rubygems-update 0.8.3 → 0.8.4

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.

data/ChangeLog CHANGED
@@ -1,3 +1,73 @@
1
+ 2005-01-01 Chad Fowler <chad@chadfowler.com>
2
+ * Released 0.8.4
3
+
4
+ 2004-12-31 Jim Weirich <jim@weirichhouse.org>
5
+
6
+ * Rakefile: Switch to standard Rake test tasks.
7
+
8
+ * lib/rubygems/remote_installer.rb
9
+ (Gem::RemoteSourceFetcher::read_data): Added a retry to try a
10
+ lower case gem name if the open failed. This fixes a problem
11
+ where case differences are preventing some gems from installing.
12
+
13
+ 2004-12-29 Jim Weirich <jim@weirichhouse.org>
14
+
15
+ * lib/rubygems/gem_commands.rb (Gem::InstallCommand::execute):
16
+ Changed the RemoteInstaller to take an options hash rather than
17
+ individual options. This will leave the interface more resilient
18
+ to changes as more options are added
19
+ (e.g. --install_dependencies).
20
+
21
+ * lib/rubygems/specification.rb (Gem::Specification): Marked array
22
+ attributes explicitly. This allows for explicit conversion to
23
+ arrays when assigned.
24
+
25
+ * test/test_specification.rb
26
+ (TestSimpleSpecification::test_array_attributes): Added test for
27
+ array_attributes forcing values to arrays.
28
+
29
+ 2004-12-28 Jim Weirich <jim@tardis>
30
+
31
+ * lib/rubygems.rb (Gem::Exception::ensure_gem_subdirectories):
32
+ Fixed the Ryan Davis patch to work correctly when directories are
33
+ not writable.
34
+
35
+ 2004-12-18 Chad Fowler <chad@chadfowler.com>
36
+ * lib/rubygems/version.rb: Erik Veenstra's sort patch.
37
+ * lib/rubygems.rb: Ryan Davis's installation bug fix.
38
+
39
+ 2004-12-14 Gavin Sinclair <gsinclair@soyabean.com.au>
40
+
41
+ * test/test_loadmanager.rb: invalidated it as a unit test; it's
42
+ incompatible with custom_require.rb.
43
+
44
+ 2004-12-12 Gavin Sinclair <gsinclair@soyabean.com.au>
45
+
46
+ * lib/rubygems/custom_require.rb: simple bug fix.
47
+
48
+ 2004-12-12 Gavin Sinclair <gsinclair@soyabean.com.au>
49
+
50
+ * lib/rubygems/custom_require.rb: new file to replace
51
+ loadpath_manager.rb and speed up the custom require functionality.
52
+
53
+ * lib/rubygems/timer.rb: new file; simple benchmarking tool that's
54
+ useful at the moment but needn't stay in RubyGems permanently.
55
+
56
+ * lib/rubygems/source_index.rb: include Enumerable and implement #size
57
+ and #length.
58
+
59
+ * lib/rubygems/specification.rb: removed lazy initialisation of
60
+ attributes to reduce #copy_of invocations; folded
61
+ Specification.copy_of into Specification#copy_of.
62
+
63
+ * lib/rubygems.rb: require 'rubygems/custom_require' instead of
64
+ 'rubygems/loadpath_manager'; removed out of date documentation; added
65
+ "require 'rubygems/timer'" to temporarily assist with benchmarks.
66
+
67
+ 2004-12-07 Jim Weirich <jim@weirichhouse.org>
68
+
69
+ * Released 0.8.3
70
+
1
71
  2004-12-06 Jim Weirich <jim@weirichhouse.org>
2
72
 
3
73
  * test/test_specification.rb
@@ -26,7 +96,7 @@
26
96
  (Gem::LocalSourceInfoCache::read_cache): Fixed initialization of
27
97
  cache.
28
98
 
29
- * lib/rubygems.rb: Updated version to 1.8.2.
99
+ * lib/rubygems.rb: Updated version to 0.8.2.
30
100
 
31
101
  2004-12-04 Jim Weirich <jim@weirichhouse.org>
32
102
 
@@ -256,6 +326,8 @@
256
326
  by Rich).
257
327
  * lib/rubygems.rb: Fixed small bug in #latest_load_paths
258
328
 
329
+ (NOTE: It looks like 0.8.0/0.8.1 was released in this timeframe)
330
+
259
331
  2004-09-14 Chad Fowler <chad@chadfowler.com>
260
332
  * lib/rubygems.rb: Fixed bug in require_gem (thanks Jamis Buck!)
261
333
  that would require a gem based on an inexact search of its name
data/Rakefile CHANGED
@@ -26,22 +26,16 @@ CLOBBER.include(
26
26
 
27
27
  task :default => [:test]
28
28
 
29
- desc "Run unit tests"
30
- task :test do
31
- test_name = ENV['TEST'] || 'test/test*.rb'
32
- ruby %{-Ilib -rscripts/runtest -e 'run_tests("#{test_name}", true)'}
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.test_files = FileList['test/test*.rb']
33
31
  end
34
32
 
35
- desc "Run Functional Tests"
36
- task :functional do
37
- test_name = ENV['TEST'] || 'test/functional.rb'
38
- ruby %{-Ilib -rscripts/runtest -e 'run_tests("#{test_name}", true)'}
33
+ Rake::TestTask.new(:functional) do |t|
34
+ t.test_files = FileList['test/functional*.rb']
39
35
  end
40
36
 
41
- desc "Run All Tests"
42
- task :alltests do
43
- test_name = ENV['TEST'] || 'test/{test,functional}*.rb'
44
- ruby %{-Ilib -rscripts/runtest -e 'run_tests("#{test_name}", true)'}
37
+ Rake::TestTask.new(:alltests) do |t|
38
+ t.test_files = FileList['test/{test,functional}*.rb']
45
39
  end
46
40
 
47
41
  desc "Run the tests for a build"
@@ -147,7 +141,7 @@ end
147
141
 
148
142
  task :tag => [:prerelease] do
149
143
  reltag = "REL_#{ENV['REL'].gsub(/\./, '_')}"
150
- reltag << ENV['REUSE'] if ENV['REUSE']
144
+ reltag << ENV['REUSE'].gsub(/\./, '_') if ENV['REUSE']
151
145
  announce "Tagging CVS with [#{reltag}]"
152
146
  sh %{cvs tag #{reltag}}
153
147
  end
@@ -158,9 +152,6 @@ end
158
152
  desc "Create the RDOC html files"
159
153
  rd = Rake::RDocTask.new("rdoc") { |rdoc|
160
154
  rdoc.rdoc_dir = 'html'
161
- # rdoc.template = 'kilmer'
162
- # rdoc.template = 'css2'
163
- rdoc.template = 'jamis'
164
155
  rdoc.title = "RubyGems"
165
156
  rdoc.options << '--line-numbers' << '--inline-source' << '--main' << 'README'
166
157
  rdoc.rdoc_files.include('README', 'TODO', 'Releases')
data/Releases CHANGED
@@ -1,5 +1,34 @@
1
1
  = RubyGems Release History
2
2
 
3
+ == Release 0.8.3: Dec 7, 2004
4
+
5
+ * Added workaround for the null byte in Dir string issue. (see
6
+ http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/121702).
7
+ (Thanks to Mauricio Fern�ndez for the quick response on this one).
8
+
9
+ * Added workaround for old version of Zlib on windows that caused
10
+ Ruwiki to fail to install. (see
11
+ http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/121770)
12
+
13
+ * Added workaround for large YAML file issues. (We dynamically cut
14
+ down the size of the source index YAML file and seem to have worked
15
+ around immediate issues.
16
+
17
+ * A user specific source index cache can be used when the site-wide
18
+ cache is unwritable (i.e. because you are running as a non-admin).
19
+ This *greatly* speeds up gem commands run in non-admin mode when the
20
+ site-wide cache is out of date.
21
+
22
+ * The gem command now used an HTTP HEAD command to detect if the
23
+ server's source index needs to be downloaed.
24
+
25
+ * gem check gemname --test will run unit tests on installed gems that
26
+ have unit tests.
27
+
28
+ == Release 0.8.1: Sep 14, 2004
29
+
30
+ * Quick release to capture some bug fixes.
31
+
3
32
  == Release 0.8.0: Sep 12, 2004
4
33
 
5
34
  * Remove need for library stubs. Set the RUBYOPT environment variable
@@ -1,3 +1,6 @@
1
+ require 'rubygems/timer'
2
+ require 'rbconfig'
3
+
1
4
  module Gem
2
5
  class LoadError < ::LoadError
3
6
  attr_accessor :name, :version_requirement
@@ -14,22 +17,11 @@ module Kernel
14
17
  # a required Gem is not found, a Gem::LoadError is raised. More information on
15
18
  # version requirements can be found in the Gem::Version documentation.
16
19
  #
17
- # As a shortcut, the +gem+ parameter can be a _path_, for example:
18
- #
19
- # require_gem 'rake/packagetask'
20
- #
21
- # This is strictly short for
22
- #
23
- # require_gem 'rake'
24
- # require 'rake/packagetask'
20
+ # You can define the environment variable GEM_SKIP as a way to not
21
+ # load specified gems. you might do this to test out changes that haven't
22
+ # been intsalled yet. Example:
25
23
  #
26
- # You can define the environment variable GEM_SKIP as a way to not
27
- # load specified gems. you might do this to test out changes that haven't
28
- # been intsalled yet. Example:
29
- #
30
- # GEM_SKIP=libA:libB ruby-I../libA -I../libB ./mycode.rb
31
- #
32
- # <i>This is an experimental feature added after versoin 0.7, on 2004-07-13. </i>
24
+ # GEM_SKIP=libA:libB ruby-I../libA -I../libB ./mycode.rb
33
25
  #
34
26
  # gem:: [String or Gem::Dependency] The gem name or dependency instance.
35
27
  # version_requirement:: [default="> 0.0.0"] The version requirement.
@@ -200,9 +192,9 @@ module Gem
200
192
  def all_load_paths
201
193
  result = []
202
194
  Gem.path.each do |gemdir|
203
- each_load_path(all_partials(gemdir)) do |load_path|
204
- result << load_path
205
- end
195
+ each_load_path(all_partials(gemdir)) do |load_path|
196
+ result << load_path
197
+ end
206
198
  end
207
199
  result
208
200
  end
@@ -212,9 +204,9 @@ module Gem
212
204
  def latest_load_paths
213
205
  result = []
214
206
  Gem.path.each do |gemdir|
215
- each_load_path(latest_partials(gemdir)) do |load_path|
216
- result << load_path
217
- end
207
+ each_load_path(latest_partials(gemdir)) do |load_path|
208
+ result << load_path
209
+ end
218
210
  end
219
211
  result
220
212
  end
@@ -225,8 +217,8 @@ module Gem
225
217
  return nil if matches.empty?
226
218
  spec = matches.last
227
219
  spec.require_paths.each do |path|
228
- result = File.join(spec.full_gem_path, path, libfile)
229
- return result if File.exists?(result)
220
+ result = File.join(spec.full_gem_path, path, libfile)
221
+ return result if File.exists?(result)
230
222
  end
231
223
  end
232
224
 
@@ -242,13 +234,13 @@ module Gem
242
234
  def latest_partials(gemdir)
243
235
  latest = {}
244
236
  all_partials(gemdir).each do |gp|
245
- base = File.basename(gp)
237
+ base = File.basename(gp)
246
238
  matches = /(.*)-((\d+\.)*\d+)/.match(base)
247
- name, version = [matches[1], matches[2]]
248
- ver = Gem::Version.new(version)
249
- if latest[name].nil? || ver > latest[name][0]
250
- latest[name] = [ver, gp]
251
- end
239
+ name, version = [matches[1], matches[2]]
240
+ ver = Gem::Version.new(version)
241
+ if latest[name].nil? || ver > latest[name][0]
242
+ latest[name] = [ver, gp]
243
+ end
252
244
  end
253
245
  latest.collect { |k,v| v[1] }
254
246
  end
@@ -257,17 +249,17 @@ module Gem
257
249
  # specified in the Gem spec. Each expanded path is yielded.
258
250
  def each_load_path(partials)
259
251
  partials.each do |gp|
260
- base = File.basename(gp)
261
- specfn = File.join(dir, "specifications", base + ".gemspec")
262
- if File.exist?(specfn)
263
- spec = eval(File.read(specfn))
264
- spec.require_paths.each do |rp|
265
- yield(File.join(gp, rp))
266
- end
267
- else
268
- filename = File.join(gp, 'lib')
269
- yield(filename) if File.exist?(filename)
270
- end
252
+ base = File.basename(gp)
253
+ specfn = File.join(dir, "specifications", base + ".gemspec")
254
+ if File.exist?(specfn)
255
+ spec = eval(File.read(specfn))
256
+ spec.require_paths.each do |rp|
257
+ yield(File.join(gp, rp))
258
+ end
259
+ else
260
+ filename = File.join(gp, 'lib')
261
+ yield(filename) if File.exist?(filename)
262
+ end
271
263
  end
272
264
  end
273
265
 
@@ -299,19 +291,19 @@ module Gem
299
291
  #
300
292
  def find_home
301
293
  ['HOME', 'USERPROFILE'].each do |homekey|
302
- return ENV[homekey] if ENV[homekey]
294
+ return ENV[homekey] if ENV[homekey]
303
295
  end
304
296
  if ENV['HOMEDRIVE'] && ENV['HOMEPATH']
305
- return "#{ENV['HOMEDRIVE']}:#{ENV['HOMEPATH']}"
297
+ return "#{ENV['HOMEDRIVE']}:#{ENV['HOMEPATH']}"
306
298
  end
307
299
  begin
308
- File.expand_path("~")
300
+ File.expand_path("~")
309
301
  rescue Exception => ex
310
- if File::ALT_SEPARATOR
311
- "C:/"
312
- else
313
- "/"
314
- end
302
+ if File::ALT_SEPARATOR
303
+ "C:/"
304
+ else
305
+ "/"
306
+ end
315
307
  end
316
308
  end
317
309
 
@@ -320,12 +312,22 @@ module Gem
320
312
  # Default home directory path to be used if an alternate value is
321
313
  # not specified in the environment.
322
314
  def default_dir
323
- #rbconfig = Dir.glob("{#{($LOAD_PATH).join(',')}}/rbconfig.rb").first
324
- #if rbconfig
325
- # module_eval File.read(rbconfig) unless const_defined?("Config")
326
- #else
327
- require 'rbconfig'
328
- #end
315
+ ## rbconfig = Dir.glob("{#{($LOAD_PATH).join(',')}}/rbconfig.rb").first
316
+ ## if rbconfig
317
+ ## module_eval File.read(rbconfig) unless const_defined?("Config")
318
+ ## else
319
+ ## require 'rbconfig'
320
+ ## end
321
+ #
322
+ # Note on above code: we have an issue if a Config class is
323
+ # already defined and we load 'rbconfig'. The above code is
324
+ # supposed to work around that but it's been commented out. In
325
+ # any case, I moved "require 'rbconfig'" to the top of this
326
+ # file, because there was a circular dependency between this
327
+ # method and our custom require. In any case, rbconfig is a
328
+ # fundamental RubyGems dependency, so it might as well be up the
329
+ # top. -- Gavin Sinclair, 2004-12-12
330
+ #
329
331
  File.join(Config::CONFIG['libdir'], 'ruby', 'gems', Config::CONFIG['ruby_version'])
330
332
  end
331
333
 
@@ -337,9 +339,9 @@ module Gem
337
339
  def ensure_gem_subdirectories(gemdir)
338
340
  DIRECTORIES.each do |filename|
339
341
  fn = File.join(gemdir, filename)
340
- if ! File.exists?(fn) && File.writable?(fn)
342
+ unless File.exists?(fn)
341
343
  require 'fileutils'
342
- FileUtils.mkdir_p(fn)
344
+ FileUtils.mkdir_p(fn) rescue nil
343
345
  end
344
346
  end
345
347
  end
@@ -350,4 +352,6 @@ end
350
352
  require 'rubygems/source_index'
351
353
  require 'rubygems/specification'
352
354
  require 'rubygems/version'
353
- require 'rubygems/loadpath_manager'
355
+ #require 'rubygems/loadpath_manager' # custom_require replaces this
356
+ require 'rubygems/custom_require'
357
+
@@ -0,0 +1,109 @@
1
+ require 'rubygems/source_index'
2
+
3
+ module Kernel
4
+ alias require__ require
5
+
6
+ #
7
+ # We replace Ruby's require with our own, which is capable of loading gems on demand.
8
+ #
9
+ # When you call <tt>require 'x'</tt>, this is what happens:
10
+ # * If the file can be loaded from the existing Ruby loadpath, it is.
11
+ # * Otherwise, installed gems are searched for a file that matches. If it's found in gem
12
+ # 'y', that gem is activated (added to the loadpath).
13
+ #
14
+ # The normal <tt>require</tt> functionality of returning false if that file has already been
15
+ # loaded is preserved.
16
+ #
17
+ def require(path)
18
+ require__ path
19
+ rescue LoadError
20
+ begin
21
+ @gempath_searcher ||= Gem::GemPathSearcher.new
22
+ if spec = @gempath_searcher.find(path)
23
+ Gem.activate(spec.name, true, "= #{spec.version}")
24
+ require__ path
25
+ else
26
+ raise LoadError, "No such file to load -- #{path}"
27
+ end
28
+ end
29
+ end
30
+ end # module Kernel
31
+
32
+
33
+ module Gem
34
+
35
+ #
36
+ # GemPathSearcher has the capability to find loadable files inside gems. It generates data
37
+ # up front to speed up searches later.
38
+ #
39
+ class GemPathSearcher
40
+
41
+ #
42
+ # Initialise the data we need to make searches later.
43
+ #
44
+ def initialize
45
+ # We want a record of all the installed gemspecs, in the order we wish to examine them.
46
+ @gemspecs = init_gemspecs
47
+ # Map gem spec to glob of full require_path directories. Preparing this information may
48
+ # speed up searches later.
49
+ @lib_dirs = {}
50
+ @gemspecs.each do |spec|
51
+ @lib_dirs[spec.object_id] = lib_dirs(spec)
52
+ end
53
+ end
54
+
55
+ #
56
+ # Look in all the installed gems until a matching _path_ is found. Return the _gemspec_
57
+ # of the gem where it was found. If no match is found, return nil.
58
+ #
59
+ # The gems are searched in alphabetical order, and in reverse version order.
60
+ #
61
+ # For example:
62
+ #
63
+ # find('log4r') # -> (log4r-1.1 spec)
64
+ # find('log4r.rb') # -> (log4r-1.1 spec)
65
+ # find('rake/rdoctask') # -> (rake-0.4.12 spec)
66
+ # find('foobarbaz') # -> nil
67
+ #
68
+ # Matching paths can have various suffixes ('.rb', '.so', and others), which may or may
69
+ # not already be attached to _file_. This method doesn't care about the full filename
70
+ # that matches; only that there is a match.
71
+ #
72
+ def find(path)
73
+ @gemspecs.each do |spec|
74
+ return spec if matching_file(spec, path)
75
+ end
76
+ nil
77
+ end
78
+
79
+ private
80
+
81
+ SUFFIX_PATTERN = "{,.rb,.so,.bundle,.dll,.sl}"
82
+
83
+ #
84
+ # Attempts to find a matching path using the require_paths of the given _spec_.
85
+ #
86
+ # Some of the intermediate results are cached in @lib_dirs for speed.
87
+ #
88
+ def matching_file(spec, path) # :doc:
89
+ glob = "#{@lib_dirs[spec.object_id]}/#{path}#{SUFFIX_PATTERN}"
90
+ return true unless Dir[glob].select { |f| File.file?(f) }.empty?
91
+ end
92
+
93
+ # Return a list of all installed gemspecs, sorted by alphabetical order and in reverse
94
+ # version order.
95
+ def init_gemspecs
96
+ Gem.source_index.map { |_, spec| spec }.sort_by { |spec|
97
+ [spec.name, spec.version.to_ints.map { |n| -n } ]
98
+ }
99
+ end
100
+
101
+ # Returns library directories glob for a gemspec. For example,
102
+ # '/usr/local/lib/ruby/gems/1.8/gems/foobar-1.0/{lib,ext}'
103
+ def lib_dirs(spec)
104
+ "#{spec.full_gem_path}/#{spec.require_paths.join(',')}"
105
+ end
106
+
107
+ end # class Gem::GemPathLoader
108
+
109
+ end # module Gem
@@ -160,7 +160,7 @@ module Gem
160
160
 
161
161
  if remote? && installed_gems.nil?
162
162
  say "Attempting remote installation of '#{gem_name}'"
163
- installer = Gem::RemoteInstaller.new(options[:http_proxy])
163
+ installer = Gem::RemoteInstaller.new(options)
164
164
  installed_gems = installer.install(gem_name, options[:version], options[:force], options[:install_dir])
165
165
  say "Successfully installed #{installed_gems[0].name}, version #{installed_gems[0].version}" if installed_gems
166
166
  end
@@ -373,7 +373,7 @@ module Gem
373
373
  say
374
374
  say "*** REMOTE GEMS ***"
375
375
  begin
376
- output_query_results(Gem::RemoteInstaller.new(options[:http_proxy]).search(options[:name]))
376
+ output_query_results(Gem::RemoteInstaller.new(options).search(options[:name]))
377
377
  rescue Gem::RemoteSourceException => e
378
378
  alert_error e.to_s
379
379
  end
@@ -521,7 +521,7 @@ module Gem
521
521
  hig[spec.name] = spec
522
522
  end
523
523
  end
524
- remote_gemspecs = Gem::RemoteInstaller.new(options[:http_proxy]).search(//)
524
+ remote_gemspecs = Gem::RemoteInstaller.new(options).search(//)
525
525
  # For some reason, this is an array of arrays. The actual list of specifications is
526
526
  # the first and only element. If there were more remote sources, perhaps there would be
527
527
  # more.
@@ -93,11 +93,18 @@ module Gem
93
93
  # Read the data from the (source based) URI.
94
94
  def read_data(uri)
95
95
  require 'rubygems/open-uri'
96
- open(uri,
97
- "User-Agent" => "RubyGems/#{Gem::RubyGemsVersion}",
98
- :proxy => @http_proxy
99
- ) do |input|
100
- input.read
96
+ begin
97
+ open(uri,
98
+ "User-Agent" => "RubyGems/#{Gem::RubyGemsVersion}",
99
+ :proxy => @http_proxy
100
+ ) do |input|
101
+ input.read
102
+ end
103
+ rescue
104
+ old_uri = uri
105
+ uri = uri.downcase
106
+ retry if old_uri != uri
107
+ raise
101
108
  end
102
109
  end
103
110
 
@@ -317,10 +324,11 @@ module Gem
317
324
  # * <tt>:no_proxy</tt>: ignore environment variables and _don't_
318
325
  # use a proxy
319
326
  #
320
- def initialize(http_proxy=nil)
327
+ def initialize(options={})
321
328
  # Ensure http_proxy env vars are used if no proxy explicitly supplied.
329
+ @options = options
322
330
  @http_proxy =
323
- case http_proxy
331
+ case @options[:http_proxy]
324
332
  when :no_proxy
325
333
  false
326
334
  when nil
@@ -457,14 +465,7 @@ module Gem
457
465
  installed_gems = []
458
466
  dependencies.each do |dependency|
459
467
  if ask_yes_no("Install required dependency #{dependency.name}?", true)
460
- remote_installer = RemoteInstaller.new(
461
- if @http_proxy == false
462
- :no_proxy
463
- elsif @http_proxy == true
464
- else
465
- @http_proxy
466
- end
467
- )
468
+ remote_installer = RemoteInstaller.new(@options)
468
469
  installed_gems << remote_installer.install(
469
470
  dependency.name,
470
471
  dependency.version_requirements,
@@ -2,5 +2,5 @@
2
2
  # This file is auto-generated by build scripts.
3
3
  # See: rake update_version
4
4
  module Gem
5
- RubyGemsVersion = '0.8.3'
5
+ RubyGemsVersion = '0.8.4'
6
6
  end
@@ -1,4 +1,7 @@
1
1
  require 'rubygems/user_interaction'
2
+
3
+ require 'forwardable'
4
+
2
5
  module Gem
3
6
 
4
7
  # The SourceIndex object indexes all the gems available from a
@@ -12,6 +15,9 @@ module Gem
12
15
  # old YAMLized source index objects to load properly.
13
16
  #
14
17
  class SourceIndex
18
+ extend Forwardable
19
+ include Enumerable
20
+
15
21
  class << self
16
22
  include Gem::UserInteraction
17
23
  end
@@ -40,7 +46,7 @@ module Gem
40
46
  def self.from_installed_gems(*spec_dirs)
41
47
  gems = {}
42
48
  if spec_dirs.empty?
43
- spec_dirs = Gem.path.collect {|dir| File.join(dir, "specifications")}
49
+ spec_dirs = Gem.path.collect { |dir| File.join(dir, "specifications") }
44
50
  end
45
51
  Dir.glob("{#{spec_dirs.join(',')}}/*.gemspec").each do |file_name|
46
52
  gemspec = load_specification(file_name)
@@ -48,7 +54,7 @@ module Gem
48
54
  end
49
55
  self.new(gems)
50
56
  end
51
-
57
+
52
58
  # Load a specification from a file (eval'd Ruby code)
53
59
  #
54
60
  # file_name:: [String] The .gemspec file
@@ -81,6 +87,8 @@ module Gem
81
87
  @gems.each(&block)
82
88
  end
83
89
 
90
+ def_delegators :@gems, :size, :length
91
+
84
92
  # Search for a gem by name and optional version
85
93
  #
86
94
  # gem_name::
@@ -21,7 +21,7 @@ module Gem
21
21
  # Potentially raised when a specification is validated.
22
22
  class InvalidSpecificationException < Gem::Exception; end
23
23
  class EndOfYAMLException < Gem::Exception; end
24
-
24
+
25
25
  ##
26
26
  # == Gem::Specification
27
27
  #
@@ -124,11 +124,21 @@ module Gem
124
124
  def self.attribute(name, default=nil)
125
125
  @@attributes << [name, default]
126
126
  @@default_value[name] = default
127
- attr_writer(name)
128
- class_eval %{
127
+ attr_accessor(name)
128
+ end
129
+
130
+ # Same as :attribute, but ensures that values assigned to the
131
+ # attribute are array values by applying :to_a to the value.
132
+ def self.array_attribute(name)
133
+ @@attributes << [name, []]
134
+ @@default_value[name] = []
135
+ module_eval %{
129
136
  def #{name}
130
- @#{name} ||= copy_of(@@default_value[:#{name}])
131
- end
137
+ @#{name} ||= []
138
+ end
139
+ def #{name}=(value)
140
+ @#{name} = value.to_a
141
+ end
132
142
  }
133
143
  end
134
144
 
@@ -212,15 +222,15 @@ module Gem
212
222
  attribute :has_rdoc, false
213
223
  attribute :required_ruby_version, Gem::Version::Requirement.default
214
224
  attribute :platform, Gem::Platform::RUBY
215
- attribute :authors, []
216
- attribute :files, []
217
- attribute :test_files, []
218
- attribute :rdoc_options, []
219
- attribute :extra_rdoc_files, []
220
- attribute :executables, []
221
- attribute :extensions, []
222
- attribute :requirements, []
223
- attribute :dependencies, []
225
+ array_attribute :authors
226
+ array_attribute :files
227
+ array_attribute :test_files
228
+ array_attribute :rdoc_options
229
+ array_attribute :extra_rdoc_files
230
+ array_attribute :executables
231
+ array_attribute :extensions
232
+ array_attribute :requirements
233
+ array_attribute :dependencies
224
234
 
225
235
  read_only :dependencies
226
236
 
@@ -582,18 +592,13 @@ module Gem
582
592
  end
583
593
 
584
594
  # Duplicate an object unless it's an immediate value.
585
- def self.copy_of(obj)
595
+ def copy_of(obj)
586
596
  case obj
587
597
  when Numeric, Symbol, true, false, nil then obj
588
598
  else obj.dup
589
599
  end
590
600
  end
591
601
 
592
- # Duplicate an object unless it's an immediate value.
593
- def copy_of(obj)
594
- self.class.copy_of(obj)
595
- end
596
-
597
602
  # Return a string containing a Ruby code representation of the given object.
598
603
  def ruby_code(obj)
599
604
  case obj
@@ -609,5 +614,6 @@ module Gem
609
614
  end
610
615
 
611
616
  end # class Specification
617
+
612
618
  end # module Gem
613
619
 
@@ -0,0 +1,19 @@
1
+ #
2
+ # This file defines a $log variable for logging, and a time() method for recording timing
3
+ # information.
4
+ #
5
+
6
+ $log = Object.new
7
+ def $log.debug(str)
8
+ STDERR.puts str
9
+ end
10
+
11
+ def time(msg, width=25)
12
+ t = Time.now
13
+ return_value = yield
14
+ elapsed = Time.now.to_f - t.to_f
15
+ elapsed = sprintf("%3.3f", elapsed)
16
+ $log.debug "#{msg.ljust(width)}: #{elapsed}s"
17
+ return_value
18
+ end
19
+
@@ -5,6 +5,10 @@ module Gem
5
5
  #
6
6
  class Dependency
7
7
  attr_accessor :name, :version_requirements
8
+
9
+ def <=>(other)
10
+ [@name] <=> [other.name]
11
+ end
8
12
 
9
13
  ##
10
14
  # Constructs the dependency
@@ -15,3 +15,20 @@ def run_tests(pattern='test/test*.rb', log_enabled=false)
15
15
  end
16
16
  }
17
17
  end
18
+
19
+ # You can run the unit tests by running this file directly, providing a pattern. For example,
20
+ #
21
+ # ruby scripts/runtests.rb spec
22
+ #
23
+ # will load just the "test/test_specification.rb" unit test (unless others match as well).
24
+
25
+ if $0 == __FILE__
26
+ $:.unshift 'lib' # Must run this from the root directory.
27
+ pattern = ARGV.shift
28
+ if pattern
29
+ pattern = "test/*#{pattern}*.rb"
30
+ run_tests(pattern, true)
31
+ else
32
+ run_tests
33
+ end
34
+ end
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1 @@
1
+ CODE = 1
@@ -0,0 +1,8 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{a}
3
+ s.version = "0.0.1"
4
+ s.date = %q{2005-01-01}
5
+ s.summary = %q{summary}
6
+ s.description = %q{desc}
7
+ s.files = ["lib/code.rb"]
8
+ end
@@ -0,0 +1,8 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{a}
3
+ s.version = "0.0.2"
4
+ s.date = %q{2005-01-01}
5
+ s.summary = %q{summary}
6
+ s.description = %q{desc}
7
+ s.files = ["lib/code.rb"]
8
+ end
@@ -0,0 +1,8 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{b}
3
+ s.version = "0.0.2"
4
+ s.date = %q{2005-01-01}
5
+ s.summary = %q{summary}
6
+ s.description = %q{desc}
7
+ s.files = ["lib/code.rb"]
8
+ end
@@ -0,0 +1,8 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{c}
3
+ s.version = "1.2"
4
+ s.date = %q{2005-01-01}
5
+ s.summary = %q{summary}
6
+ s.description = %q{desc}
7
+ s.files = ["lib/code.rb"]
8
+ end
@@ -91,6 +91,49 @@ class TestGemPaths < Test::Unit::TestCase
91
91
  end
92
92
  end
93
93
 
94
+ def test_ensure_gem_directories_new
95
+ FileUtils.rm_r("test/temp/gemdir")
96
+ Gem.use_paths("test/temp/gemdir")
97
+ Gem.send(:ensure_gem_subdirectories, "test/temp/gemdir")
98
+ assert File.exist?("test/temp/gemdir/cache")
99
+ end
100
+
101
+ def test_ensure_gem_directories_missing_parents
102
+ gemdir = "test/temp/a/b/c/gemdir"
103
+ FileUtils.rm_r("test/temp/a") rescue nil
104
+ Gem.use_paths(gemdir)
105
+ Gem.send(:ensure_gem_subdirectories, gemdir)
106
+ assert File.exist?("#{gemdir}/cache")
107
+ end
108
+
109
+ def test_ensure_gem_directories_write_protected
110
+ gemdir = "test/temp/egd"
111
+ FileUtils.rm_r gemdir rescue nil
112
+ FileUtils.mkdir_p gemdir
113
+ FileUtils.chmod 0400, gemdir
114
+ Gem.use_paths(gemdir)
115
+ Gem.send(:ensure_gem_subdirectories, gemdir)
116
+ assert ! File.exist?("#{gemdir}/cache")
117
+ ensure
118
+ FileUtils.chmod(0600, gemdir) rescue nil
119
+ FileUtils.rm_r gemdir rescue nil
120
+ end
121
+
122
+ def test_ensure_gem_directories_with_parents_write_protected
123
+ parent = "test/temp/egd"
124
+ gemdir = "#{parent}/a/b/c"
125
+
126
+ FileUtils.rm_r parent rescue nil
127
+ FileUtils.mkdir_p parent
128
+ FileUtils.chmod 0400, parent
129
+ Gem.use_paths(gemdir)
130
+ Gem.send(:ensure_gem_subdirectories, gemdir)
131
+ assert ! File.exist?("#{gemdir}/cache")
132
+ ensure
133
+ FileUtils.chmod(0600, parent) rescue nil
134
+ FileUtils.rm_r parent rescue nil
135
+ end
136
+
94
137
  private
95
138
 
96
139
  def create_additional_gem_dirs
@@ -1,12 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # This test case disabled because it's incompatible with the new custom_require.rb.
4
+
3
5
  require 'test/unit'
4
- require 'rubygems/loadpath_manager'
6
+ #require 'rubygems/loadpath_manager'
5
7
  require 'rubygems/builder'
6
8
 
7
9
  require 'test/gemenvironment'
8
10
 
9
- class TestLoadPathManager < Test::Unit::TestCase
11
+ class TestLoadPathManager #< Test::Unit::TestCase
10
12
  def setup
11
13
  TestEnvironment.create
12
14
  Gem.clear_paths
@@ -143,7 +143,7 @@ class RemoteInstallerTest < Test::Unit::TestCase
143
143
  FOO_GEM = '' # TODO
144
144
  CACHE_DIR = File.join(Gem.dir, 'cache')
145
145
 
146
- # Disable this test for now. We will come back to revisit this.
146
+ # TODO: Disable this test for now. We will come back to revisit this.
147
147
  def disable_test_install
148
148
  Gem.use_paths("test/data/gemhome")
149
149
  result = @remote_installer.install('foo')
@@ -134,6 +134,11 @@ class TestSimpleSpecification < Test::Unit::TestCase
134
134
  end
135
135
  end
136
136
 
137
+ def test_array_attributes
138
+ @spec.files = (1..10)
139
+ assert_equal Array, @spec.files.class
140
+ end
141
+
137
142
  def test_equality
138
143
  same_spec = @spec.dup
139
144
  assert_equal @spec, same_spec
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.3
3
3
  specification_version: 1
4
4
  name: rubygems-update
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.8.3
7
- date: 2004-12-07
6
+ version: 0.8.4
7
+ date: 2005-01-01
8
8
  summary: RubyGems Update GEM
9
9
  require_paths:
10
10
  - lib
@@ -41,17 +41,17 @@ files:
41
41
  - doc/doc.css
42
42
  - doc/makedoc.rb
43
43
  - examples/application
44
+ - examples/application/an-app.gemspec
44
45
  - examples/application/bin
45
46
  - examples/application/lib
46
- - examples/application/an-app.gemspec
47
47
  - examples/application/bin/myapp
48
48
  - examples/application/lib/somefunctionality.rb
49
- - gemspecs/ook.gemspec
50
- - gemspecs/README
51
49
  - gemspecs/cgikit-1.1.0.gemspec
52
50
  - gemspecs/jabber4r.gemspec
53
51
  - gemspecs/linguistics.gemspec
52
+ - gemspecs/ook.gemspec
54
53
  - gemspecs/progressbar.gemspec
54
+ - gemspecs/README
55
55
  - gemspecs/redcloth.gemspec
56
56
  - gemspecs/rublog.gemspec
57
57
  - gemspecs/ruby-doom.gemspec
@@ -59,11 +59,11 @@ files:
59
59
  - gemspecs/statistics.gemspec
60
60
  - lib/rubygems.rb
61
61
  - lib/ubygems.rb
62
- - lib/rubygems/specification.rb
63
62
  - lib/rubygems/builder.rb
64
63
  - lib/rubygems/cmd_manager.rb
65
64
  - lib/rubygems/command.rb
66
65
  - lib/rubygems/config_file.rb
66
+ - lib/rubygems/custom_require.rb
67
67
  - lib/rubygems/doc_manager.rb
68
68
  - lib/rubygems/format.rb
69
69
  - lib/rubygems/gem_commands.rb
@@ -74,11 +74,13 @@ files:
74
74
  - lib/rubygems/open-uri.rb
75
75
  - lib/rubygems/package.rb
76
76
  - lib/rubygems/remote_installer.rb
77
+ - lib/rubygems/rubygems_version.rb
77
78
  - lib/rubygems/source_index.rb
79
+ - lib/rubygems/specification.rb
80
+ - lib/rubygems/timer.rb
78
81
  - lib/rubygems/user_interaction.rb
79
82
  - lib/rubygems/validator.rb
80
83
  - lib/rubygems/version.rb
81
- - lib/rubygems/rubygems_version.rb
82
84
  - pkgs/sources
83
85
  - pkgs/sources/lib
84
86
  - pkgs/sources/sources.gemspec
@@ -88,15 +90,18 @@ files:
88
90
  - scripts/gemdoc.rb
89
91
  - scripts/runtest.rb
90
92
  - scripts/specdoc.rb
91
- - test/data
92
- - test/mock
93
93
  - test/bogussources.rb
94
+ - test/data
94
95
  - test/functional.rb
95
96
  - test/gemenvironment.rb
97
+ - test/gemutilities.rb
96
98
  - test/insure_session.rb
99
+ - test/mock
97
100
  - test/mockgemui.rb
101
+ - test/onegem.rb
98
102
  - test/simple_gem.rb
99
103
  - test/test_builder.rb
104
+ - test/test_cached_fetcher.rb
100
105
  - test/test_check_command.rb
101
106
  - test/test_command.rb
102
107
  - test/test_configfile.rb
@@ -104,34 +109,61 @@ files:
104
109
  - test/test_gemloadpaths.rb
105
110
  - test/test_gempaths.rb
106
111
  - test/test_loadmanager.rb
112
+ - test/test_local_cache.rb
107
113
  - test/test_package.rb
108
114
  - test/test_parse_commands.rb
109
115
  - test/test_process_commands.rb
110
- - test/yaml_data.rb
116
+ - test/test_remote_fetcher.rb
117
+ - test/test_remote_installer.rb
118
+ - test/test_source_index.rb
111
119
  - test/test_specification.rb
112
120
  - test/test_validator.rb
113
121
  - test/test_version_comparison.rb
114
122
  - test/testgem.rc
115
123
  - test/user_capture.rb
116
- - test/onegem.rb
117
- - test/test_cached_fetcher.rb
118
- - test/test_remote_fetcher.rb
119
- - test/test_source_index.rb
120
- - test/test_local_cache.rb
121
- - test/test_remote_installer.rb
122
- - test/gemutilities.rb
124
+ - test/yaml_data.rb
125
+ - test/data/a-0.0.1.gem
126
+ - test/data/a-0.0.2.gem
127
+ - test/data/b-0.0.2.gem
128
+ - test/data/c-1.2.gem
129
+ - test/data/gemhome
123
130
  - test/data/gems
124
- - test/data/one
125
131
  - test/data/legacy
126
132
  - test/data/lib
133
+ - test/data/one
134
+ - test/data/gemhome/cache
135
+ - test/data/gemhome/doc
136
+ - test/data/gemhome/gems
137
+ - test/data/gemhome/specifications
138
+ - test/data/gemhome/cache/a-0.0.1.gem
139
+ - test/data/gemhome/cache/a-0.0.2.gem
140
+ - test/data/gemhome/cache/b-0.0.2.gem
141
+ - test/data/gemhome/cache/c-1.2.gem
142
+ - test/data/gemhome/gems/a-0.0.1
143
+ - test/data/gemhome/gems/a-0.0.2
144
+ - test/data/gemhome/gems/b-0.0.2
145
+ - test/data/gemhome/gems/c-1.2
146
+ - test/data/gemhome/gems/a-0.0.1/lib
147
+ - test/data/gemhome/gems/a-0.0.1/lib/code.rb
148
+ - test/data/gemhome/gems/a-0.0.2/lib
149
+ - test/data/gemhome/gems/a-0.0.2/lib/code.rb
150
+ - test/data/gemhome/gems/b-0.0.2/lib
151
+ - test/data/gemhome/gems/b-0.0.2/lib/code.rb
152
+ - test/data/gemhome/gems/c-1.2/lib
153
+ - test/data/gemhome/gems/c-1.2/lib/code.rb
154
+ - test/data/gemhome/specifications/a-0.0.1.gemspec
155
+ - test/data/gemhome/specifications/a-0.0.2.gemspec
156
+ - test/data/gemhome/specifications/b-0.0.2.gemspec
157
+ - test/data/gemhome/specifications/c-1.2.gemspec
158
+ - test/data/legacy/keyedlist-0.4.0.ruby
159
+ - test/data/legacy/keyedlist-0.4.0.yaml
160
+ - test/data/lib/code.rb
127
161
  - test/data/one/lib
128
- - test/data/one/README.one
162
+ - test/data/one/one-0.0.1.gem
129
163
  - test/data/one/one.gemspec
130
164
  - test/data/one/one.yaml
165
+ - test/data/one/README.one
131
166
  - test/data/one/lib/one.rb
132
- - test/data/legacy/keyedlist-0.4.0.ruby
133
- - test/data/legacy/keyedlist-0.4.0.yaml
134
- - test/data/lib/code.rb
135
167
  - test/mock/gems
136
168
  - test/mock/gems/cache
137
169
  - test/mock/gems/doc