rubygems-update 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubygems-update might be problematic. Click here for more details.

Files changed (128) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.autotest +24 -0
  3. data/.document +4 -3
  4. data/ChangeLog +382 -1
  5. data/Manifest.txt +214 -0
  6. data/README +1 -49
  7. data/Rakefile +124 -191
  8. data/bin/gem +1 -4
  9. data/cruise_config.rb +22 -0
  10. data/doc/release_notes/rel_1_3_1.rdoc +3 -3
  11. data/doc/release_notes/rel_1_3_2.rdoc +119 -0
  12. data/lib/gauntlet_rubygems.rb +50 -0
  13. data/lib/rubygems.rb +250 -25
  14. data/lib/rubygems/builder.rb +62 -60
  15. data/lib/rubygems/command.rb +421 -319
  16. data/lib/rubygems/command_manager.rb +153 -125
  17. data/lib/rubygems/commands/check_command.rb +12 -7
  18. data/lib/rubygems/commands/cleanup_command.rb +11 -2
  19. data/lib/rubygems/commands/contents_command.rb +42 -18
  20. data/lib/rubygems/commands/generate_index_command.rb +91 -15
  21. data/lib/rubygems/commands/install_command.rb +33 -47
  22. data/lib/rubygems/commands/query_command.rb +36 -20
  23. data/lib/rubygems/commands/rdoc_command.rb +62 -68
  24. data/lib/rubygems/commands/search_command.rb +26 -32
  25. data/lib/rubygems/commands/setup_command.rb +353 -0
  26. data/lib/rubygems/commands/sources_command.rb +5 -0
  27. data/lib/rubygems/commands/specification_command.rb +23 -3
  28. data/lib/rubygems/commands/uninstall_command.rb +71 -61
  29. data/lib/rubygems/commands/unpack_command.rb +14 -12
  30. data/lib/rubygems/commands/update_command.rb +26 -5
  31. data/lib/rubygems/defaults.rb +16 -3
  32. data/lib/rubygems/dependency.rb +38 -7
  33. data/lib/rubygems/dependency_installer.rb +7 -4
  34. data/lib/rubygems/digest/digest_adapter.rb +42 -33
  35. data/lib/rubygems/digest/sha1.rb +6 -1
  36. data/lib/rubygems/digest/sha2.rb +5 -0
  37. data/lib/rubygems/doc_manager.rb +31 -11
  38. data/lib/rubygems/ext/ext_conf_builder.rb +2 -1
  39. data/lib/rubygems/ext/rake_builder.rb +6 -2
  40. data/lib/rubygems/format.rb +63 -63
  41. data/lib/rubygems/gem_openssl.rb +14 -2
  42. data/lib/rubygems/gem_path_searcher.rb +7 -3
  43. data/lib/rubygems/gem_runner.rb +59 -39
  44. data/lib/rubygems/indexer.rb +450 -109
  45. data/lib/rubygems/install_update_options.rb +13 -1
  46. data/lib/rubygems/installer.rb +25 -22
  47. data/lib/rubygems/local_remote_options.rb +5 -3
  48. data/lib/rubygems/old_format.rb +124 -120
  49. data/lib/rubygems/package/tar_header.rb +25 -3
  50. data/lib/rubygems/package/tar_input.rb +5 -5
  51. data/lib/rubygems/package/tar_output.rb +2 -0
  52. data/lib/rubygems/package/tar_reader.rb +19 -0
  53. data/lib/rubygems/package/tar_reader/entry.rb +43 -0
  54. data/lib/rubygems/package/tar_writer.rb +65 -3
  55. data/lib/rubygems/package_task.rb +117 -0
  56. data/lib/rubygems/platform.rb +12 -8
  57. data/lib/rubygems/remote_fetcher.rb +43 -24
  58. data/lib/rubygems/require_paths_builder.rb +14 -12
  59. data/lib/rubygems/requirement.rb +15 -6
  60. data/lib/rubygems/rubygems_version.rb +14 -1
  61. data/lib/rubygems/source_index.rb +38 -16
  62. data/lib/rubygems/source_info_cache_entry.rb +2 -2
  63. data/lib/rubygems/spec_fetcher.rb +43 -20
  64. data/lib/rubygems/specification.rb +1122 -947
  65. data/lib/rubygems/text.rb +30 -0
  66. data/lib/rubygems/timer.rb +14 -11
  67. data/lib/rubygems/uninstaller.rb +25 -5
  68. data/lib/rubygems/user_interaction.rb +294 -264
  69. data/lib/rubygems/validator.rb +70 -36
  70. data/lib/rubygems/version.rb +97 -33
  71. data/lib/rubygems/version_option.rb +1 -0
  72. data/setup.rb +11 -306
  73. data/test/foo/discover.rb +0 -0
  74. data/test/gem_installer_test_case.rb +22 -11
  75. data/test/gem_package_tar_test_case.rb +0 -14
  76. data/test/gemutilities.rb +89 -8
  77. data/test/mockgemui.rb +2 -1
  78. data/test/rubygems_plugin.rb +16 -0
  79. data/test/test_gem.rb +107 -36
  80. data/test/test_gem_command.rb +3 -13
  81. data/test/test_gem_command_manager.rb +1 -14
  82. data/test/test_gem_commands_cert_command.rb +1 -1
  83. data/test/test_gem_commands_contents_command.rb +63 -0
  84. data/test/test_gem_commands_environment_command.rb +1 -1
  85. data/test/test_gem_commands_generate_index_command.rb +104 -1
  86. data/test/test_gem_commands_install_command.rb +95 -0
  87. data/test/test_gem_commands_pristine_command.rb +3 -3
  88. data/test/test_gem_commands_query_command.rb +46 -0
  89. data/test/test_gem_commands_sources_command.rb +9 -5
  90. data/test/test_gem_commands_specification_command.rb +31 -0
  91. data/test/test_gem_commands_uninstall_command.rb +3 -2
  92. data/test/test_gem_commands_unpack_command.rb +3 -2
  93. data/test/test_gem_commands_update_command.rb +12 -7
  94. data/test/test_gem_dependency.rb +62 -11
  95. data/test/test_gem_dependency_installer.rb +18 -5
  96. data/test/test_gem_dependency_list.rb +6 -6
  97. data/test/test_gem_doc_manager.rb +7 -1
  98. data/test/test_gem_ext_configure_builder.rb +8 -10
  99. data/test/test_gem_ext_ext_conf_builder.rb +14 -8
  100. data/test/test_gem_gem_path_searcher.rb +1 -1
  101. data/test/test_gem_gem_runner.rb +11 -0
  102. data/test/test_gem_indexer.rb +398 -21
  103. data/test/test_gem_install_update_options.rb +20 -6
  104. data/test/test_gem_installer.rb +22 -14
  105. data/test/test_gem_local_remote_options.rb +2 -1
  106. data/test/test_gem_package_tar_header.rb +3 -3
  107. data/test/test_gem_package_tar_input.rb +3 -3
  108. data/test/test_gem_package_tar_output.rb +2 -2
  109. data/test/test_gem_package_task.rb +70 -0
  110. data/test/test_gem_platform.rb +12 -6
  111. data/test/test_gem_remote_fetcher.rb +23 -1
  112. data/test/test_gem_source_index.rb +32 -21
  113. data/test/test_gem_spec_fetcher.rb +77 -5
  114. data/test/test_gem_specification.rb +274 -1
  115. data/test/test_gem_uninstaller.rb +34 -4
  116. data/test/test_gem_version.rb +94 -4
  117. data/test/test_gem_version_option.rb +13 -0
  118. data/test/test_kernel.rb +4 -4
  119. data/util/CL2notes +56 -0
  120. data/util/gem_prelude.rb.template +251 -0
  121. metadata +30 -20
  122. metadata.gz.sig +3 -4
  123. data/TODO +0 -1
  124. data/scripts/buildtests.rb +0 -31
  125. data/scripts/gemdoc.rb +0 -67
  126. data/scripts/runtest.rb +0 -40
  127. data/scripts/specdoc.rb +0 -171
  128. data/scripts/upload_gemdoc.rb +0 -140
