Permalink
Browse files

Import RubyGems r1641

  • Loading branch information...
1 parent 2529acd commit 488fdfd592e3b4075a974338b48ee4311befb9c2 @drbrain drbrain committed Mar 9, 2008
Showing with 22,372 additions and 0 deletions.
  1. +214 −0 kernel/core/gem_prelude.rb
  2. +23 −0 lib/bin/gem.rb
  3. +24 −0 lib/rbconfig/datadir.rb
  4. +587 −0 lib/rubygems.rb
  5. +88 −0 lib/rubygems/builder.rb
  6. +406 −0 lib/rubygems/command.rb
  7. +144 −0 lib/rubygems/command_manager.rb
  8. +53 −0 lib/rubygems/commands/build_command.rb
  9. +86 −0 lib/rubygems/commands/cert_command.rb
  10. +74 −0 lib/rubygems/commands/check_command.rb
  11. +91 −0 lib/rubygems/commands/cleanup_command.rb
  12. +74 −0 lib/rubygems/commands/contents_command.rb
  13. +150 −0 lib/rubygems/commands/dependency_command.rb
  14. +86 −0 lib/rubygems/commands/environment_command.rb
  15. +60 −0 lib/rubygems/commands/fetch_command.rb
  16. +57 −0 lib/rubygems/commands/generate_index_command.rb
  17. +172 −0 lib/rubygems/commands/help_command.rb
  18. +133 −0 lib/rubygems/commands/install_command.rb
  19. +35 −0 lib/rubygems/commands/list_command.rb
  20. +101 −0 lib/rubygems/commands/lock_command.rb
  21. +111 −0 lib/rubygems/commands/mirror_command.rb
  22. +30 −0 lib/rubygems/commands/outdated_command.rb
  23. +133 −0 lib/rubygems/commands/pristine_command.rb
  24. +120 −0 lib/rubygems/commands/query_command.rb
  25. +78 −0 lib/rubygems/commands/rdoc_command.rb
  26. +37 −0 lib/rubygems/commands/search_command.rb
  27. +48 −0 lib/rubygems/commands/server_command.rb
  28. +115 −0 lib/rubygems/commands/sources_command.rb
  29. +76 −0 lib/rubygems/commands/specification_command.rb
  30. +73 −0 lib/rubygems/commands/uninstall_command.rb
  31. +95 −0 lib/rubygems/commands/unpack_command.rb
  32. +157 −0 lib/rubygems/commands/update_command.rb
  33. +86 −0 lib/rubygems/commands/which_command.rb
  34. +224 −0 lib/rubygems/config_file.rb
  35. +38 −0 lib/rubygems/custom_require.rb
  36. +53 −0 lib/rubygems/defaults.rb
  37. +65 −0 lib/rubygems/dependency.rb
  38. +196 −0 lib/rubygems/dependency_installer.rb
  39. +165 −0 lib/rubygems/dependency_list.rb
  40. +40 −0 lib/rubygems/digest/digest_adapter.rb
  41. +23 −0 lib/rubygems/digest/md5.rb
  42. +17 −0 lib/rubygems/digest/sha1.rb
  43. +17 −0 lib/rubygems/digest/sha2.rb
  44. +161 −0 lib/rubygems/doc_manager.rb
  45. +70 −0 lib/rubygems/exceptions.rb
  46. +18 −0 lib/rubygems/ext.rb
  47. +56 −0 lib/rubygems/ext/builder.rb
  48. +24 −0 lib/rubygems/ext/configure_builder.rb
  49. +23 −0 lib/rubygems/ext/ext_conf_builder.rb
  50. +27 −0 lib/rubygems/ext/rake_builder.rb
  51. +87 −0 lib/rubygems/format.rb
  52. +83 −0 lib/rubygems/gem_openssl.rb
  53. +84 −0 lib/rubygems/gem_path_searcher.rb
  54. +58 −0 lib/rubygems/gem_runner.rb
  55. +163 −0 lib/rubygems/indexer.rb
  56. +80 −0 lib/rubygems/indexer/abstract_index_builder.rb
  57. +17 −0 lib/rubygems/indexer/marshal_index_builder.rb
  58. +53 −0 lib/rubygems/indexer/master_index_builder.rb
  59. +48 −0 lib/rubygems/indexer/quick_index_builder.rb
  60. +100 −0 lib/rubygems/install_update_options.rb
  61. +479 −0 lib/rubygems/installer.rb
  62. +106 −0 lib/rubygems/local_remote_options.rb
  63. +148 −0 lib/rubygems/old_format.rb
  64. +95 −0 lib/rubygems/package.rb
  65. +24 −0 lib/rubygems/package/f_sync_dir.rb
  66. +245 −0 lib/rubygems/package/tar_header.rb
  67. +219 −0 lib/rubygems/package/tar_input.rb
  68. +148 −0 lib/rubygems/package/tar_output.rb
  69. +86 −0 lib/rubygems/package/tar_reader.rb
  70. +99 −0 lib/rubygems/package/tar_reader/entry.rb
  71. +180 −0 lib/rubygems/package/tar_writer.rb
  72. +181 −0 lib/rubygems/platform.rb
  73. +278 −0 lib/rubygems/remote_fetcher.rb
  74. +15 −0 lib/rubygems/require_paths_builder.rb
  75. +157 −0 lib/rubygems/requirement.rb
  76. +6 −0 lib/rubygems/rubygems_version.rb
  77. +786 −0 lib/rubygems/security.rb
  78. +519 −0 lib/rubygems/server.rb
  79. +436 −0 lib/rubygems/source_index.rb
  80. +232 −0 lib/rubygems/source_info_cache.rb
  81. +46 −0 lib/rubygems/source_info_cache_entry.rb
  82. +971 −0 lib/rubygems/specification.rb
  83. +25 −0 lib/rubygems/timer.rb
  84. +207 −0 lib/rubygems/uninstaller.rb
  85. +291 −0 lib/rubygems/user_interaction.rb
  86. +186 −0 lib/rubygems/validator.rb
  87. +165 −0 lib/rubygems/version.rb
  88. +49 −0 lib/rubygems/version_option.rb
  89. +10 −0 lib/ubygems.rb
  90. +8 −0 test/rubygems/bogussources.rb
  91. +27 −0 test/rubygems/data/gem-private_key.pem
  92. +20 −0 test/rubygems/data/gem-public_cert.pem
  93. +7 −0 test/rubygems/fake_certlib/openssl.rb
  94. +95 −0 test/rubygems/functional.rb
  95. +86 −0 test/rubygems/gem_installer_test_case.rb
  96. +146 −0 test/rubygems/gem_package_tar_test_case.rb
  97. +377 −0 test/rubygems/gemutilities.rb
  98. +51 −0 test/rubygems/insure_session.rb
  99. +51 −0 test/rubygems/mockgemui.rb
  100. +27 −0 test/rubygems/private_key.pem
  101. +20 −0 test/rubygems/public_cert.pem
  102. +72 −0 test/rubygems/simple_gem.rb
  103. +26 −0 test/rubygems/test_config.rb
  104. +381 −0 test/rubygems/test_gem.rb
  105. +34 −0 test/rubygems/test_gem_builder.rb
  106. +196 −0 test/rubygems/test_gem_command.rb
  107. +213 −0 test/rubygems/test_gem_command_manager.rb
  108. +75 −0 test/rubygems/test_gem_commands_build_command.rb
  109. +126 −0 test/rubygems/test_gem_commands_cert_command.rb
  110. +25 −0 test/rubygems/test_gem_commands_check_command.rb
  111. +92 −0 test/rubygems/test_gem_commands_contents_command.rb
  112. +108 −0 test/rubygems/test_gem_commands_dependency_command.rb
  113. +133 −0 test/rubygems/test_gem_commands_environment_command.rb
  114. +35 −0 test/rubygems/test_gem_commands_fetch_command.rb
  115. +32 −0 test/rubygems/test_gem_commands_generate_index_command.rb
  116. +167 −0 test/rubygems/test_gem_commands_install_command.rb
  117. +61 −0 test/rubygems/test_gem_commands_mirror_command.rb
  118. +100 −0 test/rubygems/test_gem_commands_pristine_command.rb
  119. +86 −0 test/rubygems/test_gem_commands_query_command.rb
  120. +27 −0 test/rubygems/test_gem_commands_server_command.rb
  121. +146 −0 test/rubygems/test_gem_commands_sources_command.rb
  122. +93 −0 test/rubygems/test_gem_commands_specification_command.rb
  123. +115 −0 test/rubygems/test_gem_commands_unpack_command.rb
  124. +174 −0 test/rubygems/test_gem_commands_update_command.rb
  125. +210 −0 test/rubygems/test_gem_config_file.rb
  126. +89 −0 test/rubygems/test_gem_dependency.rb
  127. +485 −0 test/rubygems/test_gem_dependency_installer.rb
  128. +212 −0 test/rubygems/test_gem_dependency_list.rb
  129. +44 −0 test/rubygems/test_gem_digest.rb
  130. +32 −0 test/rubygems/test_gem_doc_manager.rb
  131. +87 −0 test/rubygems/test_gem_ext_configure_builder.rb
  132. +122 −0 test/rubygems/test_gem_ext_ext_conf_builder.rb
  133. +73 −0 test/rubygems/test_gem_ext_rake_builder.rb
  134. +69 −0 test/rubygems/test_gem_format.rb
  135. +57 −0 test/rubygems/test_gem_gem_path_searcher.rb
  136. +35 −0 test/rubygems/test_gem_gem_runner.rb
  137. +119 −0 test/rubygems/test_gem_indexer.rb
  138. +40 −0 test/rubygems/test_gem_install_update_options.rb
  139. +806 −0 test/rubygems/test_gem_installer.rb
  140. +84 −0 test/rubygems/test_gem_local_remote_options.rb
  141. +40 −0 test/rubygems/test_gem_outdated_command.rb
  142. +138 −0 test/rubygems/test_gem_package_tar_header.rb
  143. +119 −0 test/rubygems/test_gem_package_tar_input.rb
  144. +104 −0 test/rubygems/test_gem_package_tar_output.rb
  145. +53 −0 test/rubygems/test_gem_package_tar_reader.rb
  146. +116 −0 test/rubygems/test_gem_package_tar_reader_entry.rb
  147. +151 −0 test/rubygems/test_gem_package_tar_writer.rb
  148. +259 −0 test/rubygems/test_gem_platform.rb
  149. +606 −0 test/rubygems/test_gem_remote_fetcher.rb
  150. +223 −0 test/rubygems/test_gem_requirement.rb
  151. +115 −0 test/rubygems/test_gem_server.rb
  152. +466 −0 test/rubygems/test_gem_source_index.rb
  153. +294 −0 test/rubygems/test_gem_source_info_cache.rb
  154. +48 −0 test/rubygems/test_gem_source_info_cache_entry.rb
  155. +870 −0 test/rubygems/test_gem_specification.rb
  156. +117 −0 test/rubygems/test_gem_stream_ui.rb
  157. +43 −0 test/rubygems/test_gem_uninstaller.rb
  158. +70 −0 test/rubygems/test_gem_validator.rb
  159. +206 −0 test/rubygems/test_gem_version.rb
  160. +77 −0 test/rubygems/test_gem_version_option.rb
  161. +65 −0 test/rubygems/test_kernel.rb
