rubygems-update 1.0.1 → 1.1.0

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 (172) hide show
  1. data.tar.gz.sig +0 -0
  2. data/ChangeLog +248 -0
  3. data/README +2 -0
  4. data/Rakefile +47 -23
  5. data/bin/gem +9 -4
  6. data/bin/update_rubygems +15 -1
  7. data/examples/application/bin/myapp +0 -0
  8. data/lib/rubygems.rb +506 -373
  9. data/lib/rubygems/builder.rb +14 -7
  10. data/lib/rubygems/command.rb +9 -9
  11. data/lib/rubygems/command_manager.rb +1 -0
  12. data/lib/rubygems/commands/cleanup_command.rb +67 -69
  13. data/lib/rubygems/commands/environment_command.rb +16 -10
  14. data/lib/rubygems/commands/fetch_command.rb +7 -9
  15. data/lib/rubygems/commands/install_command.rb +9 -3
  16. data/lib/rubygems/commands/list_command.rb +2 -4
  17. data/lib/rubygems/commands/mirror_command.rb +1 -1
  18. data/lib/rubygems/commands/query_command.rb +52 -5
  19. data/lib/rubygems/commands/sources_command.rb +19 -10
  20. data/lib/rubygems/commands/specification_command.rb +10 -6
  21. data/lib/rubygems/commands/uninstall_command.rb +23 -6
  22. data/lib/rubygems/commands/unpack_command.rb +15 -3
  23. data/lib/rubygems/commands/update_command.rb +27 -25
  24. data/lib/rubygems/custom_require.rb +1 -1
  25. data/lib/rubygems/defaults.rb +8 -1
  26. data/lib/rubygems/dependency_installer.rb +72 -104
  27. data/lib/rubygems/digest/digest_adapter.rb +0 -0
  28. data/lib/rubygems/digest/md5.rb +0 -0
  29. data/lib/rubygems/digest/sha1.rb +0 -0
  30. data/lib/rubygems/digest/sha2.rb +0 -0
  31. data/lib/rubygems/exceptions.rb +22 -1
  32. data/lib/rubygems/format.rb +16 -10
  33. data/lib/rubygems/indexer.rb +46 -33
  34. data/lib/rubygems/indexer/abstract_index_builder.rb +10 -2
  35. data/lib/rubygems/indexer/latest_index_builder.rb +35 -0
  36. data/lib/rubygems/indexer/master_index_builder.rb +9 -8
  37. data/lib/rubygems/indexer/quick_index_builder.rb +5 -3
  38. data/lib/rubygems/install_update_options.rb +7 -1
  39. data/lib/rubygems/installer.rb +8 -5
  40. data/lib/rubygems/package.rb +17 -774
  41. data/lib/rubygems/package/f_sync_dir.rb +24 -0
  42. data/lib/rubygems/package/tar_header.rb +245 -0
  43. data/lib/rubygems/package/tar_input.rb +219 -0
  44. data/lib/rubygems/package/tar_output.rb +143 -0
  45. data/lib/rubygems/package/tar_reader.rb +86 -0
  46. data/lib/rubygems/package/tar_reader/entry.rb +99 -0
  47. data/lib/rubygems/package/tar_writer.rb +180 -0
  48. data/lib/rubygems/remote_fetcher.rb +131 -16
  49. data/lib/rubygems/requirement.rb +2 -0
  50. data/lib/rubygems/rubygems_version.rb +1 -1
  51. data/lib/rubygems/security.rb +1 -0
  52. data/lib/rubygems/server.rb +85 -104
  53. data/lib/rubygems/source_index.rb +412 -329
  54. data/lib/rubygems/source_info_cache.rb +232 -99
  55. data/lib/rubygems/source_info_cache_entry.rb +14 -4
  56. data/lib/rubygems/specification.rb +9 -10
  57. data/lib/rubygems/timer.rb +0 -0
  58. data/lib/rubygems/uninstaller.rb +56 -32
  59. data/lib/rubygems/user_interaction.rb +4 -10
  60. data/lib/rubygems/validator.rb +0 -0
  61. data/scripts/gemdoc.rb +0 -0
  62. data/scripts/specdoc.rb +0 -0
  63. data/setup.rb +56 -19
  64. data/test/gem_installer_test_case.rb +86 -0
  65. data/test/gem_installer_test_case.rbc +0 -0
  66. data/test/gem_package_tar_test_case.rb +146 -0
  67. data/test/gem_package_tar_test_case.rbc +0 -0
  68. data/test/gemutilities.rb +123 -38
  69. data/test/gemutilities.rbc +0 -0
  70. data/test/mockgemui.rb +5 -13
  71. data/test/mockgemui.rbc +0 -0
  72. data/test/private_key.pem +27 -0
  73. data/test/public_cert.pem +20 -0
  74. data/test/simple_gem.rbc +0 -0
  75. data/test/test_config.rbc +0 -0
  76. data/test/test_gem.rb +46 -4
  77. data/test/test_gem.rbc +0 -0
  78. data/test/test_gem_builder.rbc +0 -0
  79. data/test/test_gem_command.rbc +0 -0
  80. data/test/test_gem_command_manager.rb +4 -2
  81. data/test/test_gem_command_manager.rbc +0 -0
  82. data/test/test_gem_commands_build_command.rbc +0 -0
  83. data/test/test_gem_commands_cert_command.rb +5 -1
  84. data/test/test_gem_commands_cert_command.rbc +0 -0
  85. data/test/test_gem_commands_check_command.rbc +0 -0
  86. data/test/test_gem_commands_contents_command.rbc +0 -0
  87. data/test/test_gem_commands_dependency_command.rbc +0 -0
  88. data/test/test_gem_commands_environment_command.rb +17 -1
  89. data/test/test_gem_commands_environment_command.rbc +0 -0
  90. data/test/test_gem_commands_fetch_command.rb +6 -5
  91. data/test/test_gem_commands_fetch_command.rbc +0 -0
  92. data/test/test_gem_commands_generate_index_command.rbc +0 -0
  93. data/test/test_gem_commands_install_command.rb +36 -28
  94. data/test/test_gem_commands_install_command.rbc +0 -0
  95. data/test/test_gem_commands_mirror_command.rbc +0 -0
  96. data/test/test_gem_commands_pristine_command.rbc +0 -0
  97. data/test/test_gem_commands_query_command.rb +143 -19
  98. data/test/test_gem_commands_query_command.rbc +0 -0
  99. data/test/test_gem_commands_server_command.rb +1 -1
  100. data/test/test_gem_commands_server_command.rbc +0 -0
  101. data/test/test_gem_commands_sources_command.rb +67 -9
  102. data/test/test_gem_commands_sources_command.rbc +0 -0
  103. data/test/test_gem_commands_specification_command.rb +3 -2
  104. data/test/test_gem_commands_specification_command.rbc +0 -0
  105. data/test/test_gem_commands_unpack_command.rb +46 -4
  106. data/test/test_gem_commands_unpack_command.rbc +0 -0
  107. data/test/test_gem_commands_update_command.rb +174 -0
  108. data/test/test_gem_commands_update_command.rbc +0 -0
  109. data/test/test_gem_config_file.rbc +0 -0
  110. data/test/test_gem_dependency.rbc +0 -0
  111. data/test/test_gem_dependency_installer.rb +172 -187
  112. data/test/test_gem_dependency_installer.rbc +0 -0
  113. data/test/test_gem_dependency_list.rbc +0 -0
  114. data/test/test_gem_digest.rb +0 -0
  115. data/test/test_gem_digest.rbc +0 -0
  116. data/test/test_gem_doc_manager.rbc +0 -0
  117. data/test/test_gem_ext_configure_builder.rb +9 -6
  118. data/test/test_gem_ext_configure_builder.rbc +0 -0
  119. data/test/test_gem_ext_ext_conf_builder.rbc +0 -0
  120. data/test/test_gem_ext_rake_builder.rbc +0 -0
  121. data/test/test_gem_format.rb +1 -1
  122. data/test/test_gem_format.rbc +0 -0
  123. data/test/test_gem_gem_path_searcher.rbc +0 -0
  124. data/test/test_gem_gem_runner.rbc +0 -0
  125. data/test/test_gem_indexer.rb +7 -2
  126. data/test/test_gem_indexer.rbc +0 -0
  127. data/test/test_gem_install_update_options.rbc +0 -0
  128. data/test/test_gem_installer.rb +5 -84
  129. data/test/test_gem_installer.rbc +0 -0
  130. data/test/test_gem_local_remote_options.rbc +0 -0
  131. data/test/test_gem_outdated_command.rbc +0 -0
  132. data/test/test_gem_package_tar_header.rb +137 -0
  133. data/test/test_gem_package_tar_header.rbc +0 -0
  134. data/test/test_gem_package_tar_input.rb +119 -0
  135. data/test/test_gem_package_tar_input.rbc +0 -0
  136. data/test/test_gem_package_tar_output.rb +104 -0
  137. data/test/test_gem_package_tar_output.rbc +0 -0
  138. data/test/test_gem_package_tar_reader.rb +53 -0
  139. data/test/test_gem_package_tar_reader.rbc +0 -0
  140. data/test/test_gem_package_tar_reader_entry.rb +116 -0
  141. data/test/test_gem_package_tar_reader_entry.rbc +0 -0
  142. data/test/test_gem_package_tar_writer.rb +151 -0
  143. data/test/test_gem_package_tar_writer.rbc +0 -0
  144. data/test/test_gem_platform.rbc +0 -0
  145. data/test/test_gem_remote_fetcher.rb +189 -17
  146. data/test/test_gem_remote_fetcher.rbc +0 -0
  147. data/test/test_gem_requirement.rbc +0 -0
  148. data/test/test_gem_server.rb +13 -12
  149. data/test/test_gem_server.rbc +0 -0
  150. data/test/test_gem_source_index.rb +305 -56
  151. data/test/test_gem_source_index.rbc +0 -0
  152. data/test/test_gem_source_info_cache.rb +179 -53
  153. data/test/test_gem_source_info_cache.rbc +0 -0
  154. data/test/test_gem_source_info_cache_entry.rb +41 -10
  155. data/test/test_gem_source_info_cache_entry.rbc +0 -0
  156. data/test/test_gem_specification.rb +7 -7
  157. data/test/test_gem_specification.rbc +0 -0
  158. data/test/test_gem_stream_ui.rbc +0 -0
  159. data/test/test_gem_uninstaller.rb +43 -0
  160. data/test/test_gem_uninstaller.rbc +0 -0
  161. data/test/test_gem_validator.rbc +0 -0
  162. data/test/test_gem_version.rb +1 -1
  163. data/test/test_gem_version.rbc +0 -0
  164. data/test/test_gem_version_option.rbc +0 -0
  165. data/test/test_kernel.rb +1 -0
  166. data/test/test_kernel.rbc +0 -0
  167. metadata +85 -8
  168. metadata.gz.sig +0 -0
  169. data/lib/rubygems/gem_open_uri.rb +0 -7
  170. data/lib/rubygems/open-uri.rb +0 -773
  171. data/test/test_open_uri.rb +0 -13
  172. data/test/test_package.rb +0 -608