data/bin/gem CHANGED
@@ -15,10 +15,7 @@ unless required_version.satisfied_by? Gem.ruby_version then
15
15
  abort "Expected Ruby Version #{required_version}, was #{Gem.ruby_version}"
16
16
  end
17
17
 
18
- # We need to preserve the original ARGV to use for passing gem options
19
- # to source gems. If there is a -- in the line, strip all options after
20
- # it...its for the source building process.
21
- args = !ARGV.include?("--") ? ARGV.clone : ARGV[0...ARGV.index("--")]
18
+ args = ARGV.clone
22
19
 
23
20
  begin
24
21
  Gem::GemRunner.new.run args
@@ -0,0 +1,22 @@
1
+ # Project-specific configuration for CruiseControl.rb
2
+
3
+ Project.configure do |project|
4
+
5
+ # Send email notifications about broken and fixed builds to email1@your.site, email2@your.site (default: send to nobody)
6
+ project.email_notifier.emails = ['rubygems-developers@rubyforge.org']
7
+
8
+ # Set email 'from' field to john@doe.com:
9
+ project.email_notifier.from = 'devnull+rubygems-ci@pivotallabs.com'
10
+
11
+ # Build the project by invoking rake task 'custom'
12
+ # project.rake_task = 'custom'
13
+
14
+ # Build the project by invoking shell script "build_my_app.sh". Keep in mind that when the script is invoked,
15
+ # current working directory is <em>[cruise&nbsp;data]</em>/projects/your_project/work, so if you do not keep build_my_app.sh
16
+ # in version control, it should be '../build_my_app.sh' instead
17
+ # project.build_command = 'build_my_app.sh'
18
+
19
+ # Ping Subversion for new revisions every 5 minutes (default: 30 seconds)
20
+ project.scheduler.polling_interval = 5.minutes
21
+
22
+ end
@@ -1,10 +1,10 @@
1
- = Announce: RubyGems Release 1.3.0
1
+ = Announce: RubyGems Release 1.3.1
2
2
 
