summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/rubygems.rb5
-rw-r--r--lib/rubygems/command.rb4
-rw-r--r--lib/rubygems/commands/setup_command.rb44
-rw-r--r--lib/rubygems/format.rb2
-rw-r--r--lib/rubygems/indexer.rb12
-rw-r--r--lib/rubygems/package_task.rb4
-rw-r--r--lib/rubygems/platform.rb2
-rw-r--r--lib/rubygems/security.rb6
-rw-r--r--lib/rubygems/source_index.rb46
-rw-r--r--lib/rubygems/source_info_cache.rb4
-rw-r--r--lib/rubygems/spec_fetcher.rb23
-rw-r--r--lib/rubygems/test_utilities.rb4
-rw-r--r--lib/rubygems/validator.rb2
-rw-r--r--lib/rubygems/version.rb2
14 files changed, 92 insertions, 68 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 5faca8695f..06ea950c64 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -5,13 +5,14 @@
# See LICENSE.txt for permissions.
#++
-require 'rubygems/rubygems_version'
require 'rubygems/defaults'
require 'thread'
require 'etc'
module Gem
+ RubyGemsVersion = VERSION = '1.3.5'
+
##
# Raised when RubyGems is unable to load or activate a gem. Contains the
# name and version requirements of the gem that either conflicts with
@@ -381,7 +382,7 @@ module Gem
raise Gem::Exception, msg
end
- File.join(spec.full_gem_path, spec.bindir, exec_name).sub(/.*\s.*/m, '"\&"')
+ File.join(spec.full_gem_path, spec.bindir, exec_name)
end
##
diff --git a/lib/rubygems/command.rb b/lib/rubygems/command.rb
index 3a1e2ac872..dab4366270 100644
--- a/lib/rubygems/command.rb
+++ b/lib/rubygems/command.rb
@@ -49,7 +49,7 @@ class Gem::Command
def self.build_args
@build_args ||= []
end
-
+
def self.build_args=(value)
@build_args = value
end
@@ -197,7 +197,7 @@ class Gem::Command
# def usage
# "#{program_name} FILE [FILE ...]"
# end
- #
+ #
# def arguments
# "FILE name of file to find"
# end
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index 3220a7497c..5bd5ebd468 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -88,6 +88,8 @@ By default, this RubyGems will install gem as:
end
def execute
+ @verbose = Gem.configuration.really_verbose
+
install_destdir = options[:destdir]
unless install_destdir.empty? then
@@ -113,21 +115,29 @@ By default, this RubyGems will install gem as:
remove_source_caches install_destdir
+ say "RubyGems #{Gem::VERSION} installed"
+
install_rdoc
say
- say "-" * 78
- say
+ if @verbose then
+ say "-" * 78
+ say
+ end
- release_notes = File.join Dir.pwd, 'doc', 'release_notes',
- "rel_#{Gem::RubyGemsVersion.gsub '.', '_'}.rdoc"
+ release_notes = File.join Dir.pwd, 'History.txt'
- if File.exist? release_notes then
- say File.read(release_notes)
- else
- say "Oh-no! Unable to find release notes!"
- say "Looked in: #{release_notes}" if Gem.configuration.really_verbose
- end
+ release_notes = if File.exist? release_notes then
+ open release_notes do |io|
+ text = io.gets '==='
+ text << io.gets('===')
+ text[0...-3]
+ end
+ else
+ "Oh-no! Unable to find release notes!"
+ end
+
+ say release_notes
say
say "-" * 78
@@ -145,7 +155,7 @@ By default, this RubyGems will install gem as:
end
def install_executables(bin_dir)
- say "Installing gem executable"
+ say "Installing gem executable" if @verbose
@bin_file_names = []
@@ -203,7 +213,7 @@ TEXT
end
def install_lib(lib_dir)
- say "Installing RubyGems"
+ say "Installing RubyGems" if @verbose
Dir.chdir 'lib' do
lib_files = Dir[File.join('**', '*rb')]
@@ -226,23 +236,23 @@ TEXT
if File.writable? gem_doc_dir and
(not File.exist? rubygems_doc_dir or
File.writable? rubygems_doc_dir) then
- say "Removing old RubyGems RDoc and ri"
+ say "Removing old RubyGems RDoc and ri" if @verbose
Dir[File.join(Gem.dir, 'doc', 'rubygems-[0-9]*')].each do |dir|
rm_rf dir
end
if options[:ri] then
ri_dir = File.join rubygems_doc_dir, 'ri'
- say "Installing #{rubygems_name} ri into #{ri_dir}"
+ say "Installing #{rubygems_name} ri into #{ri_dir}" if @verbose
run_rdoc '--ri', '--op', ri_dir
end
if options[:rdoc] then
rdoc_dir = File.join rubygems_doc_dir, 'rdoc'
- say "Installing #{rubygems_name} rdoc into #{rdoc_dir}"
+ say "Installing #{rubygems_name} rdoc into #{rdoc_dir}" if @verbose
run_rdoc '--op', rdoc_dir
end
- else
+ elsif @verbose then
say "Skipping RDoc generation, #{gem_doc_dir} not writable"
say "Set the GEM_HOME environment variable if you want RDoc generated"
end
@@ -327,7 +337,7 @@ abort "#{deprecation_message}"
system_cache_file = File.join(install_destdir,
Gem::SourceInfoCache.system_cache_file)
- say "Removing old source_cache files"
+ say "Removing old source_cache files" if Gem.configuration.really_verbose
rm_f user_cache_file if File.writable? File.dirname(user_cache_file)
rm_f system_cache_file if File.writable? File.dirname(system_cache_file)
end
diff --git a/lib/rubygems/format.rb b/lib/rubygems/format.rb
index b2e7897339..80aae56215 100644
--- a/lib/rubygems/format.rb
+++ b/lib/rubygems/format.rb
@@ -29,7 +29,7 @@ class Gem::Format
end
##
- # Reads the named gem file and returns a Format object, representing
+ # Reads the named gem file and returns a Format object, representing
# the data from the gem file
#
# file_path:: [String] Path to the gem file
diff --git a/lib/rubygems/indexer.rb b/lib/rubygems/indexer.rb
index 5ebde1b31c..aff8d8de17 100644
--- a/lib/rubygems/indexer.rb
+++ b/lib/rubygems/indexer.rb
@@ -141,7 +141,7 @@ class Gem::Indexer
"Complete"
Gem.time 'Generated YAML quick index gemspecs' do
- index.each do |original_name, spec|
+ index.released_gems.each do |original_name, spec|
spec_file_name = "#{original_name}.gemspec.rz"
yaml_name = File.join @quick_dir, spec_file_name
@@ -221,7 +221,7 @@ class Gem::Indexer
files = []
Gem.time 'Generated Marshal quick index gemspecs' do
- (index.gems.merge(index.prerelease_gems)).each do |original_name, spec|
+ index.gems.each do |original_name, spec|
spec_file_name = "#{original_name}.gemspec.rz"
marshal_name = File.join @quick_marshal_dir, spec_file_name
@@ -275,7 +275,7 @@ class Gem::Indexer
# Builds indicies for RubyGems 1.2 and newer. Handles full, latest, prerelease
def build_modern_indicies(index)
- build_modern_index(index.sort, @specs_index, 'specs')
+ build_modern_index(index.released_specs.sort, @specs_index, 'specs')
build_modern_index(index.latest_specs.sort,
@latest_specs_index,
'latest specs')
@@ -534,7 +534,7 @@ class Gem::Indexer
FileUtils.rm_rf @directory
end
- ##
+ ##
# Zlib::GzipWriter wrapper that gzips +filename+ on disk.
def gzip(filename)
@@ -654,8 +654,8 @@ class Gem::Indexer
files = build_marshal_gemspecs index
Gem.time 'Updated indexes' do
- update_specs_index index, @dest_specs_index, @specs_index
- update_specs_index index, @dest_latest_specs_index, @latest_specs_index
+ update_specs_index index.released_gems, @dest_specs_index, @specs_index
+ update_specs_index index.released_gems, @dest_latest_specs_index, @latest_specs_index
update_specs_index(index.prerelease_gems, @dest_prerelease_specs_index,
@prerelease_specs_index)
end
diff --git a/lib/rubygems/package_task.rb b/lib/rubygems/package_task.rb
index d7f83276f8..e80b1eceaf 100644
--- a/lib/rubygems/package_task.rb
+++ b/lib/rubygems/package_task.rb
@@ -41,7 +41,7 @@ require 'rake/packagetask'
#
# require 'rubygems'
# require 'rubygems/package_task'
-#
+#
# spec = Gem::Specification.new do |s|
# s.platform = Gem::Platform::RUBY
# s.summary = "Ruby based make-like utility."
@@ -56,7 +56,7 @@ require 'rake/packagetask'
# and dependencies are specified in standard Ruby syntax.
# EOF
# end
-#
+#
# Gem::PackageTask.new(spec) do |pkg|
# pkg.need_zip = true
# pkg.need_tar = true
diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb
index bfa8fca0ff..f5410cf4f7 100644
--- a/lib/rubygems/platform.rb
+++ b/lib/rubygems/platform.rb
@@ -103,7 +103,7 @@ class Gem::Platform
def to_s
to_a.compact.join '-'
end
-
+
def empty?
to_s.empty?
end
diff --git a/lib/rubygems/security.rb b/lib/rubygems/security.rb
index abf3cf4a6a..5cd3fb756f 100644
--- a/lib/rubygems/security.rb
+++ b/lib/rubygems/security.rb
@@ -218,7 +218,7 @@ require 'rubygems/gem_openssl'
#
# # signing key (still kept in an undisclosed location!)
# s.signing_key = '/mnt/floppy/alf-private_key.pem'
-#
+#
# # certificate chain (includes the issuer certificate now too)
# s.cert_chain = ['/home/alf/doc/seattlerb-public_cert.pem',
# '/home/alf/doc/alf_at_seattle-public_cert.pem']
@@ -274,7 +274,7 @@ require 'rubygems/gem_openssl'
# # convert a PEM format X509 certificate into DER format:
# # (note: Windows .cer files are X509 certificates in DER format)
# $ openssl x509 -in input.pem -outform der -out output.der
-#
+#
# # print out the certificate in a human-readable format:
# $ openssl x509 -in input.pem -noout -text
#
@@ -282,7 +282,7 @@ require 'rubygems/gem_openssl'
#
# # convert a PEM format RSA key into DER format:
# $ openssl rsa -in input_key.pem -outform der -out output_key.der
-#
+#
# # print out the key in a human readable format:
# $ openssl rsa -in input_key.pem -noout -text
#
diff --git a/lib/rubygems/source_index.rb b/lib/rubygems/source_index.rb
index c616aefcc0..d033fd40fe 100644
--- a/lib/rubygems/source_index.rb
+++ b/lib/rubygems/source_index.rb
@@ -30,7 +30,7 @@ class Gem::SourceIndex
include Gem::UserInteraction
- attr_reader :gems, :prerelease_gems # :nodoc:
+ attr_reader :gems # :nodoc:
##
# Directories to use to refresh this SourceIndex when calling refresh!
@@ -122,16 +122,22 @@ class Gem::SourceIndex
# #prerelease_gems
def initialize(specifications={})
- @gems, @prerelease_gems = [{}, {}]
+ @gems = {}
specifications.each{ |full_name, spec| add_spec spec }
@spec_dirs = nil
end
- ##
- # Both regular and prerelease gems
-
+ # TODO: remove method
def all_gems
- @gems.merge @prerelease_gems
+ @gems
+ end
+
+ def prerelease_gems
+ @gems.reject{ |name, gem| !gem.version.prerelease? }
+ end
+
+ def released_gems
+ @gems.reject{ |name, gem| gem.version.prerelease? }
end
##
@@ -153,8 +159,8 @@ class Gem::SourceIndex
end
##
- # Returns an Array specifications for the latest versions of each gem in
- # this index.
+ # Returns an Array specifications for the latest released versions
+ # of each gem in this index.
def latest_specs
result = Hash.new { |h,k| h[k] = [] }
@@ -165,6 +171,7 @@ class Gem::SourceIndex
curr_ver = spec.version
prev_ver = latest.key?(name) ? latest[name].version : nil
+ next if curr_ver.prerelease?
next unless prev_ver.nil? or curr_ver >= prev_ver or
latest[name].platform != Gem::Platform::RUBY
@@ -192,7 +199,14 @@ class Gem::SourceIndex
# An array including only the prerelease gemspecs
def prerelease_specs
- @prerelease_gems.values
+ prerelease_gems.values
+ end
+
+ ##
+ # An array including only the released gemspecs
+
+ def released_specs
+ released_gems.values
end
##
@@ -201,11 +215,7 @@ class Gem::SourceIndex
def add_spec(gem_spec, name = gem_spec.full_name)
# No idea why, but the Indexer wants to insert them using original_name
# instead of full_name. So we make it an optional arg.
- if gem_spec.version.prerelease?
- @prerelease_gems[name] = gem_spec
- else
- @gems[name] = gem_spec
- end
+ @gems[name] = gem_spec
end
##
@@ -221,11 +231,7 @@ class Gem::SourceIndex
# Remove a gem specification named +full_name+.
def remove_spec(full_name)
- if @gems.key? full_name then
- @gems.delete full_name
- else
- @prerelease_gems.delete full_name
- end
+ @gems.delete full_name
end
##
@@ -408,7 +414,7 @@ class Gem::SourceIndex
end
def ==(other) # :nodoc:
- self.class === other and @gems == other.gems
+ self.class === other and @gems == other.gems
end
def dump
diff --git a/lib/rubygems/source_info_cache.rb b/lib/rubygems/source_info_cache.rb
index fdb30ad8d3..4289cdb52a 100644
--- a/lib/rubygems/source_info_cache.rb
+++ b/lib/rubygems/source_info_cache.rb
@@ -286,7 +286,7 @@ class Gem::SourceInfoCache
next unless Gem.sources.include? source_uri
# TODO - Remove this gunk after 2008/11
unless pattern.kind_of?(Gem::Dependency)
- pattern = Gem::Dependency.new(pattern, Gem::Requirement.default)
+ pattern = Gem::Dependency.new(pattern, Gem::Requirement.default)
end
sic_entry.source_index.search pattern, platform_only
end.flatten.compact
@@ -306,7 +306,7 @@ class Gem::SourceInfoCache
# TODO - Remove this gunk after 2008/11
unless pattern.kind_of?(Gem::Dependency)
- pattern = Gem::Dependency.new(pattern, Gem::Requirement.default)
+ pattern = Gem::Dependency.new(pattern, Gem::Requirement.default)
end
sic_entry.source_index.search(pattern, only_platform).each do |spec|
diff --git a/lib/rubygems/spec_fetcher.rb b/lib/rubygems/spec_fetcher.rb
index f46c355413..a5f33183dd 100644
--- a/lib/rubygems/spec_fetcher.rb
+++ b/lib/rubygems/spec_fetcher.rb
@@ -22,7 +22,7 @@ class Gem::SpecFetcher
attr_reader :latest_specs # :nodoc:
##
- # Cache of all spces
+ # Cache of all released specs
attr_reader :specs # :nodoc:
@@ -61,8 +61,9 @@ class Gem::SpecFetcher
##
# Fetch specs matching +dependency+. If +all+ is true, all matching
- # versions are returned. If +matching_platform+ is false, all platforms are
- # returned. If +prerelease+ is true, prerelease versions are included.
+ # (released) versions are returned. If +matching_platform+ is
+ # false, all platforms are returned. If +prerelease+ is true,
+ # prerelease versions are included.
def fetch(dependency, all = false, matching_platform = true, prerelease = false)
specs_and_sources = find_matching dependency, all, matching_platform, prerelease
@@ -112,9 +113,9 @@ class Gem::SpecFetcher
end
##
- # Find spec names that match +dependency+. If +all+ is true, all matching
- # versions are returned. If +matching_platform+ is false, gems for all
- # platforms are returned.
+ # Find spec names that match +dependency+. If +all+ is true, all
+ # matching released versions are returned. If +matching_platform+
+ # is false, gems for all platforms are returned.
def find_matching(dependency, all = false, matching_platform = true, prerelease = false)
found = {}
@@ -161,7 +162,7 @@ class Gem::SpecFetcher
##
# Returns a list of gems available for each source in Gem::sources. If
- # +all+ is true, all versions are returned instead of only latest
+ # +all+ is true, all released versions are returned instead of only latest
# versions. If +prerelease+ is true, include prerelease versions.
def list(all = false, prerelease = false)
@@ -183,7 +184,7 @@ class Gem::SpecFetcher
cache = { :latest => @latest_specs,
:prerelease => @prerelease_specs,
:all => @specs }[type]
-
+
Gem.sources.each do |source_uri|
source_uri = URI.parse source_uri
@@ -194,6 +195,12 @@ class Gem::SpecFetcher
list[source_uri] = cache[source_uri]
end
+ if type == :all
+ list.values.map do |gems|
+ gems.reject! { |g| g[1].prerelease? }
+ end
+ end
+
list
end
diff --git a/lib/rubygems/test_utilities.rb b/lib/rubygems/test_utilities.rb
index 8b23d3236e..85541c9fc3 100644
--- a/lib/rubygems/test_utilities.rb
+++ b/lib/rubygems/test_utilities.rb
@@ -11,9 +11,9 @@ require 'rubygems/remote_fetcher'
# @fetcher = Gem::FakeFetcher.new
# @fetcher.data['http://gems.example.com/yaml'] = source_index.to_yaml
# Gem::RemoteFetcher.fetcher = @fetcher
-#
+#
# # invoke RubyGems code
-#
+#
# paths = @fetcher.paths
# assert_equal 'http://gems.example.com/yaml', paths.shift
# assert paths.empty?, paths.join(', ')
diff --git a/lib/rubygems/validator.rb b/lib/rubygems/validator.rb
index 9bccc605b5..f568227b9a 100644
--- a/lib/rubygems/validator.rb
+++ b/lib/rubygems/validator.rb
@@ -15,7 +15,7 @@ begin
Gem.activate('test-unit')
rescue Gem::LoadError
# Ignore - use the test-unit library that's part of the standard library
-end
+end
##
# Validator performs various gem file and gem database validation
diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb
index 7c49a34a73..f959429846 100644
--- a/lib/rubygems/version.rb
+++ b/lib/rubygems/version.rb
@@ -166,7 +166,7 @@ class Gem::Version
def prerelease?
parts.any? { |part| part.alpha? }
end
-
+
##
# The release for this version (e.g. 1.2.0.a -> 1.2.0)
# Non-prerelease versions return themselves