summaryrefslogtreecommitdiff
path: root/lib/rubygems
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-22 08:24:42 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-22 08:24:42 +0000
commit372dcece3f69989d133f720468f1e24aa1133cda ()
treec173ca48a23ce18afa44feb15bf68d2dd14ac619 /lib/rubygems
parentd0e5a34ac7c34e70c145024a0fed8f6042814f29 (diff)
Update to RubyGems 1.3.7.pre.1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--lib/rubygems/builder.rb2
-rw-r--r--lib/rubygems/command.rb12
-rw-r--r--lib/rubygems/command_manager.rb24
-rw-r--r--lib/rubygems/commands/contents_command.rb2
-rw-r--r--lib/rubygems/commands/dependency_command.rb4
-rw-r--r--lib/rubygems/commands/environment_command.rb5
-rw-r--r--lib/rubygems/commands/fetch_command.rb10
-rw-r--r--lib/rubygems/commands/install_command.rb3
-rw-r--r--lib/rubygems/commands/query_command.rb19
-rw-r--r--lib/rubygems/commands/server_command.rb8
-rw-r--r--lib/rubygems/commands/setup_command.rb2
-rw-r--r--lib/rubygems/commands/unpack_command.rb58
-rw-r--r--lib/rubygems/commands/update_command.rb2
-rw-r--r--lib/rubygems/defaults.rb5
-rw-r--r--lib/rubygems/dependency.rb38
-rw-r--r--lib/rubygems/dependency_installer.rb13
-rw-r--r--lib/rubygems/doc_manager.rb7
-rw-r--r--lib/rubygems/errors.rb35
-rw-r--r--lib/rubygems/exceptions.rb11
-rw-r--r--lib/rubygems/indexer.rb2
-rw-r--r--lib/rubygems/installer.rb11
-rw-r--r--lib/rubygems/package.rb10
-rw-r--r--lib/rubygems/package/f_sync_dir.rb8
-rw-r--r--lib/rubygems/package/tar_header.rb8
-rw-r--r--lib/rubygems/package/tar_output.rb8
-rw-r--r--lib/rubygems/package/tar_reader.rb8
-rw-r--r--lib/rubygems/package/tar_writer.rb8
-rw-r--r--lib/rubygems/package_task.rb3
-rw-r--r--lib/rubygems/platform.rb3
-rw-r--r--lib/rubygems/remote_fetcher.rb12
-rw-r--r--lib/rubygems/requirement.rb5
-rw-r--r--lib/rubygems/server.rb51
-rw-r--r--lib/rubygems/source_index.rb6
-rw-r--r--lib/rubygems/source_info_cache.rb8
-rw-r--r--lib/rubygems/spec_fetcher.rb40
-rw-r--r--lib/rubygems/specification.rb72
-rw-r--r--lib/rubygems/validator.rb5
-rw-r--r--lib/rubygems/version.rb4
38 files changed, 365 insertions, 167 deletions
@@ -4,6 +4,8 @@
# See LICENSE.txt for permissions.
#++
##
# The Builder class processes RubyGem specification files
# to produce a .gem file.
@@ -146,6 +146,18 @@ class Gem::Command
end
##
# Get all gem names from the command line.
def get_all_gem_names
@@ -75,10 +75,10 @@ class Gem::CommandManager
end
##
- # Register the command object.
- def register_command(command_obj)
- @commands[command_obj] = false
end
##
@@ -123,7 +123,7 @@ class Gem::CommandManager
say Gem::Command::HELP
terminate_interaction(0)
when '-v', '--version'
- say Gem::RubyGemsVersion
terminate_interaction(0)
when /^-/
alert_error "Invalid option: #{args[0]}. See 'gem --help'."
@@ -161,15 +161,19 @@ class Gem::CommandManager
retried = false
begin
- commands.const_get(const_name)
rescue NameError
- if retried then
- raise
- else
- retried = true
require "rubygems/commands/#{command_name}_command"
- retry
end
end.new
end
@@ -7,7 +7,7 @@ class Gem::Commands::ContentsCommand < Gem::Command
def initialize
super 'contents', 'Display the contents of the installed gems',
- :specdirs => [], :lib_only => false
add_version_option
@@ -159,7 +159,9 @@ class Gem::Commands::DependencyCommand < Gem::Command
response
end
- # Returns list of [specification, dep] that are satisfied by spec.
def find_reverse_dependencies(spec)
result = []
@@ -69,7 +69,7 @@ lib/rubygems/defaults/operating_system.rb
when /^packageversion/ then
out << Gem::RubyGemsPackageVersion
when /^version/ then
- out << Gem::RubyGemsVersion
when /^gemdir/, /^gemhome/, /^home/, /^GEM_HOME/ then
out << Gem.dir
when /^gempath/, /^path/, /^GEM_PATH/ then
@@ -79,7 +79,7 @@ lib/rubygems/defaults/operating_system.rb
when nil then
out = "RubyGems Environment:\n"
- out << " - RUBYGEMS VERSION: #{Gem::RubyGemsVersion}\n"
out << " - RUBY VERSION: #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}"
out << " level #{RUBY_LEVEL}" if defined? RUBY_LEVEL
@@ -109,6 +109,7 @@ lib/rubygems/defaults/operating_system.rb
out << " - GEM CONFIGURATION:\n"
Gem.configuration.each do |name, value|
out << " - #{name.inspect} => #{value.inspect}\n"
end
@@ -34,7 +34,7 @@ class Gem::Commands::FetchCommand < Gem::Command
def execute
version = options[:version] || Gem::Requirement.default
- all = Gem::Requirement.default
gem_names = get_all_gem_names
@@ -42,13 +42,17 @@ class Gem::Commands::FetchCommand < Gem::Command
dep = Gem::Dependency.new gem_name, version
dep.prerelease = options[:prerelease]
- specs_and_sources = Gem::SpecFetcher.fetcher.fetch(dep, false, true,
dep.prerelease?)
spec, source_uri = specs_and_sources.sort_by { |s,| s.version }.last
if spec.nil? then
- alert_error "Could not find #{gem_name} in any repository"
next
end
@@ -127,7 +127,8 @@ to write the specification by hand. For example:
alert_error "Error installing #{gem_name}:\n\t#{e.message}"
exit_code |= 1
rescue Gem::GemNotFoundException => e
- alert_error e.message
exit_code |= 2
end
end
@@ -21,7 +21,7 @@ class Gem::Commands::QueryCommand < Gem::Command
options[:installed] = value
end
- add_version_option
add_option('-n', '--name-matches REGEXP',
'Name of gem(s) to query on matches the',
@@ -185,8 +185,21 @@ class Gem::Commands::QueryCommand < Gem::Command
entry = gem_name.dup
if options[:versions] then
- versions = matching_tuples.map { |(name, version,_),_| version }.uniq
- entry << " (#{versions.join ', '})"
end
if options[:details] then
@@ -5,7 +5,7 @@ class Gem::Commands::ServerCommand < Gem::Command
def initialize
super 'server', 'Documentation and gem repository HTTP server',
- :port => 8808, :gemdir => Gem.dir, :daemon => false
OptionParser.accept :Port do |port|
if port =~ /\A\d+\z/ then
@@ -29,8 +29,9 @@ class Gem::Commands::ServerCommand < Gem::Command
end
add_option '-d', '--dir=GEMDIR',
- 'directory from which to serve gems' do |gemdir, options|
- options[:gemdir] = File.expand_path gemdir
end
add_option '--[no-]daemon', 'run as a daemon' do |daemon, options|
@@ -69,6 +70,7 @@ You can set up a shortcut to gem server documentation using the URL:
end
def execute
Gem::Server.run options
end
@@ -231,7 +231,7 @@ TEXT
def install_rdoc
gem_doc_dir = File.join Gem.dir, 'doc'
- rubygems_name = "rubygems-#{Gem::RubyGemsVersion}"
rubygems_doc_dir = File.join gem_doc_dir, rubygems_name
if File.writable? gem_doc_dir and
@@ -12,7 +12,8 @@ class Gem::Commands::UnpackCommand < Gem::Command
:version => Gem::Requirement.default,
:target => Dir.pwd
- add_option('--target=DIR', 'target directory for unpacking') do |value, options|
options[:target] = value
end
@@ -31,6 +32,16 @@ class Gem::Commands::UnpackCommand < Gem::Command
"#{program_name} GEMNAME"
end
#--
# TODO: allow, e.g., 'gem unpack rake-0.3.1'. Find a general solution for
# this, so that it works for uninstall as well. (And check other commands
@@ -38,11 +49,12 @@ class Gem::Commands::UnpackCommand < Gem::Command
def execute
get_all_gem_names.each do |name|
- path = get_path name, options[:version]
if path then
- basename = File.basename(path, '.gem')
- target_dir = File.expand_path File.join(options[:target], basename)
FileUtils.mkdir_p target_dir
Gem::Installer.new(path, :unpack => true).unpack target_dir
say "Unpacked gem: '#{target_dir}'"
@@ -52,14 +64,15 @@ class Gem::Commands::UnpackCommand < Gem::Command
end
end
# Return the full path to the cached gem file matching the given
# name and version requirement. Returns 'nil' if no match.
#
# Example:
#
- # get_path('rake', '> 0.4') # -> '/usr/lib/ruby/gems/1.8/cache/rake-0.4.2.gem'
- # get_path('rake', '< 0.1') # -> nil
- # get_path('rak') # -> nil (exact name required)
#--
# TODO: This should be refactored so that it's a general service. I don't
# think any of our existing classes are the right place though. Just maybe
@@ -67,30 +80,29 @@ class Gem::Commands::UnpackCommand < Gem::Command
#
# TODO: It just uses Gem.dir for now. What's an easy way to get the list of
# source directories?
- def get_path(gemname, version_req)
- return gemname if gemname =~ /\.gem$/i
- specs = Gem::source_index.find_name gemname, version_req
selected = specs.sort_by { |s| s.version }.last
- return nil if selected.nil?
- # We expect to find (basename).gem in the 'cache' directory.
- # Furthermore, the name match must be exact (ignoring case).
- if gemname =~ /^#{selected.name}$/i
- filename = selected.file_name
- path = nil
- Gem.path.find do |gem_dir|
- path = File.join gem_dir, 'cache', filename
- File.exist? path
- end
- path
- else
- nil
end
end
end
@@ -56,7 +56,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
rubygems_update = Gem::Specification.new
rubygems_update.name = 'rubygems-update'
- rubygems_update.version = Gem::Version.new Gem::RubyGemsVersion
hig['rubygems-update'] = rubygems_update
options[:user_install] = false
@@ -33,15 +33,14 @@ module Gem
# Path for gems in the user's home directory
def self.user_dir
- File.join(Gem.user_home, '.gem', ruby_engine,
- ConfigMap[:ruby_version])
end
##
# Default gem load path
def self.default_path
- if File.exist?(Gem.user_home)
[user_dir, default_dir]
else
[default_dir]
@@ -69,9 +69,6 @@ class Gem::Dependency
end
##
- # What does this dependency require?
-
- ##
# A dependency's hash is the XOR of the hashes of +name+, +type+,
# and +requirement+.
@@ -106,6 +103,9 @@ class Gem::Dependency
end
end
def requirement
return @requirement if defined?(@requirement) and @requirement
@@ -160,7 +160,16 @@ class Gem::Dependency
__requirement
end
- alias_method :version_requirement, :version_requirements
def == other # :nodoc:
Gem::Dependency === other &&
@@ -188,9 +197,12 @@ class Gem::Dependency
end
pattern = name
- pattern = /\A#{Regexp.escape pattern}\Z/ unless Regexp === pattern
- return false unless pattern =~ other.name
reqs = other.requirement.requirements
@@ -202,5 +214,19 @@ class Gem::Dependency
requirement.satisfied_by? version
end
end
@@ -69,6 +69,10 @@ class Gem::DependencyInstaller
@install_dir = options[:install_dir] || Gem.dir
@cache_dir = options[:cache_dir] || @install_dir
end
##
@@ -78,6 +82,8 @@ class Gem::DependencyInstaller
# local gems preferred over remote gems.
def find_gems_with_sources(dep)
gems_and_sources = []
if @domain == :both or @domain == :local then
@@ -99,7 +105,7 @@ class Gem::DependencyInstaller
(requirements.length > 1 or
(requirements.first != ">=" and requirements.first != ">"))
- found = Gem::SpecFetcher.fetcher.fetch dep, all, true, dep.prerelease?
gems_and_sources.push(*found)
@@ -204,8 +210,9 @@ class Gem::DependencyInstaller
end
if spec_and_source.nil? then
- raise Gem::GemNotFoundException,
- "could not find gem #{gem_name} locally or in a repository"
end
@specs_and_sources = [spec_and_source]
@@ -179,7 +179,10 @@ class Gem::DocManager
r = RDoc::RDoc.new
old_pwd = Dir.pwd
- Dir.chdir(@spec.full_gem_path)
begin
r.document args
rescue Errno::EACCES => e
@@ -193,7 +196,7 @@ class Gem::DocManager
Gem.configuration.backtrace
ui.errs.puts "(continuing with the rest of the installation)"
ensure
- Dir.chdir(old_pwd)
end
end
@@ -0,0 +1,35 @@
@@ -37,7 +37,16 @@ class Gem::FormatException < Gem::Exception
attr_accessor :file_path
end
-class Gem::GemNotFoundException < Gem::Exception; end
class Gem::InstallError < Gem::Exception; end
@@ -320,7 +320,7 @@ class Gem::Indexer
<title>#{rss_title}</title>
<link>http://#{rss_host}</link>
<description>Recently released gems from http://#{rss_host}</description>
- <generator>RubyGems v#{Gem::RubyGemsVersion}</generator>
<docs>http://cyber.law.harvard.edu/rss/rss.html</docs>
HEADER
@@ -133,7 +133,8 @@ class Gem::Installer
end
FileUtils.mkdir_p @gem_home
- raise Gem::FilePermissionError, @gem_home unless File.writable? @gem_home
@spec = @format.spec
@@ -165,7 +166,7 @@ class Gem::Installer
end
if rrgv = @spec.required_rubygems_version then
- unless rrgv.satisfied_by? Gem::Version.new(Gem::RubyGemsVersion) then
raise Gem::InstallError,
"#{@spec.name} requires RubyGems version #{rrgv}. " +
"Try 'gem update --system' to update RubyGems itself."
@@ -270,7 +271,7 @@ class Gem::Installer
##
# Creates windows .bat files for easy running of commands
- def generate_windows_script(bindir, filename)
if Gem.win_platform? then
script_name = filename + ".bat"
script_path = File.join bindir, File.basename(script_name)
@@ -295,7 +296,7 @@ class Gem::Installer
@spec.executables.each do |filename|
filename.untaint
- bin_path = File.expand_path("#{@spec.bindir}/#{filename}", @gem_dir)
mode = File.stat(bin_path).mode | 0111
File.chmod mode, bin_path
@@ -329,7 +330,7 @@ class Gem::Installer
say bin_script_path if Gem.configuration.really_verbose
- generate_windows_script bindir, filename
#else
# FileUtils.rm_f bin_script_path
# FileUtils.cp exec_path, bin_script_path,
@@ -1,8 +1,8 @@
-# -*- coding: iso-8859-1 -*-
-#++
-# Copyright (C) 2004 Mauricio Julio Fern�ndez Pradier
-# See LICENSE.txt for additional licensing information.
#--
require 'fileutils'
require 'find'
@@ -13,8 +13,10 @@ require 'zlib'
require 'rubygems/security'
require 'rubygems/specification'
# Wrapper for FileUtils meant to provide logging and additional operations if
# needed.
class Gem::FileOperations
def initialize(logger = nil)
@@ -1,8 +1,8 @@
-# -*- coding: iso-8859-1 -*-
-#++
-# Copyright (C) 2004 Mauricio Julio Fern�ndez Pradier
-# See LICENSE.txt for additional licensing information.
#--
module Gem::Package::FSyncDir
@@ -1,8 +1,8 @@
-# -*- coding: iso-8859-1 -*-
-#++
-# Copyright (C) 2004 Mauricio Julio Fern�ndez Pradier
-# See LICENSE.txt for additional licensing information.
#--
##
#--
@@ -1,8 +1,8 @@
-# -*- coding: iso-8859-1 -*-
-#++
-# Copyright (C) 2004 Mauricio Julio Fern�ndez Pradier
-# See LICENSE.txt for additional licensing information.
#--
##
# TarOutput is a wrapper to TarWriter that builds gem-format tar file.
@@ -1,8 +1,8 @@
-# -*- coding: iso-8859-1 -*-
-#++
-# Copyright (C) 2004 Mauricio Julio Fern�ndez Pradier
-# See LICENSE.txt for additional licensing information.
#--
##
# TarReader reads tar files and allows iteration over their items
@@ -1,8 +1,8 @@
-# -*- coding: iso-8859-1 -*-
-#++
-# Copyright (C) 2004 Mauricio Julio Fern�ndez Pradier
-# See LICENSE.txt for additional licensing information.
#--
##
# Allows writing of tar files
@@ -102,6 +102,7 @@ class Gem::PackageTask < Rake::PackageTask
gem_file = gem_spec.file_name
gem_path = File.join package_dir, gem_file
desc "Build the gem file #{gem_file}"
task :gem => [gem_path]
@@ -109,7 +110,7 @@ class Gem::PackageTask < Rake::PackageTask
trace = Rake.application.options.trace
Gem.configuration.verbose = trace
- file gem_path => [package_dir] + @gem_spec.files do
when_writing "Creating #{gem_spec.file_name}" do
Gem::Builder.new(gem_spec).build
verbose trace do
@@ -70,6 +70,8 @@ class Gem::Platform
when /hpux(\d+)/ then [ 'hpux', $1 ]
when /^java$/, /^jruby$/ then [ 'java', nil ]
when /^java([\d.]*)/ then [ 'java', $1 ]
when /linux/ then [ 'linux', $1 ]
when /mingw32/ then [ 'mingw32', nil ]
when /(mswin\d+)(\_(\d+))?/ then
@@ -148,6 +150,7 @@ class Gem::Platform
when /^i686-darwin(\d)/ then ['x86', 'darwin', $1 ]
when /^i\d86-linux/ then ['x86', 'linux', nil ]
when 'java', 'jruby' then [nil, 'java', nil ]
when /mswin32(\_(\d+))?/ then ['x86', 'mswin32', $2 ]
when 'powerpc-darwin' then ['powerpc', 'darwin', nil ]
when /powerpc-darwin(\d)/ then ['powerpc', 'darwin', $1 ]
@@ -88,7 +88,9 @@ class Gem::RemoteFetcher
# Always escape URI's to deal with potential spaces and such
unless URI::Generic === source_uri
- source_uri = URI.parse(URI.escape(source_uri))
end
scheme = source_uri.scheme
@@ -252,6 +254,8 @@ class Gem::RemoteFetcher
connection.start unless connection.started?
connection
end
##
@@ -309,7 +313,7 @@ class Gem::RemoteFetcher
request.basic_auth uri.user, uri.password
end
- ua = "RubyGems/#{Gem::RubyGemsVersion} #{Gem::Platform.local}"
ua << " Ruby/#{RUBY_VERSION} (#{RUBY_RELEASE_DATE}"
ua << " level #{RUBY_LEVEL}" if defined? RUBY_LEVEL
ua << ")"
@@ -351,7 +355,9 @@ class Gem::RemoteFetcher
# HACK work around EOFError bug in Net::HTTP
# NOTE Errno::ECONNABORTED raised a lot on Windows, and make impossible
# to install gems.
- rescue EOFError, Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EPIPE
requests = @requests[connection.object_id]
say "connection reset after #{requests} requests, retrying" if
Gem.configuration.really_verbose
@@ -93,9 +93,14 @@ class Gem::Requirement
requirements.uniq!
requirements << ">= 0" if requirements.empty?
@requirements = requirements.map! { |r| self.class.parse r }
end
def as_list # :nodoc:
requirements.map { |op, version| "#{op} #{version}" }
end
@@ -33,6 +33,8 @@ require 'rubygems/doc_manager'
class Gem::Server
include ERB::Util
include Gem::UserInteraction
@@ -430,29 +432,36 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
options[:addresses]).run
end
- def initialize(gem_dir, port, daemon, addresses = nil)
Socket.do_not_reverse_lookup = true
- @gem_dir = gem_dir
@port = port
@daemon = daemon
@addresses = addresses
logger = WEBrick::Log.new nil, WEBrick::BasicLog::FATAL
@server = WEBrick::HTTPServer.new :DoNotListen => true, :Logger => logger
- @spec_dir = File.join @gem_dir, 'specifications'
- unless File.directory? @spec_dir then
- raise ArgumentError, "#{@gem_dir} does not appear to be a gem repository"
end
- @source_index = Gem::SourceIndex.from_gems_in @spec_dir
end
def Marshal(req, res)
@source_index.refresh!
- res['date'] = File.stat(@spec_dir).mtime
index = Marshal.dump @source_index
@@ -471,12 +480,18 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
res.body << index
end
def latest_specs(req, res)
@source_index.refresh!
res['content-type'] = 'application/x-gzip'
- res['date'] = File.stat(@spec_dir).mtime
specs = @source_index.latest_specs.sort.map do |spec|
platform = spec.original_platform
@@ -535,7 +550,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
@source_index.refresh!
res['content-type'] = 'text/plain'
- res['date'] = File.stat(@spec_dir).mtime
case req.request_uri.path
when '/quick/index' then
@@ -586,7 +601,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
def root(req, res)
@source_index.refresh!
- res['date'] = File.stat(@spec_dir).mtime
raise WEBrick::HTTPStatus::NotFound, "`#{req.path}' not found." unless
req.path == '/'
@@ -630,16 +645,16 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
specs << {
"authors" => "Chad Fowler, Rich Kilmer, Jim Weirich, Eric Hodel and others",
"dependencies" => [],
- "doc_path" => "/doc_root/rubygems-#{Gem::RubyGemsVersion}/rdoc/index.html",
"executables" => [{"executable" => 'gem', "is_last" => true}],
"only_one_executable" => true,
- "full_name" => "rubygems-#{Gem::RubyGemsVersion}",
"has_deps" => false,
"homepage" => "http://docs.rubygems.org/",
"name" => 'rubygems',
"rdoc_installed" => true,
"summary" => "RubyGems itself",
- "version" => Gem::RubyGemsVersion,
}
specs = specs.sort_by { |spec| [spec["name"].downcase, spec["version"]] }
@@ -718,7 +733,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
# documentation - just put it underneath the main doc folder.
def show_rdoc_for_pattern(pattern, res)
- found_gems = Dir.glob("#{@gem_dir}/doc/#{pattern}").select {|path|
File.exist? File.join(path, 'rdoc/index.html')
}
case found_gems.length
@@ -771,7 +786,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
@server.mount_proc("/gem-server-rdoc-style.css") do |req, res|
res['content-type'] = 'text/css'
- res['date'] = File.stat(@spec_dir).mtime
res.body << RDOC_CSS
end
@@ -782,7 +797,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
paths = { "/gems" => "/cache/", "/doc_root" => "/doc/" }
paths.each do |mount_point, mount_dir|
@server.mount(mount_point, WEBrick::HTTPServlet::FileHandler,
- File.join(@gem_dir, mount_dir), true)
end
trap("INT") { @server.shutdown; exit! }
@@ -794,7 +809,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
def specs(req, res)
@source_index.refresh!
- res['date'] = File.stat(@spec_dir).mtime
specs = @source_index.sort.map do |_, spec|
platform = spec.original_platform
@@ -821,7 +836,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
def yaml(req, res)
@source_index.refresh!
- res['date'] = File.stat(@spec_dir).mtime
index = @source_index.to_yaml
@@ -85,10 +85,10 @@ class Gem::SourceIndex
def load_specification(file_name)
return nil unless file_name and File.exist? file_name
- spec_code = if !defined?(Encoding) then
- File.read file_name
- else
File.read file_name, :encoding => 'UTF-8'
end.untaint
begin
@@ -285,17 +285,19 @@ class Gem::SourceInfoCache
cache_data.map do |source_uri, sic_entry|
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)
end
sic_entry.source_index.search pattern, platform_only
end.flatten.compact
end
# Searches all source indexes for +pattern+. If +only_platform+ is true,
# only gems matching Gem.platforms will be selected. Returns an Array of
# pairs containing the Gem::Specification found and the source_uri it was
# found at.
def search_with_source(pattern, only_platform = false, all = false)
read_all_cache_data if all
@@ -306,7 +308,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)
end
sic_entry.source_index.search(pattern, only_platform).each do |spec|
@@ -3,6 +3,7 @@ require 'fileutils'
require 'rubygems/remote_fetcher'
require 'rubygems/user_interaction'
##
# SpecFetcher handles metadata updates from remote gem repositories.
@@ -65,22 +66,28 @@ class Gem::SpecFetcher
# 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
- specs_and_sources.map do |spec_tuple, source_uri|
[fetch_spec(spec_tuple, URI.parse(source_uri)), source_uri]
end
rescue Gem::RemoteFetcher::FetchError => e
raise unless warn_legacy e do
require 'rubygems/source_info_cache'
- return Gem::SourceInfoCache.search_with_source(dependency,
- matching_platform, all)
end
end
def fetch_spec(spec, source_uri)
spec = spec - [nil, 'ruby', '']
spec_file_name = "#{spec.join '-'}.gemspec"
@@ -117,16 +124,27 @@ class Gem::SpecFetcher
# 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 = {}
list(all, prerelease).each do |source_uri, specs|
found[source_uri] = specs.select do |spec_name, version, spec_platform|
- dependency =~ Gem::Dependency.new(spec_name, version) and
- (not matching_platform or Gem::Platform.match(spec_platform))
end
end
specs_and_sources = []
found.each do |source_uri, specs|
@@ -134,7 +152,11 @@ class Gem::SpecFetcher
specs_and_sources.push(*specs.map { |spec| [spec, uri_str] })
end
- specs_and_sources
end
##
@@ -504,8 +504,8 @@ class Gem::Specification
gemspec = nil
raise "NESTED Specification.load calls not allowed!" if @@gather
@@gather = proc { |gs| gemspec = gs }
- data = File.read(filename)
- eval(data)
gemspec
ensure
@@gather = nil
@@ -524,7 +524,7 @@ class Gem::Specification
# Sets the rubygems_version to the current RubyGems version
def mark_version
- @rubygems_version = Gem::RubyGemsVersion
end
##
@@ -677,33 +677,43 @@ class Gem::Specification
}
end
- def to_yaml(opts = {}) # :nodoc:
mark_version
attributes = @@attributes.map { |name,| name.to_s }.sort
attributes = attributes - %w[name version platform]
yaml = YAML.quick_emit object_id, opts do |out|
out.map taguri, to_yaml_style do |map|
- map.add 'name', @name
- map.add 'version', @version
- platform = case @original_platform
- when nil, '' then
- 'ruby'
- when String then
- @original_platform
- else
- @original_platform.to_s
- end
- map.add 'platform', platform
-
- attributes.each do |name|
- map.add name, instance_variable_get("@#{name}")
- end
end
end
end
def yaml_initialize(tag, vals) # :nodoc:
vals.each do |ivar, val|
instance_variable_set "@#{ivar}", val
@@ -759,7 +769,7 @@ class Gem::Specification
result << " s.specification_version = #{specification_version}"
result << nil
- result << " if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then"
unless dependencies.empty? then
dependencies.each do |dep|
@@ -804,9 +814,9 @@ class Gem::Specification
extend Gem::UserInteraction
normalize
- if rubygems_version != Gem::RubyGemsVersion then
raise Gem::InvalidSpecificationException,
- "expected RubyGems version #{Gem::RubyGemsVersion}, was #{rubygems_version}"
end
@@required_attributes.each do |symbol|
@@ -1052,7 +1062,7 @@ class Gem::Specification
#
# Do not set this, it is set automatically when the gem is packaged.
- required_attribute :rubygems_version, Gem::RubyGemsVersion
##
# :attr_accessor: specification_version
@@ -1481,14 +1491,12 @@ class Gem::Specification
end
overwrite_accessor :files do
- result = []
- result.push(*@files) if defined?(@files)
- result.push(*@test_files) if defined?(@test_files)
- result.push(*(add_bindir(@executables)))
- result.push(*@extra_rdoc_files) if defined?(@extra_rdoc_files)
- result.push(*@extensions) if defined?(@extensions)
- result.uniq.compact
end
-
end
-
@@ -10,11 +10,10 @@ require 'digest'
require 'rubygems/format'
require 'rubygems/installer'
-# Load test-unit 2.x if it's a gem
begin
- Gem.activate('test-unit')
rescue Gem::LoadError
- # Ignore - use the test-unit library that's part of the standard library
end
##
@@ -212,7 +212,7 @@ class Gem::Version
end
def hash # :nodoc:
- segments.hash
end
def inspect # :nodoc:
@@ -234,6 +234,7 @@ class Gem::Version
def marshal_load array
initialize array[0]
end
##
# A version is considered a prerelease if it contains a letter.
@@ -244,6 +245,7 @@ class Gem::Version
def pretty_print q # :nodoc:
q.text "Gem::Version.new(#{version.inspect})"
end
##
# The release for this version (e.g. 1.2.0.a -> 1.2.0).
# Non-prerelease versions return themselves.