3
3
  NOTE: RubyGems 1.1 and 1.2 have problems upgrading when there is no
4
4
  rubygems-update installed. You will need to follow the second set of update
5
5
  instructions if you see "Nothing to update".
6
6
 
7
- Release 1.3.0 fixes some bugs.
7
+ Release 1.3.1 fixes some bugs.
8
8
 
9
9
  Bugs fixed:
10
10
 
@@ -13,7 +13,7 @@ Bugs fixed:
13
13
  * Fix requires for Gem::inflate, Gem::deflate, etc.
14
14
  * Make Gem.dir respect :gemhome value from config. (Note: this feature may be
15
15
  removed since it is hard to implement on 1.9.)
16
- * Kernel methods are now private. Patch #20801 by Stefan Rusterholz.
16
+ * Kernel methods are now private. Patch #20801 by James M. Lawrence.
17
17
  * Gem::location_of_caller now behaves on Windows. Patch by Daniel Berger.
18
18
  * Silence PATH warning.
19
19
 
@@ -0,0 +1,119 @@
1
+ = Announce: RubyGems Release 1.3.2
2
+
3
+ NOTE: RubyGems 1.1 and 1.2 have problems upgrading when there is no
4
+ rubygems-update installed. You will need to follow the second set of update
5
+ instructions if you see "Nothing to update".
6
+
7
+ Release 1.3.2 fixes some bugs and adds some features.
8
+
9
+ Select New Features:
10
+
11
+ * RubyGems now loads plugins from rubygems_plugin.rb in installed gems.
12
+ This can be used to add commands (See Gem::CommandManager) or add
13
+ install/uninstall hooks (See Gem::Installer and Gem::Uninstaller).
14
+ * Gem::Version now understands prerelease versions using letters. (eg.
15
+ '1.2.1.b') Thanks to Josh Susser, Alex Vollmer and Phil Hagelberg.
16
+ * RubyGems now includes a Rake task for creating gems which replaces rake's
17
+ Rake::GemPackageTask. See Gem::PackageTask.
18
+ * Gem::find_files now returns paths in $LOAD_PATH.
19
+ * Added Gem::promote_load_path for use with Gem::find_files
20
+ * Added Gem::bin_path to make finding executables easier. Patch #24114 by
21
+ James Tucker.
22
+ * Various improvements to build arguments for installing gems.
23
+ * `gem contents` added --all and --no-prefix.
24
+ * Gem::Specification
25
+ * #validate strips directories and errors on not-files.
26
+ * #description no longer removes newlines.
27
+ * #name must be a String.
28
+ * FIXME and TODO are no longer allowed in various fields.
29
+ * Added support for a license attribute. Feature #11041 (partial).
30
+ * Removed Gem::Specification::list, too much process growth. Bug #23668 by
31
+ Steve Purcell.
32
+ * `gem generate_index`
33
+ * Can now generate an RSS feed.
34
+ * Modern indicies can now be updated incrementally.
35
+ * Legacy indicies can be updated separately from modern.
36
+
37
+ Select Bugs Fixed:
38
+
39
+ * Better gem activation error message. Patch #23082.
40
+ * Kernel methods are now private. Patch #20801 by James M. Lawrence.
41
+ * Fixed various usability issues with `gem check`.
42
+ * `gem update` now rescues InstallError and continues. Bug #19268 by Gabriel
43
+ Wilkins.
44
+ * Allow 'https', 'file' as a valid schemes for --source. Patch #22485.
45
+ * `gem install`
46
+ * Now removes existing path before installing. Bug #22837.
47
+ * Uses Gem::bin_path in executable stubs to work around Kernel#load bug in
48
+ 1.9.
49
+ * Correctly handle build args (after --) via the API. Bug #23210.
50
+ * --user-install
51
+ * `gem install --no-user-install` now works. Patch #23573 by Alf Mikula.
52
+ * `gem uninstall` can now uninstall from ~/.gem. Bug #23760 by Roger Pack.
53
+ * setup.rb
54
+ * Clarify RubyGems RDoc installation location. Bug #22656 by Gian Marco
55
+ Gherardi.
56
+ * Allow setup to run from read-only location. Patch #21862 by Luis Herrera.
57
+ * Fixed overwriting ruby executable when BASERUBY was not set. Bug #24958
58
+ by Michael Soulier.
59
+ * Ensure we're in a RubyGems dir when installing.
60
+ * Deal with extraneous quotation mark when autogenerating .bat file on MS
61
+ Windows. Bug #22712.
62
+
63
+ Deprecation Notices:
64
+
65
+ * Gem::manage_gems has been removed.
66
+ * Time::today will be removed in RubyGems 1.4.
67
+
68
+ For a full list of changes to RubyGems and the contributor for each change, see
69
+ the ChangeLog file.
70
+
71
+ Special thanks to Chad Wooley for backwards compatibility testing and Luis
72
+ Lavena and Daniel Berger for continuing windows support.
73
+
74
+ == How can I get RubyGems?
75
+
76
+ NOTE: If you have installed RubyGems using a package system you may want to
77
+ install a new RubyGems through the same packaging system.
78
+
79
+ If you have a recent version of RubyGems (0.8.5 or later), then all
80
+ you need to do is:
81
+
82
+ $ gem update --system (you might need to be admin/root)
83
+
84
+ NOTE: RubyGems 1.1 and 1.2 have problems upgrading when there is no
85
+ rubygems-update installed. You will need to follow the second set of update
86
+ instructions if you see "Nothing to update".
87
+
88
+ NOTE: You may have to run the command twice if you have any previosly
89
+ installed rubygems-update gems.
90
+
91
+ If you have an older version of RubyGems installed, then you can still
92
+ do it in two steps:
93
+
94
+ $ gem install rubygems-update (again, might need to be admin/root)
95
+ $ update_rubygems (... here too)
96
+
97
+ If you don't have any gems install, there is still the pre-gem
98
+ approach to getting software ... doing it manually:
99
+
100
+ 1. DOWNLOAD FROM: http://rubyforge.org/frs/?group_id=126
101
+ 2. UNPACK INTO A DIRECTORY AND CD THERE
102
+ 3. INSTALL WITH: ruby setup.rb (you may need admin/root privilege)
103
+
104
+ == To File Bugs
105
+
106
+ The RubyGems bug tracker can be found on RubyForge at:
107
+ http://rubyforge.org/tracker/?func=add&group_id=126&atid=575
108
+
109
+ When filing a bug, `gem env` output will be helpful in diagnosing the issue.
110
+
111
+ If you find a bug where RubyGems crashes, please provide debug output. You can
112
+ do that with `gem --debug the_command`.
113
+
114
+ == Thanks
115
+
116
+ Keep those gems coming!
117
+
118
+ -- The RubyGems team
119
+
@@ -0,0 +1,50 @@
1
+ require 'rubygems'
2
+ require 'gauntlet'
3
+
4
+ ##
5
+ # GemGauntlet validates all current gems. Currently these packages are
6
+ # borked:
7
+ #
8
+ # Asami-0.04 : No such file or directory - bin/Asami.rb
9
+ # ObjectGraph-1.0.1 : No such file or directory - bin/objectgraph
10
+ # evil-ruby-0.1.0 : authors must be Array of Strings
11
+ # fresh_cookies-1.0.0 : authors must be Array of Strings
12
+ # plugems_deploy-0.2.0 : authors must be Array of Strings
13
+ # pmsrb-0.2.0 : authors must be Array of Strings
14
+ # pqa-1.6 : authors must be Array of Strings
15
+ # rant-0.5.7 : authors must be Array of Strings
16
+ # rvsh-0.4.5 : No such file or directory - bin/rvsh
17
+ # xen-0.1.2.1 : authors must be Array of Strings
18
+
19
+ class GemGauntlet < Gauntlet
20
+ def run(name)
21
+ warn name
22
+
23
+ spec = begin
24
+ Gem::Specification.load 'gemspec'
25
+ rescue SyntaxError
26
+ Gem::Specification.from_yaml File.read('gemspec')
27
+ end
28
+ spec.validate
29
+
30
+ self.data[name] = false
31
+ self.dirty = true
32
+ rescue SystemCallError, Gem::InvalidSpecificationException => e
33
+ self.data[name] = e.message
34
+ self.dirty = true
35
+ end
36
+
37
+ def should_skip?(name)
38
+ self.data[name] == false
39
+ end
40
+
41
+ def report
42
+ self.data.sort.reject { |k,v| !v }.each do |k,v|
43
+ puts "%-21s: %s" % [k, v]
44
+ end
45
+ end
46
+ end
47
+
48
+ gauntlet = GemGauntlet.new
49
+ gauntlet.run_the_gauntlet ARGV.shift
50
+ gauntlet.report
@@ -8,6 +8,7 @@
8
8
  require 'rubygems/rubygems_version'
