rubygems-update 1.4.2 → 1.5.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.
- data.tar.gz.sig +0 -0
- data/.autotest +4 -5
- data/{test/foo/discover.rb → .gemtest} +0 -0
- data/ChangeLog +13 -0
- data/History.txt +35 -1
- data/Manifest.txt +89 -88
- data/README.rdoc +21 -10
- data/Rakefile +31 -17
- data/UPGRADING.rdoc +81 -0
- data/ci_build.sh +27 -0
- data/cruise_config.rb +20 -13
- data/lib/rbconfig/datadir.rb +1 -1
- data/lib/rubygems.rb +102 -45
- data/lib/rubygems/builder.rb +5 -11
- data/lib/rubygems/command_manager.rb +0 -1
- data/lib/rubygems/commands/check_command.rb +2 -17
- data/lib/rubygems/commands/cleanup_command.rb +1 -1
- data/lib/rubygems/commands/dependency_command.rb +5 -18
- data/lib/rubygems/commands/environment_command.rb +5 -4
- data/lib/rubygems/commands/fetch_command.rb +0 -1
- data/lib/rubygems/commands/generate_index_command.rb +1 -10
- data/lib/rubygems/commands/help_command.rb +0 -5
- data/lib/rubygems/commands/query_command.rb +4 -24
- data/lib/rubygems/commands/setup_command.rb +4 -19
- data/lib/rubygems/commands/sources_command.rb +15 -37
- data/lib/rubygems/commands/specification_command.rb +1 -2
- data/lib/rubygems/commands/unpack_command.rb +19 -7
- data/lib/rubygems/commands/update_command.rb +29 -44
- data/lib/rubygems/config_file.rb +25 -19
- data/lib/rubygems/custom_require.rb +4 -6
- data/lib/rubygems/dependency.rb +1 -43
- data/lib/rubygems/dependency_installer.rb +1 -1
- data/lib/rubygems/doc_manager.rb +3 -1
- data/lib/rubygems/ext/builder.rb +3 -1
- data/lib/rubygems/ext/rake_builder.rb +10 -2
- data/lib/rubygems/format.rb +7 -4
- data/lib/rubygems/gem_runner.rb +1 -1
- data/lib/rubygems/indexer.rb +11 -74
- data/lib/rubygems/install_update_options.rb +13 -8
- data/lib/rubygems/installer.rb +139 -95
- data/{test/gem_installer_test_case.rb → lib/rubygems/installer_test_case.rb} +41 -2
- data/{test/mockgemui.rb → lib/rubygems/mock_gem_ui.rb} +8 -1
- data/lib/rubygems/old_format.rb +2 -1
- data/lib/rubygems/package.rb +17 -2
- data/lib/rubygems/package/tar_input.rb +7 -3
- data/lib/rubygems/package/tar_output.rb +2 -0
- data/lib/rubygems/package/tar_reader/entry.rb +4 -0
- data/{test/gem_package_tar_test_case.rb → lib/rubygems/package/tar_test_case.rb} +5 -2
- data/lib/rubygems/package_task.rb +6 -4
- data/lib/rubygems/remote_fetcher.rb +10 -2
- data/lib/rubygems/require_paths_builder.rb +2 -1
- data/lib/rubygems/server.rb +3 -44
- data/lib/rubygems/source_index.rb +3 -216
- data/lib/rubygems/spec_fetcher.rb +15 -63
- data/lib/rubygems/specification.rb +1 -1
- data/{test/gemutilities.rb → lib/rubygems/test_case.rb} +219 -90
- data/lib/rubygems/test_utilities.rb +7 -20
- data/lib/rubygems/uninstaller.rb +27 -28
- data/lib/rubygems/user_interaction.rb +81 -42
- data/lib/rubygems/validator.rb +0 -73
- data/test/{bogussources.rb → rubygems/bogussources.rb} +0 -0
- data/test/{data → rubygems/data}/gem-private_key.pem +0 -0
- data/test/{data → rubygems/data}/gem-public_cert.pem +0 -0
- data/test/{fake_certlib → rubygems/fake_certlib}/openssl.rb +0 -0
- data/test/rubygems/foo/discover.rb +0 -0
- data/test/{functional.rb → rubygems/functional.rb} +0 -0
- data/test/{insure_session.rb → rubygems/insure_session.rb} +0 -0
- data/test/{plugin → rubygems/plugin}/exception/rubygems_plugin.rb +0 -0
- data/test/{plugin → rubygems/plugin}/load/rubygems_plugin.rb +0 -0
- data/test/{plugin → rubygems/plugin}/standarderror/rubygems_plugin.rb +0 -0
- data/test/{private_key.pem → rubygems/private_key.pem} +0 -0
- data/test/{public_cert.pem → rubygems/public_cert.pem} +0 -0
- data/test/rubygems/{commands → rubygems/commands}/crash_command.rb +0 -0
- data/test/{rubygems_plugin.rb → rubygems/rubygems_plugin.rb} +0 -0
- data/test/rubygems/sff/discover.rb +0 -0
- data/test/{simple_gem.rb → rubygems/simple_gem.rb} +2 -2
- data/test/{test_config.rb → rubygems/test_config.rb} +2 -2
- data/test/{test_gem.rb → rubygems/test_gem.rb} +12 -2
- data/test/{test_gem_builder.rb → rubygems/test_gem_builder.rb} +2 -2
- data/test/{test_gem_command.rb → rubygems/test_gem_command.rb} +3 -3
- data/test/{test_gem_command_manager.rb → rubygems/test_gem_command_manager.rb} +15 -6
- data/test/{test_gem_commands_build_command.rb → rubygems/test_gem_commands_build_command.rb} +2 -2
- data/test/{test_gem_commands_cert_command.rb → rubygems/test_gem_commands_cert_command.rb} +2 -2
- data/test/{test_gem_commands_check_command.rb → rubygems/test_gem_commands_check_command.rb} +2 -2
- data/test/{test_gem_commands_contents_command.rb → rubygems/test_gem_commands_contents_command.rb} +3 -3
- data/test/{test_gem_commands_dependency_command.rb → rubygems/test_gem_commands_dependency_command.rb} +4 -4
- data/test/{test_gem_commands_environment_command.rb → rubygems/test_gem_commands_environment_command.rb} +12 -3
- data/test/{test_gem_commands_fetch_command.rb → rubygems/test_gem_commands_fetch_command.rb} +2 -2
- data/test/{test_gem_commands_generate_index_command.rb → rubygems/test_gem_commands_generate_index_command.rb} +7 -11
- data/test/{test_gem_commands_install_command.rb → rubygems/test_gem_commands_install_command.rb} +2 -2
- data/test/{test_gem_commands_list_command.rb → rubygems/test_gem_commands_list_command.rb} +2 -2
- data/test/{test_gem_commands_lock_command.rb → rubygems/test_gem_commands_lock_command.rb} +2 -2
- data/test/{test_gem_commands_outdated_command.rb → rubygems/test_gem_commands_outdated_command.rb} +2 -2
- data/test/{test_gem_commands_owner_command.rb → rubygems/test_gem_commands_owner_command.rb} +5 -5
- data/test/{test_gem_commands_pristine_command.rb → rubygems/test_gem_commands_pristine_command.rb} +2 -2
- data/test/{test_gem_commands_push_command.rb → rubygems/test_gem_commands_push_command.rb} +3 -3
- data/test/{test_gem_commands_query_command.rb → rubygems/test_gem_commands_query_command.rb} +2 -2
- data/test/{test_gem_commands_server_command.rb → rubygems/test_gem_commands_server_command.rb} +2 -2
- data/test/{test_gem_commands_sources_command.rb → rubygems/test_gem_commands_sources_command.rb} +8 -8
- data/test/{test_gem_commands_specification_command.rb → rubygems/test_gem_commands_specification_command.rb} +3 -3
- data/test/{test_gem_commands_stale_command.rb → rubygems/test_gem_commands_stale_command.rb} +2 -2
- data/test/{test_gem_commands_uninstall_command.rb → rubygems/test_gem_commands_uninstall_command.rb} +16 -10
- data/test/{test_gem_commands_unpack_command.rb → rubygems/test_gem_commands_unpack_command.rb} +42 -2
- data/test/{test_gem_commands_update_command.rb → rubygems/test_gem_commands_update_command.rb} +2 -2
- data/test/{test_gem_commands_which_command.rb → rubygems/test_gem_commands_which_command.rb} +3 -3
- data/test/{test_gem_config_file.rb → rubygems/test_gem_config_file.rb} +2 -2
- data/test/{test_gem_dependency.rb → rubygems/test_gem_dependency.rb} +3 -27
- data/test/{test_gem_dependency_installer.rb → rubygems/test_gem_dependency_installer.rb} +2 -2
- data/test/{test_gem_dependency_list.rb → rubygems/test_gem_dependency_list.rb} +3 -3
- data/test/{test_gem_doc_manager.rb → rubygems/test_gem_doc_manager.rb} +2 -2
- data/test/{test_gem_ext_configure_builder.rb → rubygems/test_gem_ext_configure_builder.rb} +4 -4
- data/test/{test_gem_ext_ext_conf_builder.rb → rubygems/test_gem_ext_ext_conf_builder.rb} +46 -2
- data/test/{test_gem_ext_rake_builder.rb → rubygems/test_gem_ext_rake_builder.rb} +2 -2
- data/test/{test_gem_format.rb → rubygems/test_gem_format.rb} +24 -6
- data/test/{test_gem_gem_path_searcher.rb → rubygems/test_gem_gem_path_searcher.rb} +2 -2
- data/test/{test_gem_gem_runner.rb → rubygems/test_gem_gem_runner.rb} +2 -2
- data/test/{test_gem_gemcutter_utilities.rb → rubygems/test_gem_gemcutter_utilities.rb} +4 -4
- data/test/{test_gem_indexer.rb → rubygems/test_gem_indexer.rb} +4 -121
- data/test/{test_gem_install_update_options.rb → rubygems/test_gem_install_update_options.rb} +3 -3
- data/test/{test_gem_installer.rb → rubygems/test_gem_installer.rb} +106 -13
- data/test/{test_gem_local_remote_options.rb → rubygems/test_gem_local_remote_options.rb} +2 -2
- data/test/{test_gem_package_tar_header.rb → rubygems/test_gem_package_tar_header.rb} +2 -2
- data/test/{test_gem_package_tar_input.rb → rubygems/test_gem_package_tar_input.rb} +21 -4
- data/test/{test_gem_package_tar_output.rb → rubygems/test_gem_package_tar_output.rb} +2 -2
- data/test/{test_gem_package_tar_reader.rb → rubygems/test_gem_package_tar_reader.rb} +2 -2
- data/test/{test_gem_package_tar_reader_entry.rb → rubygems/test_gem_package_tar_reader_entry.rb} +12 -2
- data/test/{test_gem_package_tar_writer.rb → rubygems/test_gem_package_tar_writer.rb} +2 -2
- data/test/{test_gem_package_task.rb → rubygems/test_gem_package_task.rb} +15 -2
- data/test/{test_gem_platform.rb → rubygems/test_gem_platform.rb} +2 -2
- data/test/{test_gem_remote_fetcher.rb → rubygems/test_gem_remote_fetcher.rb} +7 -7
- data/test/{test_gem_requirement.rb → rubygems/test_gem_requirement.rb} +2 -2
- data/test/{test_gem_security.rb → rubygems/test_gem_security.rb} +3 -4
- data/test/{test_gem_server.rb → rubygems/test_gem_server.rb} +2 -132
- data/test/rubygems/test_gem_silent_ui.rb +113 -0
- data/test/{test_gem_source_index.rb → rubygems/test_gem_source_index.rb} +2 -61
- data/test/{test_gem_spec_fetcher.rb → rubygems/test_gem_spec_fetcher.rb} +2 -2
- data/test/{test_gem_specification.rb → rubygems/test_gem_specification.rb} +4 -4
- data/test/{test_gem_stream_ui.rb → rubygems/test_gem_stream_ui.rb} +24 -2
- data/test/{test_gem_text.rb → rubygems/test_gem_text.rb} +2 -2
- data/test/{test_gem_uninstaller.rb → rubygems/test_gem_uninstaller.rb} +15 -12
- data/test/{test_gem_validator.rb → rubygems/test_gem_validator.rb} +3 -3
- data/test/{test_gem_version.rb → rubygems/test_gem_version.rb} +2 -2
- data/test/{test_gem_version_option.rb → rubygems/test_gem_version_option.rb} +2 -2
- data/test/{test_kernel.rb → rubygems/test_kernel.rb} +7 -10
- metadata +281 -177
- metadata.gz.sig +0 -0
- data/lib/rubygems/commands/mirror_command.rb +0 -111
- data/lib/rubygems/source_info_cache.rb +0 -394
- data/lib/rubygems/source_info_cache_entry.rb +0 -56
- data/test/test_gem_commands_mirror_command.rb +0 -60
@@ -1,25 +1,64 @@
|
|
1
|
-
require
|
1
|
+
require 'rubygems/test_case'
|
2
2
|
require 'rubygems/installer'
|
3
3
|
|
4
4
|
class Gem::Installer
|
5
|
+
|
6
|
+
##
|
7
|
+
# Available through requiring rubygems/installer_test_case
|
8
|
+
|
5
9
|
attr_accessor :gem_dir
|
6
10
|
|
11
|
+
##
|
12
|
+
# Available through requiring rubygems/installer_test_case
|
13
|
+
|
7
14
|
attr_writer :format
|
15
|
+
|
16
|
+
##
|
17
|
+
# Available through requiring rubygems/installer_test_case
|
18
|
+
|
8
19
|
attr_writer :gem_home
|
20
|
+
|
21
|
+
##
|
22
|
+
# Available through requiring rubygems/installer_test_case
|
23
|
+
|
9
24
|
attr_writer :env_shebang
|
25
|
+
|
26
|
+
##
|
27
|
+
# Available through requiring rubygems/installer_test_case
|
28
|
+
|
10
29
|
attr_writer :ignore_dependencies
|
30
|
+
|
31
|
+
##
|
32
|
+
# Available through requiring rubygems/installer_test_case
|
33
|
+
|
11
34
|
attr_writer :format_executable
|
35
|
+
|
36
|
+
##
|
37
|
+
# Available through requiring rubygems/installer_test_case
|
38
|
+
|
12
39
|
attr_writer :security_policy
|
40
|
+
|
41
|
+
##
|
42
|
+
# Available through requiring rubygems/installer_test_case
|
43
|
+
|
13
44
|
attr_writer :spec
|
45
|
+
|
46
|
+
##
|
47
|
+
# Available through requiring rubygems/installer_test_case
|
48
|
+
|
14
49
|
attr_writer :wrappers
|
15
50
|
end
|
16
51
|
|
17
|
-
|
52
|
+
##
|
53
|
+
# A test case for Gem::Installer.
|
54
|
+
|
55
|
+
class Gem::InstallerTestCase < Gem::TestCase
|
18
56
|
|
19
57
|
def setup
|
20
58
|
super
|
21
59
|
|
22
60
|
@spec = quick_gem 'a'
|
61
|
+
|
23
62
|
@gem = File.join @tempdir, @spec.file_name
|
24
63
|
|
25
64
|
@installer = util_installer @spec, @gem, @gemhome
|
@@ -1,7 +1,11 @@
|
|
1
1
|
require 'stringio'
|
2
2
|
require 'rubygems/user_interaction'
|
3
3
|
|
4
|
-
|
4
|
+
##
|
5
|
+
# This Gem::StreamUI subclass records input and output to StringIO for
|
6
|
+
# retrieval during tests.
|
7
|
+
|
8
|
+
class Gem::MockGemUi < Gem::StreamUI
|
5
9
|
class TermError < RuntimeError; end
|
6
10
|
|
7
11
|
module TTY
|
@@ -13,6 +17,9 @@ class MockGemUi < Gem::StreamUI
|
|
13
17
|
@tty
|
14
18
|
end
|
15
19
|
|
20
|
+
def noecho
|
21
|
+
yield self
|
22
|
+
end
|
16
23
|
end
|
17
24
|
|
18
25
|
def initialize(input = "")
|
data/lib/rubygems/old_format.rb
CHANGED
data/lib/rubygems/package.rb
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
# See LICENSE.txt for additional licensing information.
|
5
5
|
#++
|
6
6
|
|
7
|
-
require 'rubygems/security'
|
8
7
|
require 'rubygems/specification'
|
9
8
|
|
10
9
|
##
|
@@ -40,7 +39,23 @@ module Gem::Package
|
|
40
39
|
class ClosedIO < Error; end
|
41
40
|
class BadCheckSum < Error; end
|
42
41
|
class TooLongFileName < Error; end
|
43
|
-
class FormatError < Error
|
42
|
+
class FormatError < Error
|
43
|
+
attr_reader :path
|
44
|
+
|
45
|
+
def initialize message, path = nil
|
46
|
+
@path = path
|
47
|
+
|
48
|
+
message << " in #{path}" if path
|
49
|
+
|
50
|
+
super message
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
##
|
56
|
+
# Raised when a tar file is corrupt
|
57
|
+
|
58
|
+
class TarInvalidError < Error; end
|
44
59
|
|
45
60
|
def self.open(io, mode = "r", signer = nil, &block)
|
46
61
|
tar_type = case mode
|
@@ -4,8 +4,8 @@
|
|
4
4
|
# See LICENSE.txt for additional licensing information.
|
5
5
|
#--
|
6
6
|
|
7
|
-
require
|
8
|
-
|
7
|
+
require 'zlib'
|
8
|
+
Gem.load_yaml
|
9
9
|
|
10
10
|
class Gem::Package::TarInput
|
11
11
|
|
@@ -111,7 +111,11 @@ class Gem::Package::TarInput
|
|
111
111
|
@tarreader.rewind
|
112
112
|
@fileops = Gem::FileOperations.new
|
113
113
|
|
114
|
-
|
114
|
+
unless has_meta then
|
115
|
+
path = io.path if io.respond_to? :path
|
116
|
+
error = Gem::Package::FormatError.new 'no metadata found', path
|
117
|
+
raise error
|
118
|
+
end
|
115
119
|
end
|
116
120
|
|
117
121
|
def close
|
@@ -79,6 +79,7 @@ class Gem::Package::TarOutput
|
|
79
79
|
# if we have a signing key, then sign the data
|
80
80
|
# digest and return the signature
|
81
81
|
if @signer then
|
82
|
+
require 'rubygems/security'
|
82
83
|
digest = Gem::Security::OPT[:dgst_algo].digest sio.string
|
83
84
|
@data_signature = @signer.sign digest
|
84
85
|
inner.write sio.string
|
@@ -107,6 +108,7 @@ class Gem::Package::TarOutput
|
|
107
108
|
# if we have a signing key, then sign the metadata digest and return
|
108
109
|
# the signature
|
109
110
|
if @signer then
|
111
|
+
require 'rubygems/security'
|
110
112
|
digest = Gem::Security::OPT[:dgst_algo].digest sio.string
|
111
113
|
@meta_signature = @signer.sign digest
|
112
114
|
io.write sio.string
|
@@ -1,7 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require 'rubygems/test_case'
|
2
2
|
require 'rubygems/package'
|
3
3
|
|
4
|
-
|
4
|
+
##
|
5
|
+
# A test case for Gem::Package::Tar* classes
|
6
|
+
|
7
|
+
class Gem::Package::TarTestCase < Gem::TestCase
|
5
8
|
|
6
9
|
def ASCIIZ(str, length)
|
7
10
|
str + "\0" * (length - str.length)
|
@@ -86,7 +86,7 @@ class Gem::PackageTask < Rake::PackageTask
|
|
86
86
|
# Initialization tasks without the "yield self" or define operations.
|
87
87
|
|
88
88
|
def init(gem)
|
89
|
-
super gem.
|
89
|
+
super gem.full_name, :noversion
|
90
90
|
@gem_spec = gem
|
91
91
|
@package_files += gem_spec.files if gem_spec.files
|
92
92
|
end
|
@@ -114,11 +114,13 @@ class Gem::PackageTask < Rake::PackageTask
|
|
114
114
|
chdir(gem_dir) do
|
115
115
|
when_writing "Creating #{gem_spec.file_name}" do
|
116
116
|
Gem::Builder.new(gem_spec).build
|
117
|
-
verbose
|
118
|
-
mv gem_file,
|
119
|
-
|
117
|
+
verbose trace do
|
118
|
+
mv gem_file, '..'
|
119
|
+
end
|
120
120
|
end
|
121
121
|
end
|
122
122
|
end
|
123
123
|
end
|
124
|
+
|
124
125
|
end
|
126
|
+
|
@@ -195,12 +195,20 @@ class Gem::RemoteFetcher
|
|
195
195
|
|
196
196
|
def escape(str)
|
197
197
|
return unless str
|
198
|
-
|
198
|
+
@uri_parser ||= uri_escaper
|
199
|
+
@uri_parser.escape str
|
199
200
|
end
|
200
201
|
|
201
202
|
def unescape(str)
|
202
203
|
return unless str
|
203
|
-
|
204
|
+
@uri_parser ||= uri_escaper
|
205
|
+
@uri_parser.unescape str
|
206
|
+
end
|
207
|
+
|
208
|
+
def uri_escaper
|
209
|
+
URI::Parser.new
|
210
|
+
rescue NameError
|
211
|
+
URI
|
204
212
|
end
|
205
213
|
|
206
214
|
##
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
|
3
|
+
# TODO: remove after 1.9.1 dropped
|
3
4
|
module Gem::RequirePathsBuilder
|
4
5
|
def write_require_paths_file_if_needed(spec = @spec, gem_home = @gem_home)
|
5
6
|
return if spec.require_paths == ["lib"] &&
|
@@ -13,5 +14,5 @@ module Gem::RequirePathsBuilder
|
|
13
14
|
file.puts spec.bindir if spec.bindir
|
14
15
|
end
|
15
16
|
end
|
16
|
-
end
|
17
|
+
end if Gem::QUICKLOADER_SUCKAGE
|
17
18
|
|
data/lib/rubygems/server.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'webrick'
|
2
|
-
require 'yaml'
|
3
2
|
require 'zlib'
|
4
3
|
require 'erb'
|
5
4
|
|
@@ -21,7 +20,6 @@ require 'rubygems/doc_manager'
|
|
21
20
|
# * legacy indexes:
|
22
21
|
# * "/Marshal.#{Gem.marshal_version}" - Full SourceIndex dump of metadata
|
23
22
|
# for installed gems
|
24
|
-
# * "/yaml" - YAML dump of metadata for installed gems - deprecated
|
25
23
|
#
|
26
24
|
# == Usage
|
27
25
|
#
|
@@ -554,19 +552,6 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
|
554
552
|
add_date res
|
555
553
|
|
556
554
|
case req.request_uri.path
|
557
|
-
when '/quick/index' then
|
558
|
-
res.body << @source_index.map { |name,| name }.sort.join("\n")
|
559
|
-
when '/quick/index.rz' then
|
560
|
-
index = @source_index.map { |name,| name }.sort.join("\n")
|
561
|
-
res['content-type'] = 'application/x-deflate'
|
562
|
-
res.body << Gem.deflate(index)
|
563
|
-
when '/quick/latest_index' then
|
564
|
-
index = @source_index.latest_specs.map { |spec| spec.full_name }
|
565
|
-
res.body << index.sort.join("\n")
|
566
|
-
when '/quick/latest_index.rz' then
|
567
|
-
index = @source_index.latest_specs.map { |spec| spec.full_name }
|
568
|
-
res['content-type'] = 'application/x-deflate'
|
569
|
-
res.body << Gem.deflate(index.sort.join("\n"))
|
570
555
|
when %r|^/quick/(Marshal.#{Regexp.escape Gem.marshal_version}/)?(.*?)-([0-9.]+)(-.*?)?\.gemspec\.rz$| then
|
571
556
|
dep = Gem::Dependency.new $2, $3
|
572
557
|
specs = @source_index.search dep
|
@@ -591,9 +576,6 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
|
591
576
|
elsif marshal_format then
|
592
577
|
res['content-type'] = 'application/x-deflate'
|
593
578
|
res.body << Gem.deflate(Marshal.dump(specs.first))
|
594
|
-
else # deprecated YAML format
|
595
|
-
res['content-type'] = 'application/x-deflate'
|
596
|
-
res.body << Gem.deflate(specs.first.to_yaml)
|
597
579
|
end
|
598
580
|
else
|
599
581
|
raise WEBrick::HTTPStatus::NotFound, "`#{req.path}' not found."
|
@@ -673,10 +655,12 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
|
673
655
|
template = ERB.new(DOC_TEMPLATE)
|
674
656
|
res['content-type'] = 'text/html'
|
675
657
|
|
676
|
-
# this is used by binding, 1.9.3dev warns anyways
|
677
658
|
values = { "gem_count" => specs.size.to_s, "specs" => specs,
|
678
659
|
"total_file_count" => total_file_count.to_s }
|
679
660
|
|
661
|
+
# suppress 1.9.3dev warning about unused variable
|
662
|
+
values = values
|
663
|
+
|
680
664
|
result = template.result binding
|
681
665
|
res.body = result
|
682
666
|
end
|
@@ -770,9 +754,6 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
|
770
754
|
|
771
755
|
WEBrick::Daemon.start if @daemon
|
772
756
|
|
773
|
-
@server.mount_proc "/yaml", method(:yaml)
|
774
|
-
@server.mount_proc "/yaml.Z", method(:yaml)
|
775
|
-
|
776
757
|
@server.mount_proc "/Marshal.#{Gem.marshal_version}", method(:Marshal)
|
777
758
|
@server.mount_proc "/Marshal.#{Gem.marshal_version}.Z", method(:Marshal)
|
778
759
|
|
@@ -837,28 +818,6 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
|
837
818
|
end
|
838
819
|
end
|
839
820
|
|
840
|
-
def yaml(req, res)
|
841
|
-
@source_index.refresh!
|
842
|
-
|
843
|
-
add_date res
|
844
|
-
|
845
|
-
index = @source_index.to_yaml
|
846
|
-
|
847
|
-
if req.path =~ /Z$/ then
|
848
|
-
res['content-type'] = 'application/x-deflate'
|
849
|
-
index = Gem.deflate index
|
850
|
-
else
|
851
|
-
res['content-type'] = 'text/plain'
|
852
|
-
end
|
853
|
-
|
854
|
-
if req.request_method == 'HEAD' then
|
855
|
-
res['content-length'] = index.length
|
856
|
-
return
|
857
|
-
end
|
858
|
-
|
859
|
-
res.body << index
|
860
|
-
end
|
861
|
-
|
862
821
|
def launch
|
863
822
|
listeners = @server.listeners.map{|l| l.addr[2] }
|
864
823
|
|
@@ -4,7 +4,6 @@
|
|
4
4
|
# See LICENSE.txt for permissions.
|
5
5
|
#++
|
6
6
|
|
7
|
-
require 'rubygems/user_interaction'
|
8
7
|
require 'rubygems/specification'
|
9
8
|
|
10
9
|
##
|
@@ -22,8 +21,6 @@ class Gem::SourceIndex
|
|
22
21
|
|
23
22
|
include Enumerable
|
24
23
|
|
25
|
-
include Gem::UserInteraction
|
26
|
-
|
27
24
|
attr_reader :gems # :nodoc:
|
28
25
|
|
29
26
|
##
|
@@ -32,8 +29,6 @@ class Gem::SourceIndex
|
|
32
29
|
attr_accessor :spec_dirs
|
33
30
|
|
34
31
|
class << self
|
35
|
-
include Gem::UserInteraction
|
36
|
-
|
37
32
|
##
|
38
33
|
# Factory method to construct a source index instance for a given
|
39
34
|
# path.
|
@@ -322,19 +317,9 @@ class Gem::SourceIndex
|
|
322
317
|
latest_specs.each do |local|
|
323
318
|
dependency = Gem::Dependency.new local.name, ">= #{local.version}"
|
324
319
|
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
remotes = remotes.map { |(_, version, _), _| version }
|
329
|
-
rescue Gem::RemoteFetcher::FetchError => e
|
330
|
-
raise unless fetcher.warn_legacy e do
|
331
|
-
require 'rubygems/source_info_cache'
|
332
|
-
|
333
|
-
specs = Gem::SourceInfoCache.search_with_source dependency, true
|
334
|
-
|
335
|
-
remotes = specs.map { |spec,| spec.version }
|
336
|
-
end
|
337
|
-
end
|
320
|
+
fetcher = Gem::SpecFetcher.fetcher
|
321
|
+
remotes = fetcher.find_matching dependency
|
322
|
+
remotes = remotes.map { |(_, version, _), _| version }
|
338
323
|
|
339
324
|
latest = remotes.sort.last
|
340
325
|
|
@@ -344,43 +329,6 @@ class Gem::SourceIndex
|
|
344
329
|
outdateds
|
345
330
|
end
|
346
331
|
|
347
|
-
##
|
348
|
-
# Updates this SourceIndex from +source_uri+. If +all+ is false, only the
|
349
|
-
# latest gems are fetched.
|
350
|
-
|
351
|
-
def update(source_uri, all)
|
352
|
-
source_uri = URI.parse source_uri unless URI::Generic === source_uri
|
353
|
-
source_uri.path += '/' unless source_uri.path =~ /\/$/
|
354
|
-
|
355
|
-
use_incremental = false
|
356
|
-
|
357
|
-
begin
|
358
|
-
gem_names = fetch_quick_index source_uri, all
|
359
|
-
remove_extra gem_names
|
360
|
-
missing_gems = find_missing gem_names
|
361
|
-
|
362
|
-
return false if missing_gems.size.zero?
|
363
|
-
|
364
|
-
say "Missing metadata for #{missing_gems.size} gems" if
|
365
|
-
missing_gems.size > 0 and Gem.configuration.really_verbose
|
366
|
-
|
367
|
-
use_incremental = missing_gems.size <= Gem.configuration.bulk_threshold
|
368
|
-
rescue Gem::OperationNotSupportedError => ex
|
369
|
-
alert_error "Falling back to bulk fetch: #{ex.message}" if
|
370
|
-
Gem.configuration.really_verbose
|
371
|
-
use_incremental = false
|
372
|
-
end
|
373
|
-
|
374
|
-
if use_incremental then
|
375
|
-
update_with_missing(source_uri, missing_gems)
|
376
|
-
else
|
377
|
-
new_index = fetch_bulk_index(source_uri)
|
378
|
-
@gems.replace(new_index.gems)
|
379
|
-
end
|
380
|
-
|
381
|
-
true
|
382
|
-
end
|
383
|
-
|
384
332
|
def ==(other) # :nodoc:
|
385
333
|
self.class === other and @gems == other.gems
|
386
334
|
end
|
@@ -389,167 +337,6 @@ class Gem::SourceIndex
|
|
389
337
|
Marshal.dump(self)
|
390
338
|
end
|
391
339
|
|
392
|
-
private
|
393
|
-
|
394
|
-
def fetcher
|
395
|
-
require 'rubygems/remote_fetcher'
|
396
|
-
|
397
|
-
Gem::RemoteFetcher.fetcher
|
398
|
-
end
|
399
|
-
|
400
|
-
def fetch_index_from(source_uri)
|
401
|
-
@fetch_error = nil
|
402
|
-
|
403
|
-
indexes = %W[
|
404
|
-
Marshal.#{Gem.marshal_version}.Z
|
405
|
-
Marshal.#{Gem.marshal_version}
|
406
|
-
yaml.Z
|
407
|
-
yaml
|
408
|
-
]
|
409
|
-
|
410
|
-
indexes.each do |name|
|
411
|
-
spec_data = nil
|
412
|
-
index = source_uri + name
|
413
|
-
begin
|
414
|
-
spec_data = fetcher.fetch_path index
|
415
|
-
spec_data = unzip(spec_data) if name =~ /\.Z$/
|
416
|
-
|
417
|
-
if name =~ /Marshal/ then
|
418
|
-
return Marshal.load(spec_data)
|
419
|
-
else
|
420
|
-
return YAML.load(spec_data)
|
421
|
-
end
|
422
|
-
rescue => e
|
423
|
-
if Gem.configuration.really_verbose then
|
424
|
-
alert_error "Unable to fetch #{name}: #{e.message}"
|
425
|
-
end
|
426
|
-
|
427
|
-
@fetch_error = e
|
428
|
-
end
|
429
|
-
end
|
430
|
-
|
431
|
-
nil
|
432
|
-
end
|
433
|
-
|
434
|
-
def fetch_bulk_index(source_uri)
|
435
|
-
say "Bulk updating Gem source index for: #{source_uri}" if
|
436
|
-
Gem.configuration.verbose
|
437
|
-
|
438
|
-
index = fetch_index_from(source_uri)
|
439
|
-
if index.nil? then
|
440
|
-
raise Gem::RemoteSourceException,
|
441
|
-
"Error fetching remote gem cache: #{@fetch_error}"
|
442
|
-
end
|
443
|
-
@fetch_error = nil
|
444
|
-
index
|
445
|
-
end
|
446
|
-
|
447
|
-
##
|
448
|
-
# Get the quick index needed for incremental updates.
|
449
|
-
|
450
|
-
def fetch_quick_index(source_uri, all)
|
451
|
-
index = all ? 'index' : 'latest_index'
|
452
|
-
|
453
|
-
zipped_index = fetcher.fetch_path source_uri + "quick/#{index}.rz"
|
454
|
-
|
455
|
-
unzip(zipped_index).split("\n")
|
456
|
-
rescue ::Exception => e
|
457
|
-
unless all then
|
458
|
-
say "Latest index not found, using quick index" if
|
459
|
-
Gem.configuration.really_verbose
|
460
|
-
|
461
|
-
fetch_quick_index source_uri, true
|
462
|
-
else
|
463
|
-
raise Gem::OperationNotSupportedError,
|
464
|
-
"No quick index found: #{e.message}"
|
465
|
-
end
|
466
|
-
end
|
467
|
-
|
468
|
-
##
|
469
|
-
# Make a list of full names for all the missing gemspecs.
|
470
|
-
|
471
|
-
def find_missing(spec_names)
|
472
|
-
unless defined? @originals then
|
473
|
-
@originals = {}
|
474
|
-
each do |full_name, spec|
|
475
|
-
@originals[spec.original_name] = spec
|
476
|
-
end
|
477
|
-
end
|
478
|
-
|
479
|
-
spec_names.find_all { |full_name|
|
480
|
-
@originals[full_name].nil?
|
481
|
-
}
|
482
|
-
end
|
483
|
-
|
484
|
-
def remove_extra(spec_names)
|
485
|
-
dictionary = {}
|
486
|
-
spec_names.each { |k| dictionary[k] = true }
|
487
|
-
each do |name, spec|
|
488
|
-
remove_spec name unless dictionary.include? spec.original_name
|
489
|
-
end
|
490
|
-
end
|
491
|
-
|
492
|
-
##
|
493
|
-
# Unzip the given string.
|
494
|
-
|
495
|
-
def unzip(string)
|
496
|
-
require 'zlib'
|
497
|
-
Gem.inflate string
|
498
|
-
end
|
499
|
-
|
500
|
-
##
|
501
|
-
# Tries to fetch Marshal representation first, then YAML
|
502
|
-
|
503
|
-
def fetch_single_spec(source_uri, spec_name)
|
504
|
-
@fetch_error = nil
|
505
|
-
|
506
|
-
begin
|
507
|
-
marshal_uri = source_uri + "quick/Marshal.#{Gem.marshal_version}/#{spec_name}.gemspec.rz"
|
508
|
-
zipped = fetcher.fetch_path marshal_uri
|
509
|
-
return Marshal.load(unzip(zipped))
|
510
|
-
rescue => ex
|
511
|
-
@fetch_error = ex
|
512
|
-
|
513
|
-
if Gem.configuration.really_verbose then
|
514
|
-
say "unable to fetch marshal gemspec #{marshal_uri}: #{ex.class} - #{ex}"
|
515
|
-
end
|
516
|
-
end
|
517
|
-
|
518
|
-
begin
|
519
|
-
yaml_uri = source_uri + "quick/#{spec_name}.gemspec.rz"
|
520
|
-
zipped = fetcher.fetch_path yaml_uri
|
521
|
-
return YAML.load(unzip(zipped))
|
522
|
-
rescue => ex
|
523
|
-
@fetch_error = ex
|
524
|
-
if Gem.configuration.really_verbose then
|
525
|
-
say "unable to fetch YAML gemspec #{yaml_uri}: #{ex.class} - #{ex}"
|
526
|
-
end
|
527
|
-
end
|
528
|
-
|
529
|
-
nil
|
530
|
-
end
|
531
|
-
|
532
|
-
##
|
533
|
-
# Update the cached source index with the missing names.
|
534
|
-
|
535
|
-
def update_with_missing(source_uri, missing_names)
|
536
|
-
progress = ui.progress_reporter(missing_names.size,
|
537
|
-
"Updating metadata for #{missing_names.size} gems from #{source_uri}")
|
538
|
-
missing_names.each do |spec_name|
|
539
|
-
gemspec = fetch_single_spec(source_uri, spec_name)
|
540
|
-
if gemspec.nil? then
|
541
|
-
ui.say "Failed to download spec #{spec_name} from #{source_uri}:\n" \
|
542
|
-
"\t#{@fetch_error.message}"
|
543
|
-
else
|
544
|
-
add_spec gemspec
|
545
|
-
progress.updated spec_name
|
546
|
-
end
|
547
|
-
@fetch_error = nil
|
548
|
-
end
|
549
|
-
progress.done
|
550
|
-
progress.count
|
551
|
-
end
|
552
|
-
|
553
340
|
end
|
554
341
|
|
555
342
|
# :stopdoc:
|