diff options
34 files changed, 6649 insertions, 135 deletions
@@ -1,4 +1,6 @@ -Tue Dec 8 16:16:47 2009 Nobuyoshi Nakada <[email protected]> * lib/rubygems/defaults.rb (Gem::default_dir): removed a clause doing nothing. @@ -0,0 +1,5529 @@ @@ -0,0 +1,799 @@ @@ -0,0 +1,53 @@ @@ -0,0 +1,40 @@ @@ -5,13 +5,14 @@ # See LICENSE.txt for permissions. #++ -require 'rubygems/rubygems_version' require 'rubygems/defaults' require 'thread' require 'etc' module Gem ## # Raised when RubyGems is unable to load or activate a gem. Contains the # name and version requirements of the gem that either conflicts with @@ -381,7 +382,7 @@ module Gem raise Gem::Exception, msg end - File.join(spec.full_gem_path, spec.bindir, exec_name).sub(/.*\s.*/m, '"\&"') end ## @@ -49,7 +49,7 @@ class Gem::Command def self.build_args @build_args ||= [] end - def self.build_args=(value) @build_args = value end @@ -197,7 +197,7 @@ class Gem::Command # def usage # "#{program_name} FILE [FILE ...]" # end - # # def arguments # "FILE name of file to find" # end @@ -88,6 +88,8 @@ By default, this RubyGems will install gem as: end def execute install_destdir = options[:destdir] unless install_destdir.empty? then @@ -113,21 +115,29 @@ By default, this RubyGems will install gem as: remove_source_caches install_destdir install_rdoc say - say "-" * 78 - say - release_notes = File.join Dir.pwd, 'doc', 'release_notes', - "rel_#{Gem::RubyGemsVersion.gsub '.', '_'}.rdoc" - if File.exist? release_notes then - say File.read(release_notes) - else - say "Oh-no! Unable to find release notes!" - say "Looked in: #{release_notes}" if Gem.configuration.really_verbose - end say say "-" * 78 @@ -145,7 +155,7 @@ By default, this RubyGems will install gem as: end def install_executables(bin_dir) - say "Installing gem executable" @bin_file_names = [] @@ -203,7 +213,7 @@ TEXT end def install_lib(lib_dir) - say "Installing RubyGems" Dir.chdir 'lib' do lib_files = Dir[File.join('**', '*rb')] @@ -226,23 +236,23 @@ TEXT if File.writable? gem_doc_dir and (not File.exist? rubygems_doc_dir or File.writable? rubygems_doc_dir) then - say "Removing old RubyGems RDoc and ri" Dir[File.join(Gem.dir, 'doc', 'rubygems-[0-9]*')].each do |dir| rm_rf dir end if options[:ri] then ri_dir = File.join rubygems_doc_dir, 'ri' - say "Installing #{rubygems_name} ri into #{ri_dir}" run_rdoc '--ri', '--op', ri_dir end if options[:rdoc] then rdoc_dir = File.join rubygems_doc_dir, 'rdoc' - say "Installing #{rubygems_name} rdoc into #{rdoc_dir}" run_rdoc '--op', rdoc_dir end - else say "Skipping RDoc generation, #{gem_doc_dir} not writable" say "Set the GEM_HOME environment variable if you want RDoc generated" end @@ -327,7 +337,7 @@ abort "#{deprecation_message}" system_cache_file = File.join(install_destdir, Gem::SourceInfoCache.system_cache_file) - say "Removing old source_cache files" rm_f user_cache_file if File.writable? File.dirname(user_cache_file) rm_f system_cache_file if File.writable? File.dirname(system_cache_file) end @@ -29,7 +29,7 @@ class Gem::Format end ## - # Reads the named gem file and returns a Format object, representing # the data from the gem file # # file_path:: [String] Path to the gem file @@ -141,7 +141,7 @@ class Gem::Indexer "Complete" Gem.time 'Generated YAML quick index gemspecs' do - index.each do |original_name, spec| spec_file_name = "#{original_name}.gemspec.rz" yaml_name = File.join @quick_dir, spec_file_name @@ -221,7 +221,7 @@ class Gem::Indexer files = [] Gem.time 'Generated Marshal quick index gemspecs' do - (index.gems.merge(index.prerelease_gems)).each do |original_name, spec| spec_file_name = "#{original_name}.gemspec.rz" marshal_name = File.join @quick_marshal_dir, spec_file_name @@ -275,7 +275,7 @@ class Gem::Indexer # Builds indicies for RubyGems 1.2 and newer. Handles full, latest, prerelease def build_modern_indicies(index) - build_modern_index(index.sort, @specs_index, 'specs') build_modern_index(index.latest_specs.sort, @latest_specs_index, 'latest specs') @@ -534,7 +534,7 @@ class Gem::Indexer FileUtils.rm_rf @directory end - ## # Zlib::GzipWriter wrapper that gzips +filename+ on disk. def gzip(filename) @@ -654,8 +654,8 @@ class Gem::Indexer files = build_marshal_gemspecs index Gem.time 'Updated indexes' do - update_specs_index index, @dest_specs_index, @specs_index - update_specs_index index, @dest_latest_specs_index, @latest_specs_index update_specs_index(index.prerelease_gems, @dest_prerelease_specs_index, @prerelease_specs_index) end @@ -41,7 +41,7 @@ require 'rake/packagetask' # # require 'rubygems' # require 'rubygems/package_task' -# # spec = Gem::Specification.new do |s| # s.platform = Gem::Platform::RUBY # s.summary = "Ruby based make-like utility." @@ -56,7 +56,7 @@ require 'rake/packagetask' # and dependencies are specified in standard Ruby syntax. # EOF # end -# # Gem::PackageTask.new(spec) do |pkg| # pkg.need_zip = true # pkg.need_tar = true @@ -103,7 +103,7 @@ class Gem::Platform def to_s to_a.compact.join '-' end - def empty? to_s.empty? end @@ -218,7 +218,7 @@ require 'rubygems/gem_openssl' # # # signing key (still kept in an undisclosed location!) # s.signing_key = '/mnt/floppy/alf-private_key.pem' -# # # certificate chain (includes the issuer certificate now too) # s.cert_chain = ['/home/alf/doc/seattlerb-public_cert.pem', # '/home/alf/doc/alf_at_seattle-public_cert.pem'] @@ -274,7 +274,7 @@ require 'rubygems/gem_openssl' # # convert a PEM format X509 certificate into DER format: # # (note: Windows .cer files are X509 certificates in DER format) # $ openssl x509 -in input.pem -outform der -out output.der -# # # print out the certificate in a human-readable format: # $ openssl x509 -in input.pem -noout -text # @@ -282,7 +282,7 @@ require 'rubygems/gem_openssl' # # # convert a PEM format RSA key into DER format: # $ openssl rsa -in input_key.pem -outform der -out output_key.der -# # # print out the key in a human readable format: # $ openssl rsa -in input_key.pem -noout -text # @@ -30,7 +30,7 @@ class Gem::SourceIndex include Gem::UserInteraction - attr_reader :gems, :prerelease_gems # :nodoc: ## # Directories to use to refresh this SourceIndex when calling refresh! @@ -122,16 +122,22 @@ class Gem::SourceIndex # #prerelease_gems def initialize(specifications={}) - @gems, @prerelease_gems = [{}, {}] specifications.each{ |full_name, spec| add_spec spec } @spec_dirs = nil end - ## - # Both regular and prerelease gems - def all_gems - @gems.merge @prerelease_gems end ## @@ -153,8 +159,8 @@ class Gem::SourceIndex end ## - # Returns an Array specifications for the latest versions of each gem in - # this index. def latest_specs result = Hash.new { |h,k| h[k] = [] } @@ -165,6 +171,7 @@ class Gem::SourceIndex curr_ver = spec.version prev_ver = latest.key?(name) ? latest[name].version : nil next unless prev_ver.nil? or curr_ver >= prev_ver or latest[name].platform != Gem::Platform::RUBY @@ -192,7 +199,14 @@ class Gem::SourceIndex # An array including only the prerelease gemspecs def prerelease_specs - @prerelease_gems.values end ## @@ -201,11 +215,7 @@ class Gem::SourceIndex def add_spec(gem_spec, name = gem_spec.full_name) # No idea why, but the Indexer wants to insert them using original_name # instead of full_name. So we make it an optional arg. - if gem_spec.version.prerelease? - @prerelease_gems[name] = gem_spec - else - @gems[name] = gem_spec - end end ## @@ -221,11 +231,7 @@ class Gem::SourceIndex # Remove a gem specification named +full_name+. def remove_spec(full_name) - if @gems.key? full_name then - @gems.delete full_name - else - @prerelease_gems.delete full_name - end end ## @@ -408,7 +414,7 @@ class Gem::SourceIndex end def ==(other) # :nodoc: - self.class === other and @gems == other.gems end def dump @@ -286,7 +286,7 @@ class Gem::SourceInfoCache next unless Gem.sources.include? source_uri # TODO - Remove this gunk after 2008/11 unless pattern.kind_of?(Gem::Dependency) - pattern = Gem::Dependency.new(pattern, Gem::Requirement.default) end sic_entry.source_index.search pattern, platform_only end.flatten.compact @@ -306,7 +306,7 @@ class Gem::SourceInfoCache # TODO - Remove this gunk after 2008/11 unless pattern.kind_of?(Gem::Dependency) - pattern = Gem::Dependency.new(pattern, Gem::Requirement.default) end sic_entry.source_index.search(pattern, only_platform).each do |spec| @@ -22,7 +22,7 @@ class Gem::SpecFetcher attr_reader :latest_specs # :nodoc: ## - # Cache of all spces attr_reader :specs # :nodoc: @@ -61,8 +61,9 @@ class Gem::SpecFetcher ## # Fetch specs matching +dependency+. If +all+ is true, all matching - # versions are returned. If +matching_platform+ is false, all platforms are - # returned. If +prerelease+ is true, prerelease versions are included. def fetch(dependency, all = false, matching_platform = true, prerelease = false) specs_and_sources = find_matching dependency, all, matching_platform, prerelease @@ -112,9 +113,9 @@ class Gem::SpecFetcher end ## - # Find spec names that match +dependency+. If +all+ is true, all matching - # versions are returned. If +matching_platform+ is false, gems for all - # platforms are returned. def find_matching(dependency, all = false, matching_platform = true, prerelease = false) found = {} @@ -161,7 +162,7 @@ class Gem::SpecFetcher ## # Returns a list of gems available for each source in Gem::sources. If - # +all+ is true, all versions are returned instead of only latest # versions. If +prerelease+ is true, include prerelease versions. def list(all = false, prerelease = false) @@ -183,7 +184,7 @@ class Gem::SpecFetcher cache = { :latest => @latest_specs, :prerelease => @prerelease_specs, :all => @specs }[type] - Gem.sources.each do |source_uri| source_uri = URI.parse source_uri @@ -194,6 +195,12 @@ class Gem::SpecFetcher list[source_uri] = cache[source_uri] end list end @@ -11,9 +11,9 @@ require 'rubygems/remote_fetcher' # @fetcher = Gem::FakeFetcher.new # @fetcher.data['http://gems.example.com/yaml'] = source_index.to_yaml # Gem::RemoteFetcher.fetcher = @fetcher -# # # invoke RubyGems code -# # paths = @fetcher.paths # assert_equal 'http://gems.example.com/yaml', paths.shift # assert paths.empty?, paths.join(', ') @@ -15,7 +15,7 @@ begin Gem.activate('test-unit') rescue Gem::LoadError # Ignore - use the test-unit library that's part of the standard library -end ## # Validator performs various gem file and gem database validation @@ -166,7 +166,7 @@ class Gem::Version def prerelease? parts.any? { |part| part.alpha? } end - ## # The release for this version (e.g. 1.2.0.a -> 1.2.0) # Non-prerelease versions return themselves @@ -35,7 +35,7 @@ class TarTestCase < RubyGemTestCase linkname 100 magic 6 version 2 - uname 32 gname 32 devmajor 8 devminor 8 @@ -54,7 +54,7 @@ class TarTestCase < RubyGemTestCase next end - assert_equal expected[offset, length], actual[offset, length], "Field #{name} of the tar header differs." offset += length @@ -23,7 +23,7 @@ def install_session puts puts "with the appropriate admin privileges." puts "*****************************************************************" - puts exit end gem 'session' @@ -5,10 +5,10 @@ #++ SIMPLE_GEM = <<-GEMDATA - MD5SUM = "e3701f9db765a2358aef94c40ded71c8" if $0 == __FILE__ require 'optparse' - options = {} ARGV.options do |opts| opts.on_tail("--help", "show this message") {puts opts; exit} @@ -19,45 +19,45 @@ end require 'rubygems' - @directory = options[:directory] || Gem.dir @force = options[:force] - - gem = Gem::Installer.new(__FILE__).install(@force, @directory) if options[:gen_rdoc] Gem::DocManager.new(gem).generate_rdoc end end __END__ ---- !ruby/object:Gem::Specification rubygems_version: "1.0" name: testing -version: !ruby/object:Gem::Version version: 1.2.3 date: 2004-03-18 22:01:52.859121 -05:00 -platform: summary: This exercise the gem testing stuff. -require_paths: - lib -files: - lib/foo.rb - lib/test - lib/test.rb - lib/test/wow.rb autorequire: test test_suite_file: foo -requirements: - a computer processor ---- -- size: 109 mode: 420 path: lib/foo.rb -- size: 0 mode: 420 path: lib/test.rb -- size: 15 mode: 420 path: lib/test/wow.rb @@ -78,14 +78,6 @@ class TestGem < RubyGemTestCase end end - def test_self_bin_path_with_spaces - quick_gem 'sp ace', '3' do |s| - s.executables = ['exec'] - end - path = Gem.bin_path('sp ace', 'exec') - assert_equal %w(" "), [path[0,1], path[-1,1]], "Path should be escaped" - end - def test_self_bin_path_not_found assert_raises(Gem::GemNotFoundException) do Gem.bin_path('non-existent') @@ -449,7 +441,7 @@ class TestGem < RubyGemTestCase def test_self_refresh util_make_gems - a1_spec = File.join @gemhome, "specifications", "#{@a1.full_name}.gemspec" FileUtils.mv a1_spec, @tempdir @@ -43,6 +43,8 @@ Gem a-1 Gem a-2 Gem a_evil-9 Gem b-2 @@ -100,6 +102,8 @@ Gem a-1 Gem a-2 Gem a_evil-9 Gem b-2 @@ -57,5 +57,25 @@ class TestGemCommandsUninstallCommand < GemInstallerTestCase assert_empty output, "UI output should be empty after an uninstall error" end end @@ -18,7 +18,7 @@ class TestGemDocManager < RubyGemTestCase def test_uninstall_doc_unwritable orig_mode = File.stat(@spec.installation_path).mode - # File.chmod has no effect on MS Windows directories (it needs ACL). if win_platform? skip("test_uninstall_doc_unwritable skipped on MS Windows") @@ -9,7 +9,7 @@ require_relative 'gemutilities' require 'rubygems/indexer' unless ''.respond_to? :to_xs then - warn "Gem::Indexer tests are being skipped. Install builder gem." end class TestGemIndexer < RubyGemTestCase @@ -118,10 +118,13 @@ class TestGemIndexer < RubyGemTestCase expected = <<-EOF a-1 a-2 a_evil-9 b-2 c-1.2 d-2.0 pl-1-i386-linux EOF @@ -163,13 +166,13 @@ pl-1-i386-linux assert_indexed @tempdir, "latest_specs.#{@marshal_version}.gz" expected = <<-EOF -<?xml version="1.0"?> -<rss version="2.0"> <channel> <title>ExampleForge gems</title> <link>http://example.com</link> <description>Recently released gems from http://example.com</description> - <generator>RubyGems v#{Gem::RubyGemsVersion}</generator> <docs>http://cyber.law.harvard.edu/rss/rss.html</docs> <item> <title>a-2</title> @@ -178,9 +181,21 @@ pl-1-i386-linux </description> <author>[email protected] (A User)</author> <guid>a-2</guid> - <enclosure url="http://gems.example.com/gems/a-2.gem" - length="3072" type="application/octet-stream" /> - <pubDate>#{Gem::Specification::TODAY.rfc2822}</pubDate> <link>http://example.com</link> </item> <item> @@ -190,9 +205,9 @@ pl-1-i386-linux </description> <author>[email protected] (A User)</author> <guid>a_evil-9</guid> - <enclosure url="http://gems.example.com/gems/a_evil-9.gem" - length="3072" type="application/octet-stream" /> - <pubDate>#{Gem::Specification::TODAY.rfc2822}</pubDate> <link>http://example.com</link> </item> <item> @@ -202,9 +217,9 @@ pl-1-i386-linux </description> <author>[email protected] (A User)</author> <guid>b-2</guid> - <enclosure url="http://gems.example.com/gems/b-2.gem" - length="3072" type="application/octet-stream" /> - <pubDate>#{Gem::Specification::TODAY.rfc2822}</pubDate> <link>http://example.com</link> </item> <item> @@ -214,9 +229,33 @@ pl-1-i386-linux </description> <author>[email protected] (A User)</author> <guid>c-1.2</guid> - <enclosure url="http://gems.example.com/gems/c-1.2.gem" - length="3072" type="application/octet-stream" /> - <pubDate>#{Gem::Specification::TODAY.rfc2822}</pubDate> <link>http://example.com</link> </item> <item> @@ -226,9 +265,9 @@ pl-1-i386-linux </description> <author>[email protected] (A User)</author> <guid>pl-1-x86-linux</guid> - <enclosure url="http://gems.example.com/gems/pl-1-x86-linux.gem" - length="3072" type="application/octet-stream" /> - <pubDate>#{Gem::Specification::TODAY.rfc2822}</pubDate> <link>http://example.com</link> </item> <item> @@ -247,9 +286,9 @@ eighty characters.</pre> </description> <author>[email protected] (Example), [email protected] (Example2)</author> <guid>a-1</guid> - <enclosure url="http://gems.example.com/gems/a-1.gem" - length="3584" type="application/octet-stream" /> - <pubDate>#{(Gem::Specification::TODAY - 86400).rfc2822}</pubDate> <link>http://a.example.com</link> </item> </channel> @@ -462,9 +501,9 @@ eighty characters.</pre> @ui.output assert_match %r%^\.\.\.\.\.\.\.\.\.\.$%, @ui.output assert_match %r%^Loaded all gems$%, @ui.output - assert_match %r%^Generating Marshal quick index gemspecs for 7 gems$%, @ui.output - assert_match %r%^Generating YAML quick index gemspecs for 7 gems$%, @ui.output assert_match %r%^Complete$%, @ui.output assert_match %r%^Generating specs index$%, @ui.output @@ -473,7 +512,7 @@ eighty characters.</pre> assert_match %r%^Generating latest index$%, @ui.output assert_match %r%^Generating prerelease specs index$%, @ui.output assert_match %r%^Generating Marshal master index$%, @ui.output - assert_match %r%^Generating YAML master index for 7 gems \(this may take a while\)$%, @ui.output assert_match %r%^Complete$%, @ui.output assert_match %r%^Compressing indicies$%, @ui.output @@ -47,7 +47,7 @@ class TestGemPackageTarInput < TarTestCase meta = @spec.to_yaml f.write tar_file_header("metadata", "", 0644, meta.size) - f.write meta + "\0" * (1024 - meta.size) f.write "\0" * 1024 end @@ -45,7 +45,7 @@ class TestTarWriter < TarTestCase def test_add_file_simple_padding @tar_writer.add_file_simple 'x', 0, 100 - assert_headers_equal tar_file_header('x', '', 0, 100), @io.string[0, 512] assert_equal "\0" * 512, @io.string[512, 512] @@ -60,7 +60,7 @@ class TestTarWriter < TarTestCase end def test_add_file_simple_size - assert_raises Gem::Package::TarWriter::FileOverflow do @tar_writer.add_file_simple("lib/foo/bar", 0, 10) do |io| io.write "1" * 11 end @@ -68,7 +68,7 @@ class TestTarWriter < TarTestCase end def test_add_file_unseekable - assert_raises Gem::Package::NonSeekableIO do Gem::Package::TarWriter.new(Object.new).add_file 'x', 0 end end @@ -335,14 +335,12 @@ WARNING: Invalid .gemspec format in '#{spec_file}' @source_index.add_spec gem_a1_alpha refute @source_index.latest_specs.include?(gem_a1_alpha) - assert_nil @source_index.specification(gem_a1_alpha.full_name) assert @source_index.prerelease_specs.include?(gem_a1_alpha) - - # TODO: don't think this tests writing prerelease index to disk end def test_refresh_bang - a1_spec = File.join @gemhome, "specifications", "#{@a1.full_name}.gemspec" FileUtils.mv a1_spec, @tempdir @@ -45,6 +45,8 @@ class TestGemSpecFetcher < RubyGemTestCase util_zip(Marshal.dump(@a2)) @fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a_pre.full_name}.gemspec.rz"] = util_zip(Marshal.dump(@a_pre)) dep = Gem::Dependency.new 'a', 1 specs_and_sources = @sf.fetch dep, true @@ -273,7 +275,12 @@ RubyGems will revert to legacy indexes degrading performance. assert_equal [@uri], specs.keys - assert_equal @specs, specs[@uri].sort end def test_list_cache @@ -307,7 +314,12 @@ RubyGems will revert to legacy indexes degrading performance. specs = @sf.list true - assert_equal [@specs], specs.values, 'specs file not loaded' end def test_list_prerelease @@ -320,8 +332,10 @@ RubyGems will revert to legacy indexes degrading performance. specs = @sf.load_specs @uri, 'specs' expected = [ ['a', Gem::Version.new(1), Gem::Platform::RUBY], ['a', Gem::Version.new(2), Gem::Platform::RUBY], ['a_evil', Gem::Version.new(9), Gem::Platform::RUBY], ['c', Gem::Version.new('1.2'), Gem::Platform::RUBY], ['pl', Gem::Version.new(1), 'i386-linux'], @@ -566,7 +566,7 @@ end 'i386-mswin32_80' => 'a-1-x86-mswin32-80', 'i386-mingw32' => 'a-1-x86-mingw32' } - test_cases.each do |arch, expected| util_set_arch arch @a1.platform = 'current' @@ -199,7 +199,7 @@ class TestGemVersion < RubyGemTestCase refute Gem::Version.new('2.9').prerelease? refute Gem::Version.new('22.1.50.0').prerelease? end - def test_release assert_equal Gem::Version.new('1.2.0'), Gem::Version.new('1.2.0.a').release assert_equal Gem::Version.new('1.1'), Gem::Version.new('1.1.rc10').release @@ -219,7 +219,7 @@ class TestGemVersion < RubyGemTestCase assert_adequate( "1.4.5", "~> 1.4.4") assert_inadequate("1.5", "~> 1.4.4") assert_inadequate("2.0", "~> 1.4.4") - assert_inadequate("1.1.pre", "~> 1.0.0") assert_adequate( "1.1.pre", "~> 1.1") assert_inadequate("2.0.a", "~> 1.0") |