9
9
  require 'rubygems/defaults'
10
10
  require 'thread'
11
+ require 'etc'
11
12
 
12
13
  module Gem
13
14
  class LoadError < ::LoadError
@@ -54,18 +55,105 @@ module Kernel
54
55
  end
55
56
 
56
57
  ##
57
- # Main module to hold all RubyGem classes/modules.
58
+ # RubyGems is the Ruby standard for publishing and managing third party
59
+ # libraries.
60
+ #
61
+ # For user documentation, see:
62
+ #
63
+ # * <tt>gem help</tt> and <tt>gem help [command]</tt>
64
+ # * {RubyGems User Guide}[http://docs.rubygems.org/read/book/1]
65
+ # * {Frequently Asked Questions}[http://docs.rubygems.org/read/book/3]
66
+ #
67
+ # For gem developer documentation see:
68
+ #
69
+ # * {Creating Gems}[http://docs.rubygems.org/read/chapter/5]
70
+ # * Gem::Specification
71
+ #
72
+ # Further RubyGems documentation can be found at:
73
+ #
74
+ # * {RubyGems API}[http://rubygems.rubyforge.org/rdoc] (also available from
75
+ # <tt>gem server</tt>)
76
+ # * {RubyGems Bookshelf}[http://rubygem.org]
77
+ #
78
+ # == RubyGems Plugins
79
+ #
80
+ # As of RubyGems 1.3.2, RubyGems will load plugins installed in gems or
81
+ # $LOAD_PATH. Plugins must be named 'rubygems_plugin' are discovered via
82
+ # Gem::find_files then loaded. Take care when implementing a plugin as your
83
+ # plugin file may be loaded multiple times if multiple versions of your gem
84
+ # are installed.
85
+ #
86
+ # For an example plugin, see the graph gem which adds a `gem graph` command.
87
+ #
88
+ # == RubyGems Defaults, Packaging
89
+ #
90
+ # RubyGems defaults are stored in rubygems/defaults.rb. If you're packaging
91
+ # RubyGems or implementing Ruby you can change RubyGems' defaults.
92
+ #
93
+ # For RubyGems packagers, provide lib/rubygems/operating_system.rb and
94
+ # override any defaults from lib/rubygems/defaults.rb.
95
+ #
96
+ # For Ruby implementers, provide lib/rubygems/#{RUBY_ENGINE}.rb and override
97
+ # any defaults from lib/rubygems/defaults.rb.
98
+ #
99
+ # If you need RubyGems to perform extra work on install or uninstall, your
100
+ # defaults override file can set pre and post install and uninstall hooks.
101
+ # See Gem::pre_install, Gem::pre_uninstall, Gem::post_install,
102
+ # Gem::post_uninstall.
103
+ #
104
+ # == Bugs
105
+ #
106
+ # You can submit bugs to the
107
+ # {RubyGems bug tracker}[http://rubyforge.org/tracker/?atid=575&group_id=126&func=browse]
108
+ # on RubyForge
109
+ #
110
+ # == Credits
111
+ #
112
+ # RubyGems is currently maintained by Eric Hodel.
113
+ #
114
+ # RubyGems was originally developed at RubyConf 2003 by:
115
+ #
116
+ # * Rich Kilmer -- rich(at)infoether.com
117
+ # * Chad Fowler -- chad(at)chadfowler.com
118
+ # * David Black -- dblack(at)wobblini.net
119
+ # * Paul Brannan -- paul(at)atdesk.com
120
+ # * Jim Weirch -- {jim(at)weirichhouse.org}[mailto:jim@weirichhouse.org]
121
+ #
122
+ # Contributors:
123
+ #
124
+ # * Gavin Sinclair -- gsinclair(at)soyabean.com.au
125
+ # * George Marrows -- george.marrows(at)ntlworld.com
126
+ # * Dick Davies -- rasputnik(at)hellooperator.net
127
+ # * Mauricio Fernandez -- batsman.geo(at)yahoo.com
128
+ # * Simon Strandgaard -- neoneye(at)adslhome.dk
129
+ # * Dave Glasser -- glasser(at)mit.edu
130
+ # * Paul Duncan -- pabs(at)pablotron.org
131
+ # * Ville Aine -- vaine(at)cs.helsinki.fi
132
+ # * Eric Hodel -- drbrain(at)segment7.net
133
+ # * Daniel Berger -- djberg96(at)gmail.com
134
+ # * Phil Hagelberg -- technomancy(at)gmail.com
135
+ # * Ryan Davis
136
+ #
137
+ # (If your name is missing, PLEASE let us know!)
138
+ #
139
+ # Thanks!
140
+ #
141
+ # -The RubyGems Team
58
142
 
