mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Import RubyGems 1.0.0, r1575
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
40d8543fbd
commit
8289771e32
47 changed files with 1170 additions and 1010 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Thu Dec 20 17:36:01 2007 Eric Hodel <drbrain@segment7.net>
|
||||||
|
|
||||||
|
* lib/rubygems*: Import RubyGems 1.0.0, r1575.
|
||||||
|
|
||||||
Thu Dec 20 17:18:38 2007 Koichi Sasada <ko1@atdot.net>
|
Thu Dec 20 17:18:38 2007 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* proc.c: support Proc#binding.
|
* proc.c: support Proc#binding.
|
||||||
|
|
|
@ -131,6 +131,7 @@ module Gem
|
||||||
Dir.entries(gems_directory).each do |gem_directory_name|
|
Dir.entries(gems_directory).each do |gem_directory_name|
|
||||||
next if gem_directory_name == "." || gem_directory_name == ".."
|
next if gem_directory_name == "." || gem_directory_name == ".."
|
||||||
dash = gem_directory_name.rindex("-")
|
dash = gem_directory_name.rindex("-")
|
||||||
|
next if dash.nil?
|
||||||
gem_name = gem_directory_name[0...dash]
|
gem_name = gem_directory_name[0...dash]
|
||||||
current_version = GemVersions[gem_name]
|
current_version = GemVersions[gem_name]
|
||||||
new_version = calculate_integers_for_gem_version(gem_directory_name[dash+1..-1])
|
new_version = calculate_integers_for_gem_version(gem_directory_name[dash+1..-1])
|
||||||
|
@ -167,6 +168,7 @@ module Gem
|
||||||
|
|
||||||
def method_missing(method, *args, &block)
|
def method_missing(method, *args, &block)
|
||||||
QuickLoader.load_full_rubygems_library
|
QuickLoader.load_full_rubygems_library
|
||||||
|
super unless Gem.respond_to?(method)
|
||||||
Gem.send(method, *args, &block)
|
Gem.send(method, *args, &block)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -174,9 +176,14 @@ module Gem
|
||||||
extend QuickLoader
|
extend QuickLoader
|
||||||
|
|
||||||
end
|
end
|
||||||
|
begin
|
||||||
Gem.push_all_highest_version_gems_on_load_path
|
Gem.push_all_highest_version_gems_on_load_path
|
||||||
$".unshift File.join(Gem::ConfigMap[:libdir], "ruby", Gem::ConfigMap[:ruby_version], "rubygems.rb")
|
$".unshift File.join(Gem::ConfigMap[:libdir], "ruby", Gem::ConfigMap[:ruby_version], "rubygems.rb")
|
||||||
|
rescue Exception => e
|
||||||
|
puts "Error loading gem paths on load path in gem_prelude"
|
||||||
|
puts e
|
||||||
|
puts e.backtrace.join("\n")
|
||||||
|
end
|
||||||
|
|
||||||
#puts "Gem load in #{Time.now - t} seconds"
|
#puts "Gem load in #{Time.now - t} seconds"
|
||||||
end # Gem::Enable
|
end # Gem::Enable
|
|
@ -6,6 +6,7 @@
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require 'rubygems/rubygems_version'
|
require 'rubygems/rubygems_version'
|
||||||
|
require 'rubygems/defaults'
|
||||||
require 'thread'
|
require 'thread'
|
||||||
|
|
||||||
module Gem
|
module Gem
|
||||||
|
@ -29,8 +30,8 @@ module Kernel
|
||||||
# version).
|
# version).
|
||||||
#
|
#
|
||||||
# You can define the environment variable GEM_SKIP as a way to not
|
# You can define the environment variable GEM_SKIP as a way to not
|
||||||
# load specified gems. you might do this to test out changes that
|
# load specified gems. You might do this to test out changes that
|
||||||
# haven't been intsalled yet. Example:
|
# haven't been installed yet. Example:
|
||||||
#
|
#
|
||||||
# GEM_SKIP=libA:libB ruby-I../libA -I../libB ./mycode.rb
|
# GEM_SKIP=libA:libB ruby-I../libA -I../libB ./mycode.rb
|
||||||
#
|
#
|
||||||
|
@ -49,17 +50,6 @@ module Kernel
|
||||||
active_gem_with_options(gem_name, version_requirements)
|
active_gem_with_options(gem_name, version_requirements)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Same as the +gem+ command, but will also require a file if the gem
|
|
||||||
# provides an auto-required file name.
|
|
||||||
#
|
|
||||||
# DEPRECATED! Use +gem+ instead.
|
|
||||||
#
|
|
||||||
def require_gem(gem_name, *version_requirements)
|
|
||||||
file, lineno = location_of_caller
|
|
||||||
warn "#{file}:#{lineno}:Warning: require_gem is obsolete. Use gem instead."
|
|
||||||
active_gem_with_options(gem_name, version_requirements, :auto_require=>true)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Return the file name (string) and line number (integer) of the caller of
|
# Return the file name (string) and line number (integer) of the caller of
|
||||||
# the caller of this method.
|
# the caller of this method.
|
||||||
def location_of_caller
|
def location_of_caller
|
||||||
|
@ -84,15 +74,17 @@ module Gem
|
||||||
ConfigMap = {} unless defined?(ConfigMap)
|
ConfigMap = {} unless defined?(ConfigMap)
|
||||||
require 'rbconfig'
|
require 'rbconfig'
|
||||||
ConfigMap.merge!(
|
ConfigMap.merge!(
|
||||||
:sitedir => RbConfig::CONFIG["sitedir"],
|
:BASERUBY => RbConfig::CONFIG["BASERUBY"],
|
||||||
:ruby_version => RbConfig::CONFIG["ruby_version"],
|
:EXEEXT => RbConfig::CONFIG["EXEEXT"],
|
||||||
:libdir => RbConfig::CONFIG["libdir"],
|
:RUBY_INSTALL_NAME => RbConfig::CONFIG["RUBY_INSTALL_NAME"],
|
||||||
:sitelibdir => RbConfig::CONFIG["sitelibdir"],
|
:RUBY_SO_NAME => RbConfig::CONFIG["RUBY_SO_NAME"],
|
||||||
:arch => RbConfig::CONFIG["arch"],
|
:arch => RbConfig::CONFIG["arch"],
|
||||||
:bindir => RbConfig::CONFIG["bindir"],
|
:bindir => RbConfig::CONFIG["bindir"],
|
||||||
:EXEEXT => RbConfig::CONFIG["EXEEXT"],
|
:libdir => RbConfig::CONFIG["libdir"],
|
||||||
:RUBY_SO_NAME => RbConfig::CONFIG["RUBY_SO_NAME"],
|
:ruby_install_name => RbConfig::CONFIG["ruby_install_name"],
|
||||||
:ruby_install_name => RbConfig::CONFIG["ruby_install_name"]
|
:ruby_version => RbConfig::CONFIG["ruby_version"],
|
||||||
|
:sitedir => RbConfig::CONFIG["sitedir"],
|
||||||
|
:sitelibdir => RbConfig::CONFIG["sitelibdir"]
|
||||||
)
|
)
|
||||||
|
|
||||||
MUTEX = Mutex.new
|
MUTEX = Mutex.new
|
||||||
|
@ -207,10 +199,6 @@ module Gem
|
||||||
@sources
|
@sources
|
||||||
end
|
end
|
||||||
|
|
||||||
# An Array of the default sources that come with RubyGems.
|
|
||||||
def default_sources
|
|
||||||
%w[http://gems.rubyforge.org]
|
|
||||||
end
|
|
||||||
|
|
||||||
# Provide an alias for the old name.
|
# Provide an alias for the old name.
|
||||||
alias cache source_index
|
alias cache source_index
|
||||||
|
@ -536,18 +524,6 @@ module Gem
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
public
|
|
||||||
|
|
||||||
# Default home directory path to be used if an alternate value is
|
|
||||||
# not specified in the environment.
|
|
||||||
def default_dir
|
|
||||||
if defined? RUBY_FRAMEWORK_VERSION
|
|
||||||
return File.join(File.dirname(ConfigMap[:sitedir]), "Gems", ConfigMap[:ruby_version])
|
|
||||||
else
|
|
||||||
File.join(ConfigMap[:libdir], 'ruby', 'gems', ConfigMap[:ruby_version])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,6 +17,7 @@ class Gem::Commands::InstallCommand < Gem::Command
|
||||||
:generate_rdoc => true,
|
:generate_rdoc => true,
|
||||||
:generate_ri => true,
|
:generate_ri => true,
|
||||||
:install_dir => Gem.dir,
|
:install_dir => Gem.dir,
|
||||||
|
:format_executable => false,
|
||||||
:test => false,
|
:test => false,
|
||||||
:version => Gem::Requirement.default,
|
:version => Gem::Requirement.default,
|
||||||
})
|
})
|
||||||
|
@ -56,6 +57,7 @@ class Gem::Commands::InstallCommand < Gem::Command
|
||||||
:env_shebang => options[:env_shebang],
|
:env_shebang => options[:env_shebang],
|
||||||
:domain => options[:domain],
|
:domain => options[:domain],
|
||||||
:force => options[:force],
|
:force => options[:force],
|
||||||
|
:format_executable => options[:format_executable],
|
||||||
:ignore_dependencies => options[:ignore_dependencies],
|
:ignore_dependencies => options[:ignore_dependencies],
|
||||||
:install_dir => options[:install_dir],
|
:install_dir => options[:install_dir],
|
||||||
:security_policy => options[:security_policy],
|
:security_policy => options[:security_policy],
|
||||||
|
|
|
@ -60,10 +60,16 @@ Multiple sources and destinations may be specified.
|
||||||
if get_from.scheme.nil? then
|
if get_from.scheme.nil? then
|
||||||
get_from = get_from.to_s
|
get_from = get_from.to_s
|
||||||
elsif get_from.scheme == 'file' then
|
elsif get_from.scheme == 'file' then
|
||||||
get_from = get_from.to_s[5..-1]
|
# check if specified URI contains a drive letter (file:/D:/Temp)
|
||||||
|
get_from = get_from.to_s
|
||||||
|
get_from = if get_from =~ /^file:.*[a-z]:/i then
|
||||||
|
get_from[6..-1]
|
||||||
|
else
|
||||||
|
get_from[5..-1]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
open File.join(get_from, "Marshal.#{Gem.marshal_version}.Z"), "rb" do |y|
|
open File.join(get_from.to_s, "Marshal.#{Gem.marshal_version}.Z"), "rb" do |y|
|
||||||
sourceindex_data = Zlib::Inflate.inflate y.read
|
sourceindex_data = Zlib::Inflate.inflate y.read
|
||||||
open File.join(save_to, "Marshal.#{Gem.marshal_version}"), "wb" do |out|
|
open File.join(save_to, "Marshal.#{Gem.marshal_version}"), "wb" do |out|
|
||||||
out.write sourceindex_data
|
out.write sourceindex_data
|
||||||
|
|
|
@ -82,8 +82,10 @@ class Gem::Commands::QueryCommand < Gem::Command
|
||||||
end
|
end
|
||||||
|
|
||||||
entry = gem_name.dup
|
entry = gem_name.dup
|
||||||
|
|
||||||
if options[:versions] then
|
if options[:versions] then
|
||||||
entry << " (#{list_of_matching.map{|gem| gem.version.to_s}.join(", ")})"
|
versions = list_of_matching.map { |s| s.version }.uniq
|
||||||
|
entry << " (#{versions.join ', '})"
|
||||||
end
|
end
|
||||||
|
|
||||||
entry << "\n" << format_text(list_of_matching[0].summary, 68, 4) if
|
entry << "\n" << format_text(list_of_matching[0].summary, 68, 4) if
|
||||||
|
|
|
@ -7,17 +7,17 @@ class Gem::Commands::ServerCommand < Gem::Command
|
||||||
super 'server', 'Documentation and gem repository HTTP server',
|
super 'server', 'Documentation and gem repository HTTP server',
|
||||||
:port => 8808, :gemdir => Gem.dir, :daemon => false
|
:port => 8808, :gemdir => Gem.dir, :daemon => false
|
||||||
|
|
||||||
add_option '-p', '--port=PORT',
|
add_option '-p', '--port=PORT', Integer,
|
||||||
'port to listen on' do |port, options|
|
'port to listen on' do |port, options|
|
||||||
options[:port] = port
|
options[:port] = port
|
||||||
end
|
end
|
||||||
|
|
||||||
add_option '-d', '--dir=GEMDIR',
|
add_option '-d', '--dir=GEMDIR',
|
||||||
'directory from which to serve gems' do |gemdir, options|
|
'directory from which to serve gems' do |gemdir, options|
|
||||||
options[:gemdir] = gemdir
|
options[:gemdir] = File.expand_path gemdir
|
||||||
end
|
end
|
||||||
|
|
||||||
add_option '--[no]-daemon', 'run as a daemon' do |daemon, options|
|
add_option '--[no-]daemon', 'run as a daemon' do |daemon, options|
|
||||||
options[:daemon] = daemon
|
options[:daemon] = daemon
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,13 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
super 'unpack', 'Unpack an installed gem to the current directory',
|
super 'unpack', 'Unpack an installed gem to the current directory',
|
||||||
:version => Gem::Requirement.default
|
:version => Gem::Requirement.default,
|
||||||
|
:target => Dir.pwd
|
||||||
|
|
||||||
|
add_option('--target', 'target directory for unpacking') do |value, options|
|
||||||
|
options[:target] = value
|
||||||
|
end
|
||||||
|
|
||||||
add_version_option
|
add_version_option
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,10 +38,11 @@ class Gem::Commands::UnpackCommand < Gem::Command
|
||||||
def execute
|
def execute
|
||||||
gemname = get_one_gem_name
|
gemname = get_one_gem_name
|
||||||
path = get_path(gemname, options[:version])
|
path = get_path(gemname, options[:version])
|
||||||
if path
|
if path then
|
||||||
target_dir = File.basename(path).sub(/\.gem$/, '')
|
basename = File.basename(path).sub(/\.gem$/, '')
|
||||||
|
target_dir = File.expand_path File.join(options[:target], basename)
|
||||||
FileUtils.mkdir_p target_dir
|
FileUtils.mkdir_p target_dir
|
||||||
Gem::Installer.new(path).unpack(File.expand_path(target_dir))
|
Gem::Installer.new(path).unpack target_dir
|
||||||
say "Unpacked gem: '#{target_dir}'"
|
say "Unpacked gem: '#{target_dir}'"
|
||||||
else
|
else
|
||||||
alert_error "Gem '#{gemname}' not installed."
|
alert_error "Gem '#{gemname}' not installed."
|
||||||
|
|
|
@ -4,146 +4,152 @@ require 'rubygems/local_remote_options'
|
||||||
require 'rubygems/source_info_cache'
|
require 'rubygems/source_info_cache'
|
||||||
require 'rubygems/version_option'
|
require 'rubygems/version_option'
|
||||||
|
|
||||||
module Gem
|
class Gem::Commands::UpdateCommand < Gem::Command
|
||||||
module Commands
|
|
||||||
class UpdateCommand < Command
|
|
||||||
|
|
||||||
include Gem::InstallUpdateOptions
|
include Gem::InstallUpdateOptions
|
||||||
include Gem::LocalRemoteOptions
|
include Gem::LocalRemoteOptions
|
||||||
include Gem::VersionOption
|
include Gem::VersionOption
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
super(
|
super 'update',
|
||||||
'update',
|
|
||||||
'Update the named gems (or all installed gems) in the local repository',
|
'Update the named gems (or all installed gems) in the local repository',
|
||||||
{
|
:generate_rdoc => true,
|
||||||
:generate_rdoc => true,
|
:generate_ri => true,
|
||||||
:generate_ri => true,
|
:force => false,
|
||||||
:force => false,
|
:test => false,
|
||||||
:test => false,
|
:install_dir => Gem.dir
|
||||||
:install_dir => Gem.dir
|
|
||||||
})
|
|
||||||
|
|
||||||
add_install_update_options
|
add_install_update_options
|
||||||
|
|
||||||
add_option('--system',
|
add_option('--system',
|
||||||
'Update the RubyGems system software') do |value, options|
|
'Update the RubyGems system software') do |value, options|
|
||||||
options[:system] = value
|
options[:system] = value
|
||||||
end
|
end
|
||||||
|
|
||||||
add_local_remote_options
|
add_local_remote_options
|
||||||
|
|
||||||
add_platform_option
|
add_platform_option
|
||||||
|
end
|
||||||
|
|
||||||
|
def arguments # :nodoc:
|
||||||
|
"GEMNAME name of gem to update"
|
||||||
|
end
|
||||||
|
|
||||||
|
def defaults_str # :nodoc:
|
||||||
|
"--rdoc --ri --no-force --no-test --install-dir #{Gem.dir}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def usage # :nodoc:
|
||||||
|
"#{program_name} GEMNAME [GEMNAME ...]"
|
||||||
|
end
|
||||||
|
|
||||||
|
def execute
|
||||||
|
if options[:system] then
|
||||||
|
say "Updating RubyGems..."
|
||||||
|
|
||||||
|
unless options[:args].empty? then
|
||||||
|
fail "No gem names are allowed with the --system option"
|
||||||
end
|
end
|
||||||
|
|
||||||
def arguments # :nodoc:
|
options[:args] = ["rubygems-update"]
|
||||||
"GEMNAME name of gem to update"
|
else
|
||||||
|
say "Updating installed gems..."
|
||||||
|
end
|
||||||
|
|
||||||
|
hig = highest_installed_gems = {}
|
||||||
|
|
||||||
|
Gem::SourceIndex.from_installed_gems.each do |name, spec|
|
||||||
|
if hig[spec.name].nil? or hig[spec.name].version < spec.version then
|
||||||
|
hig[spec.name] = spec
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
remote_gemspecs = Gem::SourceInfoCache.search(//)
|
||||||
|
|
||||||
|
gems_to_update = if options[:args].empty? then
|
||||||
|
which_to_update(highest_installed_gems, remote_gemspecs)
|
||||||
|
else
|
||||||
|
options[:args]
|
||||||
|
end
|
||||||
|
|
||||||
|
options[:domain] = :remote # install from remote source
|
||||||
|
|
||||||
|
# HACK use the real API
|
||||||
|
install_command = Gem::CommandManager.instance['install']
|
||||||
|
|
||||||
|
gems_to_update.uniq.sort.each do |name|
|
||||||
|
say "Attempting remote update of #{name}"
|
||||||
|
options[:args] = [name]
|
||||||
|
options[:ignore_dependencies] = true # HACK skip seen gems instead
|
||||||
|
install_command.merge_options(options)
|
||||||
|
install_command.execute
|
||||||
|
end
|
||||||
|
|
||||||
|
if gems_to_update.include? "rubygems-update" then
|
||||||
|
latest_ruby_gem = remote_gemspecs.select do |s|
|
||||||
|
s.name == 'rubygems-update'
|
||||||
end
|
end
|
||||||
|
|
||||||
def defaults_str # :nodoc:
|
latest_ruby_gem = latest_ruby_gem.sort_by { |s| s.version }.last
|
||||||
"--rdoc --ri --no-force --no-test\n" +
|
|
||||||
"--install-dir #{Gem.dir}"
|
|
||||||
end
|
|
||||||
|
|
||||||
def usage # :nodoc:
|
say "Updating version of RubyGems to #{latest_ruby_gem.version}"
|
||||||
"#{program_name} GEMNAME [GEMNAME ...]"
|
installed = do_rubygems_update latest_ruby_gem.version
|
||||||
end
|
|
||||||
|
|
||||||
def execute
|
say "RubyGems system software updated" if installed
|
||||||
if options[:system] then
|
else
|
||||||
say "Updating RubyGems..."
|
updated = gems_to_update.uniq.sort.collect { |g| g.to_s }
|
||||||
|
|
||||||
unless options[:args].empty? then
|
if updated.empty? then
|
||||||
fail "No gem names are allowed with the --system option"
|
say "Nothing to update"
|
||||||
end
|
else
|
||||||
|
say "Gems updated: #{updated.join ', '}"
|
||||||
options[:args] = ["rubygems-update"]
|
|
||||||
else
|
|
||||||
say "Updating installed gems..."
|
|
||||||
end
|
|
||||||
|
|
||||||
hig = highest_installed_gems = {}
|
|
||||||
|
|
||||||
Gem::SourceIndex.from_installed_gems.each do |name, spec|
|
|
||||||
if hig[spec.name].nil? or hig[spec.name].version < spec.version
|
|
||||||
hig[spec.name] = spec
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
remote_gemspecs = Gem::SourceInfoCache.search(//)
|
|
||||||
|
|
||||||
gems_to_update = if options[:args].empty? then
|
|
||||||
which_to_update(highest_installed_gems, remote_gemspecs)
|
|
||||||
else
|
|
||||||
options[:args]
|
|
||||||
end
|
|
||||||
|
|
||||||
options[:domain] = :remote # install from remote source
|
|
||||||
|
|
||||||
# HACK use the real API
|
|
||||||
install_command = Gem::CommandManager.instance['install']
|
|
||||||
|
|
||||||
gems_to_update.uniq.sort.each do |name|
|
|
||||||
say "Attempting remote update of #{name}"
|
|
||||||
options[:args] = [name]
|
|
||||||
options[:ignore_dependencies] = true # HACK skip seen gems instead
|
|
||||||
install_command.merge_options(options)
|
|
||||||
install_command.execute
|
|
||||||
end
|
|
||||||
|
|
||||||
if gems_to_update.include?("rubygems-update") then
|
|
||||||
latest_ruby_gem = remote_gemspecs.select { |s|
|
|
||||||
s.name == 'rubygems-update'
|
|
||||||
}.sort_by { |s|
|
|
||||||
s.version
|
|
||||||
}.last
|
|
||||||
|
|
||||||
say "Updating version of RubyGems to #{latest_ruby_gem.version}"
|
|
||||||
installed = do_rubygems_update(latest_ruby_gem.version.to_s)
|
|
||||||
|
|
||||||
say "RubyGems system software updated" if installed
|
|
||||||
else
|
|
||||||
say "Gems: [#{gems_to_update.uniq.sort.collect{|g| g.to_s}.join(', ')}] updated"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def do_rubygems_update(version_string)
|
|
||||||
args = []
|
|
||||||
args.push '--prefix', Gem.prefix unless Gem.prefix.nil?
|
|
||||||
args << '--no-rdoc' unless options[:generate_rdoc]
|
|
||||||
args << '--no-ri' unless options[:generate_ri]
|
|
||||||
|
|
||||||
update_dir = File.join(Gem.dir, 'gems',
|
|
||||||
"rubygems-update-#{version_string}")
|
|
||||||
|
|
||||||
success = false
|
|
||||||
|
|
||||||
Dir.chdir update_dir do
|
|
||||||
say "Installing RubyGems #{version_string}"
|
|
||||||
setup_cmd = "#{Gem.ruby} setup.rb #{args.join ' '}"
|
|
||||||
|
|
||||||
# Make sure old rubygems isn't loaded
|
|
||||||
if Gem.win_platform? then
|
|
||||||
system "set RUBYOPT= & #{setup_cmd}"
|
|
||||||
else
|
|
||||||
system "RUBYOPT=\"\" #{setup_cmd}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def which_to_update(highest_installed_gems, remote_gemspecs)
|
|
||||||
result = []
|
|
||||||
highest_installed_gems.each do |l_name, l_spec|
|
|
||||||
highest_remote_gem =
|
|
||||||
remote_gemspecs.select { |spec| spec.name == l_name }.
|
|
||||||
sort_by { |spec| spec.version }.
|
|
||||||
last
|
|
||||||
if highest_remote_gem and l_spec.version < highest_remote_gem.version
|
|
||||||
result << l_name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
result
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def do_rubygems_update(version)
|
||||||
|
args = []
|
||||||
|
args.push '--prefix', Gem.prefix unless Gem.prefix.nil?
|
||||||
|
args << '--no-rdoc' unless options[:generate_rdoc]
|
||||||
|
args << '--no-ri' unless options[:generate_ri]
|
||||||
|
|
||||||
|
update_dir = File.join Gem.dir, 'gems', "rubygems-update-#{version}"
|
||||||
|
|
||||||
|
success = false
|
||||||
|
|
||||||
|
Dir.chdir update_dir do
|
||||||
|
say "Installing RubyGems #{version}"
|
||||||
|
setup_cmd = "#{Gem.ruby} setup.rb #{args.join ' '}"
|
||||||
|
|
||||||
|
# Make sure old rubygems isn't loaded
|
||||||
|
if Gem.win_platform? then
|
||||||
|
system "set RUBYOPT= & #{setup_cmd}"
|
||||||
|
else
|
||||||
|
system "RUBYOPT=\"\" #{setup_cmd}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def which_to_update(highest_installed_gems, remote_gemspecs)
|
||||||
|
result = []
|
||||||
|
|
||||||
|
highest_installed_gems.each do |l_name, l_spec|
|
||||||
|
matching_gems = remote_gemspecs.select do |spec|
|
||||||
|
spec.name == l_name and Gem.platforms.any? do |platform|
|
||||||
|
platform == spec.platform
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
highest_remote_gem = matching_gems.sort_by { |spec| spec.version }.last
|
||||||
|
|
||||||
|
if highest_remote_gem and
|
||||||
|
l_spec.version < highest_remote_gem.version then
|
||||||
|
result << l_name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
46
lib/rubygems/defaults.rb
Normal file
46
lib/rubygems/defaults.rb
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
module Gem
|
||||||
|
|
||||||
|
# An Array of the default sources that come with RubyGems.
|
||||||
|
def self.default_sources
|
||||||
|
%w[http://gems.rubyforge.org]
|
||||||
|
end
|
||||||
|
|
||||||
|
# Default home directory path to be used if an alternate value is not
|
||||||
|
# specified in the environment.
|
||||||
|
def self.default_dir
|
||||||
|
if defined? RUBY_FRAMEWORK_VERSION then
|
||||||
|
File.join File.dirname(ConfigMap[:sitedir]), 'Gems',
|
||||||
|
ConfigMap[:ruby_version]
|
||||||
|
else
|
||||||
|
File.join ConfigMap[:libdir], 'ruby', 'gems', ConfigMap[:ruby_version]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Default gem path.
|
||||||
|
def self.default_path
|
||||||
|
default_dir
|
||||||
|
end
|
||||||
|
|
||||||
|
# Deduce Ruby's --program-prefix and --program-suffix from its install name.
|
||||||
|
def self.default_exec_format
|
||||||
|
baseruby = ConfigMap[:BASERUBY] || 'ruby'
|
||||||
|
ConfigMap[:RUBY_INSTALL_NAME].sub(baseruby, '%s') rescue '%s'
|
||||||
|
end
|
||||||
|
|
||||||
|
# The default directory for binaries
|
||||||
|
def self.default_bindir
|
||||||
|
Config::CONFIG['bindir']
|
||||||
|
end
|
||||||
|
|
||||||
|
# The default system-wide source info cache directory.
|
||||||
|
def self.default_system_source_cache_dir
|
||||||
|
File.join Gem.dir, 'source_cache'
|
||||||
|
end
|
||||||
|
|
||||||
|
# The default user-specific source info cache directory.
|
||||||
|
def self.default_user_source_cache_dir
|
||||||
|
File.join Gem.user_home, '.gem', 'source_cache'
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
|
@ -15,8 +15,9 @@ class Gem::DependencyInstaller
|
||||||
:env_shebang => false,
|
:env_shebang => false,
|
||||||
:domain => :both, # HACK dup
|
:domain => :both, # HACK dup
|
||||||
:force => false,
|
:force => false,
|
||||||
|
:format_executable => false, # HACK dup
|
||||||
:ignore_dependencies => false,
|
:ignore_dependencies => false,
|
||||||
:security_policy => Gem::Security::NoSecurity, # HACK AlmostNo? Low?
|
:security_policy => nil, # HACK NoSecurity requires OpenSSL. AlmostNo? Low?
|
||||||
:wrappers => true
|
:wrappers => true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@ class Gem::DependencyInstaller
|
||||||
# current directory. :remote searches only gems in Gem::sources.
|
# current directory. :remote searches only gems in Gem::sources.
|
||||||
# :both searches both.
|
# :both searches both.
|
||||||
# :force:: See Gem::Installer#install.
|
# :force:: See Gem::Installer#install.
|
||||||
|
# :format_executable:: See Gem::Installer#initialize.
|
||||||
# :ignore_dependencies: Don't install any dependencies.
|
# :ignore_dependencies: Don't install any dependencies.
|
||||||
# :install_dir: See Gem::Installer#install.
|
# :install_dir: See Gem::Installer#install.
|
||||||
# :security_policy: See Gem::Installer::new and Gem::Security.
|
# :security_policy: See Gem::Installer::new and Gem::Security.
|
||||||
|
@ -39,6 +41,7 @@ class Gem::DependencyInstaller
|
||||||
@env_shebang = options[:env_shebang]
|
@env_shebang = options[:env_shebang]
|
||||||
@domain = options[:domain]
|
@domain = options[:domain]
|
||||||
@force = options[:force]
|
@force = options[:force]
|
||||||
|
@format_executable = options[:format_executable]
|
||||||
@ignore_dependencies = options[:ignore_dependencies]
|
@ignore_dependencies = options[:ignore_dependencies]
|
||||||
@install_dir = options[:install_dir] || Gem.dir
|
@install_dir = options[:install_dir] || Gem.dir
|
||||||
@security_policy = options[:security_policy]
|
@security_policy = options[:security_policy]
|
||||||
|
@ -48,7 +51,14 @@ class Gem::DependencyInstaller
|
||||||
|
|
||||||
spec_and_source = nil
|
spec_and_source = nil
|
||||||
|
|
||||||
local_gems = Dir["#{gem_name}*"].sort.reverse
|
glob = if File::ALT_SEPARATOR then
|
||||||
|
gem_name.gsub File::ALT_SEPARATOR, File::SEPARATOR
|
||||||
|
else
|
||||||
|
gem_name
|
||||||
|
end
|
||||||
|
|
||||||
|
local_gems = Dir["#{glob}*"].sort.reverse
|
||||||
|
|
||||||
unless local_gems.empty? then
|
unless local_gems.empty? then
|
||||||
local_gems.each do |gem_file|
|
local_gems.each do |gem_file|
|
||||||
next unless gem_file =~ /gem$/
|
next unless gem_file =~ /gem$/
|
||||||
|
@ -217,6 +227,7 @@ class Gem::DependencyInstaller
|
||||||
inst = Gem::Installer.new local_gem_path,
|
inst = Gem::Installer.new local_gem_path,
|
||||||
:env_shebang => @env_shebang,
|
:env_shebang => @env_shebang,
|
||||||
:force => @force,
|
:force => @force,
|
||||||
|
:format_executable => @format_executable,
|
||||||
:ignore_dependencies => @ignore_dependencies,
|
:ignore_dependencies => @ignore_dependencies,
|
||||||
:install_dir => @install_dir,
|
:install_dir => @install_dir,
|
||||||
:security_policy => @security_policy,
|
:security_policy => @security_policy,
|
||||||
|
|
|
@ -98,7 +98,7 @@ class Gem::Indexer
|
||||||
files = @master_index.files + @quick_index.files + @marshal_index.files
|
files = @master_index.files + @quick_index.files + @marshal_index.files
|
||||||
|
|
||||||
files.each do |file|
|
files.each do |file|
|
||||||
relative_name = file[/\A#{@directory}.(.*)/, 1]
|
relative_name = file[/\A#{Regexp.escape @directory}.(.*)/, 1]
|
||||||
dest_name = File.join @dest_directory, relative_name
|
dest_name = File.join @dest_directory, relative_name
|
||||||
|
|
||||||
FileUtils.rm_rf dest_name, :verbose => verbose
|
FileUtils.rm_rf dest_name, :verbose => verbose
|
||||||
|
|
|
@ -76,6 +76,13 @@ module Gem::InstallUpdateOptions
|
||||||
'dependent gems') do |value, options|
|
'dependent gems') do |value, options|
|
||||||
options[:include_dependencies] = value
|
options[:include_dependencies] = value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add_option(:"Install/Update", '--[no-]format-executable',
|
||||||
|
'Make installed executable names match ruby.',
|
||||||
|
'If ruby is ruby18, foo_exec will be',
|
||||||
|
'foo_exec18') do |value, options|
|
||||||
|
options[:format_executable] = value
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Default options for the gem install command.
|
# Default options for the gem install command.
|
||||||
|
|
|
@ -28,9 +28,20 @@ class Gem::Installer
|
||||||
class ExtensionBuildError < Gem::InstallError; end
|
class ExtensionBuildError < Gem::InstallError; end
|
||||||
|
|
||||||
include Gem::UserInteraction
|
include Gem::UserInteraction
|
||||||
|
|
||||||
include Gem::RequirePathsBuilder
|
include Gem::RequirePathsBuilder
|
||||||
|
|
||||||
|
class << self
|
||||||
|
|
||||||
|
attr_writer :exec_format
|
||||||
|
|
||||||
|
# Defaults to use Ruby's program prefix and suffix.
|
||||||
|
def exec_format
|
||||||
|
@exec_format ||= Gem.default_exec_format
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Constructs an Installer instance that will install the gem located at
|
# Constructs an Installer instance that will install the gem located at
|
||||||
# +gem+. +options+ is a Hash with the following keys:
|
# +gem+. +options+ is a Hash with the following keys:
|
||||||
|
@ -40,18 +51,26 @@ class Gem::Installer
|
||||||
# for a signed-gems-only policy.
|
# for a signed-gems-only policy.
|
||||||
# :ignore_dependencies:: Don't raise if a dependency is missing.
|
# :ignore_dependencies:: Don't raise if a dependency is missing.
|
||||||
# :install_dir:: The directory to install the gem into.
|
# :install_dir:: The directory to install the gem into.
|
||||||
|
# :format_executable:: Format the executable the same as the ruby executable.
|
||||||
|
# If your ruby is ruby18, foo_exec will be installed as
|
||||||
|
# foo_exec18.
|
||||||
# :security_policy:: Use the specified security policy. See Gem::Security
|
# :security_policy:: Use the specified security policy. See Gem::Security
|
||||||
# :wrappers:: Install wrappers if true, symlinks if false.
|
# :wrappers:: Install wrappers if true, symlinks if false.
|
||||||
def initialize(gem, options={})
|
def initialize(gem, options={})
|
||||||
@gem = gem
|
@gem = gem
|
||||||
|
|
||||||
options = { :force => false, :install_dir => Gem.dir }.merge options
|
options = {
|
||||||
|
:force => false,
|
||||||
|
:install_dir => Gem.dir,
|
||||||
|
:exec_format => false,
|
||||||
|
}.merge options
|
||||||
|
|
||||||
@env_shebang = options[:env_shebang]
|
@env_shebang = options[:env_shebang]
|
||||||
@force = options[:force]
|
@force = options[:force]
|
||||||
gem_home = options[:install_dir]
|
gem_home = options[:install_dir]
|
||||||
@gem_home = Pathname.new(gem_home).expand_path
|
@gem_home = Pathname.new(gem_home).expand_path
|
||||||
@ignore_dependencies = options[:ignore_dependencies]
|
@ignore_dependencies = options[:ignore_dependencies]
|
||||||
|
@format_executable = options[:format_executable]
|
||||||
@security_policy = options[:security_policy]
|
@security_policy = options[:security_policy]
|
||||||
@wrappers = options[:wrappers]
|
@wrappers = options[:wrappers]
|
||||||
|
|
||||||
|
@ -114,7 +133,7 @@ class Gem::Installer
|
||||||
generate_bin
|
generate_bin
|
||||||
build_extensions
|
build_extensions
|
||||||
write_spec
|
write_spec
|
||||||
|
|
||||||
write_require_paths_file_if_needed
|
write_require_paths_file_if_needed
|
||||||
|
|
||||||
# HACK remove? Isn't this done in multiple places?
|
# HACK remove? Isn't this done in multiple places?
|
||||||
|
@ -190,9 +209,12 @@ class Gem::Installer
|
||||||
def generate_windows_script(bindir, filename)
|
def generate_windows_script(bindir, filename)
|
||||||
if Gem.win_platform? then
|
if Gem.win_platform? then
|
||||||
script_name = filename + ".bat"
|
script_name = filename + ".bat"
|
||||||
File.open(File.join(bindir, File.basename(script_name)), "w") do |file|
|
script_path = File.join bindir, File.basename(script_name)
|
||||||
|
File.open script_path, 'w' do |file|
|
||||||
file.puts windows_stub_script(bindir, filename)
|
file.puts windows_stub_script(bindir, filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
say script_path if Gem.configuration.really_verbose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -209,7 +231,7 @@ class Gem::Installer
|
||||||
|
|
||||||
@spec.executables.each do |filename|
|
@spec.executables.each do |filename|
|
||||||
filename.untaint
|
filename.untaint
|
||||||
bin_path = File.join @gem_dir, 'bin', filename
|
bin_path = File.expand_path File.join(@gem_dir, @spec.bindir, filename)
|
||||||
mode = File.stat(bin_path).mode | 0111
|
mode = File.stat(bin_path).mode | 0111
|
||||||
File.chmod mode, bin_path
|
File.chmod mode, bin_path
|
||||||
|
|
||||||
|
@ -229,10 +251,24 @@ class Gem::Installer
|
||||||
# http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/193379
|
# http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/193379
|
||||||
#
|
#
|
||||||
def generate_bin_script(filename, bindir)
|
def generate_bin_script(filename, bindir)
|
||||||
File.open(File.join(bindir, File.basename(filename)), "w", 0755) do |file|
|
bin_script_path = File.join bindir, formatted_program_filename(filename)
|
||||||
file.print app_script_text(filename)
|
|
||||||
end
|
exec_path = File.join @gem_dir, @spec.bindir, filename
|
||||||
generate_windows_script bindir, filename
|
|
||||||
|
# HACK some gems don't have #! in their executables, restore 2008/06
|
||||||
|
#if File.read(exec_path, 2) == '#!' then
|
||||||
|
File.open bin_script_path, 'w', 0755 do |file|
|
||||||
|
file.print app_script_text(filename)
|
||||||
|
end
|
||||||
|
|
||||||
|
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,
|
||||||
|
# :verbose => Gem.configuration.really_verbose
|
||||||
|
#end
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -247,7 +283,7 @@ class Gem::Installer
|
||||||
end
|
end
|
||||||
|
|
||||||
src = File.join @gem_dir, 'bin', filename
|
src = File.join @gem_dir, 'bin', filename
|
||||||
dst = File.join bindir, File.basename(filename)
|
dst = File.join bindir, formatted_program_filename(filename)
|
||||||
|
|
||||||
if File.exist? dst then
|
if File.exist? dst then
|
||||||
if File.symlink? dst then
|
if File.symlink? dst then
|
||||||
|
@ -258,7 +294,7 @@ class Gem::Installer
|
||||||
File.unlink dst
|
File.unlink dst
|
||||||
end
|
end
|
||||||
|
|
||||||
File.symlink src, dst
|
FileUtils.symlink src, dst, :verbose => Gem.configuration.really_verbose
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -351,6 +387,9 @@ TEXT
|
||||||
begin
|
begin
|
||||||
Dir.chdir File.join(@gem_dir, File.dirname(extension))
|
Dir.chdir File.join(@gem_dir, File.dirname(extension))
|
||||||
results = builder.build(extension, @gem_dir, dest_path, results)
|
results = builder.build(extension, @gem_dir, dest_path, results)
|
||||||
|
|
||||||
|
say results.join("\n") if Gem.configuration.really_verbose
|
||||||
|
|
||||||
rescue => ex
|
rescue => ex
|
||||||
results = results.join "\n"
|
results = results.join "\n"
|
||||||
|
|
||||||
|
@ -402,6 +441,17 @@ Results logged to #{File.join(Dir.pwd, 'gem_make.out')}
|
||||||
File.open(path, "wb") do |out|
|
File.open(path, "wb") do |out|
|
||||||
out.write file_data
|
out.write file_data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
say path if Gem.configuration.really_verbose
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Prefix and suffix the program filename the same as ruby.
|
||||||
|
def formatted_program_filename(filename)
|
||||||
|
if @format_executable then
|
||||||
|
self.class.exec_format % File.basename(filename)
|
||||||
|
else
|
||||||
|
filename
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,7 @@ module Gem::Package
|
||||||
end
|
end
|
||||||
|
|
||||||
def calculate_checksum(hdr)
|
def calculate_checksum(hdr)
|
||||||
|
#hdr.split('').map { |c| c[0] }.inject { |a, b| a + b } # HACK rubinius
|
||||||
hdr.unpack("C*").inject{|a,b| a+b}
|
hdr.unpack("C*").inject{|a,b| a+b}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,23 @@ class Gem::Platform
|
||||||
|
|
||||||
attr_accessor :version
|
attr_accessor :version
|
||||||
|
|
||||||
|
DEPRECATED_CONSTS = [
|
||||||
|
:DARWIN,
|
||||||
|
:LINUX_586,
|
||||||
|
:MSWIN32,
|
||||||
|
:PPC_DARWIN,
|
||||||
|
:WIN32,
|
||||||
|
:X86_LINUX
|
||||||
|
]
|
||||||
|
|
||||||
|
def self.const_missing(name) # TODO remove six months from 2007/12
|
||||||
|
if DEPRECATED_CONSTS.include? name then
|
||||||
|
raise NameError, "#{name} has been removed, use CURRENT instead"
|
||||||
|
else
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.local
|
def self.local
|
||||||
arch = Gem::ConfigMap[:arch]
|
arch = Gem::ConfigMap[:arch]
|
||||||
arch = "#{arch}_60" if arch =~ /mswin32$/
|
arch = "#{arch}_60" if arch =~ /mswin32$/
|
||||||
|
@ -160,33 +177,5 @@ class Gem::Platform
|
||||||
|
|
||||||
CURRENT = 'current'
|
CURRENT = 'current'
|
||||||
|
|
||||||
##
|
|
||||||
# A One Click Installer-compatible gem, built with VC6 for 32 bit Windows.
|
|
||||||
#
|
|
||||||
# CURRENT is preferred over this constant, avoid its use at all costs.
|
|
||||||
|
|
||||||
MSWIN32 = new ['x86', 'mswin32', '60']
|
|
||||||
|
|
||||||
##
|
|
||||||
# An x86 Linux-compatible gem
|
|
||||||
#
|
|
||||||
# CURRENT is preferred over this constant, avoid its use at all costs.
|
|
||||||
|
|
||||||
X86_LINUX = new ['x86', 'linux', nil]
|
|
||||||
|
|
||||||
##
|
|
||||||
# A PowerPC Darwin-compatible gem
|
|
||||||
#
|
|
||||||
# CURRENT is preferred over this constant, avoid its use at all costs.
|
|
||||||
|
|
||||||
PPC_DARWIN = new ['ppc', 'darwin', nil]
|
|
||||||
|
|
||||||
# :stopdoc:
|
|
||||||
# Here lie legacy constants. These are deprecated.
|
|
||||||
WIN32 = 'mswin32'
|
|
||||||
LINUX_586 = 'i586-linux'
|
|
||||||
DARWIN = 'powerpc-darwin'
|
|
||||||
# :startdoc:
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Gem::RemoteFetcher
|
||||||
|
|
||||||
# Cached RemoteFetcher instance.
|
# Cached RemoteFetcher instance.
|
||||||
def self.fetcher
|
def self.fetcher
|
||||||
@fetcher ||= new Gem.configuration[:http_proxy]
|
@fetcher ||= self.new Gem.configuration[:http_proxy]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Initialize a remote fetcher using the source URI and possible proxy
|
# Initialize a remote fetcher using the source URI and possible proxy
|
||||||
|
@ -45,8 +45,12 @@ class Gem::RemoteFetcher
|
||||||
end
|
end
|
||||||
rescue Timeout::Error
|
rescue Timeout::Error
|
||||||
raise FetchError, "timed out fetching #{uri}"
|
raise FetchError, "timed out fetching #{uri}"
|
||||||
rescue OpenURI::HTTPError, IOError, SocketError, SystemCallError => e
|
rescue IOError, SocketError, SystemCallError => e
|
||||||
raise FetchError, "#{e.class}: #{e} reading #{uri}"
|
raise FetchError, "#{e.class}: #{e} reading #{uri}"
|
||||||
|
rescue OpenURI::HTTPError => e
|
||||||
|
body = e.io.readlines.join "\n\t"
|
||||||
|
message = "#{e.class}: #{e} reading #{uri}\n\t#{body}"
|
||||||
|
raise FetchError, message
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the size of +uri+ in bytes.
|
# Returns the size of +uri+ in bytes.
|
||||||
|
@ -79,7 +83,7 @@ class Gem::RemoteFetcher
|
||||||
end
|
end
|
||||||
|
|
||||||
rescue SocketError, SystemCallError, Timeout::Error => e
|
rescue SocketError, SystemCallError, Timeout::Error => e
|
||||||
raise FetchError, "#{e.message} (#{e.class})"
|
raise FetchError, "#{e.message} (#{e.class})\n\tgetting size of #{uri}"
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -1,195 +0,0 @@
|
||||||
#--
|
|
||||||
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
|
||||||
# All rights reserved.
|
|
||||||
# See LICENSE.txt for permissions.
|
|
||||||
#++
|
|
||||||
|
|
||||||
require 'fileutils'
|
|
||||||
|
|
||||||
require 'rubygems'
|
|
||||||
require 'rubygems/installer'
|
|
||||||
require 'rubygems/source_info_cache'
|
|
||||||
|
|
||||||
module Gem
|
|
||||||
|
|
||||||
class RemoteInstaller
|
|
||||||
|
|
||||||
include UserInteraction
|
|
||||||
|
|
||||||
# <tt>options[:http_proxy]</tt>::
|
|
||||||
# * [String]: explicit specification of proxy; overrides any
|
|
||||||
# environment variable setting
|
|
||||||
# * nil: respect environment variables (HTTP_PROXY, HTTP_PROXY_USER, HTTP_PROXY_PASS)
|
|
||||||
# * <tt>:no_proxy</tt>: ignore environment variables and _don't_
|
|
||||||
# use a proxy
|
|
||||||
#
|
|
||||||
# * <tt>:cache_dir</tt>: override where downloaded gems are cached.
|
|
||||||
def initialize(options={})
|
|
||||||
@options = options
|
|
||||||
@source_index_hash = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
# This method will install package_name onto the local system.
|
|
||||||
#
|
|
||||||
# gem_name::
|
|
||||||
# [String] Name of the Gem to install
|
|
||||||
#
|
|
||||||
# version_requirement::
|
|
||||||
# [default = ">= 0"] Gem version requirement to install
|
|
||||||
#
|
|
||||||
# Returns::
|
|
||||||
# an array of Gem::Specification objects, one for each gem installed.
|
|
||||||
#
|
|
||||||
def install(gem_name, version_requirement = Gem::Requirement.default,
|
|
||||||
force = false, install_dir = Gem.dir)
|
|
||||||
unless version_requirement.respond_to?(:satisfied_by?)
|
|
||||||
version_requirement = Gem::Requirement.new [version_requirement]
|
|
||||||
end
|
|
||||||
installed_gems = []
|
|
||||||
begin
|
|
||||||
spec, source = find_gem_to_install(gem_name, version_requirement)
|
|
||||||
dependencies = find_dependencies_not_installed(spec.dependencies)
|
|
||||||
|
|
||||||
installed_gems << install_dependencies(dependencies, force, install_dir)
|
|
||||||
|
|
||||||
cache_dir = @options[:cache_dir] || File.join(install_dir, "cache")
|
|
||||||
destination_file = File.join(cache_dir, spec.full_name + ".gem")
|
|
||||||
|
|
||||||
download_gem(destination_file, source, spec)
|
|
||||||
|
|
||||||
installer = new_installer(destination_file)
|
|
||||||
installed_gems.unshift installer.install(force, install_dir)
|
|
||||||
rescue RemoteInstallationSkipped => e
|
|
||||||
alert_error e.message
|
|
||||||
end
|
|
||||||
installed_gems.flatten
|
|
||||||
end
|
|
||||||
|
|
||||||
# Return a hash mapping the available source names to the source
|
|
||||||
# index of that source.
|
|
||||||
def source_index_hash
|
|
||||||
return @source_index_hash if @source_index_hash
|
|
||||||
@source_index_hash = {}
|
|
||||||
Gem::SourceInfoCache.cache_data.each do |source_uri, sic_entry|
|
|
||||||
@source_index_hash[source_uri] = sic_entry.source_index
|
|
||||||
end
|
|
||||||
@source_index_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
# Finds the Gem::Specification objects and the corresponding source URI
|
|
||||||
# for gems matching +gem_name+ and +version_requirement+
|
|
||||||
def specs_n_sources_matching(gem_name, version_requirement)
|
|
||||||
specs_n_sources = []
|
|
||||||
|
|
||||||
source_index_hash.each do |source_uri, source_index|
|
|
||||||
specs = source_index.search(/^#{Regexp.escape gem_name}$/i,
|
|
||||||
version_requirement)
|
|
||||||
# TODO move to SourceIndex#search?
|
|
||||||
ruby_version = Gem::Version.new RUBY_VERSION
|
|
||||||
specs = specs.select do |spec|
|
|
||||||
spec.required_ruby_version.nil? or
|
|
||||||
spec.required_ruby_version.satisfied_by? ruby_version
|
|
||||||
end
|
|
||||||
specs.each { |spec| specs_n_sources << [spec, source_uri] }
|
|
||||||
end
|
|
||||||
|
|
||||||
if specs_n_sources.empty? then
|
|
||||||
raise GemNotFoundException, "Could not find #{gem_name} (#{version_requirement}) in any repository"
|
|
||||||
end
|
|
||||||
|
|
||||||
specs_n_sources = specs_n_sources.sort_by { |gs,| gs.version }.reverse
|
|
||||||
|
|
||||||
specs_n_sources
|
|
||||||
end
|
|
||||||
|
|
||||||
# Find a gem to be installed by interacting with the user.
|
|
||||||
def find_gem_to_install(gem_name, version_requirement)
|
|
||||||
specs_n_sources = specs_n_sources_matching gem_name, version_requirement
|
|
||||||
|
|
||||||
top_3_versions = specs_n_sources.map{|gs| gs.first.version}.uniq[0..3]
|
|
||||||
specs_n_sources.reject!{|gs| !top_3_versions.include?(gs.first.version)}
|
|
||||||
|
|
||||||
binary_gems = specs_n_sources.reject { |item|
|
|
||||||
item[0].platform.nil? || item[0].platform==Platform::RUBY
|
|
||||||
}
|
|
||||||
|
|
||||||
# only non-binary gems...return latest
|
|
||||||
return specs_n_sources.first if binary_gems.empty?
|
|
||||||
|
|
||||||
list = specs_n_sources.collect { |spec, source_uri|
|
|
||||||
"#{spec.name} #{spec.version} (#{spec.platform})"
|
|
||||||
}
|
|
||||||
|
|
||||||
list << "Skip this gem"
|
|
||||||
list << "Cancel installation"
|
|
||||||
|
|
||||||
string, index = choose_from_list(
|
|
||||||
"Select which gem to install for your platform (#{RUBY_PLATFORM})",
|
|
||||||
list)
|
|
||||||
|
|
||||||
if index.nil? or index == (list.size - 1) then
|
|
||||||
raise RemoteInstallationCancelled, "Installation of #{gem_name} cancelled."
|
|
||||||
end
|
|
||||||
|
|
||||||
if index == (list.size - 2) then
|
|
||||||
raise RemoteInstallationSkipped, "Installation of #{gem_name} skipped."
|
|
||||||
end
|
|
||||||
|
|
||||||
specs_n_sources[index]
|
|
||||||
end
|
|
||||||
|
|
||||||
def find_dependencies_not_installed(dependencies)
|
|
||||||
to_install = []
|
|
||||||
dependencies.each do |dependency|
|
|
||||||
srcindex = Gem::SourceIndex.from_installed_gems
|
|
||||||
matches = srcindex.find_name(dependency.name, dependency.requirement_list)
|
|
||||||
to_install.push dependency if matches.empty?
|
|
||||||
end
|
|
||||||
to_install
|
|
||||||
end
|
|
||||||
|
|
||||||
# Install all the given dependencies. Returns an array of
|
|
||||||
# Gem::Specification objects, one for each dependency installed.
|
|
||||||
#
|
|
||||||
# TODO: For now, we recursively install, but this is not the right
|
|
||||||
# way to do things (e.g. if a package fails to download, we
|
|
||||||
# shouldn't install anything).
|
|
||||||
def install_dependencies(dependencies, force, install_dir)
|
|
||||||
return if @options[:ignore_dependencies]
|
|
||||||
installed_gems = []
|
|
||||||
dependencies.each do |dep|
|
|
||||||
if @options[:include_dependencies] ||
|
|
||||||
ask_yes_no("Install required dependency #{dep.name}?", true)
|
|
||||||
remote_installer = RemoteInstaller.new @options
|
|
||||||
installed_gems << remote_installer.install(dep.name,
|
|
||||||
dep.version_requirements,
|
|
||||||
force, install_dir)
|
|
||||||
elsif force then
|
|
||||||
# ignore
|
|
||||||
else
|
|
||||||
raise DependencyError, "Required dependency #{dep.name} not installed"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
installed_gems
|
|
||||||
end
|
|
||||||
|
|
||||||
def download_gem(destination_file, source, spec)
|
|
||||||
return if File.exist? destination_file
|
|
||||||
uri = source + "/gems/#{spec.full_name}.gem"
|
|
||||||
response = Gem::RemoteFetcher.fetcher.fetch_path uri
|
|
||||||
write_gem_to_file response, destination_file
|
|
||||||
end
|
|
||||||
|
|
||||||
def write_gem_to_file(body, destination_file)
|
|
||||||
FileUtils.mkdir_p(File.dirname(destination_file)) unless File.exist?(destination_file)
|
|
||||||
File.open(destination_file, 'wb') do |out|
|
|
||||||
out.write(body)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def new_installer(gem)
|
|
||||||
return Installer.new(gem, @options)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
|
@ -2,5 +2,5 @@
|
||||||
# This file is auto-generated by build scripts.
|
# This file is auto-generated by build scripts.
|
||||||
# See: rake update_version
|
# See: rake update_version
|
||||||
module Gem
|
module Gem
|
||||||
RubyGemsVersion = '0.9.5'
|
RubyGemsVersion = '1.0.0'
|
||||||
end
|
end
|
||||||
|
|
|
@ -318,7 +318,7 @@ require 'rubygems/gem_openssl'
|
||||||
|
|
||||||
module Gem::Security
|
module Gem::Security
|
||||||
|
|
||||||
class Exception < Exception; end
|
class Exception < Gem::Exception; end
|
||||||
|
|
||||||
#
|
#
|
||||||
# default options for most of the methods below
|
# default options for most of the methods below
|
||||||
|
|
|
@ -368,19 +368,34 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
||||||
when '/quick/index.rz' then
|
when '/quick/index.rz' then
|
||||||
index = @source_index.map { |name,_| name }.join("\n")
|
index = @source_index.map { |name,_| name }.join("\n")
|
||||||
res.body << Zlib::Deflate.deflate(index)
|
res.body << Zlib::Deflate.deflate(index)
|
||||||
when %r|^/quick/(.*)-([0-9.]+)\.gemspec(\.marshal)?\.rz$| then
|
when %r|^/quick/(Marshal.#{Regexp.escape Gem.marshal_version}/)?(.*?)-([0-9.]+)(-.*?)?\.gemspec\.rz$| then
|
||||||
specs = @source_index.search $1, $2
|
dep = Gem::Dependency.new $2, $3
|
||||||
|
specs = @source_index.search dep
|
||||||
|
|
||||||
|
selector = [$2, $3, $4].map { |s| s.inspect }.join ' '
|
||||||
|
|
||||||
|
platform = if $4 then
|
||||||
|
Gem::Platform.new $4.sub(/^-/, '')
|
||||||
|
else
|
||||||
|
Gem::Platform::RUBY
|
||||||
|
end
|
||||||
|
|
||||||
|
specs = specs.select { |s| s.platform == platform }
|
||||||
|
|
||||||
if specs.empty? then
|
if specs.empty? then
|
||||||
res.status = 404
|
res.status = 404
|
||||||
|
res.body = "No gems found matching #{selector}"
|
||||||
elsif specs.length > 1 then
|
elsif specs.length > 1 then
|
||||||
res.status = 500
|
res.status = 500
|
||||||
elsif $3 # marshal quickindex instead of YAML
|
res.body = "Multiple gems found matching #{selector}"
|
||||||
|
elsif $1 then # marshal quickindex instead of YAML
|
||||||
res.body << Zlib::Deflate.deflate(Marshal.dump(specs.first))
|
res.body << Zlib::Deflate.deflate(Marshal.dump(specs.first))
|
||||||
else # deprecated YAML format
|
else # deprecated YAML format
|
||||||
res.body << Zlib::Deflate.deflate(specs.first.to_yaml)
|
res.body << Zlib::Deflate.deflate(specs.first.to_yaml)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
res.status = 404
|
res.status = 404
|
||||||
|
res.body = "#{req.request_uri} not found"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require 'forwardable'
|
|
||||||
|
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require 'rubygems/user_interaction'
|
require 'rubygems/user_interaction'
|
||||||
require 'rubygems/specification'
|
require 'rubygems/specification'
|
||||||
|
@ -23,7 +21,6 @@ module Gem
|
||||||
# YAMLized source index objects to load properly.
|
# YAMLized source index objects to load properly.
|
||||||
#
|
#
|
||||||
class SourceIndex
|
class SourceIndex
|
||||||
extend Forwardable
|
|
||||||
|
|
||||||
include Enumerable
|
include Enumerable
|
||||||
|
|
||||||
|
@ -186,40 +183,40 @@ module Gem
|
||||||
Gem::SHA256.new.hexdigest(@gems[gem_full_name].to_yaml).to_s
|
Gem::SHA256.new.hexdigest(@gems[gem_full_name].to_yaml).to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def_delegators :@gems, :size, :length
|
def size
|
||||||
|
@gems.size
|
||||||
|
end
|
||||||
|
alias length size
|
||||||
|
|
||||||
# Find a gem by an exact match on the short name.
|
# Find a gem by an exact match on the short name.
|
||||||
def find_name(gem_name, version_requirement = Gem::Requirement.default)
|
def find_name(gem_name, version_requirement = Gem::Requirement.default)
|
||||||
search(/^#{gem_name}$/, version_requirement)
|
search(/^#{gem_name}$/, version_requirement)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Search for a gem by short name pattern and optional version
|
# Search for a gem by Gem::Dependency +gem_pattern+. If +only_platform+
|
||||||
|
# is true, only gems matching Gem::Platform.local will be returned. An
|
||||||
|
# Array of matching Gem::Specification objects is returned.
|
||||||
#
|
#
|
||||||
# gem_name::
|
# For backwards compatibility, a String or Regexp pattern may be passed as
|
||||||
# [String] a partial for the (short) name of the gem, or
|
# +gem_pattern+, and a Gem::Requirement for +platform_only+. This
|
||||||
# [Regex] a pattern to match against the short name
|
# behavior is deprecated and will be removed.
|
||||||
# version_requirement::
|
def search(gem_pattern, platform_only = false)
|
||||||
# [String | default=Gem::Requirement.default] version to
|
|
||||||
# find
|
|
||||||
# return::
|
|
||||||
# [Array] list of Gem::Specification objects in sorted (version)
|
|
||||||
# order. Empty if not found.
|
|
||||||
#
|
|
||||||
def search(gem_pattern, platform_only_or_version_req = false)
|
|
||||||
version_requirement = nil
|
version_requirement = nil
|
||||||
only_platform = false
|
only_platform = false
|
||||||
|
|
||||||
case gem_pattern
|
case gem_pattern # TODO warn after 2008/03, remove three months after
|
||||||
when Regexp then
|
when Regexp then
|
||||||
version_requirement = platform_only_or_version_req ||
|
version_requirement = platform_only || Gem::Requirement.default
|
||||||
Gem::Requirement.default
|
|
||||||
when Gem::Dependency then
|
when Gem::Dependency then
|
||||||
only_platform = platform_only_or_version_req
|
only_platform = platform_only
|
||||||
version_requirement = gem_pattern.version_requirements
|
version_requirement = gem_pattern.version_requirements
|
||||||
gem_pattern = gem_pattern.name.empty? ? // : /^#{gem_pattern.name}$/
|
gem_pattern = if gem_pattern.name.empty? then
|
||||||
|
//
|
||||||
|
else
|
||||||
|
/^#{Regexp.escape gem_pattern.name}$/
|
||||||
|
end
|
||||||
else
|
else
|
||||||
version_requirement = platform_only_or_version_req ||
|
version_requirement = platform_only || Gem::Requirement.default
|
||||||
Gem::Requirement.default
|
|
||||||
gem_pattern = /#{gem_pattern}/i
|
gem_pattern = /#{gem_pattern}/i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -176,7 +176,7 @@ class Gem::SourceInfoCache
|
||||||
|
|
||||||
# The name of the system cache file. (class method)
|
# The name of the system cache file. (class method)
|
||||||
def self.system_cache_file
|
def self.system_cache_file
|
||||||
@system_cache_file ||= File.join(Gem.dir, "source_cache")
|
@system_cache_file ||= Gem.default_system_source_cache_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
# The name of the user cache file.
|
# The name of the user cache file.
|
||||||
|
@ -187,7 +187,7 @@ class Gem::SourceInfoCache
|
||||||
# The name of the user cache file. (class method)
|
# The name of the user cache file. (class method)
|
||||||
def self.user_cache_file
|
def self.user_cache_file
|
||||||
@user_cache_file ||=
|
@user_cache_file ||=
|
||||||
ENV['GEMCACHE'] || File.join(Gem.user_home, ".gem", "source_cache")
|
ENV['GEMCACHE'] || Gem.default_user_source_cache_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
# Write data to the proper cache.
|
# Write data to the proper cache.
|
||||||
|
@ -217,7 +217,7 @@ class Gem::SourceInfoCache
|
||||||
unless File.exist? dir then
|
unless File.exist? dir then
|
||||||
begin
|
begin
|
||||||
FileUtils.mkdir_p(dir)
|
FileUtils.mkdir_p(dir)
|
||||||
rescue RuntimeError
|
rescue RuntimeError, SystemCallError
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,17 +4,18 @@
|
||||||
# See LICENSE.txt for permissions.
|
# See LICENSE.txt for permissions.
|
||||||
#++
|
#++
|
||||||
|
|
||||||
require 'time'
|
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require 'rubygems/version'
|
require 'rubygems/version'
|
||||||
require 'rubygems/platform'
|
require 'rubygems/platform'
|
||||||
|
|
||||||
# :stopdoc:
|
# :stopdoc:
|
||||||
# Time::today has been deprecated in 0.9.5 and will be removed.
|
# Time::today has been deprecated in 0.9.5 and will be removed.
|
||||||
def Time.today
|
if RUBY_VERSION < '1.9' then
|
||||||
t = Time.now
|
def Time.today
|
||||||
t - ((t.to_i + t.gmt_offset) % 86400)
|
t = Time.now
|
||||||
end unless defined? Time.today
|
t - ((t.to_i + t.gmt_offset) % 86400)
|
||||||
|
end unless defined? Time.today
|
||||||
|
end
|
||||||
# :startdoc:
|
# :startdoc:
|
||||||
|
|
||||||
module Gem
|
module Gem
|
||||||
|
@ -239,7 +240,7 @@ module Gem
|
||||||
@specification_version,
|
@specification_version,
|
||||||
@name,
|
@name,
|
||||||
@version,
|
@version,
|
||||||
(Time === @date ? @date : Time.parse(@date.to_s)),
|
(Time === @date ? @date : (require 'time'; Time.parse(@date.to_s))),
|
||||||
@summary,
|
@summary,
|
||||||
@required_ruby_version,
|
@required_ruby_version,
|
||||||
@required_rubygems_version,
|
@required_rubygems_version,
|
||||||
|
@ -293,14 +294,9 @@ module Gem
|
||||||
spec
|
spec
|
||||||
end
|
end
|
||||||
|
|
||||||
def warn_deprecated(old, new)
|
|
||||||
# How (if at all) to implement this? We only want to warn when
|
|
||||||
# a gem is being built, I should think.
|
|
||||||
end
|
|
||||||
|
|
||||||
# REQUIRED gemspec attributes ------------------------------------
|
# REQUIRED gemspec attributes ------------------------------------
|
||||||
|
|
||||||
required_attribute :rubygems_version, RubyGemsVersion
|
required_attribute :rubygems_version, Gem::RubyGemsVersion
|
||||||
required_attribute :specification_version, CURRENT_SPECIFICATION_VERSION
|
required_attribute :specification_version, CURRENT_SPECIFICATION_VERSION
|
||||||
required_attribute :name
|
required_attribute :name
|
||||||
required_attribute :version
|
required_attribute :version
|
||||||
|
@ -349,12 +345,12 @@ module Gem
|
||||||
# DEPRECATED gemspec attributes ----------------------------------
|
# DEPRECATED gemspec attributes ----------------------------------
|
||||||
|
|
||||||
def test_suite_file
|
def test_suite_file
|
||||||
warn_deprecated(:test_suite_file, :test_files)
|
warn 'test_suite_file deprecated, use test_files'
|
||||||
test_files.first
|
test_files.first
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_suite_file=(val)
|
def test_suite_file=(val)
|
||||||
warn_deprecated(:test_suite_file, :test_files)
|
warn 'test_suite_file= deprecated, use test_files='
|
||||||
@test_files = [] unless defined? @test_files
|
@test_files = [] unless defined? @test_files
|
||||||
@test_files << val
|
@test_files << val
|
||||||
end
|
end
|
||||||
|
@ -386,6 +382,7 @@ module Gem
|
||||||
case platform
|
case platform
|
||||||
when Gem::Platform::CURRENT then
|
when Gem::Platform::CURRENT then
|
||||||
@new_platform = Gem::Platform.local
|
@new_platform = Gem::Platform.local
|
||||||
|
@original_platform = @new_platform.to_s
|
||||||
|
|
||||||
when Gem::Platform then
|
when Gem::Platform then
|
||||||
@new_platform = platform
|
@new_platform = platform
|
||||||
|
@ -393,14 +390,14 @@ module Gem
|
||||||
# legacy constants
|
# legacy constants
|
||||||
when nil, Gem::Platform::RUBY then
|
when nil, Gem::Platform::RUBY then
|
||||||
@new_platform = Gem::Platform::RUBY
|
@new_platform = Gem::Platform::RUBY
|
||||||
when Gem::Platform::WIN32 then
|
when 'mswin32' then # was Gem::Platform::WIN32
|
||||||
@new_platform = Gem::Platform::MSWIN32
|
@new_platform = Gem::Platform.new 'x86-mswin32'
|
||||||
when Gem::Platform::LINUX_586 then
|
when 'i586-linux' then # was Gem::Platform::LINUX_586
|
||||||
@new_platform = Gem::Platform::X86_LINUX
|
@new_platform = Gem::Platform.new 'x86-linux'
|
||||||
when Gem::Platform::DARWIN then
|
when 'powerpc-darwin' then # was Gem::Platform::DARWIN
|
||||||
@new_platform = Gem::Platform::PPC_DARWIN
|
@new_platform = Gem::Platform.new 'ppc-darwin'
|
||||||
else
|
else
|
||||||
@new_platform = platform
|
@new_platform = Gem::Platform.new platform
|
||||||
end
|
end
|
||||||
|
|
||||||
@platform = @new_platform.to_s
|
@platform = @new_platform.to_s
|
||||||
|
@ -422,11 +419,16 @@ module Gem
|
||||||
# way to do it.
|
# way to do it.
|
||||||
case date
|
case date
|
||||||
when String then
|
when String then
|
||||||
@date = Time.parse date
|
@date = if /\A(\d{4})-(\d{2})-(\d{2})\Z/ =~ date then
|
||||||
|
Time.local($1.to_i, $2.to_i, $3.to_i)
|
||||||
|
else
|
||||||
|
require 'time'
|
||||||
|
Time.parse date
|
||||||
|
end
|
||||||
when Time then
|
when Time then
|
||||||
@date = Time.parse date.strftime("%Y-%m-%d")
|
@date = Time.local(date.year, date.month, date.day)
|
||||||
when Date then
|
when Date then
|
||||||
@date = Time.parse date.to_s
|
@date = Time.local(date.year, date.month, date.day)
|
||||||
else
|
else
|
||||||
@date = TODAY
|
@date = TODAY
|
||||||
end
|
end
|
||||||
|
@ -751,7 +753,10 @@ module Gem
|
||||||
out.map taguri, to_yaml_style do |map|
|
out.map taguri, to_yaml_style do |map|
|
||||||
map.add 'name', @name
|
map.add 'name', @name
|
||||||
map.add 'version', @version
|
map.add 'version', @version
|
||||||
platform = if String === @original_platform then
|
platform = case @original_platform
|
||||||
|
when nil, '' then
|
||||||
|
'ruby'
|
||||||
|
when String then
|
||||||
@original_platform
|
@original_platform
|
||||||
else
|
else
|
||||||
@original_platform.to_s
|
@original_platform.to_s
|
||||||
|
@ -801,13 +806,14 @@ module Gem
|
||||||
:version,
|
:version,
|
||||||
]
|
]
|
||||||
|
|
||||||
attributes = @@attributes.sort_by { |name,| name.to_s }
|
attributes = @@attributes.sort_by { |attr_name,| attr_name.to_s }
|
||||||
|
|
||||||
attributes.each do |name, default|
|
attributes.each do |attr_name, default|
|
||||||
next if handled.include? name
|
next if handled.include? attr_name
|
||||||
current_value = self.send(name)
|
current_value = self.send(attr_name)
|
||||||
if current_value != default or self.class.required_attribute? name then
|
if current_value != default or
|
||||||
result << " s.#{name} = #{ruby_code current_value}"
|
self.class.required_attribute? attr_name then
|
||||||
|
result << " s.#{attr_name} = #{ruby_code current_value}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -832,6 +838,8 @@ module Gem
|
||||||
# Raises InvalidSpecificationException if the spec does not pass
|
# Raises InvalidSpecificationException if the spec does not pass
|
||||||
# the checks..
|
# the checks..
|
||||||
def validate
|
def validate
|
||||||
|
extend Gem::UserInteraction
|
||||||
|
|
||||||
normalize
|
normalize
|
||||||
|
|
||||||
if rubygems_version != RubyGemsVersion then
|
if rubygems_version != RubyGemsVersion then
|
||||||
|
@ -858,6 +866,31 @@ module Gem
|
||||||
"invalid platform #{platform.inspect}, see Gem::Platform"
|
"invalid platform #{platform.inspect}, see Gem::Platform"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unless Array === authors and
|
||||||
|
authors.all? { |author| String === author } then
|
||||||
|
raise Gem::InvalidSpecificationException,
|
||||||
|
'authors must be Array of Strings'
|
||||||
|
end
|
||||||
|
|
||||||
|
# Warnings
|
||||||
|
|
||||||
|
%w[author email homepage rubyforge_project summary].each do |attribute|
|
||||||
|
value = self.send attribute
|
||||||
|
alert_warning "no #{attribute} specified" if value.nil? or value.empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
alert_warning "RDoc will not be generated (has_rdoc == false)" unless
|
||||||
|
has_rdoc
|
||||||
|
|
||||||
|
alert_warning "deprecated autorequire specified" if autorequire
|
||||||
|
|
||||||
|
executables.each do |executable|
|
||||||
|
executable_path = File.join bindir, executable
|
||||||
|
shebang = File.read(executable_path, 2) == '#!'
|
||||||
|
|
||||||
|
alert_warning "#{executable_path} is missing #! line" unless shebang
|
||||||
|
end
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ class Gem::Uninstaller
|
||||||
cache_dir = File.join spec.installation_path, 'cache'
|
cache_dir = File.join spec.installation_path, 'cache'
|
||||||
gem = File.join cache_dir, "#{spec.full_name}.gem"
|
gem = File.join cache_dir, "#{spec.full_name}.gem"
|
||||||
|
|
||||||
unless File.exist? gemspec then
|
unless File.exist? gem then
|
||||||
gem = File.join cache_dir, "#{original_platform_name}.gem"
|
gem = File.join cache_dir, "#{original_platform_name}.gem"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -157,8 +157,9 @@ module Gem
|
||||||
# XXX: why do we need this gem_spec when we've already got 'spec'?
|
# XXX: why do we need this gem_spec when we've already got 'spec'?
|
||||||
test_files = gem_spec.test_files
|
test_files = gem_spec.test_files
|
||||||
if test_files.empty?
|
if test_files.empty?
|
||||||
say "There are no unit tests to run for #{gem_spec.name}-#{gem_spec.version}"
|
say "There are no unit tests to run for #{gem_spec.full_name}"
|
||||||
return
|
require 'test/unit/ui/console/testrunner'
|
||||||
|
return Test::Unit::TestResult.new
|
||||||
end
|
end
|
||||||
gem gem_spec.name, "= #{gem_spec.version.version}"
|
gem gem_spec.name, "= #{gem_spec.version.version}"
|
||||||
test_files.each do |f| require f end
|
test_files.each do |f| require f end
|
||||||
|
|
|
@ -75,7 +75,7 @@ class Gem::Version
|
||||||
|
|
||||||
# Strip ignored trailing zeros.
|
# Strip ignored trailing zeros.
|
||||||
def normalize
|
def normalize
|
||||||
@ints = @version.to_s.scan(/\d+/).map { |s| s.to_i }
|
@ints = build_array_from_version_string
|
||||||
|
|
||||||
return if @ints.length == 1
|
return if @ints.length == 1
|
||||||
|
|
||||||
|
@ -127,19 +127,26 @@ class Gem::Version
|
||||||
@ints <=> other.ints
|
@ints <=> other.ints
|
||||||
end
|
end
|
||||||
|
|
||||||
def hash
|
alias eql? == # :nodoc:
|
||||||
|
|
||||||
|
def hash # :nodoc:
|
||||||
to_ints.inject { |hash_code, n| hash_code + n }
|
to_ints.inject { |hash_code, n| hash_code + n }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return a new version object where the next to the last revision
|
# Return a new version object where the next to the last revision
|
||||||
# number is one greater. (e.g. 5.3.1 => 5.4)
|
# number is one greater. (e.g. 5.3.1 => 5.4)
|
||||||
def bump
|
def bump
|
||||||
ints = @ints.dup
|
ints = build_array_from_version_string
|
||||||
ints.pop if ints.size > 1
|
ints.pop if ints.size > 1
|
||||||
ints[-1] += 1
|
ints[-1] += 1
|
||||||
self.class.new(ints.join("."))
|
self.class.new(ints.join("."))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def build_array_from_version_string
|
||||||
|
@version.to_s.scan(/\d+/).map { |s| s.to_i }
|
||||||
|
end
|
||||||
|
private :build_array_from_version_string
|
||||||
|
|
||||||
#:stopdoc:
|
#:stopdoc:
|
||||||
|
|
||||||
require 'rubygems/requirement'
|
require 'rubygems/requirement'
|
||||||
|
|
|
@ -89,6 +89,9 @@ class RubyGemTestCase < Test::Unit::TestCase
|
||||||
@gem_repo = "http://gems.example.com"
|
@gem_repo = "http://gems.example.com"
|
||||||
Gem.sources.replace [@gem_repo]
|
Gem.sources.replace [@gem_repo]
|
||||||
|
|
||||||
|
@orig_BASERUBY = Gem::ConfigMap[:BASERUBY]
|
||||||
|
Gem::ConfigMap[:BASERUBY] = Gem::ConfigMap[:RUBY_INSTALL_NAME]
|
||||||
|
|
||||||
@orig_arch = Gem::ConfigMap[:arch]
|
@orig_arch = Gem::ConfigMap[:arch]
|
||||||
|
|
||||||
if win_platform?
|
if win_platform?
|
||||||
|
@ -101,6 +104,7 @@ class RubyGemTestCase < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
|
Gem::ConfigMap[:BASERUBY] = @orig_BASERUBY
|
||||||
Gem::ConfigMap[:arch] = @orig_arch
|
Gem::ConfigMap[:arch] = @orig_arch
|
||||||
|
|
||||||
if defined? Gem::RemoteFetcher then
|
if defined? Gem::RemoteFetcher then
|
||||||
|
@ -153,7 +157,7 @@ class RubyGemTestCase < Test::Unit::TestCase
|
||||||
path
|
path
|
||||||
end
|
end
|
||||||
|
|
||||||
def quick_gem(gemname, version='0.0.2')
|
def quick_gem(gemname, version='2')
|
||||||
require 'rubygems/specification'
|
require 'rubygems/specification'
|
||||||
|
|
||||||
spec = Gem::Specification.new do |s|
|
spec = Gem::Specification.new do |s|
|
||||||
|
@ -166,6 +170,7 @@ class RubyGemTestCase < Test::Unit::TestCase
|
||||||
s.has_rdoc = true
|
s.has_rdoc = true
|
||||||
s.summary = "this is a summary"
|
s.summary = "this is a summary"
|
||||||
s.description = "This is a test description"
|
s.description = "This is a test description"
|
||||||
|
|
||||||
yield(s) if block_given?
|
yield(s) if block_given?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -205,9 +210,9 @@ class RubyGemTestCase < Test::Unit::TestCase
|
||||||
s.require_paths = %w[lib]
|
s.require_paths = %w[lib]
|
||||||
end
|
end
|
||||||
|
|
||||||
@a0_0_1 = quick_gem('a', '0.0.1', &spec)
|
@a1 = quick_gem('a', '1', &spec)
|
||||||
@a0_0_2 = quick_gem('a', '0.0.2', &spec)
|
@a2 = quick_gem('a', '2', &spec)
|
||||||
@b0_0_2 = quick_gem('b', '0.0.2', &spec)
|
@b2 = quick_gem('b', '2', &spec)
|
||||||
@c1_2 = quick_gem('c', '1.2', &spec)
|
@c1_2 = quick_gem('c', '1.2', &spec)
|
||||||
@pl1 = quick_gem 'pl', '1' do |s| # l for legacy
|
@pl1 = quick_gem 'pl', '1' do |s| # l for legacy
|
||||||
s.files = %w[lib/code.rb]
|
s.files = %w[lib/code.rb]
|
||||||
|
@ -216,13 +221,13 @@ class RubyGemTestCase < Test::Unit::TestCase
|
||||||
s.instance_variable_set :@original_platform, 'i386-linux'
|
s.instance_variable_set :@original_platform, 'i386-linux'
|
||||||
end
|
end
|
||||||
|
|
||||||
write_file File.join(*%W[gems #{@a0_0_1.original_name} lib code.rb]) do end
|
write_file File.join(*%W[gems #{@a1.original_name} lib code.rb]) do end
|
||||||
write_file File.join(*%W[gems #{@a0_0_2.original_name} lib code.rb]) do end
|
write_file File.join(*%W[gems #{@a2.original_name} lib code.rb]) do end
|
||||||
write_file File.join(*%W[gems #{@b0_0_2.original_name} lib code.rb]) do end
|
write_file File.join(*%W[gems #{@b2.original_name} lib code.rb]) do end
|
||||||
write_file File.join(*%W[gems #{@c1_2.original_name} lib code.rb]) do end
|
write_file File.join(*%W[gems #{@c1_2.original_name} lib code.rb]) do end
|
||||||
write_file File.join(*%W[gems #{@pl1.original_name} lib code.rb]) do end
|
write_file File.join(*%W[gems #{@pl1.original_name} lib code.rb]) do end
|
||||||
|
|
||||||
[@a0_0_1, @a0_0_2, @b0_0_2, @c1_2, @pl1].each { |spec| util_build_gem spec }
|
[@a1, @a2, @b2, @c1_2, @pl1].each { |spec| util_build_gem spec }
|
||||||
|
|
||||||
FileUtils.rm_r File.join(@gemhome, 'gems', @pl1.original_name)
|
FileUtils.rm_r File.join(@gemhome, 'gems', @pl1.original_name)
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ require 'test/unit'
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require 'rubygems/gem_openssl'
|
require 'rubygems/gem_openssl'
|
||||||
|
require 'rubygems/installer'
|
||||||
require 'pathname'
|
require 'pathname'
|
||||||
|
|
||||||
class TestGem < RubyGemTestCase
|
class TestGem < RubyGemTestCase
|
||||||
|
@ -17,9 +18,9 @@ class TestGem < RubyGemTestCase
|
||||||
util_make_gems
|
util_make_gems
|
||||||
|
|
||||||
expected = [
|
expected = [
|
||||||
File.join(@gemhome, *%W[gems #{@a0_0_1.full_name} lib]),
|
File.join(@gemhome, *%W[gems #{@a1.full_name} lib]),
|
||||||
File.join(@gemhome, *%W[gems #{@a0_0_2.full_name} lib]),
|
File.join(@gemhome, *%W[gems #{@a2.full_name} lib]),
|
||||||
File.join(@gemhome, *%W[gems #{@b0_0_2.full_name} lib]),
|
File.join(@gemhome, *%W[gems #{@b2.full_name} lib]),
|
||||||
File.join(@gemhome, *%W[gems #{@c1_2.full_name} lib]),
|
File.join(@gemhome, *%W[gems #{@c1_2.full_name} lib]),
|
||||||
File.join(@gemhome, *%W[gems #{@pl1.full_name} lib]),
|
File.join(@gemhome, *%W[gems #{@pl1.full_name} lib]),
|
||||||
]
|
]
|
||||||
|
@ -89,6 +90,42 @@ class TestGem < RubyGemTestCase
|
||||||
assert_match @default_dir_re, Gem.default_dir
|
assert_match @default_dir_re, Gem.default_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_self_default_exec_format
|
||||||
|
orig_BASERUBY = Gem::ConfigMap[:BASERUBY]
|
||||||
|
orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:RUBY_INSTALL_NAME]
|
||||||
|
Gem::ConfigMap[:BASERUBY] = 'ruby'
|
||||||
|
Gem::ConfigMap[:RUBY_INSTALL_NAME] = 'ruby'
|
||||||
|
|
||||||
|
assert_equal '%s', Gem.default_exec_format
|
||||||
|
ensure
|
||||||
|
Gem::ConfigMap[:BASERUBY] = orig_BASERUBY
|
||||||
|
Gem::ConfigMap[:RUBY_INSTALL_NAME] = orig_RUBY_INSTALL_NAME
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_self_default_exec_format_18
|
||||||
|
orig_BASERUBY = Gem::ConfigMap[:BASERUBY]
|
||||||
|
orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:RUBY_INSTALL_NAME]
|
||||||
|
Gem::ConfigMap[:BASERUBY] = 'ruby'
|
||||||
|
Gem::ConfigMap[:RUBY_INSTALL_NAME] = 'ruby18'
|
||||||
|
|
||||||
|
assert_equal '%s18', Gem.default_exec_format
|
||||||
|
ensure
|
||||||
|
Gem::ConfigMap[:BASERUBY] = orig_BASERUBY
|
||||||
|
Gem::ConfigMap[:RUBY_INSTALL_NAME] = orig_RUBY_INSTALL_NAME
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_self_default_exec_format_jruby
|
||||||
|
orig_BASERUBY = Gem::ConfigMap[:BASERUBY]
|
||||||
|
orig_RUBY_INSTALL_NAME = Gem::ConfigMap[:RUBY_INSTALL_NAME]
|
||||||
|
Gem::ConfigMap[:BASERUBY] = 'ruby'
|
||||||
|
Gem::ConfigMap[:RUBY_INSTALL_NAME] = 'jruby'
|
||||||
|
|
||||||
|
assert_equal 'j%s', Gem.default_exec_format
|
||||||
|
ensure
|
||||||
|
Gem::ConfigMap[:BASERUBY] = orig_BASERUBY
|
||||||
|
Gem::ConfigMap[:RUBY_INSTALL_NAME] = orig_RUBY_INSTALL_NAME
|
||||||
|
end
|
||||||
|
|
||||||
def test_self_default_sources
|
def test_self_default_sources
|
||||||
assert_equal %w[http://gems.rubyforge.org], Gem.default_sources
|
assert_equal %w[http://gems.rubyforge.org], Gem.default_sources
|
||||||
end
|
end
|
||||||
|
@ -174,8 +211,8 @@ class TestGem < RubyGemTestCase
|
||||||
util_make_gems
|
util_make_gems
|
||||||
|
|
||||||
expected = [
|
expected = [
|
||||||
File.join(@gemhome, *%W[gems #{@a0_0_2.full_name} lib]),
|
File.join(@gemhome, *%W[gems #{@a2.full_name} lib]),
|
||||||
File.join(@gemhome, *%W[gems #{@b0_0_2.full_name} lib]),
|
File.join(@gemhome, *%W[gems #{@b2.full_name} lib]),
|
||||||
File.join(@gemhome, *%W[gems #{@c1_2.full_name} lib]),
|
File.join(@gemhome, *%W[gems #{@c1_2.full_name} lib]),
|
||||||
File.join(@gemhome, *%W[gems #{@pl1.full_name} lib]),
|
File.join(@gemhome, *%W[gems #{@pl1.full_name} lib]),
|
||||||
]
|
]
|
||||||
|
@ -251,10 +288,10 @@ class TestGem < RubyGemTestCase
|
||||||
|
|
||||||
assert_equal File.join(@tempdir, *%w[gemhome gems c-1.2 lib code.rb]),
|
assert_equal File.join(@tempdir, *%w[gemhome gems c-1.2 lib code.rb]),
|
||||||
Gem.required_location("c", "code.rb")
|
Gem.required_location("c", "code.rb")
|
||||||
assert_equal File.join(@tempdir, *%w[gemhome gems a-0.0.1 lib code.rb]),
|
assert_equal File.join(@tempdir, *%w[gemhome gems a-1 lib code.rb]),
|
||||||
Gem.required_location("a", "code.rb", "<0.0.2")
|
Gem.required_location("a", "code.rb", "< 2")
|
||||||
assert_equal File.join(@tempdir, *%w[gemhome gems a-0.0.2 lib code.rb]),
|
assert_equal File.join(@tempdir, *%w[gemhome gems a-2 lib code.rb]),
|
||||||
Gem.required_location("a", "code.rb", "=0.0.2")
|
Gem.required_location("a", "code.rb", "= 2")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_searcher
|
def test_self_searcher
|
||||||
|
@ -298,73 +335,6 @@ class TestGem < RubyGemTestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_require_gem_autorequire
|
|
||||||
name = "AutorequireArray"
|
|
||||||
files = %w(a.rb b.rb)
|
|
||||||
gem = quick_gem(name) do |s|
|
|
||||||
s.files = files.map { |f| File.join("lib", f) }
|
|
||||||
s.autorequire = files
|
|
||||||
end
|
|
||||||
|
|
||||||
fullname = gem.full_name
|
|
||||||
|
|
||||||
write_file "gems/#{fullname}/lib/a.rb" do |io|
|
|
||||||
io.puts "$LOADED_A = true"
|
|
||||||
end
|
|
||||||
|
|
||||||
write_file "gems/#{fullname}/lib/b.rb" do |io|
|
|
||||||
io.puts "$LOADED_B = true"
|
|
||||||
end
|
|
||||||
|
|
||||||
Gem.source_index = nil
|
|
||||||
|
|
||||||
old_loaded = $".dup
|
|
||||||
old_verbose = $VERBOSE
|
|
||||||
$VERBOSE = nil
|
|
||||||
require_gem name
|
|
||||||
$VERBOSE = old_verbose
|
|
||||||
new_loaded = $".dup
|
|
||||||
|
|
||||||
if RUBY_VERSION > "1.9" then
|
|
||||||
files = files.map do |file|
|
|
||||||
File.join @gemhome, 'gems', gem.full_name, 'lib', file
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
assert_equal files, (new_loaded - old_loaded)
|
|
||||||
assert defined?($LOADED_A)
|
|
||||||
assert defined?($LOADED_B)
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_require_gem_autorequire_string
|
|
||||||
name = "AutorequireString"
|
|
||||||
file = "c.rb"
|
|
||||||
gem = quick_gem(name) do |s|
|
|
||||||
s.files = File.join("lib", file)
|
|
||||||
s.autorequire = file
|
|
||||||
end
|
|
||||||
|
|
||||||
fullname = gem.full_name
|
|
||||||
|
|
||||||
write_file("gems/#{fullname}/lib/c.rb") do |io|
|
|
||||||
io.puts "$LOADED_C = true"
|
|
||||||
end
|
|
||||||
|
|
||||||
old_loaded = $".dup
|
|
||||||
old_verbose = $VERBOSE
|
|
||||||
$VERBOSE = nil
|
|
||||||
require_gem name
|
|
||||||
$VERBOSE = old_verbose
|
|
||||||
new_loaded = $".dup
|
|
||||||
|
|
||||||
if RUBY_VERSION > "1.9" then
|
|
||||||
file = File.join @gemhome, 'gems', gem.full_name, 'lib', file
|
|
||||||
end
|
|
||||||
|
|
||||||
assert_equal(Array(file), (new_loaded - old_loaded))
|
|
||||||
assert(defined? $LOADED_C)
|
|
||||||
end
|
|
||||||
|
|
||||||
def util_ensure_gem_dirs
|
def util_ensure_gem_dirs
|
||||||
Gem.ensure_gem_subdirectories @gemhome
|
Gem.ensure_gem_subdirectories @gemhome
|
||||||
@additional.each do |dir|
|
@additional.each do |dir|
|
||||||
|
|
|
@ -8,31 +8,31 @@ class TestGemCommandsBuildCommand < RubyGemTestCase
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
|
|
||||||
|
@gem = quick_gem 'some_gem' do |s|
|
||||||
|
s.rubyforge_project = 'example'
|
||||||
|
end
|
||||||
|
|
||||||
@cmd = Gem::Commands::BuildCommand.new
|
@cmd = Gem::Commands::BuildCommand.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute
|
def test_execute
|
||||||
gem = quick_gem 'some_gem'
|
gemspec_file = File.join(@tempdir, "#{@gem.full_name}.gemspec")
|
||||||
|
|
||||||
gemspec_file = File.join(@tempdir, "#{gem.full_name}.gemspec")
|
|
||||||
|
|
||||||
File.open gemspec_file, 'w' do |gs|
|
File.open gemspec_file, 'w' do |gs|
|
||||||
gs.write gem.to_ruby
|
gs.write @gem.to_ruby
|
||||||
end
|
end
|
||||||
|
|
||||||
util_test_build_gem gem, gemspec_file
|
util_test_build_gem @gem, gemspec_file
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_yaml
|
def test_execute_yaml
|
||||||
gem = quick_gem 'some_gem'
|
gemspec_file = File.join(@tempdir, "#{@gem.full_name}.gemspec")
|
||||||
|
|
||||||
gemspec_file = File.join(@tempdir, "#{gem.full_name}.gemspec")
|
|
||||||
|
|
||||||
File.open gemspec_file, 'w' do |gs|
|
File.open gemspec_file, 'w' do |gs|
|
||||||
gs.write gem.to_yaml
|
gs.write @gem.to_yaml
|
||||||
end
|
end
|
||||||
|
|
||||||
util_test_build_gem gem, gemspec_file
|
util_test_build_gem @gem, gemspec_file
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_bad_gem
|
def test_execute_bad_gem
|
||||||
|
@ -57,8 +57,8 @@ class TestGemCommandsBuildCommand < RubyGemTestCase
|
||||||
output = @ui.output.split "\n"
|
output = @ui.output.split "\n"
|
||||||
assert_equal " Successfully built RubyGem", output.shift
|
assert_equal " Successfully built RubyGem", output.shift
|
||||||
assert_equal " Name: some_gem", output.shift
|
assert_equal " Name: some_gem", output.shift
|
||||||
assert_equal " Version: 0.0.2", output.shift
|
assert_equal " Version: 2", output.shift
|
||||||
assert_equal " File: some_gem-0.0.2.gem", output.shift
|
assert_equal " File: some_gem-2.gem", output.shift
|
||||||
assert_equal [], output
|
assert_equal [], output
|
||||||
assert_equal '', @ui.error
|
assert_equal '', @ui.error
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ class TestGemCommandsDependencyCommand < RubyGemTestCase
|
||||||
|
|
||||||
def test_execute
|
def test_execute
|
||||||
quick_gem 'foo' do |gem|
|
quick_gem 'foo' do |gem|
|
||||||
gem.add_dependency 'bar', '> 1.0.0'
|
gem.add_dependency 'bar', '> 1'
|
||||||
end
|
end
|
||||||
|
|
||||||
@cmd.options[:args] = %w[foo]
|
@cmd.options[:args] = %w[foo]
|
||||||
|
@ -22,7 +22,7 @@ class TestGemCommandsDependencyCommand < RubyGemTestCase
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal "Gem foo-0.0.2\n bar (> 1.0.0)\n\n", @ui.output
|
assert_equal "Gem foo-2\n bar (> 1)\n\n", @ui.output
|
||||||
assert_equal '', @ui.error
|
assert_equal '', @ui.error
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class TestGemCommandsDependencyCommand < RubyGemTestCase
|
||||||
|
|
||||||
def test_execute_pipe_format
|
def test_execute_pipe_format
|
||||||
quick_gem 'foo' do |gem|
|
quick_gem 'foo' do |gem|
|
||||||
gem.add_dependency 'bar', '> 1.0.0'
|
gem.add_dependency 'bar', '> 1'
|
||||||
end
|
end
|
||||||
|
|
||||||
@cmd.options[:args] = %w[foo]
|
@cmd.options[:args] = %w[foo]
|
||||||
|
@ -51,13 +51,13 @@ class TestGemCommandsDependencyCommand < RubyGemTestCase
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal "bar --version '> 1.0.0'\n", @ui.output
|
assert_equal "bar --version '> 1'\n", @ui.output
|
||||||
assert_equal '', @ui.error
|
assert_equal '', @ui.error
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_reverse
|
def test_execute_reverse
|
||||||
quick_gem 'foo' do |gem|
|
quick_gem 'foo' do |gem|
|
||||||
gem.add_dependency 'bar', '> 1.0.0'
|
gem.add_dependency 'bar', '> 1'
|
||||||
end
|
end
|
||||||
|
|
||||||
quick_gem 'baz' do |gem|
|
quick_gem 'baz' do |gem|
|
||||||
|
@ -72,10 +72,10 @@ class TestGemCommandsDependencyCommand < RubyGemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
expected = <<-EOF
|
expected = <<-EOF
|
||||||
Gem foo-0.0.2
|
Gem foo-2
|
||||||
bar (> 1.0.0)
|
bar (> 1)
|
||||||
Used by
|
Used by
|
||||||
baz-0.0.2 (foo (>= 0))
|
baz-2 (foo (>= 0))
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ Gem foo-0.0.2
|
||||||
|
|
||||||
def test_execute_remote
|
def test_execute_remote
|
||||||
foo = quick_gem 'foo' do |gem|
|
foo = quick_gem 'foo' do |gem|
|
||||||
gem.add_dependency 'bar', '> 1.0.0'
|
gem.add_dependency 'bar', '> 1'
|
||||||
end
|
end
|
||||||
|
|
||||||
util_setup_source_info_cache foo
|
util_setup_source_info_cache foo
|
||||||
|
@ -100,7 +100,7 @@ Gem foo-0.0.2
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal "Gem foo-0.0.2\n bar (> 1.0.0)\n\n", @ui.output
|
assert_equal "Gem foo-2\n bar (> 1)\n\n", @ui.output
|
||||||
assert_equal '', @ui.error
|
assert_equal '', @ui.error
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,12 @@ class TestGemCommandsMirrorCommand < RubyGemTestCase
|
||||||
|
|
||||||
File.open File.join(Gem.user_home, '.gemmirrorrc'), 'w' do |fp|
|
File.open File.join(Gem.user_home, '.gemmirrorrc'), 'w' do |fp|
|
||||||
fp.puts "---"
|
fp.puts "---"
|
||||||
fp.puts "- from: file://#{@tempdir}"
|
# tempdir could be a drive+path (under windows)
|
||||||
|
if @tempdir.match(/[a-z]:/i)
|
||||||
|
fp.puts "- from: file:///#{@tempdir}"
|
||||||
|
else
|
||||||
|
fp.puts "- from: file://#{@tempdir}"
|
||||||
|
end
|
||||||
fp.puts " to: #{mirror}"
|
fp.puts " to: #{mirror}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -42,9 +47,9 @@ class TestGemCommandsMirrorCommand < RubyGemTestCase
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
|
||||||
assert File.exist?(File.join(mirror, 'gems', "#{@a0_0_1.full_name}.gem"))
|
assert File.exist?(File.join(mirror, 'gems', "#{@a1.full_name}.gem"))
|
||||||
assert File.exist?(File.join(mirror, 'gems', "#{@a0_0_2.full_name}.gem"))
|
assert File.exist?(File.join(mirror, 'gems', "#{@a2.full_name}.gem"))
|
||||||
assert File.exist?(File.join(mirror, 'gems', "#{@b0_0_2.full_name}.gem"))
|
assert File.exist?(File.join(mirror, 'gems', "#{@b2.full_name}.gem"))
|
||||||
assert File.exist?(File.join(mirror, 'gems', "#{@c1_2.full_name}.gem"))
|
assert File.exist?(File.join(mirror, 'gems', "#{@c1_2.full_name}.gem"))
|
||||||
assert File.exist?(File.join(mirror, "Marshal.#{@marshal_version}"))
|
assert File.exist?(File.join(mirror, "Marshal.#{@marshal_version}"))
|
||||||
ensure
|
ensure
|
||||||
|
|
|
@ -10,13 +10,17 @@ class TestGemCommandsQueryCommand < RubyGemTestCase
|
||||||
@foo_gem = quick_gem 'foo' do |spec|
|
@foo_gem = quick_gem 'foo' do |spec|
|
||||||
spec.summary = 'This is a lot of text. ' * 5
|
spec.summary = 'This is a lot of text. ' * 5
|
||||||
end
|
end
|
||||||
|
@foo_gem_p = quick_gem 'foo' do |spec|
|
||||||
|
spec.summary = 'This is a lot of text. ' * 5
|
||||||
|
spec.platform = Gem::Platform::CURRENT
|
||||||
|
end
|
||||||
@bar_gem = quick_gem 'bar'
|
@bar_gem = quick_gem 'bar'
|
||||||
|
|
||||||
@cmd = Gem::Commands::QueryCommand.new
|
@cmd = Gem::Commands::QueryCommand.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute
|
def test_execute
|
||||||
util_setup_source_info_cache @foo_gem
|
util_setup_source_info_cache @foo_gem, @foo_gem_p
|
||||||
|
|
||||||
@cmd.handle_options %w[-r]
|
@cmd.handle_options %w[-r]
|
||||||
|
|
||||||
|
@ -28,7 +32,7 @@ class TestGemCommandsQueryCommand < RubyGemTestCase
|
||||||
|
|
||||||
*** REMOTE GEMS ***
|
*** REMOTE GEMS ***
|
||||||
|
|
||||||
foo (0.0.2)
|
foo (2)
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
assert_equal expected, @ui.output
|
assert_equal expected, @ui.output
|
||||||
|
@ -48,7 +52,7 @@ foo (0.0.2)
|
||||||
|
|
||||||
*** REMOTE GEMS ***
|
*** REMOTE GEMS ***
|
||||||
|
|
||||||
foo (0.0.2)
|
foo (2)
|
||||||
This is a lot of text. This is a lot of text. This is a lot of
|
This is a lot of text. This is a lot of text. This is a lot of
|
||||||
text. This is a lot of text. This is a lot of text.
|
text. This is a lot of text. This is a lot of text.
|
||||||
EOF
|
EOF
|
||||||
|
|
27
test/rubygems/test_gem_commands_server_command.rb
Normal file
27
test/rubygems/test_gem_commands_server_command.rb
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
require 'test/unit'
|
||||||
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
|
require 'rubygems/commands/server_command'
|
||||||
|
|
||||||
|
class TestGemCommandsServerCommand < RubyGemTestCase
|
||||||
|
|
||||||
|
def setup
|
||||||
|
super
|
||||||
|
|
||||||
|
@cmd = Gem::Commands::ServerCommand.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_handle_options
|
||||||
|
@cmd.send :handle_options, %w[-p 8808 --no-daemon]
|
||||||
|
|
||||||
|
assert_equal false, @cmd.options[:daemon]
|
||||||
|
assert_equal @gemhome, @cmd.options[:gemdir]
|
||||||
|
assert_equal 8808, @cmd.options[:port]
|
||||||
|
|
||||||
|
@cmd.send :handle_options, %w[-p 9999 -d /nonexistent --daemon]
|
||||||
|
|
||||||
|
assert_equal true, @cmd.options[:daemon]
|
||||||
|
assert_equal '/nonexistent', @cmd.options[:gemdir]
|
||||||
|
assert_equal 9999, @cmd.options[:port]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -7,7 +7,9 @@ class TestGemCommandsUnpackCommand < RubyGemTestCase
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
|
|
||||||
@cmd = Gem::Commands::UnpackCommand.new
|
Dir.chdir @tempdir do
|
||||||
|
@cmd = Gem::Commands::UnpackCommand.new
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute
|
def test_execute
|
||||||
|
@ -15,13 +17,29 @@ class TestGemCommandsUnpackCommand < RubyGemTestCase
|
||||||
|
|
||||||
@cmd.options[:args] = %w[a]
|
@cmd.options[:args] = %w[a]
|
||||||
|
|
||||||
|
use_ui @ui do
|
||||||
|
Dir.chdir @tempdir do
|
||||||
|
@cmd.execute
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
assert File.exist?(File.join(@tempdir, 'a-2'))
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_execute_with_target_option
|
||||||
|
util_make_gems
|
||||||
|
|
||||||
|
target = 'with_target'
|
||||||
|
@cmd.options[:args] = %w[a]
|
||||||
|
@cmd.options[:target] = target
|
||||||
|
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
Dir.chdir @tempdir do
|
Dir.chdir @tempdir do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
assert File.exist?(File.join(@tempdir, 'a-0.0.2'))
|
assert File.exist?(File.join(@tempdir, target, 'a-2'))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_execute_exact_match
|
def test_execute_exact_match
|
||||||
|
|
|
@ -22,7 +22,7 @@ class TestGemFormat < RubyGemTestCase
|
||||||
|
|
||||||
gems = Dir[File.join(@gemhome, 'cache', '*.gem')]
|
gems = Dir[File.join(@gemhome, 'cache', '*.gem')]
|
||||||
|
|
||||||
names = [@a0_0_1, @a0_0_2, @b0_0_2, @c1_2, @pl1].map do |spec|
|
names = [@a1, @a2, @b2, @c1_2, @pl1].map do |spec|
|
||||||
spec.original_name
|
spec.original_name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -53,16 +53,16 @@ class TestGemIndexer < RubyGemTestCase
|
||||||
assert_indexed quickdir, "index"
|
assert_indexed quickdir, "index"
|
||||||
assert_indexed quickdir, "index.rz"
|
assert_indexed quickdir, "index.rz"
|
||||||
|
|
||||||
assert_indexed quickdir, "#{@a0_0_1.full_name}.gemspec.rz"
|
assert_indexed quickdir, "#{@a1.full_name}.gemspec.rz"
|
||||||
assert_indexed quickdir, "#{@a0_0_2.full_name}.gemspec.rz"
|
assert_indexed quickdir, "#{@a2.full_name}.gemspec.rz"
|
||||||
assert_indexed quickdir, "#{@b0_0_2.full_name}.gemspec.rz"
|
assert_indexed quickdir, "#{@b2.full_name}.gemspec.rz"
|
||||||
assert_indexed quickdir, "#{@c1_2.full_name}.gemspec.rz"
|
assert_indexed quickdir, "#{@c1_2.full_name}.gemspec.rz"
|
||||||
|
|
||||||
assert_indexed quickdir, "#{@pl1.original_name}.gemspec.rz"
|
assert_indexed quickdir, "#{@pl1.original_name}.gemspec.rz"
|
||||||
deny_indexed quickdir, "#{@pl1.full_name}.gemspec.rz"
|
deny_indexed quickdir, "#{@pl1.full_name}.gemspec.rz"
|
||||||
|
|
||||||
assert_indexed marshal_quickdir, "#{@a0_0_1.full_name}.gemspec.rz"
|
assert_indexed marshal_quickdir, "#{@a1.full_name}.gemspec.rz"
|
||||||
assert_indexed marshal_quickdir, "#{@a0_0_2.full_name}.gemspec.rz"
|
assert_indexed marshal_quickdir, "#{@a2.full_name}.gemspec.rz"
|
||||||
|
|
||||||
deny_indexed quickdir, "#{@c1_2.full_name}.gemspec"
|
deny_indexed quickdir, "#{@c1_2.full_name}.gemspec"
|
||||||
deny_indexed marshal_quickdir, "#{@c1_2.full_name}.gemspec"
|
deny_indexed marshal_quickdir, "#{@c1_2.full_name}.gemspec"
|
||||||
|
|
|
@ -16,7 +16,7 @@ class TestGemInstallUpdateOptions < RubyGemTestCase
|
||||||
@cmd.add_install_update_options
|
@cmd.add_install_update_options
|
||||||
|
|
||||||
args = %w[-i /install_to --rdoc --ri -E -f -t -w -P HighSecurity
|
args = %w[-i /install_to --rdoc --ri -E -f -t -w -P HighSecurity
|
||||||
--ignore-dependencies --include-dependencies]
|
--ignore-dependencies --format-exec --include-dependencies]
|
||||||
|
|
||||||
assert @cmd.handles?(args)
|
assert @cmd.handles?(args)
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,11 +9,13 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
||||||
require 'rubygems/installer'
|
require 'rubygems/installer'
|
||||||
|
|
||||||
class Gem::Installer
|
class Gem::Installer
|
||||||
|
attr_accessor :gem_dir
|
||||||
|
|
||||||
attr_writer :format
|
attr_writer :format
|
||||||
attr_writer :gem_dir
|
|
||||||
attr_writer :gem_home
|
attr_writer :gem_home
|
||||||
attr_writer :env_shebang
|
attr_writer :env_shebang
|
||||||
attr_writer :ignore_dependencies
|
attr_writer :ignore_dependencies
|
||||||
|
attr_writer :format_executable
|
||||||
attr_writer :security_policy
|
attr_writer :security_policy
|
||||||
attr_writer :spec
|
attr_writer :spec
|
||||||
attr_writer :wrappers
|
attr_writer :wrappers
|
||||||
|
@ -37,11 +39,11 @@ class TestGemInstaller < RubyGemTestCase
|
||||||
@installer.spec = @spec
|
@installer.spec = @spec
|
||||||
end
|
end
|
||||||
|
|
||||||
def util_gem_dir(version = '0.0.2')
|
def util_gem_dir(version = '2')
|
||||||
File.join @gemhome, "gems", "a-#{version}" # HACK
|
File.join @gemhome, "gems", "a-#{version}" # HACK
|
||||||
end
|
end
|
||||||
|
|
||||||
def util_gem_bindir(version = '0.0.2')
|
def util_gem_bindir(version = '2')
|
||||||
File.join util_gem_dir(version), "bin"
|
File.join util_gem_dir(version), "bin"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -49,18 +51,19 @@ class TestGemInstaller < RubyGemTestCase
|
||||||
File.join @gemhome, "bin"
|
File.join @gemhome, "bin"
|
||||||
end
|
end
|
||||||
|
|
||||||
def util_make_exec(version = '0.0.2', shebang = "#!/usr/bin/ruby")
|
def util_make_exec(version = '2', shebang = "#!/usr/bin/ruby")
|
||||||
@spec.executables = ["my_exec"]
|
@spec.executables = ["my_exec"]
|
||||||
|
|
||||||
FileUtils.mkdir_p util_gem_bindir(version)
|
FileUtils.mkdir_p util_gem_bindir(version)
|
||||||
exec_file = File.join(util_gem_bindir(version), "my_exec")
|
exec_file = @installer.formatted_program_filename "my_exec"
|
||||||
File.open exec_file, 'w' do |f|
|
exec_path = File.join util_gem_bindir(version), exec_file
|
||||||
|
File.open exec_path, 'w' do |f|
|
||||||
f.puts shebang
|
f.puts shebang
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_app_script_text
|
def test_app_script_text
|
||||||
util_make_exec '0.0.2', ''
|
util_make_exec '2', ''
|
||||||
|
|
||||||
expected = <<-EOF
|
expected = <<-EOF
|
||||||
#!#{Gem.ruby}
|
#!#{Gem.ruby}
|
||||||
|
@ -144,15 +147,15 @@ load 'my_exec'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_ensure_dependency
|
def test_ensure_dependency
|
||||||
dep = Gem::Dependency.new 'a', '>= 0.0.2'
|
dep = Gem::Dependency.new 'a', '>= 2'
|
||||||
assert @installer.ensure_dependency(@spec, dep)
|
assert @installer.ensure_dependency(@spec, dep)
|
||||||
|
|
||||||
dep = Gem::Dependency.new 'b', '> 0.0.2'
|
dep = Gem::Dependency.new 'b', '> 2'
|
||||||
e = assert_raise Gem::InstallError do
|
e = assert_raise Gem::InstallError do
|
||||||
@installer.ensure_dependency @spec, dep
|
@installer.ensure_dependency @spec, dep
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal 'a requires b (> 0.0.2)', e.message
|
assert_equal 'a requires b (> 2)', e.message
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_expand_and_validate_gem_dir
|
def test_expand_and_validate_gem_dir
|
||||||
|
@ -226,7 +229,32 @@ load 'my_exec'
|
||||||
"You may need to remove this file if you broke the test once"
|
"You may need to remove this file if you broke the test once"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generate_bin_scripts
|
def test_generate_bin_bindir
|
||||||
|
@installer.wrappers = true
|
||||||
|
|
||||||
|
@spec.executables = ["my_exec"]
|
||||||
|
@spec.bindir = '.'
|
||||||
|
|
||||||
|
exec_file = @installer.formatted_program_filename "my_exec"
|
||||||
|
exec_path = File.join util_gem_dir(@spec.version), exec_file
|
||||||
|
File.open exec_path, 'w' do |f|
|
||||||
|
f.puts '#!/usr/bin/ruby'
|
||||||
|
end
|
||||||
|
|
||||||
|
@installer.gem_dir = util_gem_dir
|
||||||
|
|
||||||
|
@installer.generate_bin
|
||||||
|
|
||||||
|
assert_equal true, File.directory?(util_inst_bindir)
|
||||||
|
installed_exec = File.join(util_inst_bindir, "my_exec")
|
||||||
|
assert_equal true, File.exist?(installed_exec)
|
||||||
|
assert_equal(0100755, File.stat(installed_exec).mode) unless win_platform?
|
||||||
|
|
||||||
|
wrapper = File.read installed_exec
|
||||||
|
assert_match %r|generated by RubyGems|, wrapper
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_generate_bin_script
|
||||||
@installer.wrappers = true
|
@installer.wrappers = true
|
||||||
util_make_exec
|
util_make_exec
|
||||||
@installer.gem_dir = util_gem_dir
|
@installer.gem_dir = util_gem_dir
|
||||||
|
@ -241,7 +269,36 @@ load 'my_exec'
|
||||||
assert_match %r|generated by RubyGems|, wrapper
|
assert_match %r|generated by RubyGems|, wrapper
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generate_bin_scripts_install_dir
|
def test_generate_bin_script_format
|
||||||
|
@installer.format_executable = true
|
||||||
|
@installer.wrappers = true
|
||||||
|
util_make_exec
|
||||||
|
@installer.gem_dir = util_gem_dir
|
||||||
|
|
||||||
|
Gem::Installer.exec_format = 'foo-%s-bar'
|
||||||
|
@installer.generate_bin
|
||||||
|
assert_equal true, File.directory?(util_inst_bindir)
|
||||||
|
installed_exec = File.join util_inst_bindir, 'foo-my_exec-bar'
|
||||||
|
assert_equal true, File.exist?(installed_exec)
|
||||||
|
ensure
|
||||||
|
Gem::Installer.exec_format = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_generate_bin_script_format_disabled
|
||||||
|
@installer.wrappers = true
|
||||||
|
util_make_exec
|
||||||
|
@installer.gem_dir = util_gem_dir
|
||||||
|
|
||||||
|
Gem::Installer.exec_format = 'foo-%s-bar'
|
||||||
|
@installer.generate_bin
|
||||||
|
assert_equal true, File.directory?(util_inst_bindir)
|
||||||
|
installed_exec = File.join util_inst_bindir, 'my_exec'
|
||||||
|
assert_equal true, File.exist?(installed_exec)
|
||||||
|
ensure
|
||||||
|
Gem::Installer.exec_format = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_generate_bin_script_install_dir
|
||||||
@installer.wrappers = true
|
@installer.wrappers = true
|
||||||
@spec.executables = ["my_exec"]
|
@spec.executables = ["my_exec"]
|
||||||
|
|
||||||
|
@ -265,13 +322,13 @@ load 'my_exec'
|
||||||
assert_match %r|generated by RubyGems|, wrapper
|
assert_match %r|generated by RubyGems|, wrapper
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generate_bin_scripts_no_execs
|
def test_generate_bin_script_no_execs
|
||||||
@installer.wrappers = true
|
@installer.wrappers = true
|
||||||
@installer.generate_bin
|
@installer.generate_bin
|
||||||
assert_equal false, File.exist?(util_inst_bindir)
|
assert_equal false, File.exist?(util_inst_bindir)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generate_bin_scripts_no_perms
|
def test_generate_bin_script_no_perms
|
||||||
@installer.wrappers = true
|
@installer.wrappers = true
|
||||||
util_make_exec
|
util_make_exec
|
||||||
|
|
||||||
|
@ -286,7 +343,30 @@ load 'my_exec'
|
||||||
File.chmod 0700, util_inst_bindir unless $DEBUG
|
File.chmod 0700, util_inst_bindir unless $DEBUG
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generate_bin_symlinks
|
def test_generate_bin_script_no_shebang
|
||||||
|
@installer.wrappers = true
|
||||||
|
@spec.executables = ["my_exec"]
|
||||||
|
|
||||||
|
gem_dir = File.join @gemhome, 'gems', @spec.full_name
|
||||||
|
gem_bindir = File.join gem_dir, 'bin'
|
||||||
|
FileUtils.mkdir_p gem_bindir
|
||||||
|
File.open File.join(gem_bindir, "my_exec"), 'w' do |f|
|
||||||
|
f.puts "blah blah blah"
|
||||||
|
end
|
||||||
|
|
||||||
|
@installer.generate_bin
|
||||||
|
|
||||||
|
installed_exec = File.join @gemhome, 'bin', 'my_exec'
|
||||||
|
assert_equal true, File.exist?(installed_exec)
|
||||||
|
assert_equal 0100755, File.stat(installed_exec).mode unless win_platform?
|
||||||
|
|
||||||
|
wrapper = File.read installed_exec
|
||||||
|
assert_match %r|generated by RubyGems|, wrapper
|
||||||
|
# HACK some gems don't have #! in their executables, restore 2008/06
|
||||||
|
#assert_no_match %r|generated by RubyGems|, wrapper
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_generate_bin_symlink
|
||||||
return if win_platform? #Windows FS do not support symlinks
|
return if win_platform? #Windows FS do not support symlinks
|
||||||
|
|
||||||
@installer.wrappers = false
|
@installer.wrappers = false
|
||||||
|
@ -301,13 +381,13 @@ load 'my_exec'
|
||||||
File.readlink(installed_exec))
|
File.readlink(installed_exec))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generate_bin_symlinks_no_execs
|
def test_generate_bin_symlink_no_execs
|
||||||
@installer.wrappers = false
|
@installer.wrappers = false
|
||||||
@installer.generate_bin
|
@installer.generate_bin
|
||||||
assert_equal false, File.exist?(util_inst_bindir)
|
assert_equal false, File.exist?(util_inst_bindir)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generate_bin_symlinks_no_perms
|
def test_generate_bin_symlink_no_perms
|
||||||
@installer.wrappers = false
|
@installer.wrappers = false
|
||||||
util_make_exec
|
util_make_exec
|
||||||
@installer.gem_dir = util_gem_dir
|
@installer.gem_dir = util_gem_dir
|
||||||
|
@ -323,7 +403,7 @@ load 'my_exec'
|
||||||
File.chmod 0700, util_inst_bindir unless $DEBUG
|
File.chmod 0700, util_inst_bindir unless $DEBUG
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generate_bin_symlinks_update_newer
|
def test_generate_bin_symlink_update_newer
|
||||||
return if win_platform? #Windows FS do not support symlinks
|
return if win_platform? #Windows FS do not support symlinks
|
||||||
|
|
||||||
@installer.wrappers = false
|
@installer.wrappers = false
|
||||||
|
@ -338,22 +418,22 @@ load 'my_exec'
|
||||||
@spec = Gem::Specification.new do |s|
|
@spec = Gem::Specification.new do |s|
|
||||||
s.files = ['lib/code.rb']
|
s.files = ['lib/code.rb']
|
||||||
s.name = "a"
|
s.name = "a"
|
||||||
s.version = "0.0.3"
|
s.version = "3"
|
||||||
s.summary = "summary"
|
s.summary = "summary"
|
||||||
s.description = "desc"
|
s.description = "desc"
|
||||||
s.require_path = 'lib'
|
s.require_path = 'lib'
|
||||||
end
|
end
|
||||||
|
|
||||||
util_make_exec '0.0.3'
|
util_make_exec '3'
|
||||||
@installer.gem_dir = File.join util_gem_dir('0.0.3')
|
@installer.gem_dir = File.join util_gem_dir('3')
|
||||||
@installer.generate_bin
|
@installer.generate_bin
|
||||||
installed_exec = File.join(util_inst_bindir, "my_exec")
|
installed_exec = File.join(util_inst_bindir, "my_exec")
|
||||||
assert_equal(File.join(util_gem_bindir('0.0.3'), "my_exec"),
|
assert_equal(File.join(util_gem_bindir('3'), "my_exec"),
|
||||||
File.readlink(installed_exec),
|
File.readlink(installed_exec),
|
||||||
"Ensure symlink moved to latest version")
|
"Ensure symlink moved to latest version")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generate_bin_symlinks_update_older
|
def test_generate_bin_symlink_update_older
|
||||||
return if win_platform? #Windows FS do not support symlinks
|
return if win_platform? #Windows FS do not support symlinks
|
||||||
|
|
||||||
@installer.wrappers = false
|
@installer.wrappers = false
|
||||||
|
@ -368,25 +448,25 @@ load 'my_exec'
|
||||||
spec = Gem::Specification.new do |s|
|
spec = Gem::Specification.new do |s|
|
||||||
s.files = ['lib/code.rb']
|
s.files = ['lib/code.rb']
|
||||||
s.name = "a"
|
s.name = "a"
|
||||||
s.version = "0.0.1"
|
s.version = "1"
|
||||||
s.summary = "summary"
|
s.summary = "summary"
|
||||||
s.description = "desc"
|
s.description = "desc"
|
||||||
s.require_path = 'lib'
|
s.require_path = 'lib'
|
||||||
end
|
end
|
||||||
|
|
||||||
util_make_exec '0.0.1'
|
util_make_exec '1'
|
||||||
@installer.gem_dir = util_gem_dir('0.0.1')
|
@installer.gem_dir = util_gem_dir('1')
|
||||||
@installer.spec = spec
|
@installer.spec = spec
|
||||||
|
|
||||||
@installer.generate_bin
|
@installer.generate_bin
|
||||||
|
|
||||||
installed_exec = File.join(util_inst_bindir, "my_exec")
|
installed_exec = File.join(util_inst_bindir, "my_exec")
|
||||||
assert_equal(File.join(util_gem_dir('0.0.2'), "bin", "my_exec"),
|
assert_equal(File.join(util_gem_dir('2'), "bin", "my_exec"),
|
||||||
File.readlink(installed_exec),
|
File.readlink(installed_exec),
|
||||||
"Ensure symlink not moved")
|
"Ensure symlink not moved")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generate_bin_symlinks_update_remove_wrapper
|
def test_generate_bin_symlink_update_remove_wrapper
|
||||||
return if win_platform? #Windows FS do not support symlinks
|
return if win_platform? #Windows FS do not support symlinks
|
||||||
|
|
||||||
@installer.wrappers = true
|
@installer.wrappers = true
|
||||||
|
@ -400,23 +480,23 @@ load 'my_exec'
|
||||||
@spec = Gem::Specification.new do |s|
|
@spec = Gem::Specification.new do |s|
|
||||||
s.files = ['lib/code.rb']
|
s.files = ['lib/code.rb']
|
||||||
s.name = "a"
|
s.name = "a"
|
||||||
s.version = "0.0.3"
|
s.version = "3"
|
||||||
s.summary = "summary"
|
s.summary = "summary"
|
||||||
s.description = "desc"
|
s.description = "desc"
|
||||||
s.require_path = 'lib'
|
s.require_path = 'lib'
|
||||||
end
|
end
|
||||||
|
|
||||||
@installer.wrappers = false
|
@installer.wrappers = false
|
||||||
util_make_exec '0.0.3'
|
util_make_exec '3'
|
||||||
@installer.gem_dir = util_gem_dir '0.0.3'
|
@installer.gem_dir = util_gem_dir '3'
|
||||||
@installer.generate_bin
|
@installer.generate_bin
|
||||||
installed_exec = File.join(util_inst_bindir, "my_exec")
|
installed_exec = File.join(util_inst_bindir, "my_exec")
|
||||||
assert_equal(File.join(util_gem_dir('0.0.3'), "bin", "my_exec"),
|
assert_equal(File.join(util_gem_dir('3'), "bin", "my_exec"),
|
||||||
File.readlink(installed_exec),
|
File.readlink(installed_exec),
|
||||||
"Ensure symlink moved to latest version")
|
"Ensure symlink moved to latest version")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generate_bin_symlinks_win32
|
def test_generate_bin_symlink_win32
|
||||||
old_win_platform = Gem.win_platform?
|
old_win_platform = Gem.win_platform?
|
||||||
Gem.win_platform = true
|
Gem.win_platform = true
|
||||||
@installer.wrappers = false
|
@installer.wrappers = false
|
||||||
|
@ -454,6 +534,19 @@ load 'my_exec'
|
||||||
assert_match(/#{default_shebang}/, shebang_line)
|
assert_match(/#{default_shebang}/, shebang_line)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_initialize
|
||||||
|
spec = quick_gem 'a' do |s| s.platform = Gem::Platform.new 'mswin32' end
|
||||||
|
gem = File.join @tempdir, "#{spec.full_name}.gem"
|
||||||
|
|
||||||
|
util_build_gem spec
|
||||||
|
FileUtils.mv File.join(@gemhome, 'cache', "#{spec.full_name}.gem"),
|
||||||
|
@tempdir
|
||||||
|
|
||||||
|
installer = Gem::Installer.new gem
|
||||||
|
|
||||||
|
assert_equal File.join(@gemhome, 'gems', spec.full_name), installer.gem_dir
|
||||||
|
end
|
||||||
|
|
||||||
def test_install
|
def test_install
|
||||||
util_setup_gem
|
util_setup_gem
|
||||||
|
|
||||||
|
@ -518,7 +611,7 @@ load 'my_exec'
|
||||||
installer.install
|
installer.install
|
||||||
end
|
end
|
||||||
|
|
||||||
gem_dir = File.join(@gemhome, 'gems', 'old_ruby_required-0.0.1')
|
gem_dir = File.join(@gemhome, 'gems', 'old_ruby_required-1')
|
||||||
assert File.exist?(gem_dir)
|
assert File.exist?(gem_dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -605,8 +698,8 @@ load 'my_exec'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_install_wrong_rubygems_version
|
def test_install_wrong_rubygems_version
|
||||||
spec = quick_gem 'old_rubygems_required', '0.0.1' do |s|
|
spec = quick_gem 'old_rubygems_required', '1' do |s|
|
||||||
s.required_rubygems_version = '< 0.0.0'
|
s.required_rubygems_version = '< 0'
|
||||||
end
|
end
|
||||||
|
|
||||||
util_build_gem spec
|
util_build_gem spec
|
||||||
|
@ -618,21 +711,21 @@ load 'my_exec'
|
||||||
e = assert_raise Gem::InstallError do
|
e = assert_raise Gem::InstallError do
|
||||||
@installer.install
|
@installer.install
|
||||||
end
|
end
|
||||||
assert_equal 'old_rubygems_required requires RubyGems version < 0.0.0',
|
assert_equal 'old_rubygems_required requires RubyGems version < 0',
|
||||||
e.message
|
e.message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_installation_satisfies_dependency_eh
|
def test_installation_satisfies_dependency_eh
|
||||||
dep = Gem::Dependency.new 'a', '>= 0.0.2'
|
dep = Gem::Dependency.new 'a', '>= 2'
|
||||||
assert @installer.installation_satisfies_dependency?(dep)
|
assert @installer.installation_satisfies_dependency?(dep)
|
||||||
|
|
||||||
dep = Gem::Dependency.new 'a', '> 0.0.2'
|
dep = Gem::Dependency.new 'a', '> 2'
|
||||||
assert ! @installer.installation_satisfies_dependency?(dep)
|
assert ! @installer.installation_satisfies_dependency?(dep)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_shebang
|
def test_shebang
|
||||||
util_make_exec '0.0.2', "#!/usr/bin/ruby"
|
util_make_exec '2', "#!/usr/bin/ruby"
|
||||||
|
|
||||||
shebang = @installer.shebang 'my_exec'
|
shebang = @installer.shebang 'my_exec'
|
||||||
|
|
||||||
|
@ -640,7 +733,7 @@ load 'my_exec'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_shebang_arguments
|
def test_shebang_arguments
|
||||||
util_make_exec '0.0.2', "#!/usr/bin/ruby -ws"
|
util_make_exec '2', "#!/usr/bin/ruby -ws"
|
||||||
|
|
||||||
shebang = @installer.shebang 'my_exec'
|
shebang = @installer.shebang 'my_exec'
|
||||||
|
|
||||||
|
@ -648,14 +741,14 @@ load 'my_exec'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_shebang_empty
|
def test_shebang_empty
|
||||||
util_make_exec '0.0.2', ''
|
util_make_exec '2', ''
|
||||||
|
|
||||||
shebang = @installer.shebang 'my_exec'
|
shebang = @installer.shebang 'my_exec'
|
||||||
assert_equal "#!#{Gem.ruby}", shebang
|
assert_equal "#!#{Gem.ruby}", shebang
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_shebang_env
|
def test_shebang_env
|
||||||
util_make_exec '0.0.2', "#!/usr/bin/env ruby"
|
util_make_exec '2', "#!/usr/bin/env ruby"
|
||||||
|
|
||||||
shebang = @installer.shebang 'my_exec'
|
shebang = @installer.shebang 'my_exec'
|
||||||
|
|
||||||
|
@ -663,7 +756,7 @@ load 'my_exec'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_shebang_env_arguments
|
def test_shebang_env_arguments
|
||||||
util_make_exec '0.0.2', "#!/usr/bin/env ruby -ws"
|
util_make_exec '2', "#!/usr/bin/env ruby -ws"
|
||||||
|
|
||||||
shebang = @installer.shebang 'my_exec'
|
shebang = @installer.shebang 'my_exec'
|
||||||
|
|
||||||
|
@ -671,7 +764,7 @@ load 'my_exec'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_shebang_env_shebang
|
def test_shebang_env_shebang
|
||||||
util_make_exec '0.0.2', ''
|
util_make_exec '2', ''
|
||||||
@installer.env_shebang = true
|
@installer.env_shebang = true
|
||||||
|
|
||||||
shebang = @installer.shebang 'my_exec'
|
shebang = @installer.shebang 'my_exec'
|
||||||
|
@ -679,7 +772,7 @@ load 'my_exec'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_shebang_nested
|
def test_shebang_nested
|
||||||
util_make_exec '0.0.2', "#!/opt/local/ruby/bin/ruby"
|
util_make_exec '2', "#!/opt/local/ruby/bin/ruby"
|
||||||
|
|
||||||
shebang = @installer.shebang 'my_exec'
|
shebang = @installer.shebang 'my_exec'
|
||||||
|
|
||||||
|
@ -687,7 +780,7 @@ load 'my_exec'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_shebang_nested_arguments
|
def test_shebang_nested_arguments
|
||||||
util_make_exec '0.0.2', "#!/opt/local/ruby/bin/ruby -ws"
|
util_make_exec '2', "#!/opt/local/ruby/bin/ruby -ws"
|
||||||
|
|
||||||
shebang = @installer.shebang 'my_exec'
|
shebang = @installer.shebang 'my_exec'
|
||||||
|
|
||||||
|
@ -695,7 +788,7 @@ load 'my_exec'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_shebang_version
|
def test_shebang_version
|
||||||
util_make_exec '0.0.2', "#!/usr/bin/ruby18"
|
util_make_exec '2', "#!/usr/bin/ruby18"
|
||||||
|
|
||||||
shebang = @installer.shebang 'my_exec'
|
shebang = @installer.shebang 'my_exec'
|
||||||
|
|
||||||
|
@ -703,7 +796,7 @@ load 'my_exec'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_shebang_version_arguments
|
def test_shebang_version_arguments
|
||||||
util_make_exec '0.0.2', "#!/usr/bin/ruby18 -ws"
|
util_make_exec '2', "#!/usr/bin/ruby18 -ws"
|
||||||
|
|
||||||
shebang = @installer.shebang 'my_exec'
|
shebang = @installer.shebang 'my_exec'
|
||||||
|
|
||||||
|
@ -711,7 +804,7 @@ load 'my_exec'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_shebang_version_env
|
def test_shebang_version_env
|
||||||
util_make_exec '0.0.2', "#!/usr/bin/env ruby18"
|
util_make_exec '2', "#!/usr/bin/env ruby18"
|
||||||
|
|
||||||
shebang = @installer.shebang 'my_exec'
|
shebang = @installer.shebang 'my_exec'
|
||||||
|
|
||||||
|
@ -719,7 +812,7 @@ load 'my_exec'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_shebang_version_env_arguments
|
def test_shebang_version_env_arguments
|
||||||
util_make_exec '0.0.2', "#!/usr/bin/env ruby18 -ws"
|
util_make_exec '2', "#!/usr/bin/env ruby18 -ws"
|
||||||
|
|
||||||
shebang = @installer.shebang 'my_exec'
|
shebang = @installer.shebang 'my_exec'
|
||||||
|
|
||||||
|
@ -753,7 +846,7 @@ load 'my_exec'
|
||||||
end
|
end
|
||||||
|
|
||||||
def old_ruby_required
|
def old_ruby_required
|
||||||
spec = quick_gem 'old_ruby_required', '0.0.1' do |s|
|
spec = quick_gem 'old_ruby_required', '1' do |s|
|
||||||
s.required_ruby_version = '= 1.4.6'
|
s.required_ruby_version = '= 1.4.6'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -790,4 +883,3 @@ load 'my_exec'
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,19 @@ require 'rbconfig'
|
||||||
|
|
||||||
class TestGemPlatform < RubyGemTestCase
|
class TestGemPlatform < RubyGemTestCase
|
||||||
|
|
||||||
|
def test_self_const_missing
|
||||||
|
consts = [:DARWIN, :LINUX_586, :MSWIN32, :PPC_DARWIN, :WIN32, :X86_LINUX]
|
||||||
|
|
||||||
|
consts.each do |const|
|
||||||
|
e = assert_raise NameError do
|
||||||
|
Gem::Platform.const_missing const
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal "#{const} has been removed, use CURRENT instead",
|
||||||
|
e.message
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_self_local
|
def test_self_local
|
||||||
util_set_arch 'i686-darwin8.10.1'
|
util_set_arch 'i686-darwin8.10.1'
|
||||||
|
|
||||||
|
@ -60,6 +73,10 @@ class TestGemPlatform < RubyGemTestCase
|
||||||
'i386-mingw32' => ['x86', 'mingw32', nil],
|
'i386-mingw32' => ['x86', 'mingw32', nil],
|
||||||
'i386-mswin32' => ['x86', 'mswin32', nil],
|
'i386-mswin32' => ['x86', 'mswin32', nil],
|
||||||
'i386-mswin32_80' => ['x86', 'mswin32', '80'],
|
'i386-mswin32_80' => ['x86', 'mswin32', '80'],
|
||||||
|
'i386-mswin32-80' => ['x86', 'mswin32', '80'],
|
||||||
|
'x86-mswin32' => ['x86', 'mswin32', nil],
|
||||||
|
'x86-mswin32_60' => ['x86', 'mswin32', '60'],
|
||||||
|
'x86-mswin32-60' => ['x86', 'mswin32', '60'],
|
||||||
'i386-netbsdelf' => ['x86', 'netbsdelf', nil],
|
'i386-netbsdelf' => ['x86', 'netbsdelf', nil],
|
||||||
'i386-openbsd4.0' => ['x86', 'openbsd', '4.0'],
|
'i386-openbsd4.0' => ['x86', 'openbsd', '4.0'],
|
||||||
'i386-solaris2.10' => ['x86', 'solaris', '2.10'],
|
'i386-solaris2.10' => ['x86', 'solaris', '2.10'],
|
||||||
|
|
|
@ -140,11 +140,12 @@ gems:
|
||||||
raise SocketError
|
raise SocketError
|
||||||
end
|
end
|
||||||
|
|
||||||
|
uri = 'http://gems.example.com/yaml'
|
||||||
e = assert_raise Gem::RemoteFetcher::FetchError do
|
e = assert_raise Gem::RemoteFetcher::FetchError do
|
||||||
fetcher.fetch_size 'http://gems.example.com/yaml'
|
fetcher.fetch_size uri
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal 'SocketError (SocketError)', e.message
|
assert_equal "SocketError (SocketError)\n\tgetting size of #{uri}", e.message
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_no_proxy
|
def test_no_proxy
|
||||||
|
@ -231,6 +232,22 @@ gems:
|
||||||
assert_equal 'EOFError: EOFError reading uri', e.message
|
assert_equal 'EOFError: EOFError reading uri', e.message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_fetch_path_open_uri_http_error
|
||||||
|
fetcher = Gem::RemoteFetcher.new nil
|
||||||
|
|
||||||
|
def fetcher.open_uri_or_path(uri)
|
||||||
|
io = StringIO.new 'went boom'
|
||||||
|
err = OpenURI::HTTPError.new 'error', io
|
||||||
|
raise err
|
||||||
|
end
|
||||||
|
|
||||||
|
e = assert_raise Gem::RemoteFetcher::FetchError do
|
||||||
|
fetcher.fetch_path 'uri'
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal "OpenURI::HTTPError: error reading uri\n\twent boom", e.message
|
||||||
|
end
|
||||||
|
|
||||||
def test_fetch_path_socket_error
|
def test_fetch_path_socket_error
|
||||||
fetcher = Gem::RemoteFetcher.new nil
|
fetcher = Gem::RemoteFetcher.new nil
|
||||||
|
|
||||||
|
|
|
@ -1,161 +0,0 @@
|
||||||
#--
|
|
||||||
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
|
||||||
# All rights reserved.
|
|
||||||
# See LICENSE.txt for permissions.
|
|
||||||
#++
|
|
||||||
|
|
||||||
require 'test/unit'
|
|
||||||
require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
|
|
||||||
require 'rubygems/remote_installer'
|
|
||||||
|
|
||||||
class MockFetcher
|
|
||||||
def initialize(uri, proxy)
|
|
||||||
@uri = uri
|
|
||||||
@proxy = proxy
|
|
||||||
end
|
|
||||||
|
|
||||||
def size
|
|
||||||
1000
|
|
||||||
end
|
|
||||||
|
|
||||||
def source_index
|
|
||||||
if @uri =~ /non.existent.url/
|
|
||||||
fail Gem::RemoteSourceException,
|
|
||||||
"Error fetching remote gem cache: Mock Socket Exception"
|
|
||||||
end
|
|
||||||
result = {
|
|
||||||
'foo-1.2.3' => Gem::Specification.new do |s|
|
|
||||||
s.name = 'foo'
|
|
||||||
s.version = "1.2.3"
|
|
||||||
s.summary = "This is a cool package"
|
|
||||||
end,
|
|
||||||
'foo-tools-2.0.0' => Gem::Specification.new do |s|
|
|
||||||
s.name = 'foo-tools'
|
|
||||||
s.version = "2.0.0"
|
|
||||||
s.summary = "This is an even cooler package"
|
|
||||||
end,
|
|
||||||
'foo-2-2.0.0' => Gem::Specification.new do |s|
|
|
||||||
s.name = 'foo-2'
|
|
||||||
s.version = "2.0.0"
|
|
||||||
s.summary = "This is the coolest package evar!~!"
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
result
|
|
||||||
end
|
|
||||||
|
|
||||||
def fetch_path(path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.finish
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class TestGemRemoteInstaller < RubyGemTestCase
|
|
||||||
|
|
||||||
def setup
|
|
||||||
super
|
|
||||||
|
|
||||||
util_setup_fake_fetcher
|
|
||||||
|
|
||||||
util_setup_source_info_cache @gem1, @gem4
|
|
||||||
|
|
||||||
@installer = Gem::RemoteInstaller.new
|
|
||||||
@installer.instance_variable_set("@fetcher_class", MockFetcher)
|
|
||||||
end
|
|
||||||
|
|
||||||
def teardown
|
|
||||||
FileUtils.rm "dest_file" rescue nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_find_gem_to_install
|
|
||||||
future_gem = quick_gem @gem1.name, '9.9.9' do |spec|
|
|
||||||
spec.required_ruby_version = '> 999.999.999' # HACK
|
|
||||||
end
|
|
||||||
|
|
||||||
util_setup_source_info_cache @gem1, future_gem
|
|
||||||
version = Gem::Version::Requirement.new "> 0.0.0"
|
|
||||||
gems = @installer.find_gem_to_install(@gem1.name, version)
|
|
||||||
|
|
||||||
assert_equal @gem1.full_name, gems.first.full_name
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_source_index_hash
|
|
||||||
source_hash = @installer.source_index_hash
|
|
||||||
|
|
||||||
assert_equal 1, source_hash.size
|
|
||||||
assert source_hash.has_key?('http://gems.example.com')
|
|
||||||
assert_equal [@gem1, @gem4],
|
|
||||||
source_hash['http://gems.example.com'].search(@gem1.name)
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_specs_n_sources_matching
|
|
||||||
version = Gem::Version::Requirement.new "> 0.0.0"
|
|
||||||
specs_n_sources = @installer.specs_n_sources_matching @gem1.name, version
|
|
||||||
|
|
||||||
gems = specs_n_sources.map { |g,| g.full_name }
|
|
||||||
|
|
||||||
assert_equal [@gem1.full_name], gems,
|
|
||||||
"Gems with longer names and higher versions must not match"
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
# This test suite has a number of TODOs in the test cases. The
|
|
||||||
# TestRemoteInstaller test suite is a reworking of this class from
|
|
||||||
# scratch.
|
|
||||||
class RemoteInstallerTest #< RubyGemTestCase # HACK disabled
|
|
||||||
class RInst < Gem::RemoteInstaller
|
|
||||||
include Test::Unit::Assertions
|
|
||||||
|
|
||||||
attr_accessor :expected_destination_files
|
|
||||||
attr_accessor :expected_bodies
|
|
||||||
attr_accessor :caches
|
|
||||||
attr_accessor :responses
|
|
||||||
|
|
||||||
def source_index_hash
|
|
||||||
@caches
|
|
||||||
end
|
|
||||||
|
|
||||||
def fetch(uri)
|
|
||||||
@reponses ||= {}
|
|
||||||
@responses[uri]
|
|
||||||
end
|
|
||||||
|
|
||||||
def write_gem_to_file(body, destination_file)
|
|
||||||
expected_destination_file = expected_destination_files.pop
|
|
||||||
expected_body = expected_bodies.pop
|
|
||||||
assert_equal expected_body, body, "Unexpected body"
|
|
||||||
assert_equal expected_destination_file, destination_file, "Unexpected destination file"
|
|
||||||
end
|
|
||||||
|
|
||||||
def new_installer(gem)
|
|
||||||
return MockInstaller.new(gem)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def setup
|
|
||||||
Gem.clear_paths
|
|
||||||
@remote_installer = Gem::RemoteInstaller.new
|
|
||||||
@remote_installer.instance_eval { @fetcher_class = MockFetcher }
|
|
||||||
end
|
|
||||||
|
|
||||||
SAMPLE_SPEC = Gem::Specification.new do |s|
|
|
||||||
s.name = 'foo'
|
|
||||||
s.version = "1.2.3"
|
|
||||||
s.platform = Gem::Platform::RUBY
|
|
||||||
s.summary = "This is a cool package"
|
|
||||||
s.files = []
|
|
||||||
end
|
|
||||||
SAMPLE_CACHE = { 'foo-1.2.3' => SAMPLE_SPEC }
|
|
||||||
SAMPLE_CACHE_YAML = SAMPLE_CACHE.to_yaml
|
|
||||||
|
|
||||||
FOO_GEM = '' # TODO
|
|
||||||
CACHE_DIR = File.join(Gem.dir, 'cache')
|
|
||||||
|
|
||||||
def test_install
|
|
||||||
result = @remote_installer.install('foo')
|
|
||||||
assert_equal [nil], result
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ require 'rubygems/server'
|
||||||
require 'stringio'
|
require 'stringio'
|
||||||
|
|
||||||
class Gem::Server
|
class Gem::Server
|
||||||
|
attr_accessor :source_index
|
||||||
attr_reader :server
|
attr_reader :server
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -25,6 +26,7 @@ class TestGemServer < RubyGemTestCase
|
||||||
|
|
||||||
@server.quick @req, @res
|
@server.quick @req, @res
|
||||||
|
|
||||||
|
assert_equal 200, @res.status, @res.body
|
||||||
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
||||||
assert_equal 'text/plain', @res['content-type']
|
assert_equal 'text/plain', @res['content-type']
|
||||||
assert_equal "a-1", @res.body
|
assert_equal "a-1", @res.body
|
||||||
|
@ -36,6 +38,7 @@ class TestGemServer < RubyGemTestCase
|
||||||
|
|
||||||
@server.quick @req, @res
|
@server.quick @req, @res
|
||||||
|
|
||||||
|
assert_equal 200, @res.status, @res.body
|
||||||
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
||||||
assert_equal 'text/plain', @res['content-type']
|
assert_equal 'text/plain', @res['content-type']
|
||||||
assert_equal "a-1", Zlib::Inflate.inflate(@res.body)
|
assert_equal "a-1", Zlib::Inflate.inflate(@res.body)
|
||||||
|
@ -47,6 +50,7 @@ class TestGemServer < RubyGemTestCase
|
||||||
|
|
||||||
@server.quick @req, @res
|
@server.quick @req, @res
|
||||||
|
|
||||||
|
assert_equal 200, @res.status, @res.body
|
||||||
assert @res['date']
|
assert @res['date']
|
||||||
assert_equal 'text/plain', @res['content-type']
|
assert_equal 'text/plain', @res['content-type']
|
||||||
yaml = Zlib::Inflate.inflate(@res.body)
|
yaml = Zlib::Inflate.inflate(@res.body)
|
||||||
|
@ -55,15 +59,54 @@ class TestGemServer < RubyGemTestCase
|
||||||
assert_match %r|version: "1"|, yaml
|
assert_match %r|version: "1"|, yaml
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_quick_a_1_mswin32_gemspec_rz
|
||||||
|
a1_p = quick_gem 'a', '1' do |s| s.platform = Gem::Platform.local end
|
||||||
|
si = Gem::SourceIndex.new @a1.full_name => @a1, a1_p.full_name => a1_p
|
||||||
|
@server.source_index = si
|
||||||
|
|
||||||
|
data = StringIO.new "GET /quick/a-1-#{Gem::Platform.local}.gemspec.rz HTTP/1.0\r\n\r\n"
|
||||||
|
@req.parse data
|
||||||
|
|
||||||
|
@server.quick @req, @res
|
||||||
|
|
||||||
|
assert_equal 200, @res.status, @res.body
|
||||||
|
assert @res['date']
|
||||||
|
assert_equal 'text/plain', @res['content-type']
|
||||||
|
yaml = Zlib::Inflate.inflate(@res.body)
|
||||||
|
assert_match %r|Gem::Specification|, yaml
|
||||||
|
assert_match %r|name: a|, yaml
|
||||||
|
assert_match %r|version: "1"|, yaml
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_quick_common_substrings
|
||||||
|
ab1 = quick_gem 'ab', '1'
|
||||||
|
si = Gem::SourceIndex.new @a1.full_name => @a1, ab1.full_name => ab1
|
||||||
|
@server.source_index = si
|
||||||
|
|
||||||
|
data = StringIO.new "GET /quick/a-1.gemspec.rz HTTP/1.0\r\n\r\n"
|
||||||
|
@req.parse data
|
||||||
|
|
||||||
|
@server.quick @req, @res
|
||||||
|
|
||||||
|
assert_equal 200, @res.status, @res.body
|
||||||
|
assert @res['date']
|
||||||
|
assert_equal 'text/plain', @res['content-type']
|
||||||
|
yaml = Zlib::Inflate.inflate @res.body
|
||||||
|
assert_match %r|Gem::Specification|, yaml
|
||||||
|
assert_match %r|name: a$|, yaml
|
||||||
|
assert_match %r|version: "1"|, yaml
|
||||||
|
end
|
||||||
|
|
||||||
def test_quick_z_9_gemspec_rz
|
def test_quick_z_9_gemspec_rz
|
||||||
data = StringIO.new "GET /quick/z-9.gemspec.rz HTTP/1.0\r\n\r\n"
|
data = StringIO.new "GET /quick/z-9.gemspec.rz HTTP/1.0\r\n\r\n"
|
||||||
@req.parse data
|
@req.parse data
|
||||||
|
|
||||||
@server.quick @req, @res
|
@server.quick @req, @res
|
||||||
|
|
||||||
|
assert_equal 404, @res.status, @res.body
|
||||||
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
|
||||||
assert_equal 'text/plain', @res['content-type']
|
assert_equal 'text/plain', @res['content-type']
|
||||||
assert_equal '', @res.body
|
assert_equal 'No gems found matching "z" "9" nil', @res.body
|
||||||
assert_equal 404, @res.status
|
assert_equal 404, @res.status
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,7 @@ class TestGemSourceIndex < RubyGemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_latest_specs
|
def test_latest_specs
|
||||||
spec = quick_gem @gem1.name, '0.0.1'
|
spec = quick_gem @gem1.name, '1'
|
||||||
@source_index.add_spec spec
|
@source_index.add_spec spec
|
||||||
|
|
||||||
expected = [
|
expected = [
|
||||||
|
@ -223,7 +223,7 @@ class TestGemSourceIndex < RubyGemTestCase
|
||||||
|
|
||||||
def test_search
|
def test_search
|
||||||
assert_equal [@gem1, @gem4], @source_index.search("gem_one")
|
assert_equal [@gem1, @gem4], @source_index.search("gem_one")
|
||||||
assert_equal [@gem1], @source_index.search("gem_one", "= 0.0.2")
|
assert_equal [@gem1], @source_index.search("gem_one", "= 2")
|
||||||
|
|
||||||
assert_equal [], @source_index.search("bogusstring")
|
assert_equal [], @source_index.search("bogusstring")
|
||||||
assert_equal [], @source_index.search("gem_one", "= 3.2.1")
|
assert_equal [], @source_index.search("gem_one", "= 3.2.1")
|
||||||
|
|
|
@ -47,12 +47,13 @@ end
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
|
|
||||||
@a0_0_1 = quick_gem 'a', '0.0.1' do |s|
|
@a1 = quick_gem 'a', '1' do |s|
|
||||||
s.executable = 'exec'
|
s.executable = 'exec'
|
||||||
s.extensions << 'ext/a/extconf.rb'
|
s.extensions << 'ext/a/extconf.rb'
|
||||||
s.has_rdoc = 'true'
|
s.has_rdoc = 'true'
|
||||||
s.test_file = 'test/suite.rb'
|
s.test_file = 'test/suite.rb'
|
||||||
s.requirements << 'A working computer'
|
s.requirements << 'A working computer'
|
||||||
|
s.rubyforge_project = 'example'
|
||||||
|
|
||||||
s.add_dependency 'rake', '> 0.4'
|
s.add_dependency 'rake', '> 0.4'
|
||||||
s.add_dependency 'jabber4r', '> 0.0.0'
|
s.add_dependency 'jabber4r', '> 0.0.0'
|
||||||
|
@ -62,9 +63,14 @@ end
|
||||||
s.files = %w[lib/code.rb]
|
s.files = %w[lib/code.rb]
|
||||||
end
|
end
|
||||||
|
|
||||||
@a0_0_2 = quick_gem 'a', '0.0.2' do |s|
|
@a2 = quick_gem 'a', '2' do |s|
|
||||||
s.files = %w[lib/code.rb]
|
s.files = %w[lib/code.rb]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
FileUtils.mkdir_p File.join(@tempdir, 'bin')
|
||||||
|
File.open File.join(@tempdir, 'bin', 'exec'), 'w' do |fp|
|
||||||
|
fp.puts "#!#{Gem.ruby}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_attribute_names
|
def test_self_attribute_names
|
||||||
|
@ -107,10 +113,10 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_load
|
def test_self_load
|
||||||
spec = File.join @gemhome, 'specifications', "#{@a0_0_2.full_name}.gemspec"
|
spec = File.join @gemhome, 'specifications', "#{@a2.full_name}.gemspec"
|
||||||
gs = Gem::Specification.load spec
|
gs = Gem::Specification.load spec
|
||||||
|
|
||||||
assert_equal @a0_0_2, gs
|
assert_equal @a2, gs
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_self_load_legacy_ruby
|
def test_self_load_legacy_ruby
|
||||||
|
@ -119,7 +125,7 @@ end
|
||||||
assert_equal '0.4.0', s.version.to_s
|
assert_equal '0.4.0', s.version.to_s
|
||||||
assert_equal true, s.has_rdoc?
|
assert_equal true, s.has_rdoc?
|
||||||
assert_equal Gem::Specification::TODAY, s.date
|
assert_equal Gem::Specification::TODAY, s.date
|
||||||
assert s.required_ruby_version.satisfied_by?(Gem::Version.new('0.0.1'))
|
assert s.required_ruby_version.satisfied_by?(Gem::Version.new('1'))
|
||||||
assert_equal false, s.has_unit_tests?
|
assert_equal false, s.has_unit_tests?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -129,7 +135,7 @@ end
|
||||||
assert_equal '0.4.0', s.version.to_s
|
assert_equal '0.4.0', s.version.to_s
|
||||||
assert_equal true, s.has_rdoc?
|
assert_equal true, s.has_rdoc?
|
||||||
#assert_equal Date.today, s.date
|
#assert_equal Date.today, s.date
|
||||||
#assert s.required_ruby_version.satisfied_by?(Gem::Version.new('0.0.1'))
|
#assert s.required_ruby_version.satisfied_by?(Gem::Version.new('1'))
|
||||||
assert_equal false, s.has_unit_tests?
|
assert_equal false, s.has_unit_tests?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -197,10 +203,10 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test__dump
|
def test__dump
|
||||||
@a0_0_2.platform = Gem::Platform.local
|
@a2.platform = Gem::Platform.local
|
||||||
@a0_0_2.instance_variable_set :@original_platform, 'old_platform'
|
@a2.instance_variable_set :@original_platform, 'old_platform'
|
||||||
|
|
||||||
data = Marshal.dump @a0_0_2
|
data = Marshal.dump @a2
|
||||||
|
|
||||||
same_spec = Marshal.load data
|
same_spec = Marshal.load data
|
||||||
|
|
||||||
|
@ -208,64 +214,64 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_author
|
def test_author
|
||||||
assert_equal 'A User', @a0_0_1.author
|
assert_equal 'A User', @a1.author
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_authors
|
def test_authors
|
||||||
assert_equal ['A User'], @a0_0_1.authors
|
assert_equal ['A User'], @a1.authors
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_bindir_equals
|
def test_bindir_equals
|
||||||
@a0_0_1.bindir = 'apps'
|
@a1.bindir = 'apps'
|
||||||
|
|
||||||
assert_equal 'apps', @a0_0_1.bindir
|
assert_equal 'apps', @a1.bindir
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_bindir_equals_nil
|
def test_bindir_equals_nil
|
||||||
@a0_0_2.bindir = nil
|
@a2.bindir = nil
|
||||||
@a0_0_2.executable = 'app'
|
@a2.executable = 'app'
|
||||||
|
|
||||||
assert_equal nil, @a0_0_2.bindir
|
assert_equal nil, @a2.bindir
|
||||||
assert_equal %w[lib/code.rb app], @a0_0_2.files
|
assert_equal %w[lib/code.rb app], @a2.files
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_date
|
def test_date
|
||||||
assert_equal Gem::Specification::TODAY, @a0_0_1.date
|
assert_equal Gem::Specification::TODAY, @a1.date
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_date_equals_date
|
def test_date_equals_date
|
||||||
@a0_0_1.date = Date.new(2003, 9, 17)
|
@a1.date = Date.new(2003, 9, 17)
|
||||||
assert_equal Time.local(2003, 9, 17, 0,0,0), @a0_0_1.date
|
assert_equal Time.local(2003, 9, 17, 0,0,0), @a1.date
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_date_equals_string
|
def test_date_equals_string
|
||||||
@a0_0_1.date = '2003-09-17'
|
@a1.date = '2003-09-17'
|
||||||
assert_equal Time.local(2003, 9, 17, 0,0,0), @a0_0_1.date
|
assert_equal Time.local(2003, 9, 17, 0,0,0), @a1.date
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_date_equals_time
|
def test_date_equals_time
|
||||||
@a0_0_1.date = Time.local(2003, 9, 17, 0,0,0)
|
@a1.date = Time.local(2003, 9, 17, 0,0,0)
|
||||||
assert_equal Time.local(2003, 9, 17, 0,0,0), @a0_0_1.date
|
assert_equal Time.local(2003, 9, 17, 0,0,0), @a1.date
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_date_equals_time_local
|
def test_date_equals_time_local
|
||||||
# HACK PDT
|
# HACK PDT
|
||||||
@a0_0_1.date = Time.local(2003, 9, 17, 19,50,0)
|
@a1.date = Time.local(2003, 9, 17, 19,50,0)
|
||||||
assert_equal Time.local(2003, 9, 17, 0,0,0), @a0_0_1.date
|
assert_equal Time.local(2003, 9, 17, 0,0,0), @a1.date
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_date_equals_time_utc
|
def test_date_equals_time_utc
|
||||||
# HACK PDT
|
# HACK PDT
|
||||||
@a0_0_1.date = Time.local(2003, 9, 17, 19,50,0)
|
@a1.date = Time.local(2003, 9, 17, 19,50,0)
|
||||||
assert_equal Time.local(2003, 9, 17, 0,0,0), @a0_0_1.date
|
assert_equal Time.local(2003, 9, 17, 0,0,0), @a1.date
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_default_executable
|
def test_default_executable
|
||||||
assert_equal 'exec', @a0_0_1.default_executable
|
assert_equal 'exec', @a1.default_executable
|
||||||
|
|
||||||
@a0_0_1.default_executable = nil
|
@a1.default_executable = nil
|
||||||
@a0_0_1.instance_variable_set :@executables, nil
|
@a1.instance_variable_set :@executables, nil
|
||||||
assert_equal nil, @a0_0_1.default_executable
|
assert_equal nil, @a1.default_executable
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_dependencies
|
def test_dependencies
|
||||||
|
@ -273,11 +279,11 @@ end
|
||||||
jabber = Gem::Dependency.new 'jabber4r', '> 0.0.0'
|
jabber = Gem::Dependency.new 'jabber4r', '> 0.0.0'
|
||||||
pqa = Gem::Dependency.new 'pqa', ['> 0.4', '<= 0.6']
|
pqa = Gem::Dependency.new 'pqa', ['> 0.4', '<= 0.6']
|
||||||
|
|
||||||
assert_equal [rake, jabber, pqa], @a0_0_1.dependencies
|
assert_equal [rake, jabber, pqa], @a1.dependencies
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_description
|
def test_description
|
||||||
assert_equal 'This is a test description', @a0_0_1.description
|
assert_equal 'This is a test description', @a1.description
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_eql_eh
|
def test_eql_eh
|
||||||
|
@ -290,10 +296,10 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_equals2
|
def test_equals2
|
||||||
assert_equal @a0_0_1, @a0_0_1
|
assert_equal @a1, @a1
|
||||||
assert_equal @a0_0_1, @a0_0_1.dup
|
assert_equal @a1, @a1.dup
|
||||||
assert_not_equal @a0_0_1, @a0_0_2
|
assert_not_equal @a1, @a2
|
||||||
assert_not_equal @a0_0_1, Object.new
|
assert_not_equal @a1, Object.new
|
||||||
end
|
end
|
||||||
|
|
||||||
# The cgikit specification was reported to be causing trouble in at least
|
# The cgikit specification was reported to be causing trouble in at least
|
||||||
|
@ -322,42 +328,42 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_equals2_default_executable
|
def test_equals2_default_executable
|
||||||
spec = @a0_0_1.dup
|
spec = @a1.dup
|
||||||
spec.default_executable = 'xx'
|
spec.default_executable = 'xx'
|
||||||
|
|
||||||
assert_not_equal @a0_0_1, spec
|
assert_not_equal @a1, spec
|
||||||
assert_not_equal spec, @a0_0_1
|
assert_not_equal spec, @a1
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_equals2_extensions
|
def test_equals2_extensions
|
||||||
spec = @a0_0_1.dup
|
spec = @a1.dup
|
||||||
spec.extensions = 'xx'
|
spec.extensions = 'xx'
|
||||||
|
|
||||||
assert_not_equal @a0_0_1, spec
|
assert_not_equal @a1, spec
|
||||||
assert_not_equal spec, @a0_0_1
|
assert_not_equal spec, @a1
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_executables
|
def test_executables
|
||||||
@a0_0_1.executable = 'app'
|
@a1.executable = 'app'
|
||||||
assert_equal %w[app], @a0_0_1.executables
|
assert_equal %w[app], @a1.executables
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_executable_equals
|
def test_executable_equals
|
||||||
@a0_0_2.executable = 'app'
|
@a2.executable = 'app'
|
||||||
assert_equal 'app', @a0_0_2.executable
|
assert_equal 'app', @a2.executable
|
||||||
assert_equal %w[lib/code.rb bin/app], @a0_0_2.files
|
assert_equal %w[lib/code.rb bin/app], @a2.files
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_extensions
|
def test_extensions
|
||||||
assert_equal ['ext/a/extconf.rb'], @a0_0_1.extensions
|
assert_equal ['ext/a/extconf.rb'], @a1.extensions
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_files
|
def test_files
|
||||||
@a0_0_1.files = %w(files bin/common)
|
@a1.files = %w(files bin/common)
|
||||||
@a0_0_1.test_files = %w(test_files bin/common)
|
@a1.test_files = %w(test_files bin/common)
|
||||||
@a0_0_1.executables = %w(executables common)
|
@a1.executables = %w(executables common)
|
||||||
@a0_0_1.extra_rdoc_files = %w(extra_rdoc_files bin/common)
|
@a1.extra_rdoc_files = %w(extra_rdoc_files bin/common)
|
||||||
@a0_0_1.extensions = %w(extensions bin/common)
|
@a1.extensions = %w(extensions bin/common)
|
||||||
|
|
||||||
expected = %w[
|
expected = %w[
|
||||||
bin/common
|
bin/common
|
||||||
|
@ -367,113 +373,123 @@ end
|
||||||
files
|
files
|
||||||
test_files
|
test_files
|
||||||
]
|
]
|
||||||
assert_equal expected, @a0_0_1.files.sort
|
assert_equal expected, @a1.files.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_files_duplicate
|
def test_files_duplicate
|
||||||
@a0_0_2.files = %w[a b c d b]
|
@a2.files = %w[a b c d b]
|
||||||
@a0_0_2.extra_rdoc_files = %w[x y z x]
|
@a2.extra_rdoc_files = %w[x y z x]
|
||||||
@a0_0_2.normalize
|
@a2.normalize
|
||||||
|
|
||||||
assert_equal %w[a b c d x y z], @a0_0_2.files
|
assert_equal %w[a b c d x y z], @a2.files
|
||||||
assert_equal %w[x y z], @a0_0_2.extra_rdoc_files
|
assert_equal %w[x y z], @a2.extra_rdoc_files
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_files_extra_rdoc_files
|
def test_files_extra_rdoc_files
|
||||||
@a0_0_2.files = %w[a b c d]
|
@a2.files = %w[a b c d]
|
||||||
@a0_0_2.extra_rdoc_files = %w[x y z]
|
@a2.extra_rdoc_files = %w[x y z]
|
||||||
@a0_0_2.normalize
|
@a2.normalize
|
||||||
assert_equal %w[a b c d x y z], @a0_0_2.files
|
assert_equal %w[a b c d x y z], @a2.files
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_files_non_array
|
def test_files_non_array
|
||||||
@a0_0_1.files = "F"
|
@a1.files = "F"
|
||||||
@a0_0_1.test_files = "TF"
|
@a1.test_files = "TF"
|
||||||
@a0_0_1.executables = "X"
|
@a1.executables = "X"
|
||||||
@a0_0_1.extra_rdoc_files = "ERF"
|
@a1.extra_rdoc_files = "ERF"
|
||||||
@a0_0_1.extensions = "E"
|
@a1.extensions = "E"
|
||||||
|
|
||||||
assert_equal %w[E ERF F TF bin/X], @a0_0_1.files.sort
|
assert_equal %w[E ERF F TF bin/X], @a1.files.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_files_non_array_pathological
|
def test_files_non_array_pathological
|
||||||
@a0_0_1.instance_variable_set :@files, "F"
|
@a1.instance_variable_set :@files, "F"
|
||||||
@a0_0_1.instance_variable_set :@test_files, "TF"
|
@a1.instance_variable_set :@test_files, "TF"
|
||||||
@a0_0_1.instance_variable_set :@extra_rdoc_files, "ERF"
|
@a1.instance_variable_set :@extra_rdoc_files, "ERF"
|
||||||
@a0_0_1.instance_variable_set :@extensions, "E"
|
@a1.instance_variable_set :@extensions, "E"
|
||||||
@a0_0_1.instance_variable_set :@executables, "X"
|
@a1.instance_variable_set :@executables, "X"
|
||||||
|
|
||||||
assert_equal %w[E ERF F TF bin/X], @a0_0_1.files.sort
|
assert_equal %w[E ERF F TF bin/X], @a1.files.sort
|
||||||
assert_kind_of Integer, @a0_0_1.hash
|
assert_kind_of Integer, @a1.hash
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_full_gem_path
|
||||||
|
assert_equal File.join(@gemhome, 'gems', @a1.full_name),
|
||||||
|
@a1.full_gem_path
|
||||||
|
|
||||||
|
@a1.original_platform = 'mswin32'
|
||||||
|
|
||||||
|
assert_equal File.join(@gemhome, 'gems', @a1.original_name),
|
||||||
|
@a1.full_gem_path
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_full_name
|
def test_full_name
|
||||||
assert_equal 'a-0.0.1', @a0_0_1.full_name
|
assert_equal 'a-1', @a1.full_name
|
||||||
|
|
||||||
@a0_0_1.platform = Gem::Platform.new ['universal', 'darwin', nil]
|
@a1.platform = Gem::Platform.new ['universal', 'darwin', nil]
|
||||||
assert_equal 'a-0.0.1-universal-darwin', @a0_0_1.full_name
|
assert_equal 'a-1-universal-darwin', @a1.full_name
|
||||||
|
|
||||||
@a0_0_1.instance_variable_set :@new_platform, 'mswin32'
|
@a1.instance_variable_set :@new_platform, 'mswin32'
|
||||||
assert_equal 'a-0.0.1-mswin32', @a0_0_1.full_name, 'legacy'
|
assert_equal 'a-1-mswin32', @a1.full_name, 'legacy'
|
||||||
|
|
||||||
return if win_platform?
|
return if win_platform?
|
||||||
|
|
||||||
@a0_0_1.platform = 'current'
|
@a1.platform = 'current'
|
||||||
assert_equal 'a-0.0.1-x86-darwin-8', @a0_0_1.full_name
|
assert_equal 'a-1-x86-darwin-8', @a1.full_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_full_name_windows
|
def test_full_name_windows
|
||||||
test_cases = {
|
test_cases = {
|
||||||
'i386-mswin32' => 'a-0.0.1-x86-mswin32-60',
|
'i386-mswin32' => 'a-1-x86-mswin32-60',
|
||||||
'i386-mswin32_80' => 'a-0.0.1-x86-mswin32-80',
|
'i386-mswin32_80' => 'a-1-x86-mswin32-80',
|
||||||
'i386-mingw32' => 'a-0.0.1-x86-mingw32'
|
'i386-mingw32' => 'a-1-x86-mingw32'
|
||||||
}
|
}
|
||||||
|
|
||||||
test_cases.each do |arch, expected|
|
test_cases.each do |arch, expected|
|
||||||
util_set_arch arch
|
util_set_arch arch
|
||||||
@a0_0_1.platform = 'current'
|
@a1.platform = 'current'
|
||||||
assert_equal expected, @a0_0_1.full_name
|
assert_equal expected, @a1.full_name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_has_rdoc_eh
|
def test_has_rdoc_eh
|
||||||
assert_equal true, @a0_0_1.has_rdoc?
|
assert_equal true, @a1.has_rdoc?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_hash
|
def test_hash
|
||||||
assert_equal @a0_0_1.hash, @a0_0_1.hash
|
assert_equal @a1.hash, @a1.hash
|
||||||
assert_equal @a0_0_1.hash, @a0_0_1.dup.hash
|
assert_equal @a1.hash, @a1.dup.hash
|
||||||
assert_not_equal @a0_0_1.hash, @a0_0_2.hash
|
assert_not_equal @a1.hash, @a2.hash
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_lib_files
|
def test_lib_files
|
||||||
@a0_0_1.files = %w[lib/foo.rb Rakefile]
|
@a1.files = %w[lib/foo.rb Rakefile]
|
||||||
|
|
||||||
assert_equal %w[lib/foo.rb], @a0_0_1.lib_files
|
assert_equal %w[lib/foo.rb], @a1.lib_files
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_name
|
def test_name
|
||||||
assert_equal 'a', @a0_0_1.name
|
assert_equal 'a', @a1.name
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_original_name
|
def test_original_name
|
||||||
assert_equal 'a-0.0.1', @a0_0_1.full_name
|
assert_equal 'a-1', @a1.full_name
|
||||||
|
|
||||||
@a0_0_1.platform = 'i386-linux'
|
@a1.platform = 'i386-linux'
|
||||||
@a0_0_1.instance_variable_set :@original_platform, 'i386-linux'
|
@a1.instance_variable_set :@original_platform, 'i386-linux'
|
||||||
assert_equal 'a-0.0.1-i386-linux', @a0_0_1.original_name
|
assert_equal 'a-1-i386-linux', @a1.original_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_platform
|
def test_platform
|
||||||
assert_equal Gem::Platform::RUBY, @a0_0_1.platform
|
assert_equal Gem::Platform::RUBY, @a1.platform
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_platform_equals
|
def test_platform_equals
|
||||||
@a0_0_1.platform = nil
|
@a1.platform = nil
|
||||||
assert_equal Gem::Platform::RUBY, @a0_0_1.platform
|
assert_equal Gem::Platform::RUBY, @a1.platform
|
||||||
|
|
||||||
@a0_0_1.platform = Gem::Platform::RUBY
|
@a1.platform = Gem::Platform::RUBY
|
||||||
assert_equal Gem::Platform::RUBY, @a0_0_1.platform
|
assert_equal Gem::Platform::RUBY, @a1.platform
|
||||||
|
|
||||||
test_cases = {
|
test_cases = {
|
||||||
'i386-mswin32' => ['x86', 'mswin32', '60'],
|
'i386-mswin32' => ['x86', 'mswin32', '60'],
|
||||||
|
@ -484,29 +500,35 @@ end
|
||||||
|
|
||||||
test_cases.each do |arch, expected|
|
test_cases.each do |arch, expected|
|
||||||
util_set_arch arch
|
util_set_arch arch
|
||||||
@a0_0_1.platform = Gem::Platform::CURRENT
|
@a1.platform = Gem::Platform::CURRENT
|
||||||
assert_equal Gem::Platform.new(expected), @a0_0_1.platform
|
assert_equal Gem::Platform.new(expected), @a1.platform
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_platform_equals_current
|
||||||
|
@a1.platform = Gem::Platform::CURRENT
|
||||||
|
assert_equal Gem::Platform.local, @a1.platform
|
||||||
|
assert_equal Gem::Platform.local.to_s, @a1.original_platform
|
||||||
|
end
|
||||||
|
|
||||||
def test_platform_equals_legacy
|
def test_platform_equals_legacy
|
||||||
@a0_0_1.platform = Gem::Platform::WIN32
|
@a1.platform = 'mswin32'
|
||||||
assert_equal Gem::Platform::MSWIN32, @a0_0_1.platform
|
assert_equal Gem::Platform.new('x86-mswin32'), @a1.platform
|
||||||
|
|
||||||
@a0_0_1.platform = Gem::Platform::LINUX_586
|
@a1.platform = 'i586-linux'
|
||||||
assert_equal Gem::Platform::X86_LINUX, @a0_0_1.platform
|
assert_equal Gem::Platform.new('x86-linux'), @a1.platform
|
||||||
|
|
||||||
@a0_0_1.platform = Gem::Platform::DARWIN
|
@a1.platform = 'powerpc-darwin'
|
||||||
assert_equal Gem::Platform::PPC_DARWIN, @a0_0_1.platform
|
assert_equal Gem::Platform.new('ppc-darwin'), @a1.platform
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_require_paths
|
def test_require_paths
|
||||||
@a0_0_1.require_path = 'lib'
|
@a1.require_path = 'lib'
|
||||||
assert_equal %w[lib], @a0_0_1.require_paths
|
assert_equal %w[lib], @a1.require_paths
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_requirements
|
def test_requirements
|
||||||
assert_equal ['A working computer'], @a0_0_1.requirements
|
assert_equal ['A working computer'], @a1.requirements
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_spaceship_name
|
def test_spaceship_name
|
||||||
|
@ -539,28 +561,22 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_summary
|
def test_summary
|
||||||
assert_equal 'this is a summary', @a0_0_1.summary
|
assert_equal 'this is a summary', @a1.summary
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_test_files
|
def test_test_files
|
||||||
@a0_0_1.test_file = 'test/suite.rb'
|
@a1.test_file = 'test/suite.rb'
|
||||||
assert_equal ['test/suite.rb'], @a0_0_1.test_files
|
assert_equal ['test/suite.rb'], @a1.test_files
|
||||||
end
|
|
||||||
|
|
||||||
def test_test_suite_file
|
|
||||||
@a0_0_2.test_suite_file = 'test/suite.rb'
|
|
||||||
assert_equal ['test/suite.rb'], @a0_0_2.test_files
|
|
||||||
# XXX: what about the warning?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_to_ruby
|
def test_to_ruby
|
||||||
@a0_0_2.required_rubygems_version = Gem::Requirement.new '> 0'
|
@a2.required_rubygems_version = Gem::Requirement.new '> 0'
|
||||||
|
|
||||||
ruby_code = @a0_0_2.to_ruby
|
ruby_code = @a2.to_ruby
|
||||||
|
|
||||||
expected = "Gem::Specification.new do |s|
|
expected = "Gem::Specification.new do |s|
|
||||||
s.name = %q{a}
|
s.name = %q{a}
|
||||||
s.version = \"0.0.2\"
|
s.version = \"2\"
|
||||||
|
|
||||||
s.specification_version = #{Gem::Specification::CURRENT_SPECIFICATION_VERSION} if s.respond_to? :specification_version=
|
s.specification_version = #{Gem::Specification::CURRENT_SPECIFICATION_VERSION} if s.respond_to? :specification_version=
|
||||||
|
|
||||||
|
@ -582,17 +598,20 @@ end
|
||||||
|
|
||||||
same_spec = eval ruby_code
|
same_spec = eval ruby_code
|
||||||
|
|
||||||
assert_equal @a0_0_2, same_spec
|
assert_equal @a2, same_spec
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_to_ruby_fancy
|
def test_to_ruby_fancy
|
||||||
@a0_0_1.platform = Gem::Platform::PPC_DARWIN
|
@a1.platform = Gem::Platform.local
|
||||||
ruby_code = @a0_0_1.to_ruby
|
ruby_code = @a1.to_ruby
|
||||||
|
|
||||||
|
local = Gem::Platform.local
|
||||||
|
expected_platform = "[#{local.cpu.inspect}, #{local.os.inspect}, #{local.version.inspect}]"
|
||||||
|
|
||||||
expected = "Gem::Specification.new do |s|
|
expected = "Gem::Specification.new do |s|
|
||||||
s.name = %q{a}
|
s.name = %q{a}
|
||||||
s.version = \"0.0.1\"
|
s.version = \"1\"
|
||||||
s.platform = Gem::Platform.new([\"ppc\", \"darwin\", nil])
|
s.platform = Gem::Platform.new(#{expected_platform})
|
||||||
|
|
||||||
s.specification_version = 2 if s.respond_to? :specification_version=
|
s.specification_version = 2 if s.respond_to? :specification_version=
|
||||||
|
|
||||||
|
@ -609,6 +628,7 @@ end
|
||||||
s.homepage = %q{http://example.com}
|
s.homepage = %q{http://example.com}
|
||||||
s.require_paths = [\"lib\"]
|
s.require_paths = [\"lib\"]
|
||||||
s.requirements = [\"A working computer\"]
|
s.requirements = [\"A working computer\"]
|
||||||
|
s.rubyforge_project = %q{example}
|
||||||
s.rubygems_version = %q{#{Gem::RubyGemsVersion}}
|
s.rubygems_version = %q{#{Gem::RubyGemsVersion}}
|
||||||
s.summary = %q{this is a summary}
|
s.summary = %q{this is a summary}
|
||||||
s.test_files = [\"test/suite.rb\"]
|
s.test_files = [\"test/suite.rb\"]
|
||||||
|
@ -623,7 +643,7 @@ end
|
||||||
|
|
||||||
same_spec = eval ruby_code
|
same_spec = eval ruby_code
|
||||||
|
|
||||||
assert_equal @a0_0_1, same_spec
|
assert_equal @a1, same_spec
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_to_ruby_legacy
|
def test_to_ruby_legacy
|
||||||
|
@ -635,10 +655,10 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_to_ruby_platform
|
def test_to_ruby_platform
|
||||||
@a0_0_2.platform = Gem::Platform.local
|
@a2.platform = Gem::Platform.local
|
||||||
@a0_0_2.instance_variable_set :@original_platform, 'old_platform'
|
@a2.instance_variable_set :@original_platform, 'old_platform'
|
||||||
|
|
||||||
ruby_code = @a0_0_2.to_ruby
|
ruby_code = @a2.to_ruby
|
||||||
|
|
||||||
same_spec = eval ruby_code
|
same_spec = eval ruby_code
|
||||||
|
|
||||||
|
@ -646,28 +666,34 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_to_yaml
|
def test_to_yaml
|
||||||
yaml_str = @a0_0_1.to_yaml
|
yaml_str = @a1.to_yaml
|
||||||
same_spec = YAML.load(yaml_str)
|
same_spec = YAML.load(yaml_str)
|
||||||
|
|
||||||
assert_equal @a0_0_1, same_spec
|
assert_equal @a1, same_spec
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_to_yaml_fancy
|
def test_to_yaml_fancy
|
||||||
@a0_0_1.platform = Gem::Platform::PPC_DARWIN
|
@a1.platform = Gem::Platform.local
|
||||||
yaml_str = @a0_0_1.to_yaml
|
yaml_str = @a1.to_yaml
|
||||||
|
|
||||||
same_spec = YAML.load(yaml_str)
|
same_spec = YAML.load(yaml_str)
|
||||||
|
|
||||||
assert_equal Gem::Platform::PPC_DARWIN, same_spec.platform
|
assert_equal Gem::Platform.local, same_spec.platform
|
||||||
|
|
||||||
assert_equal @a0_0_1, same_spec
|
assert_equal @a1, same_spec
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_to_yaml_legacy_platform
|
def test_to_yaml_platform_empty_string
|
||||||
@a0_0_1.platform = 'powerpc-darwin7.9.0'
|
@a1.instance_variable_set :@original_platform, ''
|
||||||
@a0_0_1.instance_variable_set :@original_platform, 'powerpc-darwin7.9.0'
|
|
||||||
|
|
||||||
yaml_str = @a0_0_1.to_yaml
|
assert_match %r|^platform: ruby$|, @a1.to_yaml
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_to_yaml_platform_legacy
|
||||||
|
@a1.platform = 'powerpc-darwin7.9.0'
|
||||||
|
@a1.instance_variable_set :@original_platform, 'powerpc-darwin7.9.0'
|
||||||
|
|
||||||
|
yaml_str = @a1.to_yaml
|
||||||
|
|
||||||
same_spec = YAML.load(yaml_str)
|
same_spec = YAML.load(yaml_str)
|
||||||
|
|
||||||
|
@ -675,8 +701,61 @@ end
|
||||||
assert_equal 'powerpc-darwin7.9.0', same_spec.original_platform
|
assert_equal 'powerpc-darwin7.9.0', same_spec.original_platform
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_to_yaml_platform_nil
|
||||||
|
@a1.instance_variable_set :@original_platform, nil
|
||||||
|
|
||||||
|
assert_match %r|^platform: ruby$|, @a1.to_yaml
|
||||||
|
end
|
||||||
|
|
||||||
def test_validate
|
def test_validate
|
||||||
assert @a0_0_1.validate
|
Dir.chdir @tempdir do
|
||||||
|
assert @a1.validate
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_validate_authors
|
||||||
|
Dir.chdir @tempdir do
|
||||||
|
@a1.authors = []
|
||||||
|
|
||||||
|
use_ui @ui do
|
||||||
|
@a1.validate
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal "WARNING: no author specified\n", @ui.error, 'error'
|
||||||
|
|
||||||
|
@a1.authors = [Object.new]
|
||||||
|
|
||||||
|
e = assert_raise Gem::InvalidSpecificationException do
|
||||||
|
@a1.validate
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal 'authors must be Array of Strings', e.message
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_validate_autorequire
|
||||||
|
Dir.chdir @tempdir do
|
||||||
|
@a1.autorequire = 'code'
|
||||||
|
|
||||||
|
use_ui @ui do
|
||||||
|
@a1.validate
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal "WARNING: deprecated autorequire specified\n",
|
||||||
|
@ui.error, 'error'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_validate_email
|
||||||
|
Dir.chdir @tempdir do
|
||||||
|
@a1.email = ''
|
||||||
|
|
||||||
|
use_ui @ui do
|
||||||
|
@a1.validate
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal "WARNING: no email specified\n", @ui.error, 'error'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_validate_empty
|
def test_validate_empty
|
||||||
|
@ -687,51 +766,104 @@ end
|
||||||
assert_equal 'missing value for attribute name', e.message
|
assert_equal 'missing value for attribute name', e.message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_validate_executables
|
||||||
|
FileUtils.mkdir_p File.join(@tempdir, 'bin')
|
||||||
|
File.open File.join(@tempdir, 'bin', 'exec'), 'w' do end
|
||||||
|
|
||||||
|
use_ui @ui do
|
||||||
|
Dir.chdir @tempdir do
|
||||||
|
assert @a1.validate
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal '', @ui.output, 'output'
|
||||||
|
assert_equal "WARNING: bin/exec is missing #! line\n", @ui.error, 'error'
|
||||||
|
end
|
||||||
|
|
||||||
def test_validate_empty_require_paths
|
def test_validate_empty_require_paths
|
||||||
@a0_0_1.require_paths = []
|
@a1.require_paths = []
|
||||||
e = assert_raise Gem::InvalidSpecificationException do
|
e = assert_raise Gem::InvalidSpecificationException do
|
||||||
@a0_0_1.validate
|
@a1.validate
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal 'specification must have at least one require_path', e.message
|
assert_equal 'specification must have at least one require_path', e.message
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_validate_platform_bad
|
def test_validate_homepage
|
||||||
@a0_0_1.platform = Object.new
|
Dir.chdir @tempdir do
|
||||||
assert_raise Gem::InvalidSpecificationException do @a0_0_1.validate end
|
@a1.homepage = ''
|
||||||
|
|
||||||
@a0_0_1.platform = "my-custom-platform"
|
use_ui @ui do
|
||||||
e = assert_raise Gem::InvalidSpecificationException do
|
@a1.validate
|
||||||
@a0_0_1.validate
|
end
|
||||||
|
|
||||||
|
assert_equal "WARNING: no homepage specified\n", @ui.error, 'error'
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
assert_equal 'invalid platform "my-custom-platform", see Gem::Platform',
|
def test_validate_has_rdoc
|
||||||
e.message
|
Dir.chdir @tempdir do
|
||||||
|
@a1.has_rdoc = false
|
||||||
|
|
||||||
|
use_ui @ui do
|
||||||
|
@a1.validate
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal "WARNING: RDoc will not be generated (has_rdoc == false)\n",
|
||||||
|
@ui.error, 'error'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_validate_platform_legacy
|
def test_validate_platform_legacy
|
||||||
@a0_0_1.platform = Gem::Platform::WIN32
|
Dir.chdir @tempdir do
|
||||||
assert @a0_0_1.validate
|
@a1.platform = 'mswin32'
|
||||||
|
assert @a1.validate
|
||||||
|
|
||||||
@a0_0_1.platform = Gem::Platform::LINUX_586
|
@a1.platform = 'i586-linux'
|
||||||
assert @a0_0_1.validate
|
assert @a1.validate
|
||||||
|
|
||||||
@a0_0_1.platform = Gem::Platform::DARWIN
|
@a1.platform = 'powerpc-darwin'
|
||||||
assert @a0_0_1.validate
|
assert @a1.validate
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_validate_rubyforge_project
|
||||||
|
Dir.chdir @tempdir do
|
||||||
|
@a1.rubyforge_project = ''
|
||||||
|
|
||||||
|
use_ui @ui do
|
||||||
|
@a1.validate
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal "WARNING: no rubyforge_project specified\n",
|
||||||
|
@ui.error, 'error'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_validate_rubygems_version
|
def test_validate_rubygems_version
|
||||||
@a0_0_1.rubygems_version = "3"
|
@a1.rubygems_version = "3"
|
||||||
e = assert_raise Gem::InvalidSpecificationException do
|
e = assert_raise Gem::InvalidSpecificationException do
|
||||||
@a0_0_1.validate
|
@a1.validate
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal "expected RubyGems version #{Gem::RubyGemsVersion}, was 3",
|
assert_equal "expected RubyGems version #{Gem::RubyGemsVersion}, was 3",
|
||||||
e.message
|
e.message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_validate_summary
|
||||||
|
Dir.chdir @tempdir do
|
||||||
|
@a1.summary = ''
|
||||||
|
|
||||||
|
use_ui @ui do
|
||||||
|
@a1.validate
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal "WARNING: no summary specified\n", @ui.error, 'error'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_version
|
def test_version
|
||||||
assert_equal Gem::Version.new('0.0.1'), @a0_0_1.version
|
assert_equal Gem::Version.new('1'), @a1.version
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -55,6 +55,11 @@ class TestGemVersion < RubyGemTestCase
|
||||||
assert_inadequate( "1.0.0.1", "= 1.0")
|
assert_inadequate( "1.0.0.1", "= 1.0")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_bump_trailing_zeros
|
||||||
|
v = Gem::Version.new("5.0.0")
|
||||||
|
assert_equal "5.1", v.bump.to_s
|
||||||
|
end
|
||||||
|
|
||||||
def test_bump
|
def test_bump
|
||||||
v = Gem::Version.new("5.2.4")
|
v = Gem::Version.new("5.2.4")
|
||||||
assert_equal "5.3", v.bump.to_s
|
assert_equal "5.3", v.bump.to_s
|
||||||
|
@ -65,6 +70,16 @@ class TestGemVersion < RubyGemTestCase
|
||||||
assert_equal "6", v.bump.to_s
|
assert_equal "6", v.bump.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_eql_eh
|
||||||
|
v = Gem::Version.new("1.2")
|
||||||
|
|
||||||
|
assert_equal true, v.eql?(@v1_2)
|
||||||
|
assert_equal true, @v1_2.eql?(v)
|
||||||
|
|
||||||
|
assert_equal false, @v1_2.eql?(@v1_3)
|
||||||
|
assert_equal false, @v1_3.eql?(@v1_2)
|
||||||
|
end
|
||||||
|
|
||||||
def test_equals2
|
def test_equals2
|
||||||
v = Gem::Version.new("1.2")
|
v = Gem::Version.new("1.2")
|
||||||
|
|
||||||
|
|
|
@ -25,39 +25,39 @@ class TestKernel < RubyGemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_gem
|
def test_gem
|
||||||
assert gem('a', '= 0.0.1'), "Should load"
|
assert gem('a', '= 1'), "Should load"
|
||||||
assert $:.any? { |p| %r{a-0.0.1/lib} =~ p }
|
assert $:.any? { |p| %r{a-1/lib} =~ p }
|
||||||
assert $:.any? { |p| %r{a-0.0.1/bin} =~ p }
|
assert $:.any? { |p| %r{a-1/bin} =~ p }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_gem_redundent
|
def test_gem_redundent
|
||||||
assert gem('a', '= 0.0.1'), "Should load"
|
assert gem('a', '= 1'), "Should load"
|
||||||
assert ! gem('a', '= 0.0.1'), "Should not load"
|
assert ! gem('a', '= 1'), "Should not load"
|
||||||
assert_equal 1, $:.select { |p| %r{a-0.0.1/lib} =~ p }.size
|
assert_equal 1, $:.select { |p| %r{a-1/lib} =~ p }.size
|
||||||
assert_equal 1, $:.select { |p| %r{a-0.0.1/bin} =~ p }.size
|
assert_equal 1, $:.select { |p| %r{a-1/bin} =~ p }.size
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_gem_overlapping
|
def test_gem_overlapping
|
||||||
assert gem('a', '= 0.0.1'), "Should load"
|
assert gem('a', '= 1'), "Should load"
|
||||||
assert ! gem('a', '>= 0.0.1'), "Should not load"
|
assert ! gem('a', '>= 1'), "Should not load"
|
||||||
assert_equal 1, $:.select { |p| %r{a-0.0.1/lib} =~ p }.size
|
assert_equal 1, $:.select { |p| %r{a-1/lib} =~ p }.size
|
||||||
assert_equal 1, $:.select { |p| %r{a-0.0.1/bin} =~ p }.size
|
assert_equal 1, $:.select { |p| %r{a-1/bin} =~ p }.size
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_gem_conflicting
|
def test_gem_conflicting
|
||||||
assert gem('a', '= 0.0.1'), "Should load"
|
assert gem('a', '= 1'), "Should load"
|
||||||
|
|
||||||
ex = assert_raise Gem::Exception do
|
ex = assert_raise Gem::Exception do
|
||||||
gem 'a', '= 0.0.2'
|
gem 'a', '= 2'
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_match(/activate a \(= 0\.0\.2\)/, ex.message)
|
assert_match(/activate a \(= 2\)/, ex.message)
|
||||||
assert_match(/activated a-0\.0\.1/, ex.message)
|
assert_match(/activated a-1/, ex.message)
|
||||||
|
|
||||||
assert $:.any? { |p| %r{a-0.0.1/lib} =~ p }
|
assert $:.any? { |p| %r{a-1/lib} =~ p }
|
||||||
assert $:.any? { |p| %r{a-0.0.1/bin} =~ p }
|
assert $:.any? { |p| %r{a-1/bin} =~ p }
|
||||||
assert ! $:.any? { |p| %r{a-0.0.2/lib} =~ p }
|
assert ! $:.any? { |p| %r{a-2/lib} =~ p }
|
||||||
assert ! $:.any? { |p| %r{a-0.0.2/bin} =~ p }
|
assert ! $:.any? { |p| %r{a-2/bin} =~ p }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue