rubygems-update 1.8.30 → 2.0.0.preview2

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 (241) hide show
  1. checksums.yaml +6 -6
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +3 -0
  4. data/.autotest +6 -3
  5. data/History.txt +137 -63
  6. data/LICENSE.txt +1 -5
  7. data/Manifest.txt +69 -32
  8. data/README.rdoc +11 -9
  9. data/Rakefile +24 -38
  10. data/bin/gem +0 -9
  11. data/bin/update_rubygems +1 -0
  12. data/lib/rubygems.rb +193 -405
  13. data/lib/rubygems/available_set.rb +95 -0
  14. data/lib/rubygems/command.rb +88 -45
  15. data/lib/rubygems/command_manager.rb +67 -40
  16. data/lib/rubygems/commands/build_command.rb +5 -23
  17. data/lib/rubygems/commands/cert_command.rb +199 -57
  18. data/lib/rubygems/commands/check_command.rb +14 -39
  19. data/lib/rubygems/commands/cleanup_command.rb +9 -1
  20. data/lib/rubygems/commands/contents_command.rb +30 -12
  21. data/lib/rubygems/commands/dependency_command.rb +3 -8
  22. data/lib/rubygems/commands/environment_command.rb +13 -8
  23. data/lib/rubygems/commands/fetch_command.rb +3 -16
  24. data/lib/rubygems/commands/generate_index_command.rb +7 -47
  25. data/lib/rubygems/commands/help_command.rb +1 -1
  26. data/lib/rubygems/commands/install_command.rb +69 -36
  27. data/lib/rubygems/commands/list_command.rb +6 -4
  28. data/lib/rubygems/commands/lock_command.rb +1 -1
  29. data/lib/rubygems/commands/mirror_command.rb +17 -0
  30. data/lib/rubygems/commands/outdated_command.rb +6 -3
  31. data/lib/rubygems/commands/owner_command.rb +13 -5
  32. data/lib/rubygems/commands/pristine_command.rb +19 -4
  33. data/lib/rubygems/commands/push_command.rb +12 -1
  34. data/lib/rubygems/commands/query_command.rb +43 -27
  35. data/lib/rubygems/commands/rdoc_command.rb +23 -28
  36. data/lib/rubygems/commands/search_command.rb +4 -18
  37. data/lib/rubygems/commands/server_command.rb +1 -1
  38. data/lib/rubygems/commands/setup_command.rb +124 -38
  39. data/lib/rubygems/commands/sources_command.rb +16 -16
  40. data/lib/rubygems/commands/specification_command.rb +11 -13
  41. data/lib/rubygems/commands/uninstall_command.rb +24 -7
  42. data/lib/rubygems/commands/unpack_command.rb +7 -3
  43. data/lib/rubygems/commands/update_command.rb +22 -36
  44. data/lib/rubygems/commands/yank_command.rb +98 -0
  45. data/lib/rubygems/compatibility.rb +51 -0
  46. data/lib/rubygems/config_file.rb +82 -54
  47. data/lib/rubygems/core_ext/kernel_gem.rb +53 -0
  48. data/lib/rubygems/core_ext/kernel_require.rb +119 -0
  49. data/lib/rubygems/defaults.rb +10 -21
  50. data/lib/rubygems/dependency.rb +61 -10
  51. data/lib/rubygems/dependency_installer.rb +157 -69
  52. data/lib/rubygems/dependency_list.rb +11 -19
  53. data/lib/rubygems/dependency_resolver.rb +562 -0
  54. data/lib/rubygems/deprecate.rb +40 -40
  55. data/lib/rubygems/errors.rb +77 -24
  56. data/lib/rubygems/exceptions.rb +25 -7
  57. data/lib/rubygems/ext/builder.rb +20 -23
  58. data/lib/rubygems/ext/configure_builder.rb +2 -2
  59. data/lib/rubygems/ext/ext_conf_builder.rb +5 -45
  60. data/lib/rubygems/ext/rake_builder.rb +2 -2
  61. data/lib/rubygems/gem_runner.rb +3 -16
  62. data/lib/rubygems/gemcutter_utilities.rb +22 -7
  63. data/lib/rubygems/indexer.rb +6 -159
  64. data/lib/rubygems/install_message.rb +12 -0
  65. data/lib/rubygems/install_update_options.rb +56 -18
  66. data/lib/rubygems/installer.rb +244 -134
  67. data/lib/rubygems/installer_test_case.rb +71 -19
  68. data/lib/rubygems/mock_gem_ui.rb +17 -0
  69. data/lib/rubygems/name_tuple.rb +110 -0
  70. data/lib/rubygems/package.rb +514 -43
  71. data/lib/rubygems/package/digest_io.rb +64 -0
  72. data/lib/rubygems/package/old.rb +147 -0
  73. data/lib/rubygems/package/tar_header.rb +18 -55
  74. data/lib/rubygems/package/tar_reader.rb +20 -3
  75. data/lib/rubygems/package/tar_writer.rb +63 -7
  76. data/lib/rubygems/package_task.rb +3 -4
  77. data/lib/rubygems/path_support.rb +14 -7
  78. data/lib/rubygems/platform.rb +19 -26
  79. data/lib/rubygems/rdoc.rb +316 -0
  80. data/lib/rubygems/remote_fetcher.rb +117 -54
  81. data/lib/rubygems/request_set.rb +182 -0
  82. data/lib/rubygems/requirement.rb +63 -26
  83. data/lib/rubygems/security.rb +295 -555
  84. data/lib/rubygems/security/policies.rb +115 -0
  85. data/lib/rubygems/security/policy.rb +227 -0
  86. data/lib/rubygems/security/signer.rb +136 -0
  87. data/lib/rubygems/security/trust_dir.rb +104 -0
  88. data/lib/rubygems/server.rb +45 -55
  89. data/lib/rubygems/source.rb +144 -0
  90. data/lib/rubygems/source_list.rb +87 -0
  91. data/lib/rubygems/source_local.rb +92 -0
  92. data/lib/rubygems/source_specific_file.rb +28 -0
  93. data/lib/rubygems/spec_fetcher.rb +116 -184
  94. data/lib/rubygems/specification.rb +731 -335
  95. data/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem +88 -30
  96. data/lib/rubygems/ssl_certs/Entrust_net-Secure-Server-Certification-Authority.pem +90 -0
  97. data/lib/rubygems/ssl_certs/VerisignClass3PublicPrimaryCertificationAuthority-G2.pem +57 -0
  98. data/lib/rubygems/syck_hack.rb +2 -0
  99. data/lib/rubygems/test_case.rb +199 -109
  100. data/lib/rubygems/test_utilities.rb +25 -5
  101. data/lib/rubygems/uninstaller.rb +62 -20
  102. data/lib/rubygems/user_interaction.rb +10 -0
  103. data/lib/rubygems/validator.rb +33 -40
  104. data/lib/rubygems/version.rb +19 -8
  105. data/setup.rb +8 -1
  106. data/test/rubygems/alternate_cert.pem +9 -0
  107. data/test/rubygems/alternate_cert_32.pem +9 -0
  108. data/test/rubygems/alternate_key.pem +9 -0
  109. data/test/rubygems/bad_rake.rb +1 -0
  110. data/test/rubygems/child_cert.pem +9 -0
  111. data/test/rubygems/child_cert_32.pem +9 -0
  112. data/test/rubygems/child_key.pem +9 -0
  113. data/test/rubygems/data/null-type.gemspec.rz +0 -0
  114. data/test/rubygems/expired_cert.pem +9 -0
  115. data/test/rubygems/future_cert.pem +9 -0
  116. data/test/rubygems/future_cert_32.pem +9 -0
  117. data/test/rubygems/good_rake.rb +1 -0
  118. data/test/rubygems/grandchild_cert.pem +9 -0
  119. data/test/rubygems/grandchild_cert_32.pem +9 -0
  120. data/test/rubygems/grandchild_key.pem +9 -0
  121. data/test/rubygems/invalid_issuer_cert.pem +9 -0
  122. data/test/rubygems/invalid_issuer_cert_32.pem +9 -0
  123. data/test/rubygems/invalid_key.pem +9 -0
  124. data/test/rubygems/invalid_signer_cert.pem +9 -0
  125. data/test/rubygems/invalid_signer_cert_32.pem +9 -0
  126. data/test/rubygems/invalidchild_cert.pem +9 -0
  127. data/test/rubygems/invalidchild_cert_32.pem +9 -0
  128. data/test/rubygems/invalidchild_key.pem +9 -0
  129. data/test/rubygems/plugin/exception/rubygems_plugin.rb +1 -1
  130. data/test/rubygems/plugin/standarderror/rubygems_plugin.rb +1 -1
  131. data/test/rubygems/private_key.pem +7 -25
  132. data/test/rubygems/public_cert.pem +8 -18
  133. data/test/rubygems/public_cert_32.pem +10 -0
  134. data/test/rubygems/public_key.pem +4 -0
  135. data/test/rubygems/rubygems/commands/crash_command.rb +1 -1
  136. data/test/rubygems/test_config.rb +4 -6
  137. data/test/rubygems/test_deprecate.rb +76 -0
  138. data/test/rubygems/test_gem.rb +318 -83
  139. data/test/rubygems/test_gem_available_set.rb +106 -0
  140. data/test/rubygems/test_gem_command.rb +10 -0
  141. data/test/rubygems/test_gem_command_manager.rb +55 -9
  142. data/test/rubygems/test_gem_commands_build_command.rb +11 -19
  143. data/test/rubygems/test_gem_commands_cert_command.rb +441 -42
  144. data/test/rubygems/test_gem_commands_cleanup_command.rb +29 -1
  145. data/test/rubygems/test_gem_commands_contents_command.rb +23 -0
  146. data/test/rubygems/test_gem_commands_dependency_command.rb +5 -0
  147. data/test/rubygems/test_gem_commands_fetch_command.rb +19 -20
  148. data/test/rubygems/test_gem_commands_generate_index_command.rb +2 -83
  149. data/test/rubygems/test_gem_commands_help_command.rb +2 -1
  150. data/test/rubygems/test_gem_commands_install_command.rb +647 -48
  151. data/test/rubygems/test_gem_commands_mirror.rb +32 -0
  152. data/test/rubygems/test_gem_commands_owner_command.rb +4 -8
  153. data/test/rubygems/test_gem_commands_pristine_command.rb +99 -4
  154. data/test/rubygems/test_gem_commands_push_command.rb +62 -8
  155. data/test/rubygems/test_gem_commands_query_command.rb +51 -0
  156. data/test/rubygems/test_gem_commands_search_command.rb +25 -0
  157. data/test/rubygems/test_gem_commands_setup_command.rb +45 -0
  158. data/test/rubygems/test_gem_commands_sources_command.rb +21 -6
  159. data/test/rubygems/test_gem_commands_specification_command.rb +33 -1
  160. data/test/rubygems/test_gem_commands_uninstall_command.rb +91 -31
  161. data/test/rubygems/test_gem_commands_unpack_command.rb +3 -3
  162. data/test/rubygems/test_gem_commands_update_command.rb +56 -38
  163. data/test/rubygems/test_gem_commands_which_command.rb +4 -4
  164. data/test/rubygems/test_gem_commands_yank_command.rb +97 -0
  165. data/test/rubygems/test_gem_config_file.rb +66 -21
  166. data/test/rubygems/test_gem_dependency.rb +46 -0
  167. data/test/rubygems/test_gem_dependency_installer.rb +228 -18
  168. data/test/rubygems/test_gem_dependency_list.rb +0 -9
  169. data/test/rubygems/test_gem_dependency_resolver.rb +327 -0
  170. data/test/rubygems/test_gem_ext_configure_builder.rb +4 -4
  171. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +21 -49
  172. data/test/rubygems/test_gem_ext_rake_builder.rb +13 -13
  173. data/test/rubygems/test_gem_gem_runner.rb +27 -5
  174. data/test/rubygems/test_gem_gemcutter_utilities.rb +19 -0
  175. data/test/rubygems/test_gem_indexer.rb +14 -227
  176. data/test/rubygems/test_gem_install_update_options.rb +83 -3
  177. data/test/rubygems/test_gem_installer.rb +211 -236
  178. data/test/rubygems/test_gem_local_remote_options.rb +8 -2
  179. data/test/rubygems/test_gem_name_tuple.rb +15 -0
  180. data/test/rubygems/test_gem_package.rb +547 -0
  181. data/test/rubygems/test_gem_package_old.rb +37 -0
  182. data/test/rubygems/test_gem_package_tar_reader.rb +32 -0
  183. data/test/rubygems/test_gem_package_tar_writer.rb +84 -1
  184. data/test/rubygems/test_gem_path_support.rb +4 -30
  185. data/test/rubygems/test_gem_platform.rb +3 -6
  186. data/test/rubygems/test_gem_rdoc.rb +245 -0
  187. data/test/rubygems/test_gem_remote_fetcher.rb +51 -5
  188. data/test/rubygems/test_gem_request_set.rb +70 -0
  189. data/test/rubygems/test_gem_requirement.rb +53 -24
  190. data/test/rubygems/test_gem_security.rb +189 -43
  191. data/test/rubygems/test_gem_security_policy.rb +376 -0
  192. data/test/rubygems/test_gem_security_signer.rb +184 -0
  193. data/test/rubygems/test_gem_security_trust_dir.rb +94 -0
  194. data/test/rubygems/test_gem_server.rb +31 -36
  195. data/test/rubygems/test_gem_silent_ui.rb +2 -2
  196. data/test/rubygems/test_gem_source.rb +188 -0
  197. data/test/rubygems/test_gem_source_list.rb +87 -0
  198. data/test/rubygems/test_gem_source_local.rb +83 -0
  199. data/test/rubygems/test_gem_source_specific_file.rb +33 -0
  200. data/test/rubygems/test_gem_spec_fetcher.rb +91 -255
  201. data/test/rubygems/test_gem_specification.rb +293 -39
  202. data/test/rubygems/test_gem_uninstaller.rb +136 -13
  203. data/test/rubygems/test_gem_validator.rb +14 -41
  204. data/test/rubygems/test_gem_version.rb +15 -21
  205. data/test/rubygems/test_require.rb +193 -0
  206. data/test/rubygems/wrong_key_cert.pem +9 -0
  207. data/test/rubygems/wrong_key_cert_32.pem +9 -0
  208. metadata +171 -83
  209. metadata.gz.sig +1 -0
  210. data/CVE-2013-4287.txt +0 -36
  211. data/CVE-2013-4363.txt +0 -45
  212. data/ci_build.sh +0 -27
  213. data/cruise_config.rb +0 -32
  214. data/lib/rbconfig/datadir.rb +0 -13
  215. data/lib/rubygems/builder.rb +0 -99
  216. data/lib/rubygems/custom_require.rb +0 -69
  217. data/lib/rubygems/doc_manager.rb +0 -243
  218. data/lib/rubygems/format.rb +0 -82
  219. data/lib/rubygems/gem_openssl.rb +0 -90
  220. data/lib/rubygems/gem_path_searcher.rb +0 -172
  221. data/lib/rubygems/old_format.rb +0 -153
  222. data/lib/rubygems/package/f_sync_dir.rb +0 -23
  223. data/lib/rubygems/package/tar_input.rb +0 -234
  224. data/lib/rubygems/package/tar_output.rb +0 -146
  225. data/lib/rubygems/require_paths_builder.rb +0 -18
  226. data/lib/rubygems/source_index.rb +0 -406
  227. data/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem +0 -25
  228. data/lib/rubygems/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +0 -14
  229. data/lib/rubygems/ssl_certs/DigiCertHighAssuranceEVRootCA.pem +0 -23
  230. data/lib/rubygems/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +0 -28
  231. data/lib/rubygems/ssl_certs/GeoTrustGlobalCA.pem +0 -20
  232. data/test/rubygems/test_bundled_ca.rb +0 -59
  233. data/test/rubygems/test_gem_builder.rb +0 -44
  234. data/test/rubygems/test_gem_doc_manager.rb +0 -32
  235. data/test/rubygems/test_gem_ext_builder.rb +0 -58
  236. data/test/rubygems/test_gem_format.rb +0 -88
  237. data/test/rubygems/test_gem_gem_path_searcher.rb +0 -94
  238. data/test/rubygems/test_gem_package_tar_input.rb +0 -129
  239. data/test/rubygems/test_gem_package_tar_output.rb +0 -101
  240. data/test/rubygems/test_gem_source_index.rb +0 -250
  241. data/util/update_bundled_ca_certificates.rb +0 -103
@@ -14,6 +14,10 @@ class Gem::Commands::OwnerCommand < Gem::Command
14
14
  "GEM gem to manage owners for"
15
15
  end
16
16
 
17
+ def usage # :nodoc:
18
+ "#{program_name} GEM"
19
+ end
20
+
17
21
  def initialize
18
22
  super 'owner', description
19
23
  add_proxy_option
@@ -63,12 +67,16 @@ class Gem::Commands::OwnerCommand < Gem::Command
63
67
 
64
68
  def manage_owners method, name, owners
65
69
  owners.each do |owner|
66
- response = rubygems_api_request method, "api/v1/gems/#{name}/owners" do |request|
67
- request.set_form_data 'email' => owner
68
- request.add_field "Authorization", api_key
70
+ begin
71
+ response = rubygems_api_request method, "api/v1/gems/#{name}/owners" do |request|
72
+ request.set_form_data 'email' => owner
73
+ request.add_field "Authorization", api_key
74
+ end
75
+
76
+ with_response response
77
+ rescue
78
+ # ignore
69
79
  end
70
-
71
- with_response response
72
80
  end
73
81
  end
74
82
 
@@ -1,5 +1,5 @@
1
1
  require 'rubygems/command'
2
- require 'rubygems/format'
2
+ require 'rubygems/package'
3
3
  require 'rubygems/installer'