59
143
  module Gem
60
144
 
145
+ ##
146
+ # Configuration settings from ::RbConfig
147
+
61
148
  ConfigMap = {} unless defined?(ConfigMap)
149
+
62
150
  require 'rbconfig'
151
+ # :stopdoc:
63
152
  RbConfig = Config unless defined? ::RbConfig
153
+ # :startdoc:
64
154
 
65
155
  ConfigMap.merge!(
66
- :BASERUBY => RbConfig::CONFIG["BASERUBY"],
67
156
  :EXEEXT => RbConfig::CONFIG["EXEEXT"],
68
- :RUBY_INSTALL_NAME => RbConfig::CONFIG["RUBY_INSTALL_NAME"],
69
157
  :RUBY_SO_NAME => RbConfig::CONFIG["RUBY_SO_NAME"],
70
158
  :arch => RbConfig::CONFIG["arch"],
71
159
  :bindir => RbConfig::CONFIG["bindir"],
@@ -79,11 +167,16 @@ module Gem
79
167
  :vendorlibdir => RbConfig::CONFIG["vendorlibdir"]
80
168
  )
81
169
 
170
+ ##
171
+ # Default directories in a gem repository
172
+
82
173
  DIRECTORIES = %w[cache doc gems specifications] unless defined?(DIRECTORIES)
