rubygems-update 2.7.11 → 3.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +67 -0
- data/.travis.yml +24 -18
- data/CODE_OF_CONDUCT.md +10 -8
- data/CONTRIBUTING.md +148 -0
- data/History.txt +458 -8
- data/MAINTAINERS.txt +1 -0
- data/Manifest.txt +16 -9
- data/POLICIES.md +92 -0
- data/README.md +53 -26
- data/Rakefile +77 -211
- 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 +65 -0
- data/bundler/bundler.gemspec +7 -1
- data/bundler/lib/bundler/build_metadata.rb +1 -1
- 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/cli.rb +63 -21
- 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/parallel_installer.rb +5 -0
- data/bundler/lib/bundler/installer.rb +29 -6
- data/bundler/lib/bundler/plugin/events.rb +61 -0
- data/bundler/lib/bundler/plugin.rb +10 -3
- data/bundler/lib/bundler/resolver.rb +2 -2
- data/bundler/lib/bundler/rubygems_gem_installer.rb +7 -0
- data/bundler/lib/bundler/runtime.rb +8 -2
- data/bundler/lib/bundler/settings/validator.rb +23 -0
- data/bundler/lib/bundler/settings.rb +24 -3
- data/bundler/lib/bundler/shared_helpers.rb +19 -3
- data/bundler/lib/bundler/source/metadata.rb +2 -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/lib/bundler.rb +26 -8
- 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/bundler/man/bundle.ronn +3 -0
- 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 +22 -5
- data/lib/rubygems/commands/build_command.rb +41 -7
- 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 +21 -7
- data/lib/rubygems/commands/pristine_command.rb +23 -16
- data/lib/rubygems/commands/push_command.rb +19 -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 +86 -48
- 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 +50 -18
- 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 +5 -8
- 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 -19
- data/lib/rubygems/dependency.rb +15 -15
- data/lib/rubygems/dependency_installer.rb +30 -33
- data/lib/rubygems/dependency_list.rb +9 -10
- 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 -8
- 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/ext.rb +0 -1
- data/lib/rubygems/gem_runner.rb +2 -2
- data/lib/rubygems/gemcutter_utilities.rb +46 -12
- 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 +3 -29
- data/lib/rubygems/installer.rb +97 -55
- data/lib/rubygems/installer_test_case.rb +2 -16
- 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/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 +13 -4
- data/lib/rubygems/package/tar_reader/entry.rb +20 -4
- data/lib/rubygems/package/tar_reader.rb +2 -4
- data/lib/rubygems/package/tar_test_case.rb +2 -8
- data/lib/rubygems/package/tar_writer.rb +13 -15
- data/lib/rubygems/package.rb +90 -63
- 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 +2 -313
- data/lib/rubygems/remote_fetcher.rb +29 -82
- 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.rb +17 -16
- data/lib/rubygems/request_set/gem_dependency_api.rb +46 -49
- data/lib/rubygems/request_set/lockfile/parser.rb +18 -29
- data/lib/rubygems/request_set/lockfile/tokenizer.rb +9 -9
- data/lib/rubygems/request_set/lockfile.rb +12 -12
- data/lib/rubygems/request_set.rb +52 -25
- data/lib/rubygems/requirement.rb +32 -21
- 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/resolver.rb +14 -16
- data/lib/rubygems/s3_uri_signer.rb +183 -0
- data/lib/rubygems/safe_yaml.rb +18 -10
- 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/security.rb +21 -22
- data/lib/rubygems/security_option.rb +0 -1
- data/lib/rubygems/server.rb +21 -21
- 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.rb +16 -25
- 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 +219 -558
- data/lib/rubygems/specification_policy.rb +407 -0
- data/lib/rubygems/stub_specification.rb +12 -17
- data/lib/rubygems/test_case.rb +161 -75
- data/lib/rubygems/test_utilities.rb +20 -35
- data/lib/rubygems/text.rb +6 -6
- data/lib/rubygems/uninstaller.rb +38 -27
- data/lib/rubygems/uri_formatter.rb +1 -2
- data/lib/rubygems/user_interaction.rb +37 -89
- data/lib/rubygems/util/licenses.rb +27 -1
- data/lib/rubygems/util/list.rb +1 -1
- data/lib/rubygems/util.rb +32 -14
- data/lib/rubygems/validator.rb +4 -5
- data/lib/rubygems/version.rb +15 -15
- data/lib/rubygems/version_option.rb +2 -3
- data/lib/rubygems.rb +71 -102
- data/rubygems-update.gemspec +43 -0
- data/setup.rb +2 -8
- data/test/rubygems/ca_cert.pem +74 -65
- data/test/rubygems/client.pem +103 -45
- data/test/rubygems/rubygems_plugin.rb +0 -1
- data/test/rubygems/simple_gem.rb +1 -1
- data/test/rubygems/ssl_cert.pem +78 -17
- data/test/rubygems/ssl_key.pem +25 -13
- data/test/rubygems/test_bundled_ca.rb +1 -1
- data/test/rubygems/test_config.rb +7 -2
- data/test/rubygems/test_gem.rb +205 -132
- data/test/rubygems/test_gem_bundler_version_finder.rb +4 -0
- data/test/rubygems/test_gem_command.rb +0 -1
- data/test/rubygems/test_gem_command_manager.rb +18 -3
- data/test/rubygems/test_gem_commands_build_command.rb +220 -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 +54 -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 +50 -15
- 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 +161 -8
- 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 +16 -10
- data/test/rubygems/test_gem_install_update_options.rb +1 -20
- data/test/rubygems/test_gem_installer.rb +154 -119
- 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 +77 -31
- data/test/rubygems/test_gem_package_old.rb +0 -1
- data/test/rubygems/test_gem_package_tar_header.rb +42 -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 +43 -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 -136
- data/test/rubygems/test_gem_remote_fetcher.rb +241 -141
- data/test/rubygems/test_gem_request.rb +9 -9
- 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 +82 -64
- 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 +24 -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 +5 -6
- 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 +366 -198
- data/test/rubygems/test_gem_stream_ui.rb +15 -32
- data/test/rubygems/test_gem_stub_specification.rb +0 -2
- data/test/rubygems/test_gem_text.rb +4 -0
- data/test/rubygems/test_gem_uninstaller.rb +42 -3
- 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 +31 -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 +20 -12
- data/util/cops/deprecations.rb +52 -0
- data/util/create_certs.rb +6 -7
- data/util/create_certs.sh +27 -0
- data/util/create_encrypted_key.rb +4 -5
- data/util/patch_with_prs.rb +1 -1
- data/util/rubocop +8 -0
- data/util/update_bundled_ca_certificates.rb +12 -13
- data/util/update_changelog.rb +1 -1
- metadata +61 -51
- 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/test/rubygems/fix_openssl_warnings.rb +0 -13
@@ -6,8 +6,10 @@ require 'rubygems/command'
|
|
6
6
|
# RubyGems checkout or tarball.
|
7
7
|
|
8
8
|
class Gem::Commands::SetupCommand < Gem::Command
|
9
|
-
HISTORY_HEADER = /^===\s*[\d.]+\s*\/\s*\d{4}-\d{2}-\d{2}\s
|
10
|
-
VERSION_MATCHER = /^===\s*([\d.]+)\s*\/\s*\d{4}-\d{2}-\d{2}\s
|
9
|
+
HISTORY_HEADER = /^===\s*[\d.a-zA-Z]+\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/.freeze
|
10
|
+
VERSION_MATCHER = /^===\s*([\d.a-zA-Z]+)\s*\/\s*\d{4}-\d{2}-\d{2}\s*$/.freeze
|
11
|
+
|
12
|
+
ENV_PATHS = %w[/usr/bin/env /bin/env].freeze
|
11
13
|
|
12
14
|
def initialize
|
13
15
|
require 'tmpdir'
|
@@ -60,7 +62,7 @@ class Gem::Commands::SetupCommand < Gem::Command
|
|
60
62
|
|
61
63
|
add_option '--[no-]rdoc',
|
62
64
|
'Generate RDoc documentation for RubyGems' do |value, options|
|
63
|
-
if value
|
65
|
+
if value
|
64
66
|
options[:document] << 'rdoc'
|
65
67
|
else
|
66
68
|
options[:document].delete 'rdoc'
|
@@ -71,7 +73,7 @@ class Gem::Commands::SetupCommand < Gem::Command
|
|
71
73
|
|
72
74
|
add_option '--[no-]ri',
|
73
75
|
'Generate RI documentation for RubyGems' do |value, options|
|
74
|
-
if value
|
76
|
+
if value
|
75
77
|
options[:document] << 'ri'
|
76
78
|
else
|
77
79
|
options[:document].delete 'ri'
|
@@ -83,7 +85,13 @@ class Gem::Commands::SetupCommand < Gem::Command
|
|
83
85
|
add_option '--[no-]regenerate-binstubs',
|
84
86
|
'Regenerate gem binstubs' do |value, options|
|
85
87
|
options[:regenerate_binstubs] = value
|
86
|
-
|
88
|
+
end
|
89
|
+
|
90
|
+
add_option('-E', '--[no-]env-shebang',
|
91
|
+
'Rewrite executables with a shebang',
|
92
|
+
'of /usr/bin/env') do |value, options|
|
93
|
+
options[:env_shebang] = value
|
94
|
+
end
|
87
95
|
|
88
96
|
@verbose = nil
|
89
97
|
end
|
@@ -91,7 +99,7 @@ class Gem::Commands::SetupCommand < Gem::Command
|
|
91
99
|
def check_ruby_version
|
92
100
|
required_version = Gem::Requirement.new '>= 1.8.7'
|
93
101
|
|
94
|
-
unless required_version.satisfied_by? Gem.ruby_version
|
102
|
+
unless required_version.satisfied_by? Gem.ruby_version
|
95
103
|
alert_error "Expected Ruby version #{required_version}, is #{Gem.ruby_version}"
|
96
104
|
terminate_interaction 1
|
97
105
|
end
|
@@ -119,12 +127,19 @@ By default, this RubyGems will install gem as:
|
|
119
127
|
EOF
|
120
128
|
end
|
121
129
|
|
130
|
+
module MakeDirs
|
131
|
+
def mkdir_p(path, **opts)
|
132
|
+
super
|
133
|
+
(@mkdirs ||= []) << path
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
122
137
|
def execute
|
123
138
|
@verbose = Gem.configuration.really_verbose
|
124
139
|
|
125
140
|
install_destdir = options[:destdir]
|
126
141
|
|
127
|
-
unless install_destdir.empty?
|
142
|
+
unless install_destdir.empty?
|
128
143
|
ENV['GEM_HOME'] ||= File.join(install_destdir,
|
129
144
|
Gem.default_dir.gsub(/^[a-zA-Z]:/, ''))
|
130
145
|
end
|
@@ -132,11 +147,12 @@ By default, this RubyGems will install gem as:
|
|
132
147
|
check_ruby_version
|
133
148
|
|
134
149
|
require 'fileutils'
|
135
|
-
if Gem.configuration.really_verbose
|
150
|
+
if Gem.configuration.really_verbose
|
136
151
|
extend FileUtils::Verbose
|
137
152
|
else
|
138
153
|
extend FileUtils
|
139
154
|
end
|
155
|
+
extend MakeDirs
|
140
156
|
|
141
157
|
lib_dir, bin_dir = make_destination_dirs install_destdir
|
142
158
|
|
@@ -148,7 +164,12 @@ By default, this RubyGems will install gem as:
|
|
148
164
|
|
149
165
|
remove_old_lib_files lib_dir
|
150
166
|
|
151
|
-
install_default_bundler_gem
|
167
|
+
install_default_bundler_gem bin_dir
|
168
|
+
|
169
|
+
if mode = options[:dir_mode]
|
170
|
+
@mkdirs.uniq!
|
171
|
+
File.chmod(mode, @mkdirs)
|
172
|
+
end
|
152
173
|
|
153
174
|
say "RubyGems #{Gem::VERSION} installed"
|
154
175
|
|
@@ -159,7 +180,7 @@ By default, this RubyGems will install gem as:
|
|
159
180
|
documentation_success = install_rdoc
|
160
181
|
|
161
182
|
say
|
162
|
-
if @verbose
|
183
|
+
if @verbose
|
163
184
|
say "-" * 78
|
164
185
|
say
|
165
186
|
end
|
@@ -180,14 +201,14 @@ By default, this RubyGems will install gem as:
|
|
180
201
|
say @bin_file_names.map { |name| "\t#{name}\n" }
|
181
202
|
say
|
182
203
|
|
183
|
-
unless @bin_file_names.grep(/#{File::SEPARATOR}gem$/)
|
204
|
+
unless @bin_file_names.grep(/#{File::SEPARATOR}gem$/)
|
184
205
|
say "If `gem` was installed by a previous RubyGems installation, you may need"
|
185
206
|
say "to remove it by hand."
|
186
207
|
say
|
187
208
|
end
|
188
209
|
|
189
210
|
if documentation_success
|
190
|
-
if options[:document].include? 'rdoc'
|
211
|
+
if options[:document].include? 'rdoc'
|
191
212
|
say "Rdoc documentation was installed. You may now invoke:"
|
192
213
|
say " gem server"
|
193
214
|
say "and then peruse beautifully formatted documentation for your gems"
|
@@ -198,7 +219,7 @@ By default, this RubyGems will install gem as:
|
|
198
219
|
say
|
199
220
|
end
|
200
221
|
|
201
|
-
if options[:document].include? 'ri'
|
222
|
+
if options[:document].include? 'ri'
|
202
223
|
say "Ruby Interactive (ri) documentation was installed. ri is kind of like man "
|
203
224
|
say "pages for Ruby libraries. You may access it like this:"
|
204
225
|
say " ri Classname"
|
@@ -216,18 +237,19 @@ By default, this RubyGems will install gem as:
|
|
216
237
|
def install_executables(bin_dir)
|
217
238
|
@bin_file_names = []
|
218
239
|
|
240
|
+
prog_mode = options[:prog_mode] || 0755
|
241
|
+
|
219
242
|
executables = { 'gem' => 'bin' }
|
220
|
-
executables['bundler'] = 'bundler/exe' if Gem::USE_BUNDLER_FOR_GEMDEPS
|
221
243
|
executables.each do |tool, path|
|
222
244
|
say "Installing #{tool} executable" if @verbose
|
223
245
|
|
224
246
|
Dir.chdir path do
|
225
247
|
bin_files = Dir['*']
|
226
248
|
|
227
|
-
bin_files -= %w[update_rubygems
|
249
|
+
bin_files -= %w[update_rubygems]
|
228
250
|
|
229
251
|
bin_files.each do |bin_file|
|
230
|
-
bin_file_formatted = if options[:format_executable]
|
252
|
+
bin_file_formatted = if options[:format_executable]
|
231
253
|
Gem.default_exec_format % bin_file
|
232
254
|
else
|
233
255
|
bin_file
|
@@ -238,13 +260,13 @@ By default, this RubyGems will install gem as:
|
|
238
260
|
|
239
261
|
begin
|
240
262
|
bin = File.readlines bin_file
|
241
|
-
bin[0] =
|
263
|
+
bin[0] = shebang
|
242
264
|
|
243
265
|
File.open bin_tmp_file, 'w' do |fp|
|
244
266
|
fp.puts bin.join
|
245
267
|
end
|
246
268
|
|
247
|
-
install bin_tmp_file, dest_file, :mode =>
|
269
|
+
install bin_tmp_file, dest_file, :mode => prog_mode
|
248
270
|
@bin_file_names << dest_file
|
249
271
|
ensure
|
250
272
|
rm bin_tmp_file
|
@@ -266,7 +288,7 @@ By default, this RubyGems will install gem as:
|
|
266
288
|
TEXT
|
267
289
|
end
|
268
290
|
|
269
|
-
install bin_cmd_file, "#{dest_file}.bat", :mode =>
|
291
|
+
install bin_cmd_file, "#{dest_file}.bat", :mode => prog_mode
|
270
292
|
ensure
|
271
293
|
rm bin_cmd_file
|
272
294
|
end
|
@@ -275,12 +297,24 @@ By default, this RubyGems will install gem as:
|
|
275
297
|
end
|
276
298
|
end
|
277
299
|
|
278
|
-
def
|
300
|
+
def shebang
|
301
|
+
if options[:env_shebang]
|
302
|
+
ruby_name = RbConfig::CONFIG['ruby_install_name']
|
303
|
+
@env_path ||= ENV_PATHS.find {|env_path| File.executable? env_path }
|
304
|
+
"#!#{@env_path} #{ruby_name}\n"
|
305
|
+
else
|
306
|
+
"#!#{Gem.ruby}\n"
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
def install_file(file, dest_dir)
|
279
311
|
dest_file = File.join dest_dir, file
|
280
312
|
dest_dir = File.dirname dest_file
|
281
|
-
|
313
|
+
unless File.directory? dest_dir
|
314
|
+
mkdir_p dest_dir, :mode => 0755
|
315
|
+
end
|
282
316
|
|
283
|
-
install file, dest_file, :mode => 0644
|
317
|
+
install file, dest_file, :mode => options[:data_mode] || 0644
|
284
318
|
end
|
285
319
|
|
286
320
|
def install_lib(lib_dir)
|
@@ -319,7 +353,7 @@ By default, this RubyGems will install gem as:
|
|
319
353
|
|
320
354
|
if File.writable? gem_doc_dir and
|
321
355
|
(not File.exist? rubygems_doc_dir or
|
322
|
-
File.writable? rubygems_doc_dir)
|
356
|
+
File.writable? rubygems_doc_dir)
|
323
357
|
say "Removing old RubyGems RDoc and ri" if @verbose
|
324
358
|
Dir[File.join(Gem.dir, 'doc', 'rubygems-[0-9]*')].each do |dir|
|
325
359
|
rm_rf dir
|
@@ -339,7 +373,7 @@ By default, this RubyGems will install gem as:
|
|
339
373
|
rdoc.generate
|
340
374
|
|
341
375
|
return true
|
342
|
-
elsif @verbose
|
376
|
+
elsif @verbose
|
343
377
|
say "Skipping RDoc generation, #{gem_doc_dir} not writable"
|
344
378
|
say "Set the GEM_HOME environment variable if you want RDoc generated"
|
345
379
|
end
|
@@ -347,12 +381,12 @@ By default, this RubyGems will install gem as:
|
|
347
381
|
return false
|
348
382
|
end
|
349
383
|
|
350
|
-
def install_default_bundler_gem
|
384
|
+
def install_default_bundler_gem(bin_dir)
|
351
385
|
return unless Gem::USE_BUNDLER_FOR_GEMDEPS
|
352
386
|
|
353
387
|
specs_dir = Gem::Specification.default_specifications_dir
|
354
388
|
specs_dir = File.join(options[:destdir], specs_dir) unless Gem.win_platform?
|
355
|
-
mkdir_p specs_dir
|
389
|
+
mkdir_p specs_dir, :mode => 0755
|
356
390
|
|
357
391
|
# Workaround for non-git environment.
|
358
392
|
gemspec = File.open('bundler/bundler.gemspec', 'rb'){|f| f.read.gsub(/`git ls-files -z`/, "''") }
|
@@ -387,18 +421,17 @@ By default, this RubyGems will install gem as:
|
|
387
421
|
|
388
422
|
bundler_bin_dir = bundler_spec.bin_dir
|
389
423
|
bundler_bin_dir = File.join(options[:destdir], bundler_bin_dir) unless Gem.win_platform?
|
390
|
-
mkdir_p bundler_bin_dir
|
424
|
+
mkdir_p bundler_bin_dir, :mode => 0755
|
391
425
|
bundler_spec.executables.each do |e|
|
392
426
|
cp File.join("bundler", bundler_spec.bindir, e), File.join(bundler_bin_dir, e)
|
393
427
|
end
|
394
428
|
|
395
|
-
|
396
|
-
require 'rubygems/installer'
|
429
|
+
require 'rubygems/installer'
|
397
430
|
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
431
|
+
Dir.chdir("bundler") do
|
432
|
+
built_gem = Gem::Package.build(bundler_spec)
|
433
|
+
installer = Gem::Installer.at(built_gem, env_shebang: options[:env_shebang], install_as_default: true, bin_dir: bin_dir, wrappers: true)
|
434
|
+
installer.install
|
402
435
|
end
|
403
436
|
|
404
437
|
say "Bundler #{bundler_spec.version} installed"
|
@@ -411,8 +444,8 @@ By default, this RubyGems will install gem as:
|
|
411
444
|
lib_dir, bin_dir = generate_default_dirs(install_destdir)
|
412
445
|
end
|
413
446
|
|
414
|
-
mkdir_p lib_dir
|
415
|
-
mkdir_p bin_dir
|
447
|
+
mkdir_p lib_dir, :mode => 0755
|
448
|
+
mkdir_p bin_dir, :mode => 0755
|
416
449
|
|
417
450
|
return lib_dir, bin_dir
|
418
451
|
end
|
@@ -421,7 +454,7 @@ By default, this RubyGems will install gem as:
|
|
421
454
|
prefix = options[:prefix]
|
422
455
|
site_or_vendor = options[:site_or_vendor]
|
423
456
|
|
424
|
-
if prefix.empty?
|
457
|
+
if prefix.empty?
|
425
458
|
lib_dir = RbConfig::CONFIG[site_or_vendor]
|
426
459
|
bin_dir = RbConfig::CONFIG['bindir']
|
427
460
|
else
|
@@ -432,16 +465,16 @@ By default, this RubyGems will install gem as:
|
|
432
465
|
# just in case Apple and RubyGems don't get this patched up proper.
|
433
466
|
(prefix == RbConfig::CONFIG['libdir'] or
|
434
467
|
# this one is important
|
435
|
-
prefix == File.join(RbConfig::CONFIG['libdir'], 'ruby'))
|
436
|
-
|
437
|
-
|
468
|
+
prefix == File.join(RbConfig::CONFIG['libdir'], 'ruby'))
|
469
|
+
lib_dir = RbConfig::CONFIG[site_or_vendor]
|
470
|
+
bin_dir = RbConfig::CONFIG['bindir']
|
438
471
|
else
|
439
472
|
lib_dir = File.join prefix, 'lib'
|
440
473
|
bin_dir = File.join prefix, 'bin'
|
441
474
|
end
|
442
475
|
end
|
443
476
|
|
444
|
-
unless install_destdir.empty?
|
477
|
+
unless install_destdir.empty?
|
445
478
|
lib_dir = File.join install_destdir, lib_dir.gsub(/^[a-zA-Z]:/, '')
|
446
479
|
bin_dir = File.join install_destdir, bin_dir.gsub(/^[a-zA-Z]:/, '')
|
447
480
|
end
|
@@ -449,13 +482,13 @@ By default, this RubyGems will install gem as:
|
|
449
482
|
[lib_dir, bin_dir]
|
450
483
|
end
|
451
484
|
|
452
|
-
def pem_files_in
|
485
|
+
def pem_files_in(dir)
|
453
486
|
Dir.chdir dir do
|
454
487
|
Dir[File.join('**', '*pem')]
|
455
488
|
end
|
456
489
|
end
|
457
490
|
|
458
|
-
def rb_files_in
|
491
|
+
def rb_files_in(dir)
|
459
492
|
Dir.chdir dir do
|
460
493
|
Dir[File.join('**', '*rb')]
|
461
494
|
end
|
@@ -470,7 +503,7 @@ By default, this RubyGems will install gem as:
|
|
470
503
|
end
|
471
504
|
|
472
505
|
# for cleanup old bundler files
|
473
|
-
def template_files_in
|
506
|
+
def template_files_in(dir)
|
474
507
|
Dir.chdir dir do
|
475
508
|
(Dir[File.join('templates', '**', '{*,.*}')]).
|
476
509
|
select{|f| !File.directory?(f)}
|
@@ -509,7 +542,7 @@ abort "#{deprecation_message}"
|
|
509
542
|
end
|
510
543
|
end
|
511
544
|
|
512
|
-
def remove_old_lib_files
|
545
|
+
def remove_old_lib_files(lib_dir)
|
513
546
|
lib_dirs = { File.join(lib_dir, 'rubygems') => 'lib/rubygems' }
|
514
547
|
lib_dirs[File.join(lib_dir, 'bundler')] = 'bundler/lib/bundler' if Gem::USE_BUNDLER_FOR_GEMDEPS
|
515
548
|
lib_dirs.each do |old_lib_dir, new_lib_dir|
|
@@ -540,11 +573,10 @@ abort "#{deprecation_message}"
|
|
540
573
|
release_notes = File.join Dir.pwd, 'History.txt'
|
541
574
|
|
542
575
|
release_notes =
|
543
|
-
if File.exist? release_notes
|
576
|
+
if File.exist? release_notes
|
544
577
|
history = File.read release_notes
|
545
578
|
|
546
|
-
history.force_encoding Encoding::UTF_8
|
547
|
-
Object.const_defined? :Encoding
|
579
|
+
history.force_encoding Encoding::UTF_8
|
548
580
|
|
549
581
|
history = history.sub(/^# coding:.*?(?=^=)/m, '')
|
550
582
|
|
@@ -582,8 +614,14 @@ abort "#{deprecation_message}"
|
|
582
614
|
def regenerate_binstubs
|
583
615
|
require "rubygems/commands/pristine_command"
|
584
616
|
say "Regenerating binstubs"
|
617
|
+
|
618
|
+
args = %w[--all --only-executables --silent]
|
619
|
+
if options[:env_shebang]
|
620
|
+
args << "--env-shebang"
|
621
|
+
end
|
622
|
+
|
585
623
|
command = Gem::Commands::PristineCommand.new
|
586
|
-
command.invoke(
|
624
|
+
command.invoke(*args)
|
587
625
|
end
|
588
626
|
|
589
627
|
end
|
@@ -10,9 +10,10 @@ class Gem::Commands::SigninCommand < Gem::Command
|
|
10
10
|
'It defaults to https://rubygems.org'
|
11
11
|
|
12
12
|
add_option('--host HOST', 'Push to another gemcutter-compatible host') do |value, options|
|
13
|
-
|
13
|
+
options[:host] = value
|
14
14
|
end
|
15
15
|
|
16
|
+
add_otp_option
|
16
17
|
end
|
17
18
|
|
18
19
|
def description # :nodoc:
|
@@ -19,9 +19,9 @@ class Gem::Commands::SignoutCommand < Gem::Command
|
|
19
19
|
def execute
|
20
20
|
credentials_path = Gem.configuration.credentials_path
|
21
21
|
|
22
|
-
if !File.exist?(credentials_path)
|
22
|
+
if !File.exist?(credentials_path)
|
23
23
|
alert_error 'You are not currently signed in.'
|
24
|
-
elsif !File.writable?(credentials_path)
|
24
|
+
elsif !File.writable?(credentials_path)
|
25
25
|
alert_error "File '#{Gem.configuration.credentials_path}' is read-only."\
|
26
26
|
' Please make sure it is writable.'
|
27
27
|
else
|
@@ -38,13 +38,13 @@ class Gem::Commands::SourcesCommand < Gem::Command
|
|
38
38
|
add_proxy_option
|
39
39
|
end
|
40
40
|
|
41
|
-
def add_source
|
41
|
+
def add_source(source_uri) # :nodoc:
|
42
42
|
check_rubygems_https source_uri
|
43
43
|
|
44
44
|
source = Gem::Source.new source_uri
|
45
45
|
|
46
46
|
begin
|
47
|
-
if Gem.sources.include? source
|
47
|
+
if Gem.sources.include? source
|
48
48
|
say "source #{source_uri} already present in the cache"
|
49
49
|
else
|
50
50
|
source.load_specs :released
|
@@ -62,11 +62,11 @@ class Gem::Commands::SourcesCommand < Gem::Command
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
def check_rubygems_https
|
65
|
+
def check_rubygems_https(source_uri) # :nodoc:
|
66
66
|
uri = URI source_uri
|
67
67
|
|
68
68
|
if uri.scheme and uri.scheme.downcase == 'http' and
|
69
|
-
uri.host.downcase == 'rubygems.org'
|
69
|
+
uri.host.downcase == 'rubygems.org'
|
70
70
|
question = <<-QUESTION.chomp
|
71
71
|
https://rubygems.org is recommended for security over #{uri}
|
72
72
|
|
@@ -81,10 +81,10 @@ Do you want to add this insecure source?
|
|
81
81
|
path = Gem.spec_cache_dir
|
82
82
|
FileUtils.rm_rf path
|
83
83
|
|
84
|
-
unless File.exist? path
|
84
|
+
unless File.exist? path
|
85
85
|
say "*** Removed specs cache ***"
|
86
86
|
else
|
87
|
-
unless File.writable? path
|
87
|
+
unless File.writable? path
|
88
88
|
say "*** Unable to remove source cache (write protected) ***"
|
89
89
|
else
|
90
90
|
say "*** Unable to remove source cache ***"
|
@@ -175,8 +175,8 @@ To remove a source use the --remove argument:
|
|
175
175
|
list if list?
|
176
176
|
end
|
177
177
|
|
178
|
-
def remove_source
|
179
|
-
unless Gem.sources.include? source_uri
|
178
|
+
def remove_source(source_uri) # :nodoc:
|
179
|
+
unless Gem.sources.include? source_uri
|
180
180
|
say "source #{source_uri} not present in cache"
|
181
181
|
else
|
182
182
|
Gem.sources.delete source_uri
|
@@ -195,12 +195,12 @@ To remove a source use the --remove argument:
|
|
195
195
|
say "source cache successfully updated"
|
196
196
|
end
|
197
197
|
|
198
|
-
def remove_cache_file
|
198
|
+
def remove_cache_file(desc, path) # :nodoc:
|
199
199
|
FileUtils.rm_rf path
|
200
200
|
|
201
|
-
if not File.exist?(path)
|
201
|
+
if not File.exist?(path)
|
202
202
|
say "*** Removed #{desc} source cache ***"
|
203
|
-
elsif not File.writable?(path)
|
203
|
+
elsif not File.writable?(path)
|
204
204
|
say "*** Unable to remove #{desc} source cache (write protected) ***"
|
205
205
|
else
|
206
206
|
say "*** Unable to remove #{desc} source cache ***"
|
@@ -208,4 +208,3 @@ To remove a source use the --remove argument:
|
|
208
208
|
end
|
209
209
|
|
210
210
|
end
|
211
|
-
|
@@ -75,7 +75,7 @@ Specific fields in the specification can be extracted in YAML format:
|
|
75
75
|
specs = []
|
76
76
|
gem = options[:args].shift
|
77
77
|
|
78
|
-
unless gem
|
78
|
+
unless gem
|
79
79
|
raise Gem::CommandLineError,
|
80
80
|
"Please specify a gem name or file on the command line"
|
81
81
|
end
|
@@ -105,29 +105,29 @@ Specific fields in the specification can be extracted in YAML format:
|
|
105
105
|
raise Gem::CommandLineError, "--ruby and FIELD are mutually exclusive" if
|
106
106
|
field and options[:format] == :ruby
|
107
107
|
|
108
|
-
if local?
|
109
|
-
if File.exist? gem
|
108
|
+
if local?
|
109
|
+
if File.exist? gem
|
110
110
|
specs << Gem::Package.new(gem).spec rescue nil
|
111
111
|
end
|
112
112
|
|
113
|
-
if specs.empty?
|
113
|
+
if specs.empty?
|
114
114
|
specs.push(*dep.matching_specs)
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
-
if remote?
|
118
|
+
if remote?
|
119
119
|
dep.prerelease = options[:prerelease]
|
120
120
|
found, _ = Gem::SpecFetcher.fetcher.spec_for_dependency dep
|
121
121
|
|
122
122
|
specs.push(*found.map { |spec,| spec })
|
123
123
|
end
|
124
124
|
|
125
|
-
if specs.empty?
|
125
|
+
if specs.empty?
|
126
126
|
alert_error "No gem matching '#{dep}' found"
|
127
127
|
terminate_interaction 1
|
128
128
|
end
|
129
129
|
|
130
|
-
unless options[:all]
|
130
|
+
unless options[:all]
|
131
131
|
specs = [specs.max_by { |s| s.version }]
|
132
132
|
end
|
133
133
|
|
@@ -20,7 +20,7 @@ class Gem::Commands::UninstallCommand < Gem::Command
|
|
20
20
|
|
21
21
|
add_option('-a', '--[no-]all',
|
22
22
|
'Uninstall all matching versions'
|
23
|
-
|
23
|
+
) do |value, options|
|
24
24
|
options[:all] = value
|
25
25
|
end
|
26
26
|
|
@@ -81,7 +81,7 @@ class Gem::Commands::UninstallCommand < Gem::Command
|
|
81
81
|
add_option('--vendor',
|
82
82
|
'Uninstall gem from the vendor directory.',
|
83
83
|
'Only for use by gem repackagers.') do |value, options|
|
84
|
-
unless Gem.vendor_dir
|
84
|
+
unless Gem.vendor_dir
|
85
85
|
raise OptionParser::InvalidOption.new 'your platform is not supported'
|
86
86
|
end
|
87
87
|
|
@@ -114,10 +114,21 @@ that is a dependency of an existing gem. You can use the
|
|
114
114
|
"#{program_name} GEMNAME [GEMNAME ...]"
|
115
115
|
end
|
116
116
|
|
117
|
+
def check_version # :nodoc:
|
118
|
+
if options[:version] != Gem::Requirement.default and
|
119
|
+
get_all_gem_names.size > 1
|
120
|
+
alert_error "Can't use --version with multiple gems. You can specify multiple gems with" \
|
121
|
+
" version requirements using `gem uninstall 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`"
|
122
|
+
terminate_interaction 1
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
117
126
|
def execute
|
118
|
-
|
127
|
+
check_version
|
128
|
+
|
129
|
+
if options[:all] and not options[:args].empty?
|
119
130
|
uninstall_specific
|
120
|
-
elsif options[:all]
|
131
|
+
elsif options[:all]
|
121
132
|
uninstall_all
|
122
133
|
else
|
123
134
|
uninstall_specific
|
@@ -129,11 +140,7 @@ that is a dependency of an existing gem. You can use the
|
|
129
140
|
|
130
141
|
specs.each do |spec|
|
131
142
|
options[:version] = spec.version
|
132
|
-
|
133
|
-
begin
|
134
|
-
Gem::Uninstaller.new(spec.name, options).uninstall
|
135
|
-
rescue Gem::InstallError
|
136
|
-
end
|
143
|
+
uninstall_gem spec.name
|
137
144
|
end
|
138
145
|
|
139
146
|
alert "Uninstalled all gems in #{options[:install_dir]}"
|
@@ -141,9 +148,13 @@ that is a dependency of an existing gem. You can use the
|
|
141
148
|
|
142
149
|
def uninstall_specific
|
143
150
|
deplist = Gem::DependencyList.new
|
151
|
+
original_gem_version = {}
|
152
|
+
|
153
|
+
get_all_gem_names_and_versions.each do |name, version|
|
154
|
+
original_gem_version[name] = version || options[:version]
|
155
|
+
|
156
|
+
gem_specs = Gem::Specification.find_all_by_name(name, original_gem_version[name])
|
144
157
|
|
145
|
-
get_all_gem_names.uniq.each do |name|
|
146
|
-
gem_specs = Gem::Specification.find_all_by_name(name)
|
147
158
|
say("Gem '#{name}' is not installed") if gem_specs.empty?
|
148
159
|
gem_specs.each do |spec|
|
149
160
|
deplist.add spec
|
@@ -152,15 +163,36 @@ that is a dependency of an existing gem. You can use the
|
|
152
163
|
|
153
164
|
deps = deplist.strongly_connected_components.flatten.reverse
|
154
165
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
166
|
+
gems_to_uninstall = {}
|
167
|
+
|
168
|
+
deps.each do |dep|
|
169
|
+
unless gems_to_uninstall[dep.name]
|
170
|
+
gems_to_uninstall[dep.name] = true
|
171
|
+
|
172
|
+
unless original_gem_version[dep.name] == Gem::Requirement.default
|
173
|
+
options[:version] = dep.version
|
174
|
+
end
|
175
|
+
|
176
|
+
uninstall_gem(dep.name)
|
162
177
|
end
|
163
178
|
end
|
164
179
|
end
|
165
180
|
|
181
|
+
def uninstall_gem(gem_name)
|
182
|
+
uninstall(gem_name)
|
183
|
+
rescue Gem::GemNotInHomeException => e
|
184
|
+
spec = e.spec
|
185
|
+
alert("In order to remove #{spec.name}, please execute:\n" +
|
186
|
+
"\tgem uninstall #{spec.name} --install-dir=#{spec.installation_path}")
|
187
|
+
rescue Gem::UninstallError => e
|
188
|
+
spec = e.spec
|
189
|
+
alert_error("Error: unable to successfully uninstall '#{spec.name}' which is " +
|
190
|
+
"located at '#{spec.full_gem_path}'. This is most likely because" +
|
191
|
+
"the current user does not have the appropriate permissions")
|
192
|
+
terminate_interaction 1
|
193
|
+
end
|
194
|
+
|
195
|
+
def uninstall(gem_name)
|
196
|
+
Gem::Uninstaller.new(gem_name, options).uninstall
|
197
|
+
end
|
166
198
|
end
|
@@ -79,22 +79,32 @@ command help for an example.
|
|
79
79
|
dependency = Gem::Dependency.new name, options[:version]
|
80
80
|
path = get_path dependency
|
81
81
|
|
82
|
-
unless path
|
82
|
+
unless path
|
83
83
|
alert_error "Gem '#{name}' not installed nor fetchable."
|
84
84
|
next
|
85
85
|
end
|
86
86
|
|
87
|
-
if @options[:spec]
|
87
|
+
if @options[:spec]
|
88
88
|
spec, metadata = get_metadata path, security_policy
|
89
89
|
|
90
|
-
if metadata.nil?
|
90
|
+
if metadata.nil?
|
91
91
|
alert_error "--spec is unsupported on '#{name}' (old format gem)"
|
92
92
|
next
|
93
93
|
end
|
94
94
|
|
95
95
|
spec_file = File.basename spec.spec_file
|
96
96
|
|
97
|
-
|
97
|
+
FileUtils.mkdir_p @options[:target] if @options[:target]
|
98
|
+
|
99
|
+
destination = begin
|
100
|
+
if @options[:target]
|
101
|
+
File.join @options[:target], spec_file
|
102
|
+
else
|
103
|
+
spec_file
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
File.open destination, 'w' do |io|
|
98
108
|
io.write metadata
|
99
109
|
end
|
100
110
|
else
|
@@ -142,7 +152,7 @@ command help for an example.
|
|
142
152
|
# TODO: It just uses Gem.dir for now. What's an easy way to get the list of
|
143
153
|
# source directories?
|
144
154
|
|
145
|
-
def get_path
|
155
|
+
def get_path(dependency)
|
146
156
|
return dependency.name if dependency.name =~ /\.gem$/i
|
147
157
|
|
148
158
|
specs = dependency.matching_specs
|
@@ -170,7 +180,7 @@ command help for an example.
|
|
170
180
|
#--
|
171
181
|
# TODO move to Gem::Package as #raw_spec or something
|
172
182
|
|
173
|
-
def get_metadata
|
183
|
+
def get_metadata(path, security_policy = nil)
|
174
184
|
format = Gem::Package.new path, security_policy
|
175
185
|
spec = format.spec
|
176
186
|
|
@@ -192,4 +202,3 @@ command help for an example.
|
|
192
202
|
end
|
193
203
|
|
194
204
|
end
|
195
|
-
|