4
4
  require 'rubygems/version_option'
5
5
 
@@ -24,6 +24,11 @@ class Gem::Commands::PristineCommand < Gem::Command
24
24
  options[:extensions] = value
25
25
  end
26
26
 
27
+ add_option('--only-executables',
28
+ 'Only restore executables') do |value, options|
29
+ options[:only_executables] = value
30
+ end
31
+
27
32
  add_version_option('restore to', 'pristine condition')
28
33
  end
29
34
 
@@ -78,6 +83,11 @@ extensions.
78
83
  say "Restoring gems to pristine condition..."
79
84
 
80
85
  specs.each do |spec|
86
+ if spec.default_gem?
87
+ say "Skipped #{spec.full_name}, it is a default gem"
88
+ next
89
+ end
90
+
81
91
  unless spec.extensions.empty? or options[:extensions] then
82
92
  say "Skipped #{spec.full_name}, it needs to compile an extension"
83
93
  next
@@ -96,13 +106,18 @@ extensions.
96
106
  # TODO use installer options
97
107
  install_defaults = Gem::ConfigFile::PLATFORM_DEFAULTS['install']
98
108
  installer_env_shebang = install_defaults.to_s['--env-shebang']
99
-
109
+
100
110
  installer = Gem::Installer.new(gem,
101
111
  :wrappers => true,
102
112
  :force => true,
103
113
  :install_dir => spec.base_dir,
104
- :env_shebang => installer_env_shebang)
105
- installer.install
114
+ :env_shebang => installer_env_shebang,
115
+ :build_args => spec.build_args)
116
+ if options[:only_executables] then
117
+ installer.generate_bin
118
+ else
119
+ installer.install
120
+ end
106
121
 
107
122
  say "Restored #{spec.full_name}"
108
123
  end
@@ -1,6 +1,7 @@
1
1
  require 'rubygems/command'
2
2
  require 'rubygems/local_remote_options'
3
3
  require 'rubygems/gemcutter_utilities'
4
+ require 'rubygems/package'
4
5
 
5
6
  class Gem::Commands::PushCommand < Gem::Command
6
7
  include Gem::LocalRemoteOptions
@@ -39,13 +40,23 @@ class Gem::Commands::PushCommand < Gem::Command
39
40
  def send_gem name
40
41
  args = [:post, "api/v1/gems"]
41
42
 
42
- args << options[:host] if options[:host]
43
43
 
44
44
  if Gem.latest_rubygems_version < Gem::Version.new(Gem::VERSION) then
45
45
  alert_error "Using beta/unreleased version of rubygems. Not pushing."
46
46
  terminate_interaction 1
47
47
  end
48
48
 
49
+ host = options[:host]
50
+ unless host
51
+ if gem_data = Gem::Package.new(name) then
52
+ host = gem_data.spec.metadata['default_gem_server']
53
+ end
54
+ end
55
+
56
+ args << host if host
57
+
58
+ say "Pushing gem to #{host || Gem.host}..."
59
+
49
60
  response = rubygems_api_request(*args) do |request|
50
61
  request.body = Gem.read_binary name