83
174
 
175
+ # :stopdoc:
84
176
  MUTEX = Mutex.new
85
177
 
86
178
  RubyGemsPackageVersion = RubyGemsVersion
179
+ # :startdoc:
87
180
 
88
181
  ##
89
182
  # An Array of Regexps that match windows ruby platforms.
@@ -102,6 +195,7 @@ module Gem
102
195
 
103
196
  @configuration = nil
104
197
  @loaded_specs = {}
198
+ @loaded_stacks = {}
105
199
  @platforms = []
106
200
  @ruby = nil
107
201
  @sources = []
@@ -128,6 +222,14 @@ module Gem
128
222
  # Gem::Requirement and Gem::Version documentation.
129
223
 
130
224
  def self.activate(gem, *version_requirements)
225
+ if version_requirements.last.is_a?(Hash)
226
+ options = version_requirements.pop
227
+ else
228
+ options = {}
229
+ end
230
+
231
+ sources = options[:sources] || []
232
+
131
233
  if version_requirements.empty? then
132
234
  version_requirements = Gem::Requirement.default
133
235
  end
@@ -146,8 +248,14 @@ module Gem
146
248
  existing_spec = @loaded_specs[gem.name]
147
249
 
148
250
  unless matches.any? { |spec| spec.version == existing_spec.version } then
149
- raise Gem::Exception,
150
- "can't activate #{gem}, already activated #{existing_spec.full_name}"
251
+ sources_message = sources.map { |spec| spec.full_name }
252
+ stack_message = @loaded_stacks[gem.name].map { |spec| spec.full_name }
253
+
254
+ msg = "can't activate #{gem} for #{sources_message.inspect}, "
255
+ msg << "already activated #{existing_spec.full_name} for "
256
+ msg << "#{stack_message.inspect}"
257
+
258
+ raise Gem::Exception, msg
151
259
  end
152
260
 
153
261
  return false
@@ -159,10 +267,11 @@ module Gem
159
267
 
160
268
  spec.loaded = true
161
269
  @loaded_specs[spec.name] = spec
270
+ @loaded_stacks[spec.name] = sources.dup
162
271
 
163
272
  # Load dependent gems first
164
273
  spec.runtime_dependencies.each do |dep_gem|
165
- activate dep_gem
274
+ activate dep_gem, :sources => [spec, *sources]
166
275
  end
167
276
 
168
277
  # bin directory must come before library directories
@@ -227,6 +336,35 @@ module Gem
227
336
  !Gem.source_index.search(gem).empty?
228
337
  end
229
338
 