data.tar.gz.sig CHANGED
Binary file
data/ChangeLog CHANGED
@@ -1,3 +1,251 @@
1
+ 2008-03-28 Eric Hodel <drbrain@segment7.net>
2
+
3
+ * bin/gem, Rakefile: RubyGems now requires Ruby > 1.8.3.
4
+ * lib/rubygems.rb: Added Gem.ruby_version, Gem.read_binary,
5
+ Gem.binary_mode.
6
+ * lib/, test/: Read files in binary mode for windows and ruby 1.9.
7
+ * lib/rubygems/commands/update_command.rb: Only update once.
8
+ * lib/rubygems/commands/sources_command.rb: Ditto.
9
+ * lib/rubygems/source_index.rb: Fix #remove_extra, #find_missing so
10
+ legacy platform gems don't get updated repeatedly.
11
+ * doc/release_notes/rel_1_1_0.rdoc: RubyGems 1.1.0 release notes.
12
+ * lib/rubygems/rubygems_version.rb: 1.1.0.
13
+
14
+ 2008-03-28 Ryan Woodrum <rwoodrum@avvo.com>
15
+
16
+ * lib/rubygems/commands/query_command.rb: Add --installed
17
+ subcommand to check if a gem and/or version is installed.
18
+ * test/test_gem_commands_query_command.rb: Add relevant tests.
19
+ * test/gemutilities.rb: Override exit() for query tests.
20
+ * test/mockgemui.rb: Add =() to manipulate output values (clear).
21
+
22
+ 2008-03-28 Chad Woolley <thewoolleyman@gmail.com>
23
+
24
+ * lib/rubygems/source_info_cache.rb: Add reset_cache_file.
25
+
26
+ 2008-03-27 Chad Woolley <thewoolleyman@gmail.com>
27
+
28
+ * lib/rubygems/user_interaction.rb: Raise Gem::SystemExitException
29
+ instead of exiting, kill unused terminate_interaction!.
30
+ * lib/rubygems/exceptions.rb: Add Gem::SystemExitException.
31
+ * lib/rubygems/commands/install_command.rb: Raise
32
+ Gem::SystemExitException instead of exiting.
33
+ * bin/gem: Rescue Gem::SystemExitException and exit with
34
+ specified exit_code.
35
+ * test/test_gem_commands_install_command.rb: Assert on
36
+ Gem::SystemExitException and exit_code in tests.
37
+
38
+ 2008-03-27 Eric Hodel <drbrain@segment7.net>
39
+
40
+ * lib/rubygems/commands/sources_command.rb: Allow sources to be
41
+ removed without network. Fixes bug #18644 by Mikel Lindsaar.
42
+
43
+ 2008-03-27 Luis Lavena <luislavena@gmail.com>
44
+
45
+ * lib/rubygems/commands/environment_command.rb: Use platform specific
46
+ PATH_SEPARATOR instead of hardcoded ':'
47
+ * test/test_gem_commands_unpack_command.rb: Ditto.
48
+ * test/test_gem_commands_environment_command.rb: Ditto.
49
+ * test/gemutilities.rb: Fix binary file reads being truncated on
50
+ Windows.
51
+ * test/test_gem_commands_install_command.rb: Switch to read_binary.
52
+ * test/test_gem_commands_update_command.rb: Ditto.
53
+ * test/test_gem_commands_server_command.rb: Consider full path when
54
+ evaluating location (instead of hardcoded or missing drive leter).
55
+ * test/test_gem_installer.rb: Ditto.
56
+ * test/test_gem_dependency_installer.rb: exclude no-wrapper tests for
57
+ Windows.
58
+
59
+ 2008-03-26 Luis Lavena <luislavena@gmail.com>
60
+
61
+ * lib/rubygems.rb: Handle backslashes that came from GEM_HOME and
62
+ GEM_PATH on Windows.
63
+
64
+ 2008-03-25 Eric Hodel <drbrain@segment7.net>
65
+
66
+ * lib/rubygems/source_index.rb: Add updating from latest index,
67
+ default to updating from latest index. Reduces common-case update
68
+ to under 3,000 gems at present.
69
+ * lib/rubygems/remote_fetcher: Fix error reporting from net/http.
70
+ * lib/rubygems.rb: Sort methods, remove last vestiges of autorequire,
71
+ RDoc cleanup.
72
+
73
+ 2008-03-23 Luis Lavena <luislavena@gmail.com>
74
+
75
+ * setup.rb: generated Windows stubs will honors prefix using Gem.ruby
76
+ instead of hardcoded 'ruby.exe'
77
+ * lib/rubygems/installer.rb: generated Windows stubs scripts will now
78
+ work from differnt directories than Gem::bindir. Fixes bug #16259 by
79
+ Claus Folke Brobak
80
+
81
+ 2008-03-20 Eric Hodel <drbrain@segment7.net>
82
+
83
+ * test/test_gem_source_info_cache.rb: Test with real objects now.
84
+ * lib/rubygems/source_index.rb: #latest_specs now has latest specs
85
+ for all platforms.
86
+ * lib/rubygems/source_info_cache.rb: Add latest cache data, only load
87
+ full cache data when needed.
88
+
89
+ 2008-03-20 Luis Lavena <luislavena@gmail.com>
90
+
91
+ * test/gemutilities.rb: Change all the file processing mechanism to
92
+ enable binary mode by default (required for Windows file operations
93
+ dealing with non-printable characters).
94
+
95
+ 2008-03-19 Luis Lavena <luislavena@gmail.com>
96
+
97
+ * lib/rubygems/package/tar_output.rb: Adapted code to use #wrap instead
98
+ of #new when dealing with Zlib::GzipWriter (fixes SEGV and warnings due
99
+ GzipWriter object not being closed explicitly).
100
+
101
+ 2008-03-12 Eric Hodel <drbrain@segment7.net>
102
+
103
+ * lib/rubygems/indexer.rb: Add latest_index.
104
+
105
+ 2008-03-09 Eric Hodel <drbrain@segment7.net>
106
+
107
+ * lib/rubygems/defaults.rb: Add special case for RUBY_ENGINE constant
108
+ when setting default gem dir.
109
+ * Rakefile: Add update_rubinius and diff_rubinius.
110
+
111
+ 2008-03-08 Lincoln Stoll <lstoll@lstoll.net>
112
+
113
+ * lib/rubygems/server.rb: Drop use of RDoc's TemplatePage in favor of
114
+ ERB.
115
+
116
+ 2008-03-04 Ryan Davis <ryan@wrath.local>
117
+
118
+ * lib/rubygems/remote_fetcher.rb: Moved #download from
119
+ DependencyInstaller.
120
+ * lib/rubygems/commands/fetch_command.rb: Updated to use #download.
121
+ * lib/rubygems/dependency_installer.rb: install now takes name or dep.
122
+ Renamed gather_specs_to_download to find_spec_by_name_and_version.
123
+ Modifed #initialize to not take gem name or version.
124
+
125
+ 2008-03-04 Eric Hodel <drbrain@segment7.net>
126
+
127
+ * lib/rubygems/package*: Removed #open_from_io and friends, switched
128
+ to #open, no special handling for file names.
129
+ * lib/rubygems/package/tar_output.rb: Refactored ::open to use
130
+ instance methods.
131
+ * lib/rubygems/remote_fetcher.rb: Print out number of requests made
132
+ before connection reset.
133
+
134
+ 2008-02-29 Eric Hodel <drbrain@segment7.net>
135
+
136
+ * lib/rubygems/package/tar_reader/entry.rb: Removed is_directory and
137
+ is_file? in favor of file? and directory?.
138
+
139
+ 2008-02-28 Eric Hodel <drbrain@segment7.net>
140
+
141
+ * lib/rubygems/package.rb: Broke up Tar bits into separate files.
142
+ * lib/rubygems/package/tar_reader/entry.rb: Don't copy TarHeader data
143
+ into Entry, go through #header instead. Better tests for
144
+ TarReader::Entry.
145
+
146
+ 2008-02-27 Eric Hodel <drbrain@segment7.net>
147
+
148
+ * lib/rubygems/dependency_installer.rb: Automatically fall back to
149
+ local-only install on network error. Fixes bug #15759 by Chauk-Mean P.
150
+ * lib/rubygems/source_index.rb: Process spec dirs so that earlier
151
+ dirs override later dirs. Fixes bug #14816 by Kurt Stephens.
152
+
153
+ 2008-02-26 Eric Hodel <drbrain@segment7.net>
154
+
155
+ * lib/rubygems/commands/update_command.rb: Only update gems that need
156
+ updates. Fixes bug #14780 by Mathieu Lajugie. Don't force
157
+ remote-only updates. Properly handle dependencies when updating.
158
+ Fixes bug #17488 by Hongli Lai.
159
+ * lib/rubygems/commands/environment_command.rb: Display path as a
160
+ usable path.
161
+ * lib/rubygems.rb: Don't add APPLE_GEM_HOME with ENV['GEM_HOME'].
162
+
163
+ 2008-02-25 Eric Hodel <drbrain@segment7.net>
164
+
165
+ * lib/rubygems.rb: Expand sitelibdir when checking prefix. Fixes bug
166
+ #17983 by Hemant Kumar.
167
+ * setup.rb: Print release notes on installation. Tell people where
168
+ `gem` was installed.
169
+ * bin/update_rubygems: Added --help output to explain how to install
170
+ earlier versions of RubyGems. Added --version option workaround.
171
+ Fixes bug #16842 by Chad Woolley.
172
+ * lib/rubygems/install_command.rb: Give proper exit code on failure.
173
+ Fixes bug #17438 by Josh Nichols.
174
+
175
+ 2008-02-23 Eric Hodel <drbrain@segment7.net>
176
+
177
+ * lib/rubygems/remote_fetcher.rb: Change hosts correctly when
178
+ redirecting. Handle EOFError from Net::HTTP.
179
+ * lib/rubygems/commands/specification_command.rb: Pull specifications
180
+ from gem files.
181
+ * lib/rubygems/uninstaller.rb: When :executable is set, don't ask the
182
+ user. Fixes bug #16812 by Matt Mower. Raise exception instead of
183
+ printing message when gem is not in GEM_HOME.
184
+ * lib/rubygems/uninstall_command.rb: Print message when gem is not in
185
+ GEM_HOME.
186
+ * lib/rubygems/commands/cleanup_command.rb: Clean up all old gems.
187
+ * lib/rubygems/commands/unpack_command.rb: Scan every gem path when
188
+ unpacking. Fixes bug #17602 by Ryan Davis.
189
+
190
+ 2008-02-20 Eric Hodel <drbrain@segment7.net>
191
+
192
+ * lib/rubygems/install_update_options.rb: Add --bindir option to
193
+ specify destination to install executables into. Patch #17937 by
194
+ Donavan Pantke.
195
+ * lib/rubygems/specification.rb: Fix Time.today == Time.today. Bug
196
+ #17413 by Andrei Bocan.
197
+ * setup.rb: Properly check for deletablitily of user and system
198
+ caches. Bug #17869 by Alexey Verkhovsky. Fix --no-format-executable.
199
+ Fixes bug #16879 by Charles Nutter.
200
+
201
+ 2008-02-19 Eric Hodel <drbrain@segment7.net>
202
+
203
+ * lib/rubygems/remote_fetcher.rb: Add persistent connection support.
204
+ Patch #18180 by Aaron Patterson.
205
+ * lib/rubygems/installer.rb: Fix #shebang to use the ruby install
206
+ name. Patch #16878 by Donavan Pantke.
207
+ * lib/rubygems/defaults.rb, lib/rubygems.rb: Enable defaults for
208
+ Gem.path and Gem.bindir. Patch #17886 by Donavan Pantke.
209
+ * test/test_gem_ext_configure_builder.rb: Make test_self_build_fail
210
+ more platform independent. Patch #17599 by Martin Krauskopf.
211
+
212
+ 2008-02-14 Eric Hodel <drbrain@segment7.net>
213
+
214
+ * lib/rubygems/commands/fetch_command.rb: Fix a bug when fetching
215
+ from non-default sources. Report non-existent gems instead of
216
+ crashing.
217
+
218
+ 2008-01-09 Eric Hodel <drbrain@segment7.net>
219
+
220
+ * lib/rubygems/commands/update_command.rb: Use portable and safe ENV
221
+ operation. Patch by usa in ruby SVN revision 14739.
222
+ * lib/rubygems/open-uri.rb: Fix tests. Patch by NARUSE Yui.
223
+ [ruby-dev:33336]
224
+
225
+ 2007-12-23 Eric Hodel <drbrain@segment7.net>
226
+
227
+ * util/gem_prelude.rb: Remove methods from Gem, not QuickLoader, to
228
+ fix warnings.
229
+
230
+ 2007-12-22 Eric Hodel <drbrain@segment7.net>
231
+
232
+ * lib/rubygems/commands/environment_command.rb: Put GEM PATHS in the
233
+ correct order.
234
+ * lib/rubygems/commands/uninstall_command.rb: Add --install-dir to
235
+ specify which local repository to uninstall from. Patch #15151 by
236
+ Donavan Pantke.
237
+ * lib/rubygems/uninstaller.rb: Only allow uninstallation of gems from
238
+ specified directory. Properly clean up executables on uninstall.
239
+ Patch #15151 by Donavan Pantke.
240
+ * lib/rubygems/install_update_options.rb: Add --no-env-shebang
241
+ option. Patch #16508 by Donavan Pantke.
242
+ * util/gem_prelude.rb: Use require to load rubygems.rb to make
243
+ $LOADED_FEATURES correct on RubyGems update.
244
+
245
+ 2007-12-21 Eric Hodel <drbrain@segment7.net>
246
+
247
+ * util/gem_prelude.rb: Place bin before lib so bin stubs work.
248
+
1
249
  2007-12-20 Eric Hodel <drbrain@segment7.net>