51
62
  request.add_field "Content-Length", request.body.size
@@ -21,6 +21,10 @@ class Gem::Commands::QueryCommand < Gem::Command
21
21
  options[:installed] = value
22
22
  end
23
23
 
24
+ add_option('-I', 'Equivalent to --no-installed') do |value, options|
25
+ options[:installed] = false
26
+ end
27
+
24
28
  add_version_option command, "for use with --installed"
25
29
 
26
30
  add_option('-n', '--name-matches REGEXP',
@@ -80,6 +84,7 @@ class Gem::Commands::QueryCommand < Gem::Command
80
84
  req = Gem::Requirement.default
81
85
  # TODO: deprecate for real
82
86
  dep = Gem::Deprecate.skip_during { Gem::Dependency.new name, req }
87
+ dep.prerelease = prerelease
83
88
 
84
89
  if local? then
85
90
  if prerelease and not both? then
@@ -97,7 +102,7 @@ class Gem::Commands::QueryCommand < Gem::Command
97
102
  }
98
103
 
99
104
  spec_tuples = specs.map do |spec|
100
- [[spec.name, spec.version, spec.original_platform, spec], :local]
105
+ [spec.name_tuple, spec]
101
106
  end
102
107
 
103
108
  output_query_results spec_tuples
@@ -110,13 +115,27 @@ class Gem::Commands::QueryCommand < Gem::Command
110
115
  say
111
116
  end
112
117
 
113
- all = options[:all]
114
-
115
118
  fetcher = Gem::SpecFetcher.fetcher
116
- spec_tuples = fetcher.find_matching dep, all, false, prerelease
117
119
 
118
- spec_tuples += fetcher.find_matching dep, false, false, true if
119
- prerelease and all
120
+ type = if options[:all]
121
+ if options[:prerelease]
122
+ :complete
123
+ else
124
+ :released
125
+ end
126
+ elsif options[:prerelease]
127
+ :prerelease
128
+ else
129
+ :latest
130
+ end
131
+
132
+ if options[:name].source.empty?
133
+ spec_tuples = fetcher.detect(type) { true }
134
+ else
135
+ spec_tuples = fetcher.detect(type) do |gem_name, ver, plat|
136
+ options[:name] === gem_name
137
+ end
138
+ end
120
139
 
121
140
  output_query_results spec_tuples
122
141
  end
@@ -135,32 +154,30 @@ class Gem::Commands::QueryCommand < Gem::Command
135
154
  output = []
136
155
  versions = Hash.new { |h,name| h[name] = [] }
137
156
 
138
- spec_tuples.each do |spec_tuple, source_uri|
139
- versions[spec_tuple.first] << [spec_tuple, source_uri]
157
+ spec_tuples.each do |spec_tuple, source|
158
+ versions[spec_tuple.name] << [spec_tuple, source]
140
159
  end
141
160
 
142
- versions = versions.sort_by do |(name,_),_|
143
- name.downcase
161
+ versions = versions.sort_by do |(n,_),_|
162
+ n.downcase
144
163
  end
145
164
 
146
165
  versions.each do |gem_name, matching_tuples|
147
- matching_tuples = matching_tuples.sort_by do |(_, version,_),_|
148
- version
149
- end.reverse
166
+ matching_tuples = matching_tuples.sort_by { |n,_| n.version }.reverse
150
167
 
151
168
  platforms = Hash.new { |h,version| h[version] = [] }
152
169
 
153
- matching_tuples.map do |(_, version, platform,_),_|
154
- platforms[version] << platform if platform
170
+ matching_tuples.map do |n,_|
171
+ platforms[n.version] << n.platform if n.platform
155
172
  end
156
173
 
157
174
  seen = {}
158
175
 
159
- matching_tuples.delete_if do |(_, version,_),_|
160
- if seen[version] then
176
+ matching_tuples.delete_if do |n,_|
177
+ if seen[n.version] then
161
178
  true
162
179
  else
163
- seen[version] = true
180
+ seen[n.version] = true
164
181
  false
165
182
  end
166
183
  end
@@ -169,7 +186,7 @@ class Gem::Commands::QueryCommand < Gem::Command
169
186
 
170
187
  if options[:versions] then
171
188
  list = if platforms.empty? or options[:details] then
172
- matching_tuples.map { |(_, version,_),_| version }.uniq
189
+ matching_tuples.map { |n,_| n.version }.uniq
173
190
  else
174
191
  platforms.sort.reverse.map do |version, pls|
175
192
  if pls == [Gem::Platform::RUBY] then
@@ -188,12 +205,11 @@ class Gem::Commands::QueryCommand < Gem::Command
188
205
  if options[:details] then
189
206
  detail_tuple = matching_tuples.first
190
207
 
191
- spec = if detail_tuple.first.length == 4 then
192
- detail_tuple.first.last
193
- else
194
- uri = URI.parse detail_tuple.last
195
- Gem::SpecFetcher.fetcher.fetch_spec detail_tuple.first, uri
196
- end
208
+ spec = detail_tuple.last
209
+
210
+ unless spec.kind_of? Gem::Specification
211
+ spec = spec.fetch_spec detail_tuple.first
212
+ end
197
213
 
198
214
  entry << "\n"
199
215
 
@@ -243,9 +259,9 @@ class Gem::Commands::QueryCommand < Gem::Command
243
259
  entry << "\n" << " Installed at: #{loaded_from}"