339
+ ##
340
+ # Find the full path to the executable for gem +name+. If the +exec_name+
341
+ # is not given, the gem's default_executable is chosen, otherwise the
342
+ # specifed executable's path is returned. +version_requirements+ allows you
343
+ # to specify specific gem versions.
344
+
345
+ def self.bin_path(name, exec_name = nil, *version_requirements)
346
+ version_requirements = Gem::Requirement.default if
347
+ version_requirements.empty?
348
+ spec = Gem.source_index.find_name(name, version_requirements).last
349
+
350
+ raise Gem::GemNotFoundException,
351
+ "can't find gem #{name} (#{version_requirements})" unless spec
352
+
353
+ exec_name ||= spec.default_executable
354
+
355
+ unless exec_name
356
+ msg = "no default executable for #{spec.full_name}"
357
+ raise Gem::Exception, msg
358
+ end
359
+
360
+ unless spec.executables.include? exec_name
361
+ msg = "can't find executable #{exec_name} for #{spec.full_name}"
362
+ raise Gem::Exception, msg
363
+ end
364
+
365
+ File.join spec.full_gem_path, spec.bindir, exec_name
366
+ end
367
+
230
368
  ##
231
369
  # The mode needed to read a file as straight binary.
232
370
 
@@ -351,14 +489,27 @@ module Gem
351
489
  #
352
490
  # Gem.find_files('rdoc/discover').each do |path| load path end
353
491
  #
354
- # find_files does not search $LOAD_PATH for files, only gems.
492
+ # find_files search $LOAD_PATH for files as well as gems.
493
+ #
494
+ # Note that find_files will return all files even if they are from different
495
+ # versions of the same gem.
355
496
 
356
497
  def self.find_files(path)
498
+ load_path_files = $LOAD_PATH.map do |load_path|
499
+ files = Dir["#{File.expand_path path, load_path}#{Gem.suffix_pattern}"]
500
+
501
+ files.select do |load_path_file|
502
+ File.file? load_path_file.untaint
503
+ end
504
+ end.flatten
505
+
357
506
  specs = searcher.find_all path
358
507
 
359
- specs.map do |spec|
508
+ specs_files = specs.map do |spec|
360
509
  searcher.matching_files spec, path
361
510
  end.flatten
511
+
512
+ (load_path_files + specs_files).flatten.uniq
362
513
  end
363
514
 
364
515
  ##
@@ -487,22 +638,13 @@ module Gem
487
638
  # The file name and line number of the caller of the caller of this method.
488
639
 
489
640
  def self.location_of_caller
490
- caller[1] =~ /(.*?):(\d+)$/i
641
+ caller[1] =~ /(.*?):(\d+).*?$/i
491
642
  file = $1
492
643
  lineno = $2.to_i
493
644
 
494
645
  [file, lineno]
495
646
  end
496
647
 
497
- ##
498
- # manage_gems is useless and deprecated. Don't call it anymore.
499
-
500
- def self.manage_gems # :nodoc:
501
- file, lineno = location_of_caller
502
-
503
- warn "#{file}:#{lineno}:Warning: Gem::manage_gems is deprecated and will be removed on or after March 2009."
504
- end
505
-
506
648
  ##
507
649
  # The version of the Marshal format for your Ruby.
508
650
 
@@ -596,6 +738,33 @@ module Gem
596
738
  end
597
739
  end
598
740
 
741
+ ##
742
+ # Promotes the load paths of the +gem_name+ over the load paths of
743
+ # +over_name+. Useful for allowing one gem to override features in another
744
+ # using #find_files.
745
+
746
+ def self.promote_load_path(gem_name, over_name)
747
+ gem = Gem.loaded_specs[gem_name]
748
+ over = Gem.loaded_specs[over_name]
749
+
750
+ raise ArgumentError, "gem #{gem_name} is not activated" if gem.nil?
751
+ raise ArgumentError, "gem #{over_name} is not activated" if over.nil?
752
+
753
+ last_gem_path = File.join gem.full_gem_path, gem.require_paths.last
754
+
755
+ over_paths = over.require_paths.map do |path|
756
+ File.join over.full_gem_path, path
757
+ end
758
+
759
+ over_paths.each do |path|
760
+ $LOAD_PATH.delete path
761
+ end
762
+
763
+ gem = $LOAD_PATH.index(last_gem_path) + 1
764
+
765
+ $LOAD_PATH.insert(gem, *over_paths)
766
+ end
767
+
599
768
  ##
600
769
  # Refresh source_index from disk and clear searcher.
601
770
 
@@ -638,15 +807,23 @@ module Gem
638
807
 
639
808
  private_class_method :report_activate_error
640
809
 
