Skip to content

Commit

Permalink
Import RubyGems 1.0.0, r1575
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
drbrain committed Dec 20, 2007
1 parent 40d8543 commit 8289771
Show file tree
Hide file tree
Showing 47 changed files with 1,153 additions and 993 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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>

* proc.c: support Proc#binding.
Expand Down
13 changes: 10 additions & 3 deletions gem_prelude.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def push_all_highest_version_gems_on_load_path
Dir.entries(gems_directory).each do |gem_directory_name|
next if gem_directory_name == "." || gem_directory_name == ".."
dash = gem_directory_name.rindex("-")
next if dash.nil?
gem_name = gem_directory_name[0...dash]
current_version = GemVersions[gem_name]
new_version = calculate_integers_for_gem_version(gem_directory_name[dash+1..-1])
Expand Down Expand Up @@ -167,16 +168,22 @@ def const_missing(constant)

def method_missing(method, *args, &block)
QuickLoader.load_full_rubygems_library
super unless Gem.respond_to?(method)
Gem.send(method, *args, &block)
end
end

extend QuickLoader

end

Gem.push_all_highest_version_gems_on_load_path
$".unshift File.join(Gem::ConfigMap[:libdir], "ruby", Gem::ConfigMap[:ruby_version], "rubygems.rb")
begin
Gem.push_all_highest_version_gems_on_load_path
$".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"
end # Gem::Enable
48 changes: 12 additions & 36 deletions lib/rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#++

require 'rubygems/rubygems_version'
require 'rubygems/defaults'
require 'thread'

module Gem
Expand All @@ -29,8 +30,8 @@ module Kernel
# version).
#
# 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
# haven't been intsalled yet. Example:
# load specified gems. You might do this to test out changes that
# haven't been installed yet. Example:
#
# GEM_SKIP=libA:libB ruby-I../libA -I../libB ./mycode.rb
#
Expand All @@ -49,17 +50,6 @@ def gem(gem_name, *version_requirements)
active_gem_with_options(gem_name, version_requirements)
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
# the caller of this method.
def location_of_caller
Expand All @@ -84,15 +74,17 @@ module Gem
ConfigMap = {} unless defined?(ConfigMap)
require 'rbconfig'
ConfigMap.merge!(
:sitedir => RbConfig::CONFIG["sitedir"],
:ruby_version => RbConfig::CONFIG["ruby_version"],
:libdir => RbConfig::CONFIG["libdir"],
:sitelibdir => RbConfig::CONFIG["sitelibdir"],
:arch => RbConfig::CONFIG["arch"],
:bindir => RbConfig::CONFIG["bindir"],
:BASERUBY => RbConfig::CONFIG["BASERUBY"],
:EXEEXT => RbConfig::CONFIG["EXEEXT"],
:RUBY_INSTALL_NAME => RbConfig::CONFIG["RUBY_INSTALL_NAME"],
:RUBY_SO_NAME => RbConfig::CONFIG["RUBY_SO_NAME"],
:ruby_install_name => RbConfig::CONFIG["ruby_install_name"]
:arch => RbConfig::CONFIG["arch"],
:bindir => RbConfig::CONFIG["bindir"],
:libdir => RbConfig::CONFIG["libdir"],
: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
Expand Down Expand Up @@ -207,10 +199,6 @@ def sources
@sources
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.
alias cache source_index
Expand Down Expand Up @@ -536,18 +524,6 @@ def find_home
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
Expand Down
2 changes: 2 additions & 0 deletions lib/rubygems/commands/install_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def initialize
:generate_rdoc => true,
:generate_ri => true,
:install_dir => Gem.dir,
:format_executable => false,
:test => false,
:version => Gem::Requirement.default,
})
Expand Down Expand Up @@ -56,6 +57,7 @@ def execute
:env_shebang => options[:env_shebang],
:domain => options[:domain],
:force => options[:force],
:format_executable => options[:format_executable],
:ignore_dependencies => options[:ignore_dependencies],
:install_dir => options[:install_dir],
:security_policy => options[:security_policy],
Expand Down
10 changes: 8 additions & 2 deletions lib/rubygems/commands/mirror_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,16 @@ def execute
if get_from.scheme.nil? then
get_from = get_from.to_s
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

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
open File.join(save_to, "Marshal.#{Gem.marshal_version}"), "wb" do |out|
out.write sourceindex_data
Expand Down
4 changes: 3 additions & 1 deletion lib/rubygems/commands/query_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ def output_query_results(gemspecs)
end

entry = gem_name.dup

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

entry << "\n" << format_text(list_of_matching[0].summary, 68, 4) if
Expand Down
6 changes: 3 additions & 3 deletions lib/rubygems/commands/server_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ def initialize
super 'server', 'Documentation and gem repository HTTP server',
: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|
options[:port] = port
end

add_option '-d', '--dir=GEMDIR',
'directory from which to serve gems' do |gemdir, options|
options[:gemdir] = gemdir
options[:gemdir] = File.expand_path gemdir
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
end
end
Expand Down
15 changes: 11 additions & 4 deletions lib/rubygems/commands/unpack_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ class Gem::Commands::UnpackCommand < Gem::Command

def initialize
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
end

Expand All @@ -32,10 +38,11 @@ def usage # :nodoc:
def execute
gemname = get_one_gem_name
path = get_path(gemname, options[:version])
if path
target_dir = File.basename(path).sub(/\.gem$/, '')
if path then
basename = File.basename(path).sub(/\.gem$/, '')
target_dir = File.expand_path File.join(options[:target], basename)
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}'"
else
alert_error "Gem '#{gemname}' not installed."
Expand Down
Loading

0 comments on commit 8289771

Please sign in to comment.