244
260
  else
245
261
  label = 'Installed at'
246
- matching_tuples.each do |(_,version,_,s),|
262
+ matching_tuples.each do |n,s|
247
263
  loaded_from = File.dirname File.dirname(s.loaded_from)
248
- entry << "\n" << " #{label} (#{version}): #{loaded_from}"
264
+ entry << "\n" << " #{label} (#{n.version}): #{loaded_from}"
249
265
  label = ' ' * label.length
250
266
  end
251
267
  end
@@ -1,6 +1,6 @@
1
1
  require 'rubygems/command'
2
2
  require 'rubygems/version_option'
3
- require 'rubygems/doc_manager'
3
+ require 'rubygems/rdoc'
4
4
 
5
5
  class Gem::Commands::RdocCommand < Gem::Command
6
6
  include Gem::VersionOption
@@ -8,7 +8,7 @@ class Gem::Commands::RdocCommand < Gem::Command
8
8
  def initialize
9
9
  super 'rdoc', 'Generates RDoc for pre-installed gems',
10
10
  :version => Gem::Requirement.default,
11
- :include_rdoc => true, :include_ri => true, :overwrite => false
11
+ :include_rdoc => false, :include_ri => true, :overwrite => false
12
12
 
13
13
  add_option('--all',
14
14
  'Generate RDoc/RI documentation for all',
@@ -39,7 +39,7 @@ class Gem::Commands::RdocCommand < Gem::Command
39
39
  end
40
40
 
41
41
  def defaults_str # :nodoc:
42
- "--version '#{Gem::Requirement.default}' --rdoc --ri --no-overwrite"
42
+ "--version '#{Gem::Requirement.default}' --ri --no-overwrite"
43
43
  end
44
44
 
45
45
  def description # :nodoc:
@@ -54,37 +54,32 @@ The rdoc command builds RDoc and RI documentation for installed gems. Use
54
54
  end
55
55
 
56
56
  def execute
57
- if options[:all] then
58
- specs = Gem::SourceIndex.from_installed_gems.collect { |name, spec|
59
- spec
60
- }
61
- else
62
- gem_name = get_one_gem_name
63
- dep = Gem::Dependency.new gem_name, options[:version]
64
- specs = Gem::SourceIndex.from_installed_gems.search dep
57
+ specs = if options[:all] then
58
+ Gem::Specification.to_a
59
+ else
60
+ get_all_gem_names.map do |name|
61
+ Gem::Specification.find_by_name name, options[:version]
62
+ end.flatten.uniq
63
+ end
64
+
65
+ if specs.empty? then
66
+ alert_error 'No matching gems found'
67
+ terminate_interaction 1
65
68
  end
66
69
 
67
- if specs.empty?
68
- raise "Failed to find gem #{gem_name} to generate RDoc for #{options[:version]}"
69
- end
70
+ specs.each do |spec|
71
+ doc = Gem::RDoc.new spec, options[:include_rdoc], options[:include_ri]
70
72
 
71
- if options[:include_ri]
72
- specs.sort.each do |spec|
73
- doc = Gem::DocManager.new(spec)
74
- doc.generate_ri if options[:overwrite] || !doc.ri_installed?
75
- end
73
+ doc.force = options[:overwrite]
76
74
 
77
- Gem::DocManager.update_ri_cache
78
- end
79
-
80
- if options[:include_rdoc]
81
- specs.sort.each do |spec|
82
- doc = Gem::DocManager.new(spec)
83
- doc.generate_rdoc if options[:overwrite] || !doc.rdoc_installed?
75
+ begin
76
+ doc.generate
77
+ rescue Errno::ENOENT => e
78
+ e.message =~ / - /
79
+ alert_error "Unable to document #{spec.full_name}, #{$'} is missing, skipping"
80
+ terminate_interaction 1 if specs.length == 1
84
81
  end
85
82
  end
86
-
87
- true
88
83
  end
89
84
 
90
85
  end
@@ -1,30 +1,16 @@
1
1
  require 'rubygems/command'
2
- require 'rubygems/commands/query_command'
2
+ require 'rubygems/commands/list_command'
3
3
 
4
- class Gem::Commands::SearchCommand < Gem::Commands::QueryCommand
4
+ class Gem::Commands::SearchCommand < Gem::Commands::ListCommand
5
5
 
6
6
  def initialize
7
7
  super 'search', 'Display all gems whose name contains STRING'
8
8
 
9
- remove_option '--name-matches'
10
- end
11
-
12
- def arguments # :nodoc:
13
- "STRING fragment of gem name to search for"
9
+ @defaults[:domain] = :remote
14
10
  end
15
11
 
16
12
  def defaults_str # :nodoc:
17
- "--local --no-details"
18
- end
19
-
20
- def usage # :nodoc:
21
- "#{program_name} [STRING]"
22
- end
23
-
24
- def execute
25
- string = get_one_optional_argument
26
- options[:name] = /#{string}/i
27
- super
13
+ "--remote --no-details"
28
14
  end
29
15
 
30
16
  end
@@ -78,7 +78,7 @@ You can set up a shortcut to gem server documentation using the URL:
78
78
  end
79
79
 
80
80
  def execute
81
- options[:gemdir] << Gem.dir if options[:gemdir].empty?
81
+ options[:gemdir] = Gem.path if options[:gemdir].empty?
82
82
  Gem::Server.run options
83
83
  end
84
84
 
@@ -5,14 +5,22 @@ require 'rubygems/command'
5
5
  # RubyGems checkout or tarball.
6
6
 
7
7
  class Gem::Commands::SetupCommand < Gem::Command
8
+ HISTORY_HEADER = /^===\s*[\d.]+\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/
9
+ VERSION_MATCHER = /^===\s*([\d.]+)\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/
8
10
 
9
11
  def initialize
10
12
  require 'tmpdir'
11
13
 
12
14
  super 'setup', 'Install RubyGems',
13
- :format_executable => true, :rdoc => true, :ri => true,
15
+ :format_executable => true, :document => %w[ri],
14
16
  :site_or_vendor => :sitelibdir,
15
- :destdir => '', :prefix => ''
17
+ :destdir => '', :prefix => '', :previous_version => ''
18
+
19
+ add_option '--previous-version=VERSION',
20
+ 'Previous version of rubygems',
21
+ 'Used for changelog processing' do |version, options|
22
+ options[:previous_version] = version
23
+ end
16
24
 
17
25
  add_option '--prefix=PREFIX',
18
26
  'Prefix path for installing RubyGems',
@@ -37,14 +45,37 @@ class Gem::Commands::SetupCommand < Gem::Command
37
45
  options[:format_executable] = value
38
46
  end
39
47
 
48
+ add_option '--[no-]document [TYPES]', Array,
49
+ 'Generate documentation for RubyGems.',
50
+ 'List the documentation types you wish to',
51
+ 'generate. For example: rdoc,ri' do |value, options|
52
+ options[:document] = case value
53
+ when nil then %w[rdoc ri]
54
+ when false then []
55
+ else value
56
+ end
57
+ end
58
+
40
59
  add_option '--[no-]rdoc',
41
60
  'Generate RDoc documentation for RubyGems' do |value, options|
42
- options[:rdoc] = value
61
+ if value then
62
+ options[:document] << 'rdoc'
63
+ else
64
+ options[:document].delete 'rdoc'
65
+ end
66
+
67
+ options[:document].uniq!
43
68
  end
44
69
 
45
70
  add_option '--[no-]ri',
46
71
  'Generate RI documentation for RubyGems' do |value, options|
47
- options[:ri] = value
72
+ if value then
73
+ options[:document] << 'ri'
74
+ else
75
+ options[:document].delete 'ri'
76
+ end
77
+
78
+ options[:document].uniq!
48
79
  end
49
80
  end
50
81
 
@@ -58,7 +89,7 @@ class Gem::Commands::SetupCommand < Gem::Command
58
89
  end
59
90
 
60
91
  def defaults_str # :nodoc:
61
- "--format-executable --rdoc --ri"
92
+ "--format-executable --document ri"
62
93
  end
63
94
 
64
95
  def description # :nodoc:
@@ -106,11 +137,13 @@ By default, this RubyGems will install gem as:
106
137
 
107
138
  remove_old_bin_files bin_dir
108
139
 
140
+ remove_old_lib_files lib_dir
141
+
109
142
  say "RubyGems #{Gem::VERSION} installed"
110
143
 
111
144
  uninstall_old_gemcutter
112
145
 
113
- install_rdoc
146
+ documentation_success = install_rdoc
114
147
 
115
148
  say
116
149
  if @verbose then
@@ -118,16 +151,30 @@ By default, this RubyGems will install gem as:
118
151
  say
119
152
  end
120
153
 
154
+ if options[:previous_version].empty?
155
+ options[:previous_version] = Gem::VERSION.sub(/[0-9]+$/, '0')
156
+ end
157
+
158
+ options[:previous_version] = Gem::Version.new(options[:previous_version])
159
+
121
160
  release_notes = File.join Dir.pwd, 'History.txt'
122
161
 
123
162
  release_notes = if File.exist? release_notes then
124
- open release_notes do |io|
125
- text = io.gets '==='
126
- text << io.gets('===')
127
- text.force_encoding Encoding::UTF_8 if
128
- Object.const_defined? :Encoding
129
- text[0...-3].sub(/^# coding:.*?^=/mu, '')
163
+ history = File.read release_notes
164
+ history = history.sub(/^# coding:.*?^=/m, '')
165
+
166
+ text = history.split(HISTORY_HEADER)
167
+ text.shift # correct an off-by-one generated by split
168
+ version_lines = history.scan(HISTORY_HEADER)
169
+ versions = history.scan(VERSION_MATCHER).flatten.map { |x| Gem::Version.new(x) }
170
+
171
+ history_string = ""
172
+
173
+ until versions.length == 0 or versions.shift < options[:previous_version]
174
+ history_string += version_lines.shift + text.shift
130
175
  end
176
+
177
+ history_string
131
178
  else
132
179
  "Oh-no! Unable to find release notes!"
133
180
  end
@@ -147,6 +194,31 @@ By default, this RubyGems will install gem as:
147
194
  say "to remove it by hand."
148
195
  say
149
196
  end
197
+
198
+ if documentation_success
199
+ if options[:document].include? 'rdoc' then
200
+ say "Rdoc documentation was installed. You may now invoke:"
201
+ say " gem server"
202
+ say "and then peruse beautifully formatted documentation for your gems"
203
+ say "with your web browser."
204
+ say "If you do not wish to install this documentation in the future, use the"
205
+ say "--no-document flag, or set it as the default in your ~/.gemrc file. See"
206
+ say "'gem help env' for details."
207
+ say
208
+ end
209
+
210
+ if options[:document].include? 'ri' then
211
+ say "Ruby Interactive (ri) documentation was installed. ri is kind of like man "
212
+ say "pages for ruby libraries. You may access it like this:"
213
+ say " ri Classname"
214
+ say " ri Classname.class_method"
215
+ say " ri Classname#instance_method"
216
+ say "If you do not wish to install this documentation in the future, use the"
217
+ say "--no-document flag, or set it as the default in your ~/.gemrc file. See"
218
+ say "'gem help env' for details."
219
+ say
220
+ end
221
+ end
150
222
  end
151
223
 
152
224
  def install_executables(bin_dir)
@@ -210,12 +282,9 @@ TEXT
210
282
  def install_lib(lib_dir)
211
283
  say "Installing RubyGems" if @verbose
212
284
 
213
- Dir.chdir 'lib' do
214
- lib_files = Dir[File.join('**', '*rb')]
215
-
216
- # Be sure to include our SSL ca bundles
217
- lib_files += Dir[File.join('**', '*pem')]
285
+ lib_files = rb_files_in 'lib'
218
286
 
287
+ Dir.chdir 'lib' do
219
288
  lib_files.each do |lib_file|
220
289
  dest_file = File.join lib_dir, lib_file
221
290
  dest_dir = File.dirname dest_file
@@ -231,6 +300,12 @@ TEXT
231
300
  rubygems_name = "rubygems-#{Gem::VERSION}"
232
301
  rubygems_doc_dir = File.join gem_doc_dir, rubygems_name
233
302
 
303
+ begin
304
+ Gem.ensure_gem_subdirectories Gem.dir
305
+ rescue SystemCallError
306
+ # ignore
307
+ end
308
+
234
309
  if File.writable? gem_doc_dir and
235
310
  (not File.exist? rubygems_doc_dir or
236
311
  File.writable? rubygems_doc_dir) then
@@ -239,21 +314,26 @@ TEXT
239
314
  rm_rf dir
240
315
  end
241
316
 
242
- if options[:ri] then
243
- ri_dir = File.join rubygems_doc_dir, 'ri'
244
- say "Installing #{rubygems_name} ri into #{ri_dir}" if @verbose
245
- run_rdoc '--ri', '--op', ri_dir
246
- end
317
+ require 'rubygems/rdoc'
247
318
 
248
- if options[:rdoc] then
249
- rdoc_dir = File.join rubygems_doc_dir, 'rdoc'
250
- say "Installing #{rubygems_name} rdoc into #{rdoc_dir}" if @verbose
251
- run_rdoc '--op', rdoc_dir
319
+ fake_spec = Gem::Specification.new 'rubygems', Gem::VERSION
320
+ def fake_spec.full_gem_path
321
+ File.expand_path '../../../..', __FILE__
252
322
  end
323
+
324
+ generate_ri = options[:document].include? 'ri'
325
+ generate_rdoc = options[:document].include? 'rdoc'
326
+
327
+ rdoc = Gem::RDoc.new fake_spec, generate_rdoc, generate_ri
328
+ rdoc.generate
329
+
330
+ return true
253
331
  elsif @verbose then
254
332
  say "Skipping RDoc generation, #{gem_doc_dir} not writable"
255
333
  say "Set the GEM_HOME environment variable if you want RDoc generated"
256
334
  end
335
+
336
+ return false
257
337
  end
258
338
 
259
339
  def make_destination_dirs(install_destdir)
@@ -301,6 +381,12 @@ TEXT
301
381
  [lib_dir, bin_dir]
302
382
  end
303
383
 
384
+ def rb_files_in dir
385
+ Dir.chdir dir do
386
+ Dir[File.join('**', '*rb')]
387
+ end
388
+ end
389
+
304
390
  def remove_old_bin_files(bin_dir)
305
391
  old_bin_files = {
306
392
  'gem_mirror' => 'gem mirror',
@@ -333,21 +419,21 @@ abort "#{deprecation_message}"
333
419
  end
334
420
  end
335
421
 
336
- def run_rdoc(*args)
337
- begin
338
- gem 'rdoc'
339
- rescue Gem::LoadError
340
- end
422
+ def remove_old_lib_files lib_dir
423
+ lib_files = rb_files_in 'lib'
424
+
425
+ old_lib_files = rb_files_in lib_dir
341
426
 
342
- require 'rdoc/rdoc'
427
+ to_remove = old_lib_files - lib_files
343
428
 
344
- args << '--main' << 'README.rdoc' << '--quiet'
345
- args << '.'
346
- args << 'README.rdoc' << 'UPGRADING.rdoc'
347
- args << 'LICENSE.txt' << 'MIT.txt' << 'History.txt'
429
+ Dir.chdir lib_dir do
430
+ to_remove.each do |file|
431
+ FileUtils.rm_f file
348
432
 
349
- r = RDoc::RDoc.new
350
- r.document args
433
+ warn "unable to remove old file #{file} please remove it by hand" if
434
+ File.exist? file
435
+ end
436
+ end
351
437
  end
352
438
 
353
439
  def uninstall_old_gemcutter