641
- def self.required_location(gemname, libfile, *version_constraints)
642
- version_constraints = Gem::Requirement.default if version_constraints.empty?
643
- matches = Gem.source_index.find_name(gemname, version_constraints)
810
+ ##
811
+ # Full path to +libfile+ in +gemname+. Searches for the latest gem unless
812
+ # +requirements+ is given.
813
+
814
+ def self.required_location(gemname, libfile, *requirements)
815
+ requirements = Gem::Requirement.default if requirements.empty?
816
+
817
+ matches = Gem.source_index.find_name gemname, requirements
818
+
644
819
  return nil if matches.empty?
820
+
645
821
  spec = matches.last
646
822
  spec.require_paths.each do |path|
647
- result = File.join(spec.full_gem_path, path, libfile)
648
- return result if File.exist?(result)
823
+ result = File.join spec.full_gem_path, path, libfile
824
+ return result if File.exist? result
649
825
  end
826
+
650
827
  nil
651
828
  end
652
829
 
@@ -672,7 +849,7 @@ module Gem
672
849
  def self.ruby_version
673
850
  return @ruby_version if defined? @ruby_version
674
851
  version = RUBY_VERSION.dup
675
- version << ".#{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
852
+ version << ".#{RUBY_PATCHLEVEL}" if defined?(RUBY_PATCHLEVEL) && RUBY_PATCHLEVEL != -1
676
853
  @ruby_version = Gem::Version.new version
677
854
  end
678
855
 
@@ -718,9 +895,12 @@ module Gem
718
895
  @gem_path.uniq!
719
896
  @gem_path.each do |path|
720
897
  if 0 == File.expand_path(path).index(Gem.user_home)
898
+ next unless File.directory? Gem.user_home
721
899
  unless win_platform? then
722
900
  # only create by matching user
723
- next if Etc.getpwuid.uid != File::Stat.new(Gem.user_home).uid
901
+ if Etc.getpwuid.nil? || Etc.getpwuid.uid != File::Stat.new(Gem.user_home).uid
902
+ next
903
+ end
724
904
  end
725
905
  end
726
906
  ensure_gem_subdirectories path
@@ -776,6 +956,31 @@ module Gem
776
956
  ['', '.rb', '.rbw', '.so', '.bundle', '.dll', '.sl', '.jar']
777
957
  end
778
958
 
959
+ ##
960
+ # Prints the amount of time the supplied block takes to run using the debug
961
+ # UI output.
962
+
963
+ def self.time(msg, width = 0, display = Gem.configuration.verbose)
964
+ now = Time.now
965
+
966
+ value = yield
967
+
968
+ elapsed = Time.now - now
969
+
970
+ ui.say "%2$*1$s: %3$3.3fs" % [-width, msg, elapsed] if display
971
+
972
+ value
973
+ end
974
+
975
+ ##
976
+ # Lazily loads DefaultUserInteraction and returns the default UI.
977
+
978
+ def self.ui
979
+ require 'rubygems/user_interaction'
980
+
981
+ Gem::DefaultUserInteraction.ui
982
+ end
983
+
779
984
  ##
780
985
  # Use the +home+ and +paths+ values for Gem.dir and Gem.path. Used mainly
781
986
  # by the unit tests to provide environment isolation.
@@ -806,6 +1011,9 @@ module Gem
806
1011
 
807
1012
  class << self
808
1013
 
1014
+ ##
1015
+ # Hash of loaded Gem::Specification keyed by name
1016
+
809
1017
  attr_reader :loaded_specs
810
1018
 
811
1019
  ##
@@ -837,8 +1045,14 @@ module Gem
837
1045
 
838
1046
  end
839
1047
 
1048
+ ##
1049
+ # Location of Marshal quick gemspecs on remote repositories
1050
+
840
1051
  MARSHAL_SPEC_DIR = "quick/Marshal.#{Gem.marshal_version}/"
841
1052
 
1053
+ ##
1054
+ # Location of legacy YAML quick gemspecs on remote repositories
1055
+
842
1056
  YAML_SPEC_DIR = 'quick/'
843
1057
 
844
1058
  end
@@ -886,3 +1100,14 @@ if RUBY_VERSION < '1.9' then
886
1100
  end
887
1101
 
888
1102
  Gem.clear_paths
1103
+
1104
+ plugins = Gem.find_files 'rubygems_plugin'
1105
+
1106
+ plugins.each do |plugin|
1107
+ begin
1108
+ load plugin
1109
+ rescue => e
1110
+ warn "error loading #{plugin.inspect}: #{e.message} (#{e.class})"
1111
+ end
1112
+ end
1113
+