rubygems-update 2.7.11 → 3.0.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +66 -0
- data/.travis.yml +22 -18
- data/CONTRIBUTING.md +141 -0
- data/History.txt +289 -19
- data/MAINTAINERS.txt +1 -0
- data/Manifest.txt +16 -11
- data/POLICIES.md +92 -0
- data/README.md +47 -26
- data/Rakefile +47 -207
- data/{UPGRADING.rdoc → UPGRADING.md} +31 -32
- data/appveyor.yml +20 -45
- data/bin/gem +1 -2
- data/bin/update_rubygems +2 -3
- data/bundler/CHANGELOG.md +54 -0
- data/bundler/bundler.gemspec +7 -1
- data/bundler/lib/bundler.rb +26 -8
- data/bundler/lib/bundler/build_metadata.rb +2 -2
- data/bundler/lib/bundler/cli.rb +63 -21
- data/bundler/lib/bundler/cli/add.rb +15 -5
- data/bundler/lib/bundler/cli/binstubs.rb +8 -2
- data/bundler/lib/bundler/cli/doctor.rb +47 -1
- data/bundler/lib/bundler/cli/install.rb +8 -5
- data/bundler/lib/bundler/cli/list.rb +41 -5
- data/bundler/lib/bundler/cli/outdated.rb +7 -1
- data/bundler/lib/bundler/cli/pristine.rb +4 -0
- data/bundler/lib/bundler/cli/remove.rb +18 -0
- data/bundler/lib/bundler/definition.rb +15 -16
- data/bundler/lib/bundler/dependency.rb +2 -2
- data/bundler/lib/bundler/dsl.rb +19 -3
- data/bundler/lib/bundler/feature_flag.rb +7 -0
- data/bundler/lib/bundler/gem_version_promoter.rb +4 -2
- data/bundler/lib/bundler/injector.rb +168 -9
- data/bundler/lib/bundler/installer.rb +29 -6
- data/bundler/lib/bundler/installer/parallel_installer.rb +5 -0
- data/bundler/lib/bundler/plugin.rb +10 -3
- data/bundler/lib/bundler/plugin/events.rb +61 -0
- data/bundler/lib/bundler/resolver.rb +2 -2
- data/bundler/lib/bundler/runtime.rb +8 -2
- data/bundler/lib/bundler/settings.rb +24 -3
- data/bundler/lib/bundler/settings/validator.rb +23 -0
- data/bundler/lib/bundler/shared_helpers.rb +19 -3
- data/bundler/lib/bundler/source.rb +9 -9
- data/bundler/lib/bundler/templates/newgem/lib/newgem.rb.tt +1 -0
- data/bundler/lib/bundler/version.rb +1 -1
- data/bundler/man/bundle-add.ronn +13 -2
- data/bundler/man/bundle-config.ronn +21 -0
- data/bundler/man/bundle-install.ronn +1 -1
- data/bundler/man/bundle-list.ronn +19 -1
- data/bundler/man/bundle-outdated.ronn +4 -0
- data/bundler/man/bundle-remove.ronn +23 -0
- data/bundler/man/bundle-update.ronn +1 -1
- data/lib/rubygems.rb +70 -96
- data/lib/rubygems/available_set.rb +1 -1
- data/lib/rubygems/basic_specification.rb +12 -12
- data/lib/rubygems/bundler_version_finder.rb +3 -3
- data/lib/rubygems/command.rb +22 -15
- data/lib/rubygems/command_manager.rb +20 -11
- data/lib/rubygems/commands/build_command.rb +27 -8
- data/lib/rubygems/commands/cert_command.rb +45 -24
- data/lib/rubygems/commands/check_command.rb +1 -1
- data/lib/rubygems/commands/cleanup_command.rb +14 -7
- data/lib/rubygems/commands/contents_command.rb +14 -15
- data/lib/rubygems/commands/dependency_command.rb +17 -17
- data/lib/rubygems/commands/environment_command.rb +20 -1
- data/lib/rubygems/commands/fetch_command.rb +2 -3
- data/lib/rubygems/commands/generate_index_command.rb +2 -3
- data/lib/rubygems/commands/help_command.rb +12 -13
- data/lib/rubygems/commands/info_command.rb +33 -0
- data/lib/rubygems/commands/install_command.rb +21 -17
- data/lib/rubygems/commands/list_command.rb +0 -1
- data/lib/rubygems/commands/lock_command.rb +3 -4
- data/lib/rubygems/commands/open_command.rb +16 -10
- data/lib/rubygems/commands/owner_command.rb +20 -11
- data/lib/rubygems/commands/pristine_command.rb +23 -16
- data/lib/rubygems/commands/push_command.rb +17 -8
- data/lib/rubygems/commands/query_command.rb +24 -24
- data/lib/rubygems/commands/rdoc_command.rb +3 -4
- data/lib/rubygems/commands/search_command.rb +0 -1
- data/lib/rubygems/commands/server_command.rb +1 -2
- data/lib/rubygems/commands/setup_command.rb +78 -38
- data/lib/rubygems/commands/signin_command.rb +2 -1
- data/lib/rubygems/commands/signout_command.rb +2 -2
- data/lib/rubygems/commands/sources_command.rb +11 -12
- data/lib/rubygems/commands/specification_command.rb +7 -7
- data/lib/rubygems/commands/uninstall_command.rb +41 -19
- data/lib/rubygems/commands/unpack_command.rb +16 -7
- data/lib/rubygems/commands/update_command.rb +28 -23
- data/lib/rubygems/commands/which_command.rb +4 -5
- data/lib/rubygems/commands/yank_command.rb +1 -2
- data/lib/rubygems/compatibility.rb +1 -21
- data/lib/rubygems/config_file.rb +36 -36
- data/lib/rubygems/core_ext/kernel_require.rb +6 -6
- data/lib/rubygems/core_ext/kernel_warn.rb +45 -0
- data/lib/rubygems/defaults.rb +31 -12
- data/lib/rubygems/dependency.rb +14 -14
- data/lib/rubygems/dependency_installer.rb +29 -31
- data/lib/rubygems/dependency_list.rb +8 -9
- data/lib/rubygems/deprecate.rb +2 -3
- data/lib/rubygems/doctor.rb +5 -6
- data/lib/rubygems/errors.rb +3 -3
- data/lib/rubygems/exceptions.rb +11 -4
- data/lib/rubygems/ext.rb +0 -1
- data/lib/rubygems/ext/build_error.rb +0 -1
- data/lib/rubygems/ext/builder.rb +50 -23
- data/lib/rubygems/ext/cmake_builder.rb +2 -2
- data/lib/rubygems/ext/configure_builder.rb +2 -3
- data/lib/rubygems/ext/ext_conf_builder.rb +8 -7
- data/lib/rubygems/ext/rake_builder.rb +16 -18
- data/lib/rubygems/gem_runner.rb +2 -2
- data/lib/rubygems/gemcutter_utilities.rb +40 -13
- data/lib/rubygems/indexer.rb +19 -12
- data/lib/rubygems/install_default_message.rb +0 -1
- data/lib/rubygems/install_message.rb +0 -1
- data/lib/rubygems/install_update_options.rb +2 -28
- data/lib/rubygems/installer.rb +95 -75
- data/lib/rubygems/installer_test_case.rb +0 -14
- data/lib/rubygems/local_remote_options.rb +5 -4
- data/lib/rubygems/mock_gem_ui.rb +3 -4
- data/lib/rubygems/name_tuple.rb +4 -4
- data/lib/rubygems/package.rb +90 -73
- data/lib/rubygems/package/digest_io.rb +3 -4
- data/lib/rubygems/package/file_source.rb +3 -4
- data/lib/rubygems/package/io_source.rb +1 -2
- data/lib/rubygems/package/old.rb +8 -16
- data/lib/rubygems/package/source.rb +0 -1
- data/lib/rubygems/package/tar_header.rb +2 -2
- data/lib/rubygems/package/tar_reader.rb +2 -4
- data/lib/rubygems/package/tar_reader/entry.rb +20 -4
- data/lib/rubygems/package/tar_test_case.rb +2 -8
- data/lib/rubygems/package/tar_writer.rb +13 -15
- data/lib/rubygems/package_task.rb +0 -1
- data/lib/rubygems/path_support.rb +16 -6
- data/lib/rubygems/platform.rb +4 -5
- data/lib/rubygems/psych_tree.rb +1 -1
- data/lib/rubygems/rdoc.rb +0 -311
- data/lib/rubygems/remote_fetcher.rb +34 -48
- data/lib/rubygems/request.rb +16 -15
- data/lib/rubygems/request/connection_pools.rb +24 -13
- data/lib/rubygems/request/http_pool.rb +3 -4
- data/lib/rubygems/request/https_pool.rb +1 -3
- data/lib/rubygems/request_set.rb +52 -25
- data/lib/rubygems/request_set/gem_dependency_api.rb +36 -40
- data/lib/rubygems/request_set/lockfile.rb +12 -12
- data/lib/rubygems/request_set/lockfile/parser.rb +18 -29
- data/lib/rubygems/request_set/lockfile/tokenizer.rb +9 -9
- data/lib/rubygems/requirement.rb +16 -16
- data/lib/rubygems/resolver.rb +10 -15
- data/lib/rubygems/resolver/activation_request.rb +6 -6
- data/lib/rubygems/resolver/api_set.rb +5 -6
- data/lib/rubygems/resolver/api_specification.rb +2 -3
- data/lib/rubygems/resolver/best_set.rb +5 -6
- data/lib/rubygems/resolver/composed_set.rb +5 -6
- data/lib/rubygems/resolver/conflict.rb +5 -5
- data/lib/rubygems/resolver/current_set.rb +1 -2
- data/lib/rubygems/resolver/dependency_request.rb +4 -4
- data/lib/rubygems/resolver/git_set.rb +5 -6
- data/lib/rubygems/resolver/git_specification.rb +4 -5
- data/lib/rubygems/resolver/index_set.rb +5 -6
- data/lib/rubygems/resolver/index_specification.rb +3 -4
- data/lib/rubygems/resolver/installed_specification.rb +3 -4
- data/lib/rubygems/resolver/installer_set.rb +12 -12
- data/lib/rubygems/resolver/local_specification.rb +1 -2
- data/lib/rubygems/resolver/lock_set.rb +5 -6
- data/lib/rubygems/resolver/lock_specification.rb +7 -8
- data/lib/rubygems/resolver/requirement_list.rb +1 -1
- data/lib/rubygems/resolver/set.rb +2 -2
- data/lib/rubygems/resolver/source_set.rb +4 -5
- data/lib/rubygems/resolver/spec_specification.rb +1 -2
- data/lib/rubygems/resolver/specification.rb +10 -7
- data/lib/rubygems/resolver/stats.rb +1 -1
- data/lib/rubygems/resolver/vendor_set.rb +4 -5
- data/lib/rubygems/resolver/vendor_specification.rb +2 -3
- data/lib/rubygems/safe_yaml.rb +18 -10
- data/lib/rubygems/security.rb +21 -22
- data/lib/rubygems/security/policies.rb +1 -2
- data/lib/rubygems/security/policy.rb +25 -25
- data/lib/rubygems/security/signer.rb +72 -24
- data/lib/rubygems/security/trust_dir.rb +10 -10
- data/lib/rubygems/server.rb +21 -21
- data/lib/rubygems/source.rb +16 -25
- data/lib/rubygems/source/git.rb +9 -10
- data/lib/rubygems/source/installed.rb +3 -4
- data/lib/rubygems/source/local.rb +7 -7
- data/lib/rubygems/source/lock.rb +4 -4
- data/lib/rubygems/source/specific_file.rb +5 -5
- data/lib/rubygems/source/vendor.rb +2 -3
- data/lib/rubygems/source_list.rb +2 -2
- data/lib/rubygems/source_local.rb +0 -1
- data/lib/rubygems/spec_fetcher.rb +5 -6
- data/lib/rubygems/specification.rb +199 -536
- data/lib/rubygems/specification_policy.rb +407 -0
- data/lib/rubygems/ssl_certs/{rubygems.org → index.rubygems.org}/GlobalSignRootCA.pem +0 -0
- data/lib/rubygems/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +23 -0
- data/lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +25 -0
- data/lib/rubygems/stub_specification.rb +11 -15
- data/lib/rubygems/test_case.rb +141 -66
- data/lib/rubygems/test_utilities.rb +20 -35
- data/lib/rubygems/text.rb +6 -6
- data/lib/rubygems/uninstaller.rb +37 -26
- data/lib/rubygems/uri_formatter.rb +1 -2
- data/lib/rubygems/user_interaction.rb +38 -93
- data/lib/rubygems/util.rb +20 -14
- data/lib/rubygems/util/licenses.rb +27 -1
- data/lib/rubygems/util/list.rb +1 -1
- data/lib/rubygems/validator.rb +4 -5
- data/lib/rubygems/version.rb +15 -15
- data/lib/rubygems/version_option.rb +2 -3
- data/rubygems-update.gemspec +43 -0
- data/setup.rb +2 -8
- data/test/rubygems/rubygems_plugin.rb +0 -1
- data/test/rubygems/simple_gem.rb +1 -1
- data/test/rubygems/test_bundled_ca.rb +4 -7
- data/test/rubygems/test_config.rb +7 -2
- data/test/rubygems/test_gem.rb +161 -130
- data/test/rubygems/test_gem_command.rb +0 -1
- data/test/rubygems/test_gem_command_manager.rb +8 -3
- data/test/rubygems/test_gem_commands_build_command.rb +219 -15
- data/test/rubygems/test_gem_commands_cert_command.rb +69 -8
- data/test/rubygems/test_gem_commands_check_command.rb +1 -1
- data/test/rubygems/test_gem_commands_cleanup_command.rb +27 -1
- data/test/rubygems/test_gem_commands_contents_command.rb +1 -2
- data/test/rubygems/test_gem_commands_dependency_command.rb +33 -34
- data/test/rubygems/test_gem_commands_environment_command.rb +1 -0
- data/test/rubygems/test_gem_commands_fetch_command.rb +0 -1
- data/test/rubygems/test_gem_commands_generate_index_command.rb +0 -1
- data/test/rubygems/test_gem_commands_help_command.rb +7 -4
- data/test/rubygems/test_gem_commands_info_command.rb +44 -0
- data/test/rubygems/test_gem_commands_install_command.rb +79 -12
- data/test/rubygems/test_gem_commands_lock_command.rb +0 -1
- data/test/rubygems/test_gem_commands_open_command.rb +29 -0
- data/test/rubygems/test_gem_commands_outdated_command.rb +0 -1
- data/test/rubygems/test_gem_commands_owner_command.rb +93 -57
- data/test/rubygems/test_gem_commands_pristine_command.rb +65 -30
- data/test/rubygems/test_gem_commands_push_command.rb +39 -0
- data/test/rubygems/test_gem_commands_query_command.rb +102 -100
- data/test/rubygems/test_gem_commands_search_command.rb +0 -1
- data/test/rubygems/test_gem_commands_server_command.rb +0 -1
- data/test/rubygems/test_gem_commands_setup_command.rb +39 -8
- data/test/rubygems/test_gem_commands_signin_command.rb +1 -1
- data/test/rubygems/test_gem_commands_sources_command.rb +0 -1
- data/test/rubygems/test_gem_commands_specification_command.rb +2 -3
- data/test/rubygems/test_gem_commands_stale_command.rb +3 -2
- data/test/rubygems/test_gem_commands_uninstall_command.rb +81 -7
- data/test/rubygems/test_gem_commands_unpack_command.rb +17 -1
- data/test/rubygems/test_gem_commands_update_command.rb +19 -2
- data/test/rubygems/test_gem_commands_which_command.rb +0 -1
- data/test/rubygems/test_gem_commands_yank_command.rb +0 -1
- data/test/rubygems/test_gem_config_file.rb +4 -2
- data/test/rubygems/test_gem_dependency.rb +0 -1
- data/test/rubygems/test_gem_dependency_installer.rb +8 -5
- data/test/rubygems/test_gem_dependency_list.rb +6 -7
- data/test/rubygems/test_gem_dependency_resolution_error.rb +0 -1
- data/test/rubygems/test_gem_doctor.rb +1 -2
- data/test/rubygems/test_gem_ext_builder.rb +10 -23
- data/test/rubygems/test_gem_ext_cmake_builder.rb +5 -4
- data/test/rubygems/test_gem_ext_configure_builder.rb +3 -3
- data/test/rubygems/test_gem_ext_ext_conf_builder.rb +8 -9
- data/test/rubygems/test_gem_ext_rake_builder.rb +20 -5
- data/test/rubygems/test_gem_gem_runner.rb +0 -1
- data/test/rubygems/test_gem_gemcutter_utilities.rb +32 -6
- data/test/rubygems/test_gem_impossible_dependencies_error.rb +0 -1
- data/test/rubygems/test_gem_indexer.rb +1 -2
- data/test/rubygems/test_gem_install_update_options.rb +1 -20
- data/test/rubygems/test_gem_installer.rb +69 -203
- data/test/rubygems/test_gem_local_remote_options.rb +3 -3
- data/test/rubygems/test_gem_name_tuple.rb +0 -1
- data/test/rubygems/test_gem_package.rb +59 -50
- data/test/rubygems/test_gem_package_old.rb +0 -1
- data/test/rubygems/test_gem_package_tar_header.rb +1 -2
- data/test/rubygems/test_gem_package_tar_reader.rb +0 -1
- data/test/rubygems/test_gem_package_tar_reader_entry.rb +11 -0
- data/test/rubygems/test_gem_package_tar_writer.rb +40 -7
- data/test/rubygems/test_gem_package_task.rb +2 -2
- data/test/rubygems/test_gem_path_support.rb +28 -11
- data/test/rubygems/test_gem_platform.rb +4 -5
- data/test/rubygems/test_gem_rdoc.rb +1 -2
- data/test/rubygems/test_gem_remote_fetcher.rb +111 -130
- data/test/rubygems/test_gem_request.rb +5 -5
- data/test/rubygems/test_gem_request_connection_pools.rb +24 -3
- data/test/rubygems/test_gem_request_set.rb +5 -5
- data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +2 -7
- data/test/rubygems/test_gem_request_set_lockfile.rb +1 -2
- data/test/rubygems/test_gem_request_set_lockfile_parser.rb +4 -9
- data/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +1 -1
- data/test/rubygems/test_gem_requirement.rb +18 -4
- data/test/rubygems/test_gem_resolver.rb +13 -17
- data/test/rubygems/test_gem_resolver_activation_request.rb +0 -1
- data/test/rubygems/test_gem_resolver_api_set.rb +0 -1
- data/test/rubygems/test_gem_resolver_api_specification.rb +0 -1
- data/test/rubygems/test_gem_resolver_best_set.rb +0 -1
- data/test/rubygems/test_gem_resolver_composed_set.rb +0 -1
- data/test/rubygems/test_gem_resolver_conflict.rb +0 -1
- data/test/rubygems/test_gem_resolver_dependency_request.rb +0 -1
- data/test/rubygems/test_gem_resolver_git_set.rb +0 -1
- data/test/rubygems/test_gem_resolver_git_specification.rb +0 -1
- data/test/rubygems/test_gem_resolver_index_set.rb +0 -1
- data/test/rubygems/test_gem_resolver_index_specification.rb +0 -1
- data/test/rubygems/test_gem_resolver_installed_specification.rb +0 -1
- data/test/rubygems/test_gem_resolver_installer_set.rb +2 -3
- data/test/rubygems/test_gem_resolver_local_specification.rb +0 -1
- data/test/rubygems/test_gem_resolver_lock_set.rb +0 -1
- data/test/rubygems/test_gem_resolver_lock_specification.rb +0 -1
- data/test/rubygems/test_gem_resolver_requirement_list.rb +0 -1
- data/test/rubygems/test_gem_resolver_specification.rb +1 -2
- data/test/rubygems/test_gem_resolver_vendor_set.rb +0 -1
- data/test/rubygems/test_gem_resolver_vendor_specification.rb +0 -1
- data/test/rubygems/test_gem_security.rb +1 -3
- data/test/rubygems/test_gem_security_policy.rb +4 -5
- data/test/rubygems/test_gem_security_signer.rb +4 -3
- data/test/rubygems/test_gem_security_trust_dir.rb +1 -2
- data/test/rubygems/test_gem_server.rb +4 -4
- data/test/rubygems/test_gem_source.rb +0 -13
- data/test/rubygems/test_gem_source_fetch_problem.rb +0 -1
- data/test/rubygems/test_gem_source_git.rb +0 -1
- data/test/rubygems/test_gem_source_installed.rb +0 -1
- data/test/rubygems/test_gem_source_lock.rb +0 -1
- data/test/rubygems/test_gem_source_vendor.rb +0 -1
- data/test/rubygems/test_gem_spec_fetcher.rb +0 -1
- data/test/rubygems/test_gem_specification.rb +334 -198
- data/test/rubygems/test_gem_stream_ui.rb +13 -30
- data/test/rubygems/test_gem_stub_specification.rb +0 -2
- data/test/rubygems/test_gem_text.rb +4 -5
- data/test/rubygems/test_gem_uninstaller.rb +21 -1
- data/test/rubygems/test_gem_unsatisfiable_dependency_error.rb +0 -1
- data/test/rubygems/test_gem_uri_formatter.rb +0 -1
- data/test/rubygems/test_gem_util.rb +6 -11
- data/test/rubygems/test_gem_validator.rb +0 -1
- data/test/rubygems/test_gem_version.rb +11 -11
- data/test/rubygems/test_gem_version_option.rb +0 -1
- data/test/rubygems/test_remote_fetch_error.rb +0 -1
- data/test/rubygems/test_require.rb +67 -52
- data/util/CL2notes +1 -2
- data/util/ci +15 -12
- data/util/create_certs.rb +6 -7
- data/util/create_encrypted_key.rb +0 -1
- data/util/patch_with_prs.rb +1 -1
- data/util/rubocop +8 -0
- data/util/update_bundled_ca_certificates.rb +15 -14
- data/util/update_changelog.rb +1 -1
- metadata +67 -59
- data/.autotest +0 -71
- data/.document +0 -5
- data/CONTRIBUTING.rdoc +0 -130
- data/CVE-2013-4287.txt +0 -35
- data/CVE-2013-4363.txt +0 -45
- data/CVE-2015-3900.txt +0 -40
- data/POLICIES.rdoc +0 -74
- data/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem +0 -21
- data/test/rubygems/fix_openssl_warnings.rb +0 -13
@@ -25,23 +25,17 @@ class Gem::FakeFetcher
|
|
25
25
|
|
26
26
|
attr_reader :data
|
27
27
|
attr_reader :last_request
|
28
|
-
attr_reader :api_endpoints
|
29
28
|
attr_accessor :paths
|
30
29
|
|
31
30
|
def initialize
|
32
31
|
@data = {}
|
33
32
|
@paths = []
|
34
|
-
@api_endpoints = {}
|
35
|
-
end
|
36
|
-
|
37
|
-
def api_endpoint(uri)
|
38
|
-
@api_endpoints[uri] || uri
|
39
33
|
end
|
40
34
|
|
41
35
|
def find_data(path)
|
42
36
|
return File.read path.path if URI === path and 'file' == path.scheme
|
43
37
|
|
44
|
-
if URI === path and "URI::#{path.scheme.upcase}" != path.class.name
|
38
|
+
if URI === path and "URI::#{path.scheme.upcase}" != path.class.name
|
45
39
|
raise ArgumentError,
|
46
40
|
"mismatch for scheme #{path.scheme} and class #{path.class}"
|
47
41
|
end
|
@@ -50,20 +44,20 @@ class Gem::FakeFetcher
|
|
50
44
|
@paths << path
|
51
45
|
raise ArgumentError, 'need full URI' unless path =~ %r'^https?://'
|
52
46
|
|
53
|
-
unless @data.key? path
|
47
|
+
unless @data.key? path
|
54
48
|
raise Gem::RemoteFetcher::FetchError.new("no data for #{path}", path)
|
55
49
|
end
|
56
50
|
|
57
51
|
@data[path]
|
58
52
|
end
|
59
53
|
|
60
|
-
def fetch_path
|
54
|
+
def fetch_path(path, mtime = nil, head = false)
|
61
55
|
data = find_data(path)
|
62
56
|
|
63
|
-
if data.respond_to?(:call)
|
57
|
+
if data.respond_to?(:call)
|
64
58
|
data.call
|
65
59
|
else
|
66
|
-
if path.to_s =~ /gz$/ and not data.nil? and not data.empty?
|
60
|
+
if path.to_s =~ /gz$/ and not data.nil? and not data.empty?
|
67
61
|
data = Gem::Util.gunzip data
|
68
62
|
end
|
69
63
|
|
@@ -71,7 +65,7 @@ class Gem::FakeFetcher
|
|
71
65
|
end
|
72
66
|
end
|
73
67
|
|
74
|
-
def cache_update_path
|
68
|
+
def cache_update_path(uri, path = nil, update = true)
|
75
69
|
if data = fetch_path(uri)
|
76
70
|
open(path, 'wb') { |io| io.write data } if path and update
|
77
71
|
data
|
@@ -93,7 +87,7 @@ class Gem::FakeFetcher
|
|
93
87
|
|
94
88
|
def request(uri, request_class, last_modified = nil)
|
95
89
|
data = find_data(uri)
|
96
|
-
body, code, msg = data
|
90
|
+
body, code, msg = (data.respond_to?(:call) ? data.call : data)
|
97
91
|
|
98
92
|
@last_request = request_class.new uri.request_uri
|
99
93
|
yield @last_request if block_given?
|
@@ -104,21 +98,13 @@ class Gem::FakeFetcher
|
|
104
98
|
response
|
105
99
|
end
|
106
100
|
|
107
|
-
def pretty_print
|
101
|
+
def pretty_print(q) # :nodoc:
|
108
102
|
q.group 2, '[FakeFetcher', ']' do
|
109
103
|
q.breakable
|
110
104
|
q.text 'URIs:'
|
111
105
|
|
112
106
|
q.breakable
|
113
107
|
q.pp @data.keys
|
114
|
-
|
115
|
-
unless @api_endpoints.empty? then
|
116
|
-
q.breakable
|
117
|
-
q.text 'API endpoints:'
|
118
|
-
|
119
|
-
q.breakable
|
120
|
-
q.pp @api_endpoints.keys
|
121
|
-
end
|
122
108
|
end
|
123
109
|
end
|
124
110
|
|
@@ -128,7 +114,7 @@ class Gem::FakeFetcher
|
|
128
114
|
|
129
115
|
raise ArgumentError, 'need full URI' unless path =~ %r'^http://'
|
130
116
|
|
131
|
-
unless @data.key? path
|
117
|
+
unless @data.key? path
|
132
118
|
raise Gem::RemoteFetcher::FetchError.new("no data for #{path}", path)
|
133
119
|
end
|
134
120
|
|
@@ -137,9 +123,9 @@ class Gem::FakeFetcher
|
|
137
123
|
data.respond_to?(:call) ? data.call : data.length
|
138
124
|
end
|
139
125
|
|
140
|
-
def download
|
126
|
+
def download(spec, source_uri, install_dir = Gem.dir)
|
141
127
|
name = File.basename spec.cache_file
|
142
|
-
path = if Dir.pwd == install_dir
|
128
|
+
path = if Dir.pwd == install_dir # see fetch_command
|
143
129
|
install_dir
|
144
130
|
else
|
145
131
|
File.join install_dir, "cache"
|
@@ -147,7 +133,7 @@ class Gem::FakeFetcher
|
|
147
133
|
|
148
134
|
path = File.join path, name
|
149
135
|
|
150
|
-
if source_uri =~ /^http/
|
136
|
+
if source_uri =~ /^http/
|
151
137
|
File.open(path, "wb") do |f|
|
152
138
|
f.write fetch_path(File.join(source_uri, "gems", name))
|
153
139
|
end
|
@@ -158,7 +144,7 @@ class Gem::FakeFetcher
|
|
158
144
|
path
|
159
145
|
end
|
160
146
|
|
161
|
-
def download_to_cache
|
147
|
+
def download_to_cache(dependency)
|
162
148
|
found, _ = Gem::SpecFetcher.fetcher.spec_for_dependency dependency
|
163
149
|
|
164
150
|
return if found.empty?
|
@@ -201,7 +187,7 @@ class Gem::TestCase::SpecFetcherSetup
|
|
201
187
|
# Executes a SpecFetcher setup block. Yields an instance then creates the
|
202
188
|
# gems and specifications defined in the instance.
|
203
189
|
|
204
|
-
def self.declare
|
190
|
+
def self.declare(test, repository)
|
205
191
|
setup = new test, repository
|
206
192
|
|
207
193
|
yield setup
|
@@ -209,7 +195,7 @@ class Gem::TestCase::SpecFetcherSetup
|
|
209
195
|
setup.execute
|
210
196
|
end
|
211
197
|
|
212
|
-
def initialize
|
198
|
+
def initialize(test, repository) # :nodoc:
|
213
199
|
@test = test
|
214
200
|
@repository = repository
|
215
201
|
|
@@ -277,7 +263,7 @@ class Gem::TestCase::SpecFetcherSetup
|
|
277
263
|
# The specification will be yielded before gem creation for customization,
|
278
264
|
# but only the block or the dependencies may be set, not both.
|
279
265
|
|
280
|
-
def gem
|
266
|
+
def gem(name, version, dependencies = nil, &block)
|
281
267
|
@operations << [:gem, name, version, dependencies, block]
|
282
268
|
end
|
283
269
|
|
@@ -288,7 +274,7 @@ class Gem::TestCase::SpecFetcherSetup
|
|
288
274
|
# The specification will be yielded before gem creation for customization,
|
289
275
|
# but only the block or the dependencies may be set, not both.
|
290
276
|
|
291
|
-
def download
|
277
|
+
def download(name, version, dependencies = nil, &block)
|
292
278
|
@operations << [:download, name, version, dependencies, block]
|
293
279
|
end
|
294
280
|
|
@@ -307,7 +293,7 @@ class Gem::TestCase::SpecFetcherSetup
|
|
307
293
|
require 'socket'
|
308
294
|
require 'rubygems/remote_fetcher'
|
309
295
|
|
310
|
-
unless @test.fetcher
|
296
|
+
unless @test.fetcher
|
311
297
|
@test.fetcher = Gem::FakeFetcher.new
|
312
298
|
Gem::RemoteFetcher.fetcher = @test.fetcher
|
313
299
|
end
|
@@ -341,11 +327,11 @@ class Gem::TestCase::SpecFetcherSetup
|
|
341
327
|
# The specification will be yielded before creation for customization,
|
342
328
|
# but only the block or the dependencies may be set, not both.
|
343
329
|
|
344
|
-
def spec
|
330
|
+
def spec(name, version, dependencies = nil, &block)
|
345
331
|
@operations << [:spec, name, version, dependencies, block]
|
346
332
|
end
|
347
333
|
|
348
|
-
def write_spec
|
334
|
+
def write_spec(spec) # :nodoc:
|
349
335
|
File.open spec.spec_file, 'w' do |io|
|
350
336
|
io.write spec.to_ruby_for_cache
|
351
337
|
end
|
@@ -381,4 +367,3 @@ class TempIO < Tempfile
|
|
381
367
|
Gem.read_binary path
|
382
368
|
end
|
383
369
|
end
|
384
|
-
|
data/lib/rubygems/text.rb
CHANGED
@@ -28,7 +28,7 @@ module Gem::Text
|
|
28
28
|
work = clean_text(text)
|
29
29
|
|
30
30
|
while work.length > wrap do
|
31
|
-
if work =~ /^(.{0,#{wrap}})[ \n]/
|
31
|
+
if work =~ /^(.{0,#{wrap}})[ \n]/
|
32
32
|
result << $1.rstrip
|
33
33
|
work.slice!(0, $&.length)
|
34
34
|
else
|
@@ -40,10 +40,10 @@ module Gem::Text
|
|
40
40
|
result.join("\n").gsub(/^/, " " * indent)
|
41
41
|
end
|
42
42
|
|
43
|
-
def min3
|
44
|
-
if a < b && a < c
|
43
|
+
def min3(a, b, c) # :nodoc:
|
44
|
+
if a < b && a < c
|
45
45
|
a
|
46
|
-
elsif b < c
|
46
|
+
elsif b < c
|
47
47
|
b
|
48
48
|
else
|
49
49
|
c
|
@@ -52,7 +52,7 @@ module Gem::Text
|
|
52
52
|
|
53
53
|
# This code is based directly on the Text gem implementation
|
54
54
|
# Returns a value representing the "cost" of transforming str1 into str2
|
55
|
-
def levenshtein_distance
|
55
|
+
def levenshtein_distance(str1, str2)
|
56
56
|
s = str1
|
57
57
|
t = str2
|
58
58
|
n = s.length
|
@@ -73,7 +73,7 @@ module Gem::Text
|
|
73
73
|
d[j+1] + 1, # insertion
|
74
74
|
e + 1, # deletion
|
75
75
|
d[j] + cost # substitution
|
76
|
-
|
76
|
+
)
|
77
77
|
d[j] = e
|
78
78
|
e = x
|
79
79
|
end
|
data/lib/rubygems/uninstaller.rb
CHANGED
@@ -99,7 +99,7 @@ class Gem::Uninstaller
|
|
99
99
|
|
100
100
|
list.sort!
|
101
101
|
|
102
|
-
if list.empty?
|
102
|
+
if list.empty?
|
103
103
|
if other_repo_specs.empty?
|
104
104
|
if default_specs.empty?
|
105
105
|
raise Gem::InstallError, "gem #{@gem.inspect} is not installed"
|
@@ -119,19 +119,19 @@ class Gem::Uninstaller
|
|
119
119
|
}
|
120
120
|
|
121
121
|
raise Gem::InstallError, message.join("\n")
|
122
|
-
elsif @force_all
|
122
|
+
elsif @force_all
|
123
123
|
remove_all list
|
124
124
|
|
125
|
-
elsif list.size > 1
|
125
|
+
elsif list.size > 1
|
126
126
|
gem_names = list.map { |gem| gem.full_name }
|
127
127
|
gem_names << "All versions"
|
128
128
|
|
129
129
|
say
|
130
130
|
_, index = choose_from_list "Select gem to uninstall:", gem_names
|
131
131
|
|
132
|
-
if index == list.size
|
132
|
+
if index == list.size
|
133
133
|
remove_all list
|
134
|
-
elsif index >= 0 && index < list.size
|
134
|
+
elsif index >= 0 && index < list.size
|
135
135
|
uninstall_gem list[index]
|
136
136
|
else
|
137
137
|
say "Error: must enter a number [1-#{list.size+1}]"
|
@@ -194,7 +194,7 @@ class Gem::Uninstaller
|
|
194
194
|
|
195
195
|
executables = executables.map { |exec| formatted_program_filename exec }
|
196
196
|
|
197
|
-
remove = if @force_executables.nil?
|
197
|
+
remove = if @force_executables.nil?
|
198
198
|
ask_yes_no("Remove executables:\n" +
|
199
199
|
"\t#{executables.join ', '}\n\n" +
|
200
200
|
"in addition to the gem?",
|
@@ -203,7 +203,7 @@ class Gem::Uninstaller
|
|
203
203
|
@force_executables
|
204
204
|
end
|
205
205
|
|
206
|
-
if remove
|
206
|
+
if remove
|
207
207
|
bin_dir = @bin_dir || Gem.bindir(spec.base_dir)
|
208
208
|
|
209
209
|
raise Gem::FilePermissionError, bin_dir unless File.writable? bin_dir
|
@@ -213,8 +213,8 @@ class Gem::Uninstaller
|
|
213
213
|
|
214
214
|
exe_file = File.join bin_dir, exe_name
|
215
215
|
|
216
|
-
FileUtils.
|
217
|
-
FileUtils.
|
216
|
+
safe_delete { FileUtils.rm exe_file }
|
217
|
+
safe_delete { FileUtils.rm "#{exe_file}.bat" }
|
218
218
|
end
|
219
219
|
else
|
220
220
|
say "Executables and scripts will remain installed."
|
@@ -239,7 +239,7 @@ class Gem::Uninstaller
|
|
239
239
|
|
240
240
|
def remove(spec)
|
241
241
|
unless path_ok?(@gem_home, spec) or
|
242
|
-
(@user_install and path_ok?(Gem.user_dir, spec))
|
242
|
+
(@user_install and path_ok?(Gem.user_dir, spec))
|
243
243
|
e = Gem::GemNotInHomeException.new \
|
244
244
|
"Gem '#{spec.full_name}' is not installed in directory #{@gem_home}"
|
245
245
|
e.spec = spec
|
@@ -250,26 +250,26 @@ class Gem::Uninstaller
|
|
250
250
|
raise Gem::FilePermissionError, spec.base_dir unless
|
251
251
|
File.writable?(spec.base_dir)
|
252
252
|
|
253
|
-
FileUtils.
|
254
|
-
FileUtils.
|
253
|
+
safe_delete { FileUtils.rm_r spec.full_gem_path }
|
254
|
+
safe_delete { FileUtils.rm_r spec.extension_dir }
|
255
255
|
|
256
256
|
old_platform_name = spec.original_name
|
257
|
-
gemspec = spec.spec_file
|
258
|
-
|
259
|
-
unless File.exist? gemspec then
|
260
|
-
gemspec = File.join(File.dirname(gemspec), "#{old_platform_name}.gemspec")
|
261
|
-
end
|
262
|
-
|
263
|
-
FileUtils.rm_rf gemspec
|
264
257
|
|
265
258
|
gem = spec.cache_file
|
266
259
|
gem = File.join(spec.cache_dir, "#{old_platform_name}.gem") unless
|
267
260
|
File.exist? gem
|
268
261
|
|
269
|
-
FileUtils.
|
262
|
+
safe_delete { FileUtils.rm_r gem }
|
270
263
|
|
271
264
|
Gem::RDoc.new(spec).remove
|
272
265
|
|
266
|
+
gemspec = spec.spec_file
|
267
|
+
|
268
|
+
unless File.exist? gemspec
|
269
|
+
gemspec = File.join(File.dirname(gemspec), "#{old_platform_name}.gemspec")
|
270
|
+
end
|
271
|
+
|
272
|
+
safe_delete { FileUtils.rm_r gemspec }
|
273
273
|
say "Successfully uninstalled #{spec.full_name}"
|
274
274
|
|
275
275
|
Gem::Specification.reset
|
@@ -289,7 +289,7 @@ class Gem::Uninstaller
|
|
289
289
|
# Returns true if it is OK to remove +spec+ or this is a forced
|
290
290
|
# uninstallation.
|
291
291
|
|
292
|
-
def dependencies_ok?
|
292
|
+
def dependencies_ok?(spec) # :nodoc:
|
293
293
|
return true if @force_ignore
|
294
294
|
|
295
295
|
deplist = Gem::DependencyList.from_specs
|
@@ -308,15 +308,15 @@ class Gem::Uninstaller
|
|
308
308
|
##
|
309
309
|
# Asks if it is OK to remove +spec+. Returns true if it is OK.
|
310
310
|
|
311
|
-
def ask_if_ok
|
311
|
+
def ask_if_ok(spec) # :nodoc:
|
312
312
|
msg = ['']
|
313
313
|
msg << 'You have requested to uninstall the gem:'
|
314
314
|
msg << "\t#{spec.full_name}"
|
315
315
|
msg << ''
|
316
316
|
|
317
317
|
siblings = Gem::Specification.select do |s|
|
318
|
-
|
319
|
-
|
318
|
+
s.name == spec.name && s.full_name != spec.full_name
|
319
|
+
end
|
320
320
|
|
321
321
|
spec.dependent_gems.each do |dep_spec, dep, satlist|
|
322
322
|
unless siblings.any? { |s| s.satisfies_requirement? dep }
|
@@ -332,15 +332,26 @@ class Gem::Uninstaller
|
|
332
332
|
##
|
333
333
|
# Returns the formatted version of the executable +filename+
|
334
334
|
|
335
|
-
def formatted_program_filename
|
335
|
+
def formatted_program_filename(filename) # :nodoc:
|
336
336
|
# TODO perhaps the installer should leave a small manifest
|
337
337
|
# of what it did for us to find rather than trying to recreate
|
338
338
|
# it again.
|
339
|
-
if @format_executable
|
339
|
+
if @format_executable
|
340
340
|
require 'rubygems/installer'
|
341
341
|
Gem::Installer.exec_format % File.basename(filename)
|
342
342
|
else
|
343
343
|
filename
|
344
344
|
end
|
345
345
|
end
|
346
|
+
|
347
|
+
def safe_delete(&block)
|
348
|
+
block.call
|
349
|
+
rescue Errno::ENOENT
|
350
|
+
nil
|
351
|
+
rescue Errno::EPERM
|
352
|
+
e = Gem::UninstallError.new
|
353
|
+
e.spec = @spec
|
354
|
+
|
355
|
+
raise e
|
356
|
+
end
|
346
357
|
end
|
@@ -7,7 +7,6 @@
|
|
7
7
|
|
8
8
|
require 'rubygems/util'
|
9
9
|
require 'rubygems/deprecate'
|
10
|
-
require 'rubygems/text'
|
11
10
|
|
12
11
|
##
|
13
12
|
# Module that defines the default UserInteraction. Any class including this
|
@@ -15,8 +14,6 @@ require 'rubygems/text'
|
|
15
14
|
|
16
15
|
module Gem::DefaultUserInteraction
|
17
16
|
|
18
|
-
include Gem::Text
|
19
|
-
|
20
17
|
##
|
21
18
|
# The default UI is a class variable of the singleton class for this
|
22
19
|
# module.
|
@@ -98,7 +95,7 @@ module Gem::UserInteraction
|
|
98
95
|
##
|
99
96
|
# Displays an alert +statement+. Asks a +question+ if given.
|
100
97
|
|
101
|
-
def alert
|
98
|
+
def alert(statement, question = nil)
|
102
99
|
ui.alert statement, question
|
103
100
|
end
|
104
101
|
|
@@ -106,7 +103,7 @@ module Gem::UserInteraction
|
|
106
103
|
# Displays an error +statement+ to the error output location. Asks a
|
107
104
|
# +question+ if given.
|
108
105
|
|
109
|
-
def alert_error
|
106
|
+
def alert_error(statement, question = nil)
|
110
107
|
ui.alert_error statement, question
|
111
108
|
end
|
112
109
|
|
@@ -114,49 +111,49 @@ module Gem::UserInteraction
|
|
114
111
|
# Displays a warning +statement+ to the warning output location. Asks a
|
115
112
|
# +question+ if given.
|
116
113
|
|
117
|
-
def alert_warning
|
114
|
+
def alert_warning(statement, question = nil)
|
118
115
|
ui.alert_warning statement, question
|
119
116
|
end
|
120
117
|
|
121
118
|
##
|
122
119
|
# Asks a +question+ and returns the answer.
|
123
120
|
|
124
|
-
def ask
|
121
|
+
def ask(question)
|
125
122
|
ui.ask question
|
126
123
|
end
|
127
124
|
|
128
125
|
##
|
129
126
|
# Asks for a password with a +prompt+
|
130
127
|
|
131
|
-
def ask_for_password
|
128
|
+
def ask_for_password(prompt)
|
132
129
|
ui.ask_for_password prompt
|
133
130
|
end
|
134
131
|
|
135
132
|
##
|
136
133
|
# Asks a yes or no +question+. Returns true for yes, false for no.
|
137
134
|
|
138
|
-
def ask_yes_no
|
135
|
+
def ask_yes_no(question, default = nil)
|
139
136
|
ui.ask_yes_no question, default
|
140
137
|
end
|
141
138
|
|
142
139
|
##
|
143
140
|
# Asks the user to answer +question+ with an answer from the given +list+.
|
144
141
|
|
145
|
-
def choose_from_list
|
142
|
+
def choose_from_list(question, list)
|
146
143
|
ui.choose_from_list question, list
|
147
144
|
end
|
148
145
|
|
149
146
|
##
|
150
147
|
# Displays the given +statement+ on the standard output (or equivalent).
|
151
148
|
|
152
|
-
def say
|
149
|
+
def say(statement = '')
|
153
150
|
ui.say statement
|
154
151
|
end
|
155
152
|
|
156
153
|
##
|
157
154
|
# Terminates the RubyGems process with the given +exit_code+
|
158
155
|
|
159
|
-
def terminate_interaction
|
156
|
+
def terminate_interaction(exit_code = 0)
|
160
157
|
ui.terminate_interaction exit_code
|
161
158
|
end
|
162
159
|
|
@@ -165,7 +162,7 @@ module Gem::UserInteraction
|
|
165
162
|
# is true.
|
166
163
|
|
167
164
|
def verbose(msg = nil)
|
168
|
-
say(
|
165
|
+
say(msg || yield) if Gem.configuration.really_verbose
|
169
166
|
end
|
170
167
|
end
|
171
168
|
|
@@ -208,18 +205,14 @@ class Gem::StreamUI
|
|
208
205
|
# Returns true if TTY methods should be used on this StreamUI.
|
209
206
|
|
210
207
|
def tty?
|
211
|
-
|
212
|
-
@usetty
|
213
|
-
else
|
214
|
-
@usetty && @ins.tty?
|
215
|
-
end
|
208
|
+
@usetty && @ins.tty?
|
216
209
|
end
|
217
210
|
|
218
211
|
##
|
219
212
|
# Prints a formatted backtrace to the errors stream if backtraces are
|
220
213
|
# enabled.
|
221
214
|
|
222
|
-
def backtrace
|
215
|
+
def backtrace(exception)
|
223
216
|
return unless Gem.configuration.backtrace
|
224
217
|
|
225
218
|
@errs.puts "\t#{exception.backtrace.join "\n\t"}"
|
@@ -254,8 +247,8 @@ class Gem::StreamUI
|
|
254
247
|
# default.
|
255
248
|
|
256
249
|
def ask_yes_no(question, default=nil)
|
257
|
-
unless tty?
|
258
|
-
if default.nil?
|
250
|
+
unless tty?
|
251
|
+
if default.nil?
|
259
252
|
raise Gem::OperationNotSupportedError,
|
260
253
|
"Not connected to a tty and no default specified"
|
261
254
|
else
|
@@ -327,29 +320,7 @@ class Gem::StreamUI
|
|
327
320
|
|
328
321
|
def _gets_noecho
|
329
322
|
require_io_console
|
330
|
-
|
331
|
-
@ins.noecho {@ins.gets}
|
332
|
-
elsif Gem.win_platform?
|
333
|
-
require "Win32API"
|
334
|
-
password = ''
|
335
|
-
|
336
|
-
while char = Win32API.new("crtdll", "_getch", [ ], "L").Call do
|
337
|
-
break if char == 10 || char == 13 # received carriage return or newline
|
338
|
-
if char == 127 || char == 8 # backspace and delete
|
339
|
-
password.slice!(-1, 1)
|
340
|
-
else
|
341
|
-
password << char.chr
|
342
|
-
end
|
343
|
-
end
|
344
|
-
password
|
345
|
-
else
|
346
|
-
system "stty -echo"
|
347
|
-
begin
|
348
|
-
@ins.gets
|
349
|
-
ensure
|
350
|
-
system "stty echo"
|
351
|
-
end
|
352
|
-
end
|
323
|
+
@ins.noecho {@ins.gets}
|
353
324
|
end
|
354
325
|
|
355
326
|
##
|
@@ -541,11 +512,10 @@ class Gem::StreamUI
|
|
541
512
|
# Return a download reporter object chosen from the current verbosity
|
542
513
|
|
543
514
|
def download_reporter(*args)
|
544
|
-
|
545
|
-
when nil, false
|
515
|
+
if [nil, false].include?(Gem.configuration.verbose) || !@outs.tty?
|
546
516
|
SilentDownloadReporter.new(@outs, *args)
|
547
517
|
else
|
548
|
-
|
518
|
+
ThreadedDownloadReporter.new(@outs, *args)
|
549
519
|
end
|
550
520
|
end
|
551
521
|
|
@@ -582,9 +552,11 @@ class Gem::StreamUI
|
|
582
552
|
end
|
583
553
|
|
584
554
|
##
|
585
|
-
# A progress reporter that
|
555
|
+
# A progress reporter that behaves nicely with threaded downloading.
|
556
|
+
|
557
|
+
class ThreadedDownloadReporter
|
586
558
|
|
587
|
-
|
559
|
+
MUTEX = Mutex.new
|
588
560
|
|
589
561
|
##
|
590
562
|
# The current file name being displayed
|
@@ -592,71 +564,44 @@ class Gem::StreamUI
|
|
592
564
|
attr_reader :file_name
|
593
565
|
|
594
566
|
##
|
595
|
-
#
|
596
|
-
|
597
|
-
attr_reader :total_bytes
|
598
|
-
|
599
|
-
##
|
600
|
-
# The current progress (0 to 100)
|
601
|
-
|
602
|
-
attr_reader :progress
|
603
|
-
|
604
|
-
##
|
605
|
-
# Creates a new verbose download reporter that will display on
|
567
|
+
# Creates a new threaded download reporter that will display on
|
606
568
|
# +out_stream+. The other arguments are ignored.
|
607
569
|
|
608
570
|
def initialize(out_stream, *args)
|
571
|
+
@file_name = nil
|
609
572
|
@out = out_stream
|
610
|
-
@progress = 0
|
611
573
|
end
|
612
574
|
|
613
575
|
##
|
614
|
-
# Tells the download reporter that the +file_name+ is being fetched
|
615
|
-
#
|
616
|
-
|
617
|
-
def fetch(file_name, total_bytes)
|
618
|
-
@file_name = file_name
|
619
|
-
@total_bytes = total_bytes.to_i
|
620
|
-
@units = @total_bytes.zero? ? 'B' : '%'
|
576
|
+
# Tells the download reporter that the +file_name+ is being fetched.
|
577
|
+
# The other arguments are ignored.
|
621
578
|
|
622
|
-
|
579
|
+
def fetch(file_name, *args)
|
580
|
+
if @file_name.nil?
|
581
|
+
@file_name = file_name
|
582
|
+
locked_puts "Fetching #{@file_name}"
|
583
|
+
end
|
623
584
|
end
|
624
585
|
|
625
586
|
##
|
626
|
-
# Updates the
|
587
|
+
# Updates the threaded download reporter for the given number of +bytes+.
|
627
588
|
|
628
589
|
def update(bytes)
|
629
|
-
|
630
|
-
bytes
|
631
|
-
else
|
632
|
-
((bytes.to_f * 100) / total_bytes.to_f).ceil
|
633
|
-
end
|
634
|
-
|
635
|
-
return if new_progress == @progress
|
636
|
-
|
637
|
-
@progress = new_progress
|
638
|
-
update_display
|
590
|
+
# Do nothing.
|
639
591
|
end
|
640
592
|
|
641
593
|
##
|
642
594
|
# Indicates the download is complete.
|
643
595
|
|
644
596
|
def done
|
645
|
-
|
646
|
-
update_display(true, true)
|
597
|
+
# Do nothing.
|
647
598
|
end
|
648
599
|
|
649
600
|
private
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
if show_progress then
|
655
|
-
@out.print "\rFetching: %s (%3d%s)" % [@file_name, @progress, @units]
|
656
|
-
else
|
657
|
-
@out.print "Fetching: %s" % @file_name
|
601
|
+
def locked_puts(message)
|
602
|
+
MUTEX.synchronize do
|
603
|
+
@out.puts message
|
658
604
|
end
|
659
|
-
@out.puts if new_line
|
660
605
|
end
|
661
606
|
end
|
662
607
|
end
|
@@ -687,8 +632,8 @@ class Gem::SilentUI < Gem::StreamUI
|
|
687
632
|
def initialize
|
688
633
|
reader, writer = nil, nil
|
689
634
|
|
690
|
-
reader = File.open(
|
691
|
-
writer = File.open(
|
635
|
+
reader = File.open(IO::NULL, 'r')
|
636
|
+
writer = File.open(IO::NULL, 'w')
|
692
637
|
|
693
638
|
super reader, writer, writer, false
|
694
639
|
end
|