2
250
 
3
251
  * Rakefile: Require Ruby > 1.8.2. Enable CERT_DIR.
data/README CHANGED
@@ -10,6 +10,8 @@ Get it from RubyForge (http://rubygems.rubyforge.org) and run (as root, if appro
10
10
 
11
11
  For more details and other options, see:
12
12
 
13
+ ruby setup.rb --help
14
+
13
15
  * {User Guide/Installation}[http://docs.rubygems.org/read/chapter/3]
14
16
 
15
17
  == For User Documentation, see
data/Rakefile CHANGED
@@ -18,7 +18,11 @@ def announce(msg='')
18
18
  end
19
19
 
20
20
  # Disable certs for now.
21
- ENV['CERT_DIR'] ||= File.expand_path(File.join('~', '.gem'))
21
+ if RUBY_PLATFORM.match('mswin')
22
+ ENV['CERT_DIR'] ||= (File.join(ENV['USERPROFILE'], '.gem'))
23
+ else
24
+ ENV['CERT_DIR'] ||= File.expand_path(File.join('~', '.gem'))
25
+ end
22
26
 
23
27
  PKG_NAME = 'rubygems'
24
28
  def package_version
@@ -282,9 +286,9 @@ Rake::PackageTask.new("package") do |p|
282
286
  end
283
287
 
284
288
  Spec = Gem::Specification.new do |s|
285
- s.name = PKG_NAME + "-update"
289
+ s.name = PKG_NAME + "-update"
286
290
  s.version = PKG_VERSION
287
- s.required_ruby_version = Gem::Requirement.new '> 1.8.2'
291
+ s.required_ruby_version = Gem::Requirement.new '> 1.8.3'
288
292
  s.summary = "RubyGems Update GEM"
289
293
  s.description = %{RubyGems is a package management framework for Ruby. This Gem
290
294
  is a update for the base RubyGems software. You must have a base
@@ -371,35 +375,55 @@ task :rf => :rubyfiles
371
375
 
372
376
  # These tasks expect to have the following directory structure:
373
377
  #
374
- # ruby/trunk # ruby subversion HEAD checkout
375
- # rubygems/trunk # RubyGems subversion HEAD checkout
378
+ # git/git.rubini.us/code # Rubinius git HEAD checkout
379
+ # svn/ruby/trunk # ruby subversion HEAD checkout
380
+ # svn/rubygems/trunk # RubyGems subversion HEAD checkout
376
381
  #
377
- # If you don't have this directory structure, set RUBY_PATH.
382
+ # If you don't have this directory structure, set RUBY_PATH and/or
383
+ # RUBINIUS_PATH.
378
384
 
379
- desc "Updates Ruby HEAD with the currently checked-out copy of RubyGems."
380
- task :update_ruby do
381
- ruby_dir = ENV['RUBY_PATH'] || '../../ruby/trunk'
385
+ diff_options = "-urpN --exclude '*svn*' --exclude '*swp' --exclude '*rbc'"
386
+ rsync_options = "-avP --exclude '*svn*' --exclude '*swp' --exclude '*rbc' --exclude '*.rej' --exclude '*.orig'"
382
387
 
383
- options = "-avP --exclude '*svn*' --exclude '*swp' --exclude '*rbc'"
388
+ rubinius_dir = ENV['RUBINIUS_PATH'] || '../../../git/git.rubini.us/code'
389
+ ruby_dir = ENV['RUBY_PATH'] || '../../ruby/trunk'
384
390
 
385
- sh "rsync #{options} bin/gem #{ruby_dir}/bin/gem"
386
- sh "rsync #{options} lib/ #{ruby_dir}/lib"
387
- sh "rsync #{options} test/ #{ruby_dir}/test/rubygems"
388
- sh "rsync #{options} util/gem_prelude.rb #{ruby_dir}/gem_prelude.rb"
391
+ desc "Updates Ruby HEAD with the currently checked-out copy of RubyGems."
392
+ task :update_ruby do
393
+ sh "rsync #{rsync_options} bin/gem #{ruby_dir}/bin/gem"
394
+ sh "rsync #{rsync_options} lib/ #{ruby_dir}/lib"
395
+ sh "rsync #{rsync_options} test/ #{ruby_dir}/test/rubygems"
396
+ sh "rsync #{rsync_options} util/gem_prelude.rb #{ruby_dir}/gem_prelude.rb"
389
397
  end
390
398
 
391
399
  desc "Diffs Ruby HEAD with the currently checked-out copy of RubyGems."
392
400
  task :diff_ruby do
393
- ruby_dir = ENV['RUBY_PATH'] || '../../ruby/trunk'
394
-
395
401
  options = "-urpN --exclude '*svn*' --exclude '*swp' --exclude '*rbc'"
396
402
 
397
- sh "diff #{options} bin/gem #{ruby_dir}/bin/gem; true"
398
- sh "diff #{options} lib/ubygems.rb #{ruby_dir}/lib/ubygems.rb; true"
399
- sh "diff #{options} lib/rubygems.rb #{ruby_dir}/lib/rubygems.rb; true"
400
- sh "diff #{options} lib/rubygems #{ruby_dir}/lib/rubygems; true"
401
- sh "diff #{options} lib/rbconfig #{ruby_dir}/lib/rbconfig; true"
402
- sh "diff #{options} test #{ruby_dir}/test/rubygems; true"
403
- sh "diff #{options} util/gem_prelude.rb #{ruby_dir}/gem_prelude.rb; true"
403
+ sh "diff #{diff_options} bin/gem #{ruby_dir}/bin/gem; true"
404
+ sh "diff #{diff_options} lib/ubygems.rb #{ruby_dir}/lib/ubygems.rb; true"
405
+ sh "diff #{diff_options} lib/rubygems.rb #{ruby_dir}/lib/rubygems.rb; true"
406
+ sh "diff #{diff_options} lib/rubygems #{ruby_dir}/lib/rubygems; true"
407
+ sh "diff #{diff_options} lib/rbconfig #{ruby_dir}/lib/rbconfig; true"
408
+ sh "diff #{diff_options} test #{ruby_dir}/test/rubygems; true"
409
+ sh "diff #{diff_options} util/gem_prelude.rb #{ruby_dir}/gem_prelude.rb; true"
404
410
  end
405
411
 
412
+ desc "Updates Rubinius HEAD with the currently checked-out copy of RubyGems."
413
+ task :update_rubinius do
414
+ sh "rsync #{rsync_options} bin/gem #{rubinius_dir}/lib/bin/gem.rb"
415
+ sh "rsync #{rsync_options} lib/ #{rubinius_dir}/lib"
416
+ sh "rsync #{rsync_options} test/ #{rubinius_dir}/test/rubygems"
417
+ sh "rsync #{rsync_options} util/gem_prelude.rb #{rubinius_dir}/kernel/core/gem_prelude.rb"
418
+ end
419
+
420
+ desc "Diffs Rubinius HEAD with the currently checked-out copy of RubyGems."
421
+ task :diff_rubinius do
422
+ sh "diff #{diff_options} bin/gem #{rubinius_dir}/lib/bin/gem.rb; true"
423
+ sh "diff #{diff_options} lib/ubygems.rb #{rubinius_dir}/lib/ubygems.rb; true"
424
+ sh "diff #{diff_options} lib/rubygems.rb #{rubinius_dir}/lib/rubygems.rb; true"
425
+ sh "diff #{diff_options} lib/rubygems #{rubinius_dir}/lib/rubygems; true"
426
+ sh "diff #{diff_options} lib/rbconfig #{rubinius_dir}/lib/rbconfig; true"
427
+ sh "diff #{diff_options} test #{rubinius_dir}/test/rubygems; true"
428
+ sh "diff #{diff_options} util/gem_prelude.rb #{rubinius_dir}/kernel/core/gem_prelude.rb; true"
429
+ end
data/bin/gem CHANGED
@@ -7,11 +7,12 @@
7
7
 
8
8
  require 'rubygems'
9
9
  require 'rubygems/gem_runner'
10
+ require 'rubygems/exceptions'
10
11
 
11
- required_version = Gem::Requirement.new ">= 1.8.2"
12
+ required_version = Gem::Requirement.new "> 1.8.3"
12
13
 
13
- unless required_version.satisfied_by? Gem::Version.new(RUBY_VERSION) then
14
- abort "Expected Ruby Version #{required_version}, was #{RUBY_VERSION}"
14
+ unless required_version.satisfied_by? Gem.ruby_version then
15
+ abort "Expected Ruby Version #{required_version}, was #{Gem.ruby_version}"
15
16
  end
16
17
 
17
18
  # We need to preserve the original ARGV to use for passing gem options
@@ -19,5 +20,9 @@ end
19
20
  # it...its for the source building process.
20
21
  args = !ARGV.include?("--") ? ARGV.clone : ARGV[0...ARGV.index("--")]
21
22
 
22
- Gem::GemRunner.new.run args
23
+ begin
24
+ Gem::GemRunner.new.run args
25
+ rescue Gem::SystemExitException => e
26
+ exit e.exit_code
27
+ end
23
28
 
@@ -5,6 +5,20 @@
5
5
  # See LICENSE.txt for permissions.
6
6
  #++
7
7
 
8
+ require 'rubygems'
9
+
10
+ if ARGV.include? '-h' or ARGV.include? '--help' then
11
+ puts "rubygems_update [options]"
12
+ puts
13
+ puts "This will install the latest version of RubyGems."
14
+ puts
15
+ puts "\t--version=X.Y\tUpdate rubygems from the X.Y version."
16
+ exit
17
+ end
18
+
19
+ unless ARGV.grep(/--version=([\d\.]*)/).empty? then
20
+ exec "#{Gem.ruby} -S #{$PROGRAM_NAME} _#{$1}_"
21
+ end
8
22
 
9
23
  update_dir = $LOAD_PATH.find { |fn| fn =~ /rubygems-update/ }
10
24
 
@@ -20,5 +34,5 @@ else
20
34
  update_dir =~ /([0-9.]*)$/
21
35
  RGVERSION = $1
22
36
  puts "Installing RubyGems #{RGVERSION}"
23
- system "ruby setup.rb #{ARGV.join(' ')}"
37
+ system "#{Gem.ruby} setup.rb #{ARGV.join(' ')}"
24
38
  end
File without changes
@@ -17,82 +17,80 @@ end
17
17
 
18
18
  module Kernel
19
19
 
20
- # Adds a Ruby Gem to the $LOAD_PATH. Before a Gem is loaded, its
21
- # required Gems are loaded. If the version information is omitted,
22
- # the highest version Gem of the supplied name is loaded. If a Gem
23
- # is not found that meets the version requirement and/or a required
24
- # Gem is not found, a Gem::LoadError is raised. More information on
25
- # version requirements can be found in the Gem::Version
26
- # documentation.
27
- #
28
- # The +gem+ directive should be executed *before* any require
29
- # statements (otherwise rubygems might select a conflicting library
30
- # version).
20
+ ##
21
+ # Use Kernel#gem to activate a specific version of +gem_name+.
31
22
  #
32
- # You can define the environment variable GEM_SKIP as a way to not
33
- # load specified gems. You might do this to test out changes that
34
- # haven't been installed yet. Example:
23
+ # +version_requirements+ is a list of version requirements that the
24
+ # specified gem must match, most commonly "= example.version.number". See
25
+ # Gem::Requirement for how to specify a version requirement.
35
26
  #
36
- # GEM_SKIP=libA:libB ruby-I../libA -I../libB ./mycode.rb
27
+ # If you will be activating the latest version of a gem, there is no need to
28
+ # call Kernel#gem, Kernel#require will do the right thing for you.
37
29
  #
38
- # gem:: [String or Gem::Dependency] The gem name or dependency
39
- # instance.
30
+ # Kernel#gem returns true if the gem was activated, otherwise false. If the
31
+ # gem could not be found, didn't match the version requirements, or a
32
+ # different version was already activated, an exception will be raised.
40
33
  #
41
- # version_requirement:: [default=">= 0"] The version
42
- # requirement.
34
+ # Kernel#gem should be called *before* any require statements (otherwise
35
+ # RubyGems may load a conflicting library version).
43
36
  #
44
- # return:: [Boolean] true if the Gem is loaded, otherwise false.
37
+ # In older RubyGems versions, the environment variable GEM_SKIP could be
38
+ # used to skip activation of specified gems, for example to test out changes
39
+ # that haven't been installed yet. Now RubyGems defers to -I and the
40
+ # RUBYLIB environment variable to skip activation of a gem.
45
41
  #
46
- # raises:: [Gem::LoadError] if Gem cannot be found, is listed in
47
- # GEM_SKIP, or version requirement not met.
42
+ # Example:
48
43
  #
49
- def gem(gem_name, *version_requirements)
50
- active_gem_with_options(gem_name, version_requirements)
51
- end
52
-
53
- # Return the file name (string) and line number (integer) of the caller of
54
- # the caller of this method.
55
- def location_of_caller
56
- file, lineno = caller[1].split(':')
57
- lineno = lineno.to_i
58
- [file, lineno]
59
- end
60
- private :location_of_caller
44
+ # GEM_SKIP=libA:libB ruby -I../libA -I../libB ./mycode.rb
61
45
 
62
- def active_gem_with_options(gem_name, version_requirements, options={})
46
+ def gem(gem_name, *version_requirements)
63
47
  skip_list = (ENV['GEM_SKIP'] || "").split(/:/)
64
48
  raise Gem::LoadError, "skipping #{gem_name}" if skip_list.include? gem_name
65
- Gem.activate(gem_name, options[:auto_require], *version_requirements)
49
+ Gem.activate(gem_name, *version_requirements)
66
50
  end
67
- private :active_gem_with_options
51
+
68
52
  end
69
53
 
54
+ ##
70
55
  # Main module to hold all RubyGem classes/modules.
71
- #
56
+
72
57
  module Gem
73
58
 
74
59
  ConfigMap = {} unless defined?(ConfigMap)
75
60
  require 'rbconfig'
76
61
  RbConfig = Config unless defined? ::RbConfig
62
+
77
63
  ConfigMap.merge!(
78
- :BASERUBY => RbConfig::CONFIG["BASERUBY"],
79
- :EXEEXT => RbConfig::CONFIG["EXEEXT"],
80
- :RUBY_INSTALL_NAME => RbConfig::CONFIG["RUBY_INSTALL_NAME"],
81
- :RUBY_SO_NAME => RbConfig::CONFIG["RUBY_SO_NAME"],
82
- :arch => RbConfig::CONFIG["arch"],
83
- :bindir => RbConfig::CONFIG["bindir"],
84
- :libdir => RbConfig::CONFIG["libdir"],
85
- :ruby_install_name => RbConfig::CONFIG["ruby_install_name"],
86
- :ruby_version => RbConfig::CONFIG["ruby_version"],
87
- :sitedir => RbConfig::CONFIG["sitedir"],
88
- :sitelibdir => RbConfig::CONFIG["sitelibdir"]
64
+ :BASERUBY => RbConfig::CONFIG["BASERUBY"],
65
+ :EXEEXT => RbConfig::CONFIG["EXEEXT"],
66
+ :RUBY_INSTALL_NAME => RbConfig::CONFIG["RUBY_INSTALL_NAME"],
67
+ :RUBY_SO_NAME => RbConfig::CONFIG["RUBY_SO_NAME"],
68
+ :arch => RbConfig::CONFIG["arch"],
69
+ :bindir => RbConfig::CONFIG["bindir"],
70
+ :libdir => RbConfig::CONFIG["libdir"],
71
+ :ruby_install_name => RbConfig::CONFIG["ruby_install_name"],
72
+ :ruby_version => RbConfig::CONFIG["ruby_version"],
73
+ :sitedir => RbConfig::CONFIG["sitedir"],
74
+ :sitelibdir => RbConfig::CONFIG["sitelibdir"]
89
75
  )
90
76
 
77
+ DIRECTORIES = %w[cache doc gems specifications] unless defined?(DIRECTORIES)
78
+
91
79
  MUTEX = Mutex.new
92
80
 
93
81
  RubyGemsPackageVersion = RubyGemsVersion
94
82
 
95
- DIRECTORIES = %w[cache doc gems specifications] unless defined?(DIRECTORIES)
83
+ ##
84
+ # An Array of Regexps that match windows ruby platforms.
85
+
86
+ WIN_PATTERNS = [
87
+ /bccwin/i,
88
+ /cygwin/i,
89
+ /djgpp/i,
90
+ /mingw/i,
91
+ /mswin/i,
92
+ /wince/i,
93
+ ]
96
94
 
97
95
  @@source_index = nil
98
96
  @@win_platform = nil
@@ -103,10 +101,129 @@ module Gem
103
101
  @ruby = nil
104
102
  @sources = []
105
103
 
104
+ ##
105
+ # Activates an installed gem matching +gem+. The gem must satisfy
106
+ # +version_requirements+.
107
+ #
108
+ # Returns true if the gem is activated, false if it is already
109
+ # loaded, or an exception otherwise.
110
+ #
111
+ # Gem#activate adds the library paths in +gem+ to $LOAD_PATH. Before a Gem
112
+ # is activated its required Gems are activated. If the version information
113
+ # is omitted, the highest version Gem of the supplied name is loaded. If a
114
+ # Gem is not found that meets the version requirements or a required Gem is
115
+ # not found, a Gem::LoadError is raised.
116
+ #
117
+ # More information on version requirements can be found in the
118
+ # Gem::Requirement and Gem::Version documentation.
119
+
120
+ def self.activate(gem, *version_requirements)
121
+ if version_requirements.empty? then
122
+ version_requirements = Gem::Requirement.default
123
+ end
124
+
125
+ unless gem.respond_to?(:name) and
126
+ gem.respond_to?(:version_requirements) then
127
+ gem = Gem::Dependency.new(gem, version_requirements)
128
+ end
129
+
130
+ matches = Gem.source_index.find_name(gem.name, gem.version_requirements)
131
+ report_activate_error(gem) if matches.empty?
132
+
133
+ if @loaded_specs[gem.name] then
134
+ # This gem is already loaded. If the currently loaded gem is not in the
135
+ # list of candidate gems, then we have a version conflict.
136
+ existing_spec = @loaded_specs[gem.name]
137
+
138
+ unless matches.any? { |spec| spec.version == existing_spec.version } then
139
+ raise Gem::Exception,
140
+ "can't activate #{gem}, already activated #{existing_spec.full_name}]"
141
+ end
142
+
143
+ return false
144
+ end
145
+
146
+ # new load
147
+ spec = matches.last
148
+ return false if spec.loaded?
149
+
150
+ spec.loaded = true
151
+ @loaded_specs[spec.name] = spec
152
+
153
+ # Load dependent gems first
154
+ spec.dependencies.each do |dep_gem|
155
+ activate dep_gem
156
+ end
157
+
158
+ # bin directory must come before library directories
159
+ spec.require_paths.unshift spec.bindir if spec.bindir
160
+
161
+ require_paths = spec.require_paths.map do |path|
162
+ File.join spec.full_gem_path, path
163
+ end
164
+
165
+ sitelibdir = ConfigMap[:sitelibdir]
166
+
167
+ # gem directories must come after -I and ENV['RUBYLIB']
168
+ insert_index = load_path_insert_index
169
+
170
+ if insert_index then
171
+ # gem directories must come after -I and ENV['RUBYLIB']
172
+ $LOAD_PATH.insert(insert_index, *require_paths)
173
+ else
174
+ # we are probably testing in core, -I and RUBYLIB don't apply
175
+ $LOAD_PATH.unshift(*require_paths)
176
+ end
177
+
178
+ return true
179
+ end
180
+
181
+ ##
182
+ # An Array of all possible load paths for all versions of all gems in the
183
+ # Gem installation.
184
+
185
+ def self.all_load_paths
186
+ result = []
187
+
188
+ Gem.path.each do |gemdir|
189
+ each_load_path all_partials(gemdir) do |load_path|
190
+ result << load_path
191
+ end
192
+ end
193
+
194
+ result
195
+ end
196
+
197
+ ##
198
+ # Return all the partial paths in +gemdir+.
199
+
200
+ def self.all_partials(gemdir)
201
+ Dir[File.join(gemdir, 'gems/*')]
202
+ end
203
+
204
+ private_class_method :all_partials
205
+
206
+ ##
207
+ # The mode needed to read a file as straight binary.
208
+
209
+ def self.binary_mode
210
+ @binary_mode ||= RUBY_VERSION > '1.9' ? 'rb:ascii-8bit' : 'rb'
211
+ end
212
+
213
+ ##
214
+ # The path where gem executables are to be installed.
215
+
216
+ def self.bindir(install_dir=Gem.dir)
217
+ return File.join(install_dir, 'bin') unless
218
+ install_dir.to_s == Gem.default_dir
219
+ Gem.default_bindir
220
+ end
221
+
222
+ ##
106
223
  # Reset the +dir+ and +path+ values. The next time +dir+ or +path+
107
224
  # is requested, the values will be calculated from scratch. This is
108
225
  # mainly used by the unit tests to provide test isolation.
109
- #
226
+
110
227
  def self.clear_paths
111
228
  @gem_home = nil
112
229
  @gem_path = nil
@@ -116,415 +233,430 @@ module Gem
116
233
  end
117
234
  end
118
235
 
119
- # The version of the Marshal format for your Ruby.
120
- def self.marshal_version
121
- "#{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}"
236
+ ##
237
+ # The path to standard location of the user's .gemrc file.
238
+
239
+ def self.config_file
240
+ File.join Gem.user_home, '.gemrc'
122
241
  end
123
242
 
124
243
  ##
125
- # The directory prefix this RubyGems was installed at.
244
+ # The standard configuration object for gems.
126
245
 
127
- def self.prefix
128
- prefix = File.dirname File.expand_path(__FILE__)
129
- if prefix == ConfigMap[:sitelibdir] then
130
- nil
131
- else
132
- File.dirname prefix
133
- end
246
+ def self.configuration
247
+ return @configuration if @configuration
248
+ require 'rubygems/config_file'
249
+ @configuration = Gem::ConfigFile.new []
134
250
  end
135
251
 
136
- # Returns an Cache of specifications that are in the Gem.path
137
- #
138
- # return:: [Gem::SourceIndex] Index of installed Gem::Specifications
139
- #
140
- def self.source_index
141
- @@source_index ||= SourceIndex.from_installed_gems
252
+ ##
253
+ # Use the given configuration object (which implements the ConfigFile
254
+ # protocol) as the standard configuration object.
255
+
256
+ def self.configuration=(config)
257
+ @configuration = config
142
258
  end
143
259
 
144
260
  ##
145
- # An Array of Regexps that match windows ruby platforms.
261
+ # The path the the data directory specified by the gem name. If the
262
+ # package is not available as a gem, return nil.
146
263
 
147
- WIN_PATTERNS = [
148
- /bccwin/i,
149
- /cygwin/i,
150
- /djgpp/i,
151
- /mingw/i,
152
- /mswin/i,
153
- /wince/i,
154
- ]
264
+ def self.datadir(gem_name)
265
+ spec = @loaded_specs[gem_name]
266
+ return nil if spec.nil?
267
+ File.join(spec.full_gem_path, 'data', gem_name)
268
+ end
155
269
 
156
270
  ##
157
- # Is this a windows platform?
271
+ # The path where gems are to be installed.
158
272
 
159
- def self.win_platform?
160
- if @@win_platform.nil? then
161
- @@win_platform = !!WIN_PATTERNS.find { |r| RUBY_PLATFORM =~ r }
162
- end
273
+ def self.dir
274
+ @gem_home ||= nil
275
+ set_home(ENV['GEM_HOME'] || default_dir) unless @gem_home
276
+ @gem_home
277
+ end
163
278
 
164
- @@win_platform
279
+ ##
280
+ # Expand each partial gem path with each of the required paths specified
281
+ # in the Gem spec. Each expanded path is yielded.
282
+
283
+ def self.each_load_path(partials)
284
+ partials.each do |gp|
285
+ base = File.basename(gp)
286
+ specfn = File.join(dir, "specifications", base + ".gemspec")
287
+ if File.exist?(specfn)
288
+ spec = eval(File.read(specfn))
289
+ spec.require_paths.each do |rp|
290
+ yield(File.join(gp, rp))
291
+ end
292
+ else
293
+ filename = File.join(gp, 'lib')
294
+ yield(filename) if File.exist?(filename)
295
+ end
296
+ end
165
297
  end
166
298
 
167
- class << self
299
+ private_class_method :each_load_path
168
300
 
169
- attr_reader :loaded_specs
301
+ ##
302
+ # Quietly ensure the named Gem directory contains all the proper
303
+ # subdirectories. If we can't create a directory due to a permission
304
+ # problem, then we will silently continue.
170
305
 
171
- # Quietly ensure the named Gem directory contains all the proper
172
- # subdirectories. If we can't create a directory due to a permission
173
- # problem, then we will silently continue.
174
- def ensure_gem_subdirectories(gemdir)
175
- require 'fileutils'
306
+ def self.ensure_gem_subdirectories(gemdir)
307
+ require 'fileutils'
176
308
 
177
- Gem::DIRECTORIES.each do |filename|
178
- fn = File.join gemdir, filename
179
- FileUtils.mkdir_p fn rescue nil unless File.exist? fn
180
- end
309
+ Gem::DIRECTORIES.each do |filename|
310
+ fn = File.join gemdir, filename
311
+ FileUtils.mkdir_p fn rescue nil unless File.exist? fn
312
+ end
313
+ end
314
+
315
+ ##
316
+ # Finds the user's home directory.
317
+ #--
318
+ # Some comments from the ruby-talk list regarding finding the home
319
+ # directory:
320
+ #
321
+ # I have HOME, USERPROFILE and HOMEDRIVE + HOMEPATH. Ruby seems
322
+ # to be depending on HOME in those code samples. I propose that
323
+ # it should fallback to USERPROFILE and HOMEDRIVE + HOMEPATH (at
324
+ # least on Win32).
325
+
326
+ def self.find_home
327
+ ['HOME', 'USERPROFILE'].each do |homekey|
328
+ return ENV[homekey] if ENV[homekey]
181
329
  end
182
330
 
183
- def platforms
184
- @platforms ||= [Gem::Platform::RUBY, Gem::Platform.local]
331
+ if ENV['HOMEDRIVE'] && ENV['HOMEPATH'] then
332
+ return "#{ENV['HOMEDRIVE']}:#{ENV['HOMEPATH']}"
185
333
  end
186
334
 
187
- # Returns an Array of sources to fetch remote gems from. If the sources
188
- # list is empty, attempts to load the "sources" gem, then uses
189
- # default_sources if it is not installed.
190
- def sources
191
- if @sources.empty? then
192
- begin
193
- gem 'sources', '> 0.0.1'
194
- require 'sources'
195
- rescue LoadError
196
- @sources = default_sources
197
- end
335
+ begin
336
+ File.expand_path("~")
337
+ rescue
338
+ if File::ALT_SEPARATOR then
339
+ "C:/"
340
+ else
341
+ "/"
198
342
  end
199
-
200
- @sources
201
343
  end
344
+ end
202
345
 
346
+ private_class_method :find_home
203
347
 
204
- # Provide an alias for the old name.
205
- alias cache source_index
206
-
207
- # The directory path where Gems are to be installed.
208
- #
209
- # return:: [String] The directory path
210
- #
211
- def dir
212
- @gem_home ||= nil
213
- set_home(ENV['GEM_HOME'] || default_dir) unless @gem_home
214
- @gem_home
215
- end
348
+ ##
349
+ # Return a list of all possible load paths for the latest version for all
350
+ # gems in the Gem installation.
216
351
 
217
- # The directory path where executables are to be installed.
218
- #
219
- def bindir(install_dir=Gem.dir)
220
- return File.join(install_dir, 'bin') unless
221
- install_dir.to_s == Gem.default_dir
352
+ def self.latest_load_paths
353
+ result = []
222
354
 
223
- if defined? RUBY_FRAMEWORK_VERSION then # mac framework support
224
- '/usr/bin'
225
- else # generic install
226
- ConfigMap[:bindir]
355
+ Gem.path.each do |gemdir|
356
+ each_load_path(latest_partials(gemdir)) do |load_path|
357
+ result << load_path
227
358
  end
228
359
  end
229
360
 
230
- # List of directory paths to search for Gems.
231
- #
232
- # return:: [List<String>] List of directory paths.
233
- #
234
- def path
235
- @gem_path ||= nil
236
- unless @gem_path
237
- paths = [ENV['GEM_PATH']]
238
- paths << APPLE_GEM_HOME if defined? APPLE_GEM_HOME
239
- set_paths(paths.compact.join(File::PATH_SEPARATOR))
361
+ result
362
+ end
363
+
364
+ ##
365
+ # Return only the latest partial paths in the given +gemdir+.
366
+
367
+ def self.latest_partials(gemdir)
368
+ latest = {}
369
+ all_partials(gemdir).each do |gp|
370
+ base = File.basename(gp)
371
+ if base =~ /(.*)-((\d+\.)*\d+)/ then
372
+ name, version = $1, $2
373
+ ver = Gem::Version.new(version)
374
+ if latest[name].nil? || ver > latest[name][0]
375
+ latest[name] = [ver, gp]
376
+ end
240
377
  end
241
- @gem_path
242
378
  end
379
+ latest.collect { |k,v| v[1] }
380
+ end
243
381
 
244
- # The home directory for the user.
245
- def user_home
246
- @user_home ||= find_home
247
- end
382
+ private_class_method :latest_partials
248
383
 
249
- # Return the path to standard location of the users .gemrc file.
250
- def config_file
251
- File.join(Gem.user_home, '.gemrc')
384
+ ##
385
+ # The index to insert activated gem paths into the $LOAD_PATH.
386
+ #
387
+ # Defaults to the site lib directory unless gem_prelude.rb has loaded paths,
388
+ # then it inserts the activated gem's paths before the gem_prelude.rb paths
389
+ # so you can override the gem_prelude.rb default $LOAD_PATH paths.
390
+
391
+ def self.load_path_insert_index
392
+ index = $LOAD_PATH.index ConfigMap[:sitelibdir]
393
+
394
+ $LOAD_PATH.each_with_index do |path, i|
395
+ if path.instance_variables.include?(:@gem_prelude_index) or
396
+ path.instance_variables.include?('@gem_prelude_index') then
397
+ index = i
398
+ break
399
+ end
252
400
  end
253
401
 
254
- # The standard configuration object for gems.
255
- def configuration
256
- return @configuration if @configuration
257
- require 'rubygems/config_file'
258
- @configuration = Gem::ConfigFile.new []
259
- end
402
+ index
403
+ end
260
404
 
261
- # Use the given configuration object (which implements the
262
- # ConfigFile protocol) as the standard configuration object.
263
- def configuration=(config)
264
- @configuration = config
265
- end
405
+ ##
406
+ # The file name and line number of the caller of the caller of this method.
266
407
 
267
- # Return the path the the data directory specified by the gem
268
- # name. If the package is not available as a gem, return nil.
269
- def datadir(gem_name)
270
- spec = @loaded_specs[gem_name]
271
- return nil if spec.nil?
272
- File.join(spec.full_gem_path, 'data', gem_name)
273
- end
408
+ def self.location_of_caller
409
+ file, lineno = caller[1].split(':')
410
+ lineno = lineno.to_i
411
+ [file, lineno]
412
+ end
274
413
 
275
- # Return the searcher object to search for matching gems.
276
- def searcher
277
- MUTEX.synchronize do
278
- @searcher ||= Gem::GemPathSearcher.new
279
- end
280
- end
414
+ private_class_method :location_of_caller
281
415
 
282
- # Return the Ruby command to use to execute the Ruby interpreter.
283
- def ruby
284
- if @ruby.nil? then
285
- @ruby = File.join(ConfigMap[:bindir],
286
- ConfigMap[:ruby_install_name])
287
- @ruby << ConfigMap[:EXEEXT]
288
- end
416
+ ##
417
+ # manage_gems is useless and deprecated. Don't call it anymore.
418
+ #--
419
+ # TODO warn w/ RubyGems 1.2.x release.
289
420
 
290
- @ruby
291
- end
421
+ def self.manage_gems
422
+ #file, lineno = location_of_caller
292
423
 
293
- # Activate a gem (i.e. add it to the Ruby load path). The gem
294
- # must satisfy all the specified version constraints. If
295
- # +autorequire+ is true, then automatically require the specified
296
- # autorequire file in the gem spec.
297
- #
298
- # Returns true if the gem is loaded by this call, false if it is
299
- # already loaded, or an exception otherwise.
300
- #
301
- def activate(gem, autorequire, *version_requirements)
302
- if version_requirements.empty? then
303
- version_requirements = Gem::Requirement.default
304
- end
424
+ #warn "#{file}:#{lineno}:Warning: Gem#manage_gems is deprecated and will be removed on or after September 2008."
425
+ end
305
426
 
306
- unless gem.respond_to?(:name) && gem.respond_to?(:version_requirements)
307
- gem = Gem::Dependency.new(gem, version_requirements)
308
- end
427
+ ##
428
+ # The version of the Marshal format for your Ruby.
309
429
 
310
- matches = Gem.source_index.find_name(gem.name, gem.version_requirements)
311
- report_activate_error(gem) if matches.empty?
430
+ def self.marshal_version
431
+ "#{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}"
432
+ end
312
433
 
313
- if @loaded_specs[gem.name]
314
- # This gem is already loaded. If the currently loaded gem is
315
- # not in the list of candidate gems, then we have a version
316
- # conflict.
317
- existing_spec = @loaded_specs[gem.name]
318
- if ! matches.any? { |spec| spec.version == existing_spec.version }
319
- fail Gem::Exception, "can't activate #{gem}, already activated #{existing_spec.full_name}]"
320
- end
321
- return false
322
- end
434
+ ##
435
+ # Array of paths to search for Gems.
323
436
 
324
- # new load
325
- spec = matches.last
326
- if spec.loaded?
327
- return false unless autorequire
328
- result = spec.autorequire ? require(spec.autorequire) : false
329
- return result || false
330
- end
437
+ def self.path
438
+ @gem_path ||= nil
331
439
 
332
- spec.loaded = true
333
- @loaded_specs[spec.name] = spec
440
+ unless @gem_path then
441
+ paths = [ENV['GEM_PATH']] || [default_path]
334
442
 
335
- # Load dependent gems first
336
- spec.dependencies.each do |dep_gem|
337
- activate(dep_gem, autorequire)
443
+ if defined?(APPLE_GEM_HOME) and not ENV['GEM_PATH'] then
444
+ paths << APPLE_GEM_HOME
338
445
  end
339
446
 
340
- # bin directory must come before library directories
341
- spec.require_paths.unshift spec.bindir if spec.bindir
447
+ set_paths paths.compact.join(File::PATH_SEPARATOR)
448
+ end
342
449
 
343
- require_paths = spec.require_paths.map do |path|
344
- File.join spec.full_gem_path, path
345
- end
450
+ @gem_path
451
+ end
346
452
 
347
- sitelibdir = ConfigMap[:sitelibdir]
453
+ ##
454
+ # Array of platforms this RubyGems supports.
348
455
 
349
- # gem directories must come after -I and ENV['RUBYLIB']
350
- $:.insert($:.index(sitelibdir), *require_paths)
456
+ def self.platforms
457
+ @platforms ||= [Gem::Platform::RUBY, Gem::Platform.local]
458
+ end
351
459
 
352
- # Now autorequire
353
- if autorequire && spec.autorequire then # DEPRECATED
354
- Array(spec.autorequire).each do |a_lib|
355
- require a_lib
356
- end
357
- end
460
+ ##
461
+ # The directory prefix this RubyGems was installed at.
358
462
 
359
- return true
463
+ def self.prefix
464
+ prefix = File.dirname File.expand_path(__FILE__)
465
+
466
+ if prefix == File.expand_path(ConfigMap[:sitelibdir]) then
467
+ nil
468
+ else
469
+ File.dirname prefix
360
470
  end
471
+ end
472
+
473
+ ##
474
+ # Safely read a file in binary mode on all platforms.
475
+
476
+ def self.read_binary(path)
477
+ File.open path, binary_mode do |f| f.read end
478
+ end
479
+
480
+ ##
481
+ # Report a load error during activation. The message of load error
482
+ # depends on whether it was a version mismatch or if there are not gems of
483
+ # any version by the requested name.
361
484
 
362
- # Report a load error during activation. The message of load
363
- # error depends on whether it was a version mismatch or if there
364
- # are not gems of any version by the requested name.
365
- def report_activate_error(gem)
366
- matches = Gem.source_index.find_name(gem.name)
485
+ def self.report_activate_error(gem)
486
+ matches = Gem.source_index.find_name(gem.name)
367
487
 
368
- if matches.empty? then
369
- error = Gem::LoadError.new(
488
+ if matches.empty? then
489
+ error = Gem::LoadError.new(
370
490
  "Could not find RubyGem #{gem.name} (#{gem.version_requirements})\n")
371
- else
372
- error = Gem::LoadError.new(
491
+ else
492
+ error = Gem::LoadError.new(
373
493
  "RubyGem version error: " +
374
494
  "#{gem.name}(#{matches.first.version} not #{gem.version_requirements})\n")
375
- end
376
-
377
- error.name = gem.name
378
- error.version_requirement = gem.version_requirements
379
- raise error
380
- end
381
- private :report_activate_error
382
-
383
- # Use the +home+ and (optional) +paths+ values for +dir+ and +path+.
384
- # Used mainly by the unit tests to provide environment isolation.
385
- #
386
- def use_paths(home, paths=[])
387
- clear_paths
388
- set_home(home) if home
389
- set_paths(paths.join(File::PATH_SEPARATOR)) if paths
390
495
  end
391
496
 
392
- # Return a list of all possible load paths for all versions for
393
- # all gems in the Gem installation.
394
- #
395
- def all_load_paths
396
- result = []
397
- Gem.path.each do |gemdir|
398
- each_load_path(all_partials(gemdir)) do |load_path|
399
- result << load_path
400
- end
401
- end
402
- result
403
- end
497
+ error.name = gem.name
498
+ error.version_requirement = gem.version_requirements
499
+ raise error
500
+ end
404
501
 
405
- # Return a list of all possible load paths for the latest version
406
- # for all gems in the Gem installation.
407
- def latest_load_paths
408
- result = []
409
- Gem.path.each do |gemdir|
410
- each_load_path(latest_partials(gemdir)) do |load_path|
411
- result << load_path
412
- end
413
- end
414
- result
415
- end
502
+ private_class_method :report_activate_error
416
503
 
417
- def required_location(gemname, libfile, *version_constraints)
418
- version_constraints = Gem::Requirement.default if version_constraints.empty?
419
- matches = Gem.source_index.find_name(gemname, version_constraints)
420
- return nil if matches.empty?
421
- spec = matches.last
422
- spec.require_paths.each do |path|
423
- result = File.join(spec.full_gem_path, path, libfile)
424
- return result if File.exist?(result)
425
- end
426
- nil
504
+ def self.required_location(gemname, libfile, *version_constraints)
505
+ version_constraints = Gem::Requirement.default if version_constraints.empty?
506
+ matches = Gem.source_index.find_name(gemname, version_constraints)
507
+ return nil if matches.empty?
508
+ spec = matches.last
509
+ spec.require_paths.each do |path|
510
+ result = File.join(spec.full_gem_path, path, libfile)
511
+ return result if File.exist?(result)
427
512
  end
513
+ nil
514
+ end
428
515
 
429
- def suffixes
430
- ['', '.rb', '.rbw', '.so', '.bundle', '.dll', '.sl', '.jar']
431
- end
516
+ ##
517
+ # The path to the running Ruby interpreter.
432
518
 
433
- def suffix_pattern
434
- @suffix_pattern ||= "{#{suffixes.join(',')}}"
519
+ def self.ruby
520
+ if @ruby.nil? then
521
+ @ruby = File.join(ConfigMap[:bindir],
522
+ ConfigMap[:ruby_install_name])
523
+ @ruby << ConfigMap[:EXEEXT]
435
524
  end
436
525
 
437
- # manage_gems is useless and deprecated. Don't call it anymore. This
438
- # will warn in two releases.
439
- def manage_gems
440
- # do nothing
441
- end
526
+ @ruby
527
+ end
442
528
 
443
- private
529
+ ##
530
+ # A Gem::Version for the currently running ruby.
444
531
 
445
- # Return all the partial paths in the given +gemdir+.
446
- def all_partials(gemdir)
447
- Dir[File.join(gemdir, 'gems/*')]
448
- end
532
+ def self.ruby_version
533
+ return @ruby_version if defined? @ruby_version
534
+ version = RUBY_VERSION.dup
535
+ version << ".#{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
536
+ @ruby_version = Gem::Version.new version
537
+ end
449
538
 
450
- # Return only the latest partial paths in the given +gemdir+.
451
- def latest_partials(gemdir)
452
- latest = {}
453
- all_partials(gemdir).each do |gp|
454
- base = File.basename(gp)
455
- if base =~ /(.*)-((\d+\.)*\d+)/ then
456
- name, version = $1, $2
457
- ver = Gem::Version.new(version)
458
- if latest[name].nil? || ver > latest[name][0]
459
- latest[name] = [ver, gp]
460
- end
461
- end
462
- end
463
- latest.collect { |k,v| v[1] }
539
+ ##
540
+ # The GemPathSearcher object used to search for matching installed gems.
541
+
542
+ def self.searcher
543
+ MUTEX.synchronize do
544
+ @searcher ||= Gem::GemPathSearcher.new
464
545
  end
546
+ end
547
+
548
+ ##
549
+ # Set the Gem home directory (as reported by Gem.dir).
550
+
551
+ def self.set_home(home)
552
+ home = home.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
553
+ @gem_home = home
554
+ ensure_gem_subdirectories(@gem_home)
555
+ end
465
556
 
466
- # Expand each partial gem path with each of the required paths
467
- # specified in the Gem spec. Each expanded path is yielded.
468
- def each_load_path(partials)
469
- partials.each do |gp|
470
- base = File.basename(gp)
471
- specfn = File.join(dir, "specifications", base + ".gemspec")
472
- if File.exist?(specfn)
473
- spec = eval(File.read(specfn))
474
- spec.require_paths.each do |rp|
475
- yield(File.join(gp, rp))
476
- end
477
- else
478
- filename = File.join(gp, 'lib')
479
- yield(filename) if File.exist?(filename)
557
+ private_class_method :set_home
558
+
559
+ ##
560
+ # Set the Gem search path (as reported by Gem.path).
561
+
562
+ def self.set_paths(gpaths)
563
+ if gpaths
564
+ @gem_path = gpaths.split(File::PATH_SEPARATOR)
565
+
566
+ if File::ALT_SEPARATOR then
567
+ @gem_path.map! do |path|
568
+ path.gsub File::ALT_SEPARATOR, File::SEPARATOR
480
569
  end
481
570
  end
571
+
572
+ @gem_path << Gem.dir
573
+ else
574
+ @gem_path = [Gem.dir]
482
575
  end
483
576
 
484
- # Set the Gem home directory (as reported by +dir+).
485
- def set_home(home)
486
- @gem_home = home
487
- ensure_gem_subdirectories(@gem_home)
488
- end
577
+ @gem_path.uniq!
578
+ @gem_path.each do |gp| ensure_gem_subdirectories(gp) end
579
+ end
489
580
 
490
- # Set the Gem search path (as reported by +path+).
491
- def set_paths(gpaths)
492
- if gpaths
493
- @gem_path = gpaths.split(File::PATH_SEPARATOR)
494
- @gem_path << Gem.dir
495
- else
496
- @gem_path = [Gem.dir]
497
- end
498
- @gem_path.uniq!
499
- @gem_path.each do |gp| ensure_gem_subdirectories(gp) end
500
- end
581
+ private_class_method :set_paths
501
582
 
502
- # Some comments from the ruby-talk list regarding finding the home
503
- # directory:
504
- #
505
- # I have HOME, USERPROFILE and HOMEDRIVE + HOMEPATH. Ruby seems
506
- # to be depending on HOME in those code samples. I propose that
507
- # it should fallback to USERPROFILE and HOMEDRIVE + HOMEPATH (at
508
- # least on Win32).
509
- #
510
- def find_home
511
- ['HOME', 'USERPROFILE'].each do |homekey|
512
- return ENV[homekey] if ENV[homekey]
513
- end
514
- if ENV['HOMEDRIVE'] && ENV['HOMEPATH']
515
- return "#{ENV['HOMEDRIVE']}:#{ENV['HOMEPATH']}"
516
- end
583
+ ##
584
+ # Returns the Gem::SourceIndex of specifications that are in the Gem.path
585
+
586
+ def self.source_index
587
+ @@source_index ||= SourceIndex.from_installed_gems
588
+ end
589
+
590
+ ##
591
+ # Returns an Array of sources to fetch remote gems from. If the sources
592
+ # list is empty, attempts to load the "sources" gem, then uses
593
+ # default_sources if it is not installed.
594
+
595
+ def self.sources
596
+ if @sources.empty? then
517
597
  begin
518
- File.expand_path("~")
519
- rescue StandardError => ex
520
- if File::ALT_SEPARATOR
521
- "C:/"
522
- else
523
- "/"
524
- end
598
+ gem 'sources', '> 0.0.1'
599
+ require 'sources'
600
+ rescue LoadError
601
+ @sources = default_sources
525
602
  end
526
603
  end
527
604
 
605
+ @sources
606
+ end
607
+
608
+ ##
609
+ # Glob pattern for require-able path suffixes.
610
+
611
+ def self.suffix_pattern
612
+ @suffix_pattern ||= "{#{suffixes.join(',')}}"
613
+ end
614
+
615
+ ##
616
+ # Suffixes for require-able paths.
617
+
618
+ def self.suffixes
619
+ ['', '.rb', '.rbw', '.so', '.bundle', '.dll', '.sl', '.jar']
620
+ end
621
+
622
+ ##
623
+ # Use the +home+ and +paths+ values for Gem.dir and Gem.path. Used mainly
624
+ # by the unit tests to provide environment isolation.
625
+
626
+ def self.use_paths(home, paths=[])
627
+ clear_paths
628
+ set_home(home) if home
629
+ set_paths(paths.join(File::PATH_SEPARATOR)) if paths
630
+ end
631
+
632
+ ##
633
+ # The home directory for the user.
634
+
635
+ def self.user_home
636
+ @user_home ||= find_home
637
+ end
638
+
639
+ ##
640
+ # Is this a windows platform?
641
+
642
+ def self.win_platform?
643
+ if @@win_platform.nil? then
644
+ @@win_platform = !!WIN_PATTERNS.find { |r| RUBY_PLATFORM =~ r }
645
+ end
646
+
647
+ @@win_platform
648
+ end
649
+
650
+ class << self
651
+
652
+ attr_reader :loaded_specs
653
+
654
+ # :stopdoc:
655
+
656
+ alias cache source_index # an alias for the old name
657
+
658
+ # :startdoc:
659
+
528
660
  end
529
661
 
530
662
  end
@@ -532,6 +664,7 @@ end
532
664
  # Modify the non-gem version of datadir to handle gem package names.
533
665
 
534
666
  require 'rbconfig/datadir'
667
+
535
668
  module Config # :nodoc:
536
669
  class << self
537
670
  alias gem_original_datadir datadir