@@ -0,0 +1,214 @@
+# depends on: array.rb dir.rb env.rb file.rb hash.rb module.rb regexp.rb
+
+# empty gem_prelude.rb
+#
+# p Gem::Enable
+
+if defined?(Gem::Enable) && Gem::Enable then
+
+ module Kernel
+
+ def gem(gem_name, *version_requirements)
+ Gem.push_gem_version_on_load_path(gem_name, *version_requirements)
+ end
+
+ end
+
+ module Gem
+
+ ConfigMap = {
+ :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"],
+ :EXEEXT => RbConfig::CONFIG["EXEEXT"],
+ :RUBY_SO_NAME => RbConfig::CONFIG["RUBY_SO_NAME"],
+ :ruby_install_name => RbConfig::CONFIG["ruby_install_name"]
+ }
+
+ class << self
+
+ def default_dir
+ if defined? RUBY_FRAMEWORK_VERSION
+ return File.join(File.dirname(ConfigMap[:sitedir]), "Gems")
+ else
+ File.join(ConfigMap[:libdir], 'ruby', 'gems', ConfigMap[:ruby_version])
+ end
+ end
+
+ def dir
+ @gem_home ||= nil
+ set_home(ENV['GEM_HOME'] || default_dir) unless @gem_home
+ @gem_home
+ end
+
+ def path
+ @gem_path ||= nil
+ unless @gem_path
+ paths = [ENV['GEM_PATH']]
+ paths << APPLE_GEM_HOME if defined? APPLE_GEM_HOME
+ set_paths(paths.compact.join(File::PATH_SEPARATOR))
+ end
+ @gem_path
+ end
+
+ # Set the Gem home directory (as reported by +dir+).
+ def set_home(home)
+ @gem_home = home
+ ensure_gem_subdirectories(@gem_home)
+ end
+
+ def set_paths(gpaths)
+ if gpaths
+ @gem_path = gpaths.split(File::PATH_SEPARATOR)
+ @gem_path << Gem.dir
+ else
+ @gem_path = [Gem.dir]
+ end
+ @gem_path.uniq!
+ @gem_path.each do |gp| ensure_gem_subdirectories(gp) end
+ end
+
+ def ensure_gem_subdirectories(path)
+ end
+
+ end
+
+ module QuickLoader
+
+ class << self
+ def load_full_rubygems_library
+ class << Gem
+ Gem.methods(false).each do |method_name|
+ undef_method method_name
+ end
+ end
+
+ Kernel.send :undef_method, :gem
+
+ $".delete File.join(Gem::ConfigMap[:libdir], 'ruby',
+ Gem::ConfigMap[:ruby_version], 'rubygems.rb')
+
+ require 'rubygems'
+ end
+ end
+
+ GemPaths = {}
+ GemVersions = {}
+
+ def push_gem_version_on_load_path(gem_name, *version_requirements)
+ if version_requirements.empty?
+ unless GemPaths.has_key?(gem_name)
+ raise LoadError.new("Could not find RubyGem #{gem_name} (>= 0)\n")
+ end
+
+ # highest version gems already active
+ return false
+ else
+ if version_requirements.length > 1
+ QuickLoader.load_full_rubygems_library
+ return gem(gem_name, *version_requirements)
+ end
+
+ requirement, version = version_requirements[0].split
+ requirement.strip!
+
+ if requirement == ">" || requirement == ">="
+ if (GemVersions[gem_name] <=> Gem.calculate_integers_for_gem_version(version)) >= 0
+ return false
+ end
+ elsif requirement == "~>"
+ loaded_version = GemVersions[gem_name]
+ required_version = Gem.calculate_integers_for_gem_version(version)
+ if loaded_version && (loaded_version[0] == required_version[0])
+ return false
+ end
+ end
+
+ QuickLoader.load_full_rubygems_library
+ gem(gem_name, *version_requirements)
+ end
+ end
+
+ def calculate_integers_for_gem_version(gem_version)
+ numbers = gem_version.split(".").collect {|n| n.to_i}
+ numbers.pop while numbers.last == 0
+ numbers << 0 if numbers.empty?
+ numbers
+ end
+
+ def push_all_highest_version_gems_on_load_path
+ Gem.path.each do |path|
+ gems_directory = File.join(path, "gems")
+ if File.exist?(gems_directory)
+ 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])
+ if current_version
+ if (current_version <=> new_version) == -1
+ GemVersions[gem_name] = new_version
+ GemPaths[gem_name] = File.join(gems_directory, gem_directory_name)
+ end
+ else
+ GemVersions[gem_name] = new_version
+ GemPaths[gem_name] = File.join(gems_directory, gem_directory_name)
+ end
+ end
+ end
+ end
+
+ require_paths = []
+
+ GemPaths.values.each do |path|
+ if File.exist?(File.join(path, ".require_paths"))
+ require_paths.concat(File.read(File.join(path, ".require_paths")).split.map {|require_path| File.join(path, require_path)})
+ else
+ require_paths << File.join(path, "bin") if File.exist?(File.join(path, "bin"))
+ require_paths << File.join(path, "lib") if File.exist?(File.join(path, "lib"))
+ end
+ end
+
+ # "tag" the first require_path inserted into the $LOAD_PATH to enable
+ # indexing correctly with rubygems proper when it inserts an explicitly
+ # gem version
+ unless require_paths.empty?
+ require_paths.first.instance_variable_set(:@gem_prelude_index, true)
+ end
+ # gem directories must come after -I and ENV['RUBYLIB']
+ $:[$:.index(ConfigMap[:sitelibdir]),0] = require_paths
+ end
+
+ def const_missing(constant)
+ QuickLoader.load_full_rubygems_library
+ Gem.const_get(constant)
+ end
+
+ 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
+
+ begin
+ Gem.push_all_highest_version_gems_on_load_path
+ $" << 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
+
+end
+
View
@@ -0,0 +1,23 @@
+#!/usr/bin/env ruby
+#--
+# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
+# All rights reserved.
+# See LICENSE.txt for permissions.
+#++
+
+require 'rubygems'
+require 'rubygems/gem_runner'
+
+required_version = Gem::Requirement.new ">= 1.8.3"
+
+unless required_version.satisfied_by? Gem::Version.new(RUBY_VERSION) then
+ abort "Expected Ruby Version #{required_version}, was #{RUBY_VERSION}"
+end
+
+# We need to preserve the original ARGV to use for passing gem options
+# to source gems. If there is a -- in the line, strip all options after
+# it...its for the source building process.
+args = !ARGV.include?("--") ? ARGV.clone : ARGV[0...ARGV.index("--")]
+
+Gem::GemRunner.new.run args
+
@@ -0,0 +1,24 @@
+#!/usr/bin/env ruby
+#--
+# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
+# All rights reserved.
+# See LICENSE.txt for permissions.
+#++
+
+
+module Config
+
+ # Only define datadir if it doesn't already exist.
+ unless Config.respond_to?(:datadir)
+
+ # Return the path to the data directory associated with the given
+ # package name. Normally this is just
+ # "#{Config::CONFIG['datadir']}/#{package_name}", but may be
+ # modified by packages like RubyGems to handle versioned data
+ # directories.
+ def Config.datadir(package_name)
+ File.join(CONFIG['datadir'], package_name)
+ end
+
+ end
+end
Oops, something went wrong. Retry.

0 comments on commit 488fdfd

Please sign in to comment.