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
data/lib/rubygems/source.rb
CHANGED
@@ -16,7 +16,7 @@ class Gem::Source
|
|
16
16
|
:released => 'specs',
|
17
17
|
:latest => 'latest_specs',
|
18
18
|
:prerelease => 'prerelease_specs',
|
19
|
-
}
|
19
|
+
}.freeze
|
20
20
|
|
21
21
|
##
|
22
22
|
# The URI this source will fetch gems from.
|
@@ -36,15 +36,6 @@ class Gem::Source
|
|
36
36
|
end
|
37
37
|
|
38
38
|
@uri = uri
|
39
|
-
@api_uri = nil
|
40
|
-
end
|
41
|
-
|
42
|
-
##
|
43
|
-
# Use an SRV record on the host to look up the true endpoint for the index.
|
44
|
-
|
45
|
-
def api_uri # :nodoc:
|
46
|
-
require 'rubygems/remote_fetcher'
|
47
|
-
@api_uri ||= Gem::RemoteFetcher.fetcher.api_endpoint uri
|
48
39
|
end
|
49
40
|
|
50
41
|
##
|
@@ -77,7 +68,7 @@ class Gem::Source
|
|
77
68
|
end
|
78
69
|
end
|
79
70
|
|
80
|
-
def ==
|
71
|
+
def ==(other) # :nodoc:
|
81
72
|
self.class === other and @uri == other.uri
|
82
73
|
end
|
83
74
|
|
@@ -87,9 +78,9 @@ class Gem::Source
|
|
87
78
|
# Returns a Set that can fetch specifications from this source.
|
88
79
|
|
89
80
|
def dependency_resolver_set # :nodoc:
|
90
|
-
return Gem::Resolver::IndexSet.new self if 'file' ==
|
81
|
+
return Gem::Resolver::IndexSet.new self if 'file' == uri.scheme
|
91
82
|
|
92
|
-
bundler_api_uri =
|
83
|
+
bundler_api_uri = uri + './api/v1/dependencies'
|
93
84
|
|
94
85
|
begin
|
95
86
|
fetcher = Gem::RemoteFetcher.fetcher
|
@@ -97,7 +88,7 @@ class Gem::Source
|
|
97
88
|
rescue Gem::RemoteFetcher::FetchError
|
98
89
|
Gem::Resolver::IndexSet.new self
|
99
90
|
else
|
100
|
-
if response.respond_to? :uri
|
91
|
+
if response.respond_to? :uri
|
101
92
|
Gem::Resolver::APISet.new response.uri
|
102
93
|
else
|
103
94
|
Gem::Resolver::APISet.new bundler_api_uri
|
@@ -135,29 +126,29 @@ class Gem::Source
|
|
135
126
|
##
|
136
127
|
# Fetches a specification for the given +name_tuple+.
|
137
128
|
|
138
|
-
def fetch_spec
|
129
|
+
def fetch_spec(name_tuple)
|
139
130
|
fetcher = Gem::RemoteFetcher.fetcher
|
140
131
|
|
141
132
|
spec_file_name = name_tuple.spec_name
|
142
133
|
|
143
|
-
|
134
|
+
source_uri = uri + "#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}"
|
144
135
|
|
145
|
-
cache_dir = cache_dir
|
136
|
+
cache_dir = cache_dir source_uri
|
146
137
|
|
147
138
|
local_spec = File.join cache_dir, spec_file_name
|
148
139
|
|
149
|
-
if File.exist? local_spec
|
140
|
+
if File.exist? local_spec
|
150
141
|
spec = Gem.read_binary local_spec
|
151
142
|
spec = Marshal.load(spec) rescue nil
|
152
143
|
return spec if spec
|
153
144
|
end
|
154
145
|
|
155
|
-
|
146
|
+
source_uri.path << '.rz'
|
156
147
|
|
157
|
-
spec = fetcher.fetch_path
|
148
|
+
spec = fetcher.fetch_path source_uri
|
158
149
|
spec = Gem::Util.inflate spec
|
159
150
|
|
160
|
-
if update_cache?
|
151
|
+
if update_cache?
|
161
152
|
FileUtils.mkdir_p cache_dir
|
162
153
|
|
163
154
|
File.open local_spec, 'wb' do |io|
|
@@ -184,7 +175,7 @@ class Gem::Source
|
|
184
175
|
file = FILES[type]
|
185
176
|
fetcher = Gem::RemoteFetcher.fetcher
|
186
177
|
file_name = "#{file}.#{Gem.marshal_version}"
|
187
|
-
spec_path =
|
178
|
+
spec_path = uri + "#{file_name}.gz"
|
188
179
|
cache_dir = cache_dir spec_path
|
189
180
|
local_file = File.join(cache_dir, file_name)
|
190
181
|
retried = false
|
@@ -212,15 +203,15 @@ class Gem::Source
|
|
212
203
|
|
213
204
|
def download(spec, dir=Dir.pwd)
|
214
205
|
fetcher = Gem::RemoteFetcher.fetcher
|
215
|
-
fetcher.download spec,
|
206
|
+
fetcher.download spec, uri.to_s, dir
|
216
207
|
end
|
217
208
|
|
218
|
-
def pretty_print
|
209
|
+
def pretty_print(q) # :nodoc:
|
219
210
|
q.group 2, '[Remote:', ']' do
|
220
211
|
q.breakable
|
221
212
|
q.text @uri.to_s
|
222
213
|
|
223
|
-
if api =
|
214
|
+
if api = uri
|
224
215
|
q.breakable
|
225
216
|
q.text 'API URI: '
|
226
217
|
q.text api.to_s
|
data/lib/rubygems/source/git.rb
CHANGED
@@ -50,7 +50,7 @@ class Gem::Source::Git < Gem::Source
|
|
50
50
|
# repository may contain multiple gems. If +submodules+ is true, submodules
|
51
51
|
# will be checked out when the gem is installed.
|
52
52
|
|
53
|
-
def initialize
|
53
|
+
def initialize(name, repository, reference, submodules = false)
|
54
54
|
super repository
|
55
55
|
|
56
56
|
@name = name
|
@@ -63,7 +63,7 @@ class Gem::Source::Git < Gem::Source
|
|
63
63
|
@git = ENV['git'] || 'git'
|
64
64
|
end
|
65
65
|
|
66
|
-
def <=>
|
66
|
+
def <=>(other)
|
67
67
|
case other
|
68
68
|
when Gem::Source::Git then
|
69
69
|
0
|
@@ -77,7 +77,7 @@ class Gem::Source::Git < Gem::Source
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
def ==
|
80
|
+
def ==(other) # :nodoc:
|
81
81
|
super and
|
82
82
|
@name == other.name and
|
83
83
|
@repository == other.repository and
|
@@ -93,7 +93,7 @@ class Gem::Source::Git < Gem::Source
|
|
93
93
|
|
94
94
|
return false unless File.exist? repo_cache_dir
|
95
95
|
|
96
|
-
unless File.exist? install_dir
|
96
|
+
unless File.exist? install_dir
|
97
97
|
system @git, 'clone', '--quiet', '--no-checkout',
|
98
98
|
repo_cache_dir, install_dir
|
99
99
|
end
|
@@ -117,7 +117,7 @@ class Gem::Source::Git < Gem::Source
|
|
117
117
|
def cache # :nodoc:
|
118
118
|
return unless @remote
|
119
119
|
|
120
|
-
if File.exist? repo_cache_dir
|
120
|
+
if File.exist? repo_cache_dir
|
121
121
|
Dir.chdir repo_cache_dir do
|
122
122
|
system @git, 'fetch', '--quiet', '--force', '--tags',
|
123
123
|
@repository, 'refs/heads/*:refs/heads/*'
|
@@ -145,7 +145,7 @@ class Gem::Source::Git < Gem::Source
|
|
145
145
|
##
|
146
146
|
# Nothing to download for git gems
|
147
147
|
|
148
|
-
def download
|
148
|
+
def download(full_spec, path) # :nodoc:
|
149
149
|
end
|
150
150
|
|
151
151
|
##
|
@@ -157,7 +157,7 @@ class Gem::Source::Git < Gem::Source
|
|
157
157
|
File.join base_dir, 'gems', "#{@name}-#{dir_shortref}"
|
158
158
|
end
|
159
159
|
|
160
|
-
def pretty_print
|
160
|
+
def pretty_print(q) # :nodoc:
|
161
161
|
q.group 2, '[Git: ', ']' do
|
162
162
|
q.breakable
|
163
163
|
q.text @repository
|
@@ -206,7 +206,7 @@ class Gem::Source::Git < Gem::Source
|
|
206
206
|
|
207
207
|
Dir.chdir directory do
|
208
208
|
spec = Gem::Specification.load file
|
209
|
-
if spec
|
209
|
+
if spec
|
210
210
|
spec.base_dir = base_dir
|
211
211
|
|
212
212
|
spec.extension_dir =
|
@@ -228,7 +228,7 @@ class Gem::Source::Git < Gem::Source
|
|
228
228
|
require 'digest' # required here to avoid deadlocking in Gem.activate_bin_path (because digest is a gem on 2.5+)
|
229
229
|
|
230
230
|
normalized =
|
231
|
-
if @repository =~ %r%^\w+://(\w+@)?%
|
231
|
+
if @repository =~ %r%^\w+://(\w+@)?%
|
232
232
|
uri = URI(@repository).normalize.to_s.sub %r%/$%,''
|
233
233
|
uri.sub(/\A(\w+)/) { $1.downcase }
|
234
234
|
else
|
@@ -239,4 +239,3 @@ class Gem::Source::Git < Gem::Source
|
|
239
239
|
end
|
240
240
|
|
241
241
|
end
|
242
|
-
|
@@ -11,7 +11,7 @@ class Gem::Source::Installed < Gem::Source
|
|
11
11
|
##
|
12
12
|
# Installed sources sort before all other sources
|
13
13
|
|
14
|
-
def <=>
|
14
|
+
def <=>(other)
|
15
15
|
case other
|
16
16
|
when Gem::Source::Git,
|
17
17
|
Gem::Source::Lock,
|
@@ -29,13 +29,12 @@ class Gem::Source::Installed < Gem::Source
|
|
29
29
|
##
|
30
30
|
# We don't need to download an installed gem
|
31
31
|
|
32
|
-
def download
|
32
|
+
def download(spec, path)
|
33
33
|
nil
|
34
34
|
end
|
35
35
|
|
36
|
-
def pretty_print
|
36
|
+
def pretty_print(q) # :nodoc:
|
37
37
|
q.text '[Installed]'
|
38
38
|
end
|
39
39
|
|
40
40
|
end
|
41
|
-
|
@@ -15,7 +15,7 @@ class Gem::Source::Local < Gem::Source
|
|
15
15
|
##
|
16
16
|
# Local sorts before Gem::Source and after Gem::Source::Installed
|
17
17
|
|
18
|
-
def <=>
|
18
|
+
def <=>(other)
|
19
19
|
case other
|
20
20
|
when Gem::Source::Installed,
|
21
21
|
Gem::Source::Lock then
|
@@ -34,7 +34,7 @@ class Gem::Source::Local < Gem::Source
|
|
34
34
|
"#<%s specs: %p>" % [self.class, keys]
|
35
35
|
end
|
36
36
|
|
37
|
-
def load_specs
|
37
|
+
def load_specs(type) # :nodoc:
|
38
38
|
@load_specs_names[type] ||= begin
|
39
39
|
names = []
|
40
40
|
|
@@ -78,8 +78,8 @@ class Gem::Source::Local < Gem::Source
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
def find_gem
|
82
|
-
prerelease = false
|
81
|
+
def find_gem(gem_name, version = Gem::Requirement.default, # :nodoc:
|
82
|
+
prerelease = false)
|
83
83
|
load_specs :complete
|
84
84
|
|
85
85
|
found = []
|
@@ -101,7 +101,7 @@ class Gem::Source::Local < Gem::Source
|
|
101
101
|
found.max_by { |s| s.version }
|
102
102
|
end
|
103
103
|
|
104
|
-
def fetch_spec
|
104
|
+
def fetch_spec(name) # :nodoc:
|
105
105
|
load_specs :complete
|
106
106
|
|
107
107
|
if data = @specs[name]
|
@@ -111,7 +111,7 @@ class Gem::Source::Local < Gem::Source
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
-
def download
|
114
|
+
def download(spec, cache_dir = nil) # :nodoc:
|
115
115
|
load_specs :complete
|
116
116
|
|
117
117
|
@specs.each do |name, data|
|
@@ -121,7 +121,7 @@ class Gem::Source::Local < Gem::Source
|
|
121
121
|
raise Gem::Exception, "Unable to find file for '#{spec.full_name}'"
|
122
122
|
end
|
123
123
|
|
124
|
-
def pretty_print
|
124
|
+
def pretty_print(q) # :nodoc:
|
125
125
|
q.group 2, '[Local gems:', ']' do
|
126
126
|
q.breakable
|
127
127
|
q.seplist @specs.keys do |v|
|
data/lib/rubygems/source/lock.rb
CHANGED
@@ -15,11 +15,11 @@ class Gem::Source::Lock < Gem::Source
|
|
15
15
|
# Creates a new Lock source that wraps +source+ and moves it earlier in the
|
16
16
|
# sort list.
|
17
17
|
|
18
|
-
def initialize
|
18
|
+
def initialize(source)
|
19
19
|
@wrapped = source
|
20
20
|
end
|
21
21
|
|
22
|
-
def <=>
|
22
|
+
def <=>(other) # :nodoc:
|
23
23
|
case other
|
24
24
|
when Gem::Source::Lock then
|
25
25
|
@wrapped <=> other.wrapped
|
@@ -30,7 +30,7 @@ class Gem::Source::Lock < Gem::Source
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
def ==
|
33
|
+
def ==(other) # :nodoc:
|
34
34
|
0 == (self <=> other)
|
35
35
|
end
|
36
36
|
|
@@ -41,7 +41,7 @@ class Gem::Source::Lock < Gem::Source
|
|
41
41
|
##
|
42
42
|
# Delegates to the wrapped source's fetch_spec method.
|
43
43
|
|
44
|
-
def fetch_spec
|
44
|
+
def fetch_spec(name_tuple)
|
45
45
|
@wrapped.fetch_spec name_tuple
|
46
46
|
end
|
47
47
|
|
@@ -27,22 +27,22 @@ class Gem::Source::SpecificFile < Gem::Source
|
|
27
27
|
|
28
28
|
attr_reader :spec
|
29
29
|
|
30
|
-
def load_specs
|
30
|
+
def load_specs(*a) # :nodoc:
|
31
31
|
[@name]
|
32
32
|
end
|
33
33
|
|
34
|
-
def fetch_spec
|
34
|
+
def fetch_spec(name) # :nodoc:
|
35
35
|
return @spec if name == @name
|
36
36
|
raise Gem::Exception, "Unable to find '#{name}'"
|
37
37
|
@spec
|
38
38
|
end
|
39
39
|
|
40
|
-
def download
|
40
|
+
def download(spec, dir = nil) # :nodoc:
|
41
41
|
return @path if spec == @spec
|
42
42
|
raise Gem::Exception, "Unable to download '#{spec.full_name}'"
|
43
43
|
end
|
44
44
|
|
45
|
-
def pretty_print
|
45
|
+
def pretty_print(q) # :nodoc:
|
46
46
|
q.group 2, '[SpecificFile:', ']' do
|
47
47
|
q.breakable
|
48
48
|
q.text @path
|
@@ -59,7 +59,7 @@ class Gem::Source::SpecificFile < Gem::Source
|
|
59
59
|
#
|
60
60
|
# Otherwise Gem::Source#<=> is used.
|
61
61
|
|
62
|
-
def <=>
|
62
|
+
def <=>(other)
|
63
63
|
case other
|
64
64
|
when Gem::Source::SpecificFile then
|
65
65
|
return nil if @spec.name != other.spec.name
|
@@ -7,11 +7,11 @@ class Gem::Source::Vendor < Gem::Source::Installed
|
|
7
7
|
##
|
8
8
|
# Creates a new Vendor source for a gem that was unpacked at +path+.
|
9
9
|
|
10
|
-
def initialize
|
10
|
+
def initialize(path)
|
11
11
|
@uri = path
|
12
12
|
end
|
13
13
|
|
14
|
-
def <=>
|
14
|
+
def <=>(other)
|
15
15
|
case other
|
16
16
|
when Gem::Source::Lock then
|
17
17
|
-1
|
@@ -25,4 +25,3 @@ class Gem::Source::Vendor < Gem::Source::Installed
|
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
28
|
-
|
data/lib/rubygems/source_list.rb
CHANGED
@@ -105,7 +105,7 @@ class Gem::SourceList
|
|
105
105
|
@sources.empty?
|
106
106
|
end
|
107
107
|
|
108
|
-
def ==
|
108
|
+
def ==(other) # :nodoc:
|
109
109
|
to_a == other
|
110
110
|
end
|
111
111
|
|
@@ -140,7 +140,7 @@ class Gem::SourceList
|
|
140
140
|
##
|
141
141
|
# Deletes +source+ from the source list which may be a Gem::Source or a URI.
|
142
142
|
|
143
|
-
def delete
|
143
|
+
def delete(source)
|
144
144
|
if source.kind_of? Gem::Source
|
145
145
|
@sources.delete source
|
146
146
|
else
|
@@ -54,7 +54,7 @@ class Gem::SpecFetcher
|
|
54
54
|
# If you need to retrieve specifications from a different +source+, you can
|
55
55
|
# send it as an argument.
|
56
56
|
|
57
|
-
def initialize
|
57
|
+
def initialize(sources = nil)
|
58
58
|
@sources = sources || Gem.sources
|
59
59
|
|
60
60
|
@update_cache =
|
@@ -202,10 +202,10 @@ class Gem::SpecFetcher
|
|
202
202
|
}.compact
|
203
203
|
|
204
204
|
matches = if matches.empty? && type != :prerelease
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
205
|
+
suggest_gems_from_name gem_name, :prerelease
|
206
|
+
else
|
207
|
+
matches.uniq.sort_by { |name, dist| dist }
|
208
|
+
end
|
209
209
|
|
210
210
|
matches.first(5).map { |name, dist| name }
|
211
211
|
end
|
@@ -271,4 +271,3 @@ class Gem::SpecFetcher
|
|
271
271
|
end
|
272
272
|
|
273
273
|
end
|
274
|
-
|
@@ -1,5 +1,5 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
# frozen_string_literal: true
|
2
|
+
# -*- coding: utf-8 -*-
|
3
3
|
#--
|
4
4
|
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
5
5
|
# All rights reserved.
|
@@ -13,9 +13,9 @@ require 'rubygems/platform'
|
|
13
13
|
require 'rubygems/deprecate'
|
14
14
|
require 'rubygems/basic_specification'
|
15
15
|
require 'rubygems/stub_specification'
|
16
|
+
require 'rubygems/specification_policy'
|
16
17
|
require 'rubygems/util/list'
|
17
18
|
require 'stringio'
|
18
|
-
require 'uri'
|
19
19
|
|
20
20
|
##
|
21
21
|
# The Specification class contains the information for a Gem. Typically
|
@@ -89,13 +89,13 @@ class Gem::Specification < Gem::BasicSpecification
|
|
89
89
|
'Added "required_rubygems_version"',
|
90
90
|
'Now forward-compatible with future versions',
|
91
91
|
],
|
92
|
-
3
|
93
|
-
|
92
|
+
3 => [
|
93
|
+
'Added Fixnum validation to the specification_version'
|
94
94
|
],
|
95
|
-
4
|
95
|
+
4 => [
|
96
96
|
'Added sandboxed freeform metadata to the specification version.'
|
97
97
|
]
|
98
|
-
}
|
98
|
+
}.freeze
|
99
99
|
|
100
100
|
MARSHAL_FIELDS = { # :nodoc:
|
101
101
|
-1 => 16,
|
@@ -103,16 +103,18 @@ class Gem::Specification < Gem::BasicSpecification
|
|
103
103
|
2 => 16,
|
104
104
|
3 => 17,
|
105
105
|
4 => 18,
|
106
|
-
}
|
106
|
+
}.freeze
|
107
107
|
|
108
108
|
today = Time.now.utc
|
109
109
|
TODAY = Time.utc(today.year, today.month, today.day) # :nodoc:
|
110
110
|
|
111
|
+
# rubocop:disable Style/MutableConstant
|
111
112
|
LOAD_CACHE = {} # :nodoc:
|
113
|
+
# rubocop:enable Style/MutableConstant
|
112
114
|
|
113
115
|
private_constant :LOAD_CACHE if defined? private_constant
|
114
116
|
|
115
|
-
VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z
|
117
|
+
VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z/.freeze # :nodoc:
|
116
118
|
|
117
119
|
# :startdoc:
|
118
120
|
|
@@ -135,7 +137,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
135
137
|
:autorequire => nil,
|
136
138
|
:bindir => 'bin',
|
137
139
|
:cert_chain => [],
|
138
|
-
:date =>
|
140
|
+
:date => nil,
|
139
141
|
:dependencies => [],
|
140
142
|
:description => nil,
|
141
143
|
:email => nil,
|
@@ -154,7 +156,6 @@ class Gem::Specification < Gem::BasicSpecification
|
|
154
156
|
:required_ruby_version => Gem::Requirement.default,
|
155
157
|
:required_rubygems_version => Gem::Requirement.default,
|
156
158
|
:requirements => [],
|
157
|
-
:rubyforge_project => nil,
|
158
159
|
:rubygems_version => Gem::VERSION,
|
159
160
|
:signing_key => nil,
|
160
161
|
:specification_version => CURRENT_SPECIFICATION_VERSION,
|
@@ -163,19 +164,21 @@ class Gem::Specification < Gem::BasicSpecification
|
|
163
164
|
:version => nil,
|
164
165
|
}.freeze
|
165
166
|
|
167
|
+
# rubocop:disable Style/MutableConstant
|
166
168
|
INITIALIZE_CODE_FOR_DEFAULTS = { } # :nodoc:
|
169
|
+
# rubocop:enable Style/MutableConstant
|
167
170
|
|
168
171
|
@@default_value.each do |k,v|
|
169
172
|
INITIALIZE_CODE_FOR_DEFAULTS[k] = case v
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
173
|
+
when [], {}, true, false, nil, Numeric, Symbol
|
174
|
+
v.inspect
|
175
|
+
when String
|
176
|
+
v.dump
|
177
|
+
when Numeric
|
178
|
+
"default_value(:#{k})"
|
179
|
+
else
|
180
|
+
"default_value(:#{k}).dup"
|
181
|
+
end
|
179
182
|
end
|
180
183
|
|
181
184
|
@@attributes = @@default_value.keys.sort_by { |s| s.to_s }
|
@@ -260,31 +263,23 @@ class Gem::Specification < Gem::BasicSpecification
|
|
260
263
|
].flatten.compact.uniq.sort
|
261
264
|
end
|
262
265
|
|
263
|
-
######################################################################
|
264
|
-
# :section: Recommended gemspec attributes
|
265
|
-
|
266
266
|
##
|
267
|
-
#
|
267
|
+
# A list of authors for this gem.
|
268
268
|
#
|
269
|
-
#
|
270
|
-
#
|
271
|
-
# spec.author = 'John Jones'
|
272
|
-
|
273
|
-
def author= o
|
274
|
-
self.authors = [o]
|
275
|
-
end
|
276
|
-
|
277
|
-
##
|
278
|
-
# Sets the list of authors, ensuring it is an array.
|
269
|
+
# Alternatively, a single author can be specified by assigning a string to
|
270
|
+
# `spec.author`
|
279
271
|
#
|
280
272
|
# Usage:
|
281
273
|
#
|
282
274
|
# spec.authors = ['John Jones', 'Mary Smith']
|
283
275
|
|
284
|
-
def authors=
|
276
|
+
def authors=(value)
|
285
277
|
@authors = Array(value).flatten.grep(String)
|
286
278
|
end
|
287
279
|
|
280
|
+
######################################################################
|
281
|
+
# :section: Recommended gemspec attributes
|
282
|
+
|
288
283
|
##
|
289
284
|
# A long description of this gem
|
290
285
|
#
|
@@ -346,7 +341,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
346
341
|
# Usage:
|
347
342
|
# spec.license = 'MIT'
|
348
343
|
|
349
|
-
def license=o
|
344
|
+
def license=(o)
|
350
345
|
self.licenses = [o]
|
351
346
|
end
|
352
347
|
|
@@ -363,7 +358,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
363
358
|
# Usage:
|
364
359
|
# spec.licenses = ['MIT', 'GPL-2.0']
|
365
360
|
|
366
|
-
def licenses=
|
361
|
+
def licenses=(licenses)
|
367
362
|
@licenses = Array licenses
|
368
363
|
end
|
369
364
|
|
@@ -403,6 +398,17 @@ class Gem::Specification < Gem::BasicSpecification
|
|
403
398
|
######################################################################
|
404
399
|
# :section: Optional gemspec attributes
|
405
400
|
|
401
|
+
##
|
402
|
+
# Singular (alternative) writer for #authors
|
403
|
+
#
|
404
|
+
# Usage:
|
405
|
+
#
|
406
|
+
# spec.author = 'John Jones'
|
407
|
+
|
408
|
+
def author=(o)
|
409
|
+
self.authors = [o]
|
410
|
+
end
|
411
|
+
|
406
412
|
##
|
407
413
|
# The path in the gem for executable scripts. Usually 'bin'
|
408
414
|
#
|
@@ -450,9 +456,9 @@ class Gem::Specification < Gem::BasicSpecification
|
|
450
456
|
#
|
451
457
|
# spec.platform = Gem::Platform.local
|
452
458
|
|
453
|
-
def platform=
|
459
|
+
def platform=(platform)
|
454
460
|
if @original_platform.nil? or
|
455
|
-
@original_platform == Gem::Platform::RUBY
|
461
|
+
@original_platform == Gem::Platform::RUBY
|
456
462
|
@original_platform = platform
|
457
463
|
end
|
458
464
|
|
@@ -618,7 +624,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
618
624
|
# Sets the version of RubyGems that installed this gem. See also
|
619
625
|
# #installed_by_version.
|
620
626
|
|
621
|
-
def installed_by_version=
|
627
|
+
def installed_by_version=(version) # :nodoc:
|
622
628
|
@installed_by_version = Gem::Version.new version
|
623
629
|
end
|
624
630
|
|
@@ -643,9 +649,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
643
649
|
# ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
|
644
650
|
# #<Gem::Version "2.0.0.247">
|
645
651
|
#
|
646
|
-
#
|
647
|
-
# `<=`: `<= 2.2.2` will not match any patch-level of 2.2.2 after the `p0`
|
648
|
-
# release. It is much safer to specify `< 2.2.3` instead
|
652
|
+
# Prereleases can also be specified.
|
649
653
|
#
|
650
654
|
# Usage:
|
651
655
|
#
|
@@ -655,17 +659,17 @@ class Gem::Specification < Gem::BasicSpecification
|
|
655
659
|
# # Only with ruby 2.0.x
|
656
660
|
# spec.required_ruby_version = '~> 2.0'
|
657
661
|
#
|
658
|
-
# # Only
|
659
|
-
# spec.required_ruby_version =
|
662
|
+
# # Only prereleases or final releases after 2.6.0.preview2
|
663
|
+
# spec.required_ruby_version = '> 2.6.0.preview2'
|
660
664
|
|
661
|
-
def required_ruby_version=
|
665
|
+
def required_ruby_version=(req)
|
662
666
|
@required_ruby_version = Gem::Requirement.create req
|
663
667
|
end
|
664
668
|
|
665
669
|
##
|
666
670
|
# The RubyGems version required by this gem
|
667
671
|
|
668
|
-
def required_rubygems_version=
|
672
|
+
def required_rubygems_version=(req)
|
669
673
|
@required_rubygems_version = Gem::Requirement.create req
|
670
674
|
end
|
671
675
|
|
@@ -690,7 +694,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
690
694
|
# spec.test_files = Dir.glob('test/tc_*.rb')
|
691
695
|
# spec.test_files = ['tests/test-suite.rb']
|
692
696
|
|
693
|
-
def test_files=
|
697
|
+
def test_files=(files) # :nodoc:
|
694
698
|
@test_files = Array files
|
695
699
|
end
|
696
700
|
|
@@ -725,12 +729,11 @@ class Gem::Specification < Gem::BasicSpecification
|
|
725
729
|
attr_writer :original_platform # :nodoc:
|
726
730
|
|
727
731
|
##
|
728
|
-
#
|
729
|
-
# rubyforge_project is "rubygems".
|
732
|
+
# Deprecated and ignored.
|
730
733
|
#
|
731
|
-
#
|
734
|
+
# Formerly used to set rubyforge project.
|
732
735
|
|
733
|
-
|
736
|
+
attr_writer :rubyforge_project
|
734
737
|
|
735
738
|
##
|
736
739
|
# The Gem::Specification version of this gemspec.
|
@@ -740,7 +743,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
740
743
|
attr_accessor :specification_version
|
741
744
|
|
742
745
|
def self._all # :nodoc:
|
743
|
-
unless defined?(@@all) && @@all
|
746
|
+
unless defined?(@@all) && @@all
|
744
747
|
@@all = stubs.map(&:to_spec)
|
745
748
|
if @@all.any?(&:nil?) # TODO: remove once we're happy
|
746
749
|
raise "pid: #{$$} nil spec! included in #{stubs.inspect}"
|
@@ -761,18 +764,18 @@ class Gem::Specification < Gem::BasicSpecification
|
|
761
764
|
|
762
765
|
def self.each_gemspec(dirs) # :nodoc:
|
763
766
|
dirs.each do |dir|
|
764
|
-
|
767
|
+
Gem::Util.glob_files_in_dir("*.gemspec", dir).each do |path|
|
765
768
|
yield path.untaint
|
766
769
|
end
|
767
770
|
end
|
768
771
|
end
|
769
772
|
|
770
|
-
def self.gemspec_stubs_in
|
771
|
-
|
773
|
+
def self.gemspec_stubs_in(dir, pattern)
|
774
|
+
Gem::Util.glob_files_in_dir(pattern, dir).map { |path| yield path }.select(&:valid?)
|
772
775
|
end
|
773
776
|
private_class_method :gemspec_stubs_in
|
774
777
|
|
775
|
-
def self.default_stubs
|
778
|
+
def self.default_stubs(pattern)
|
776
779
|
base_dir = Gem.default_dir
|
777
780
|
gems_dir = File.join base_dir, "gems"
|
778
781
|
gemspec_stubs_in(default_specifications_dir, pattern) do |path|
|
@@ -781,59 +784,29 @@ class Gem::Specification < Gem::BasicSpecification
|
|
781
784
|
end
|
782
785
|
private_class_method :default_stubs
|
783
786
|
|
784
|
-
def self.installed_stubs
|
787
|
+
def self.installed_stubs(dirs, pattern)
|
785
788
|
map_stubs(dirs, pattern) do |path, base_dir, gems_dir|
|
786
789
|
Gem::StubSpecification.gemspec_stub(path, base_dir, gems_dir)
|
787
790
|
end
|
788
791
|
end
|
789
792
|
private_class_method :installed_stubs
|
790
793
|
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
}
|
798
|
-
end
|
799
|
-
else # FIXME: remove when 1.8 is dropped
|
800
|
-
def self.map_stubs(dirs, pattern) # :nodoc:
|
801
|
-
dirs.map { |dir|
|
802
|
-
base_dir = File.dirname dir
|
803
|
-
gems_dir = File.join base_dir, "gems"
|
804
|
-
gemspec_stubs_in(dir, pattern) { |path| yield path, base_dir, gems_dir }
|
805
|
-
}.flatten 1
|
806
|
-
end
|
794
|
+
def self.map_stubs(dirs, pattern) # :nodoc:
|
795
|
+
dirs.flat_map { |dir|
|
796
|
+
base_dir = File.dirname dir
|
797
|
+
gems_dir = File.join base_dir, "gems"
|
798
|
+
gemspec_stubs_in(dir, pattern) { |path| yield path, base_dir, gems_dir }
|
799
|
+
}
|
807
800
|
end
|
808
801
|
private_class_method :map_stubs
|
809
802
|
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
if uniq_takes_a_block
|
814
|
-
def self.uniq_by(list, &block) # :nodoc:
|
815
|
-
list.uniq(&block)
|
816
|
-
end
|
817
|
-
else # FIXME: remove when 1.8 is dropped
|
818
|
-
def self.uniq_by(list) # :nodoc:
|
819
|
-
values = {}
|
820
|
-
list.each { |item|
|
821
|
-
value = yield item
|
822
|
-
values[value] ||= item
|
823
|
-
}
|
824
|
-
values.values
|
825
|
-
end
|
803
|
+
def self.uniq_by(list, &block) # :nodoc:
|
804
|
+
list.uniq(&block)
|
826
805
|
end
|
827
806
|
private_class_method :uniq_by
|
828
807
|
|
829
|
-
|
830
|
-
|
831
|
-
list.sort_by!(&block)
|
832
|
-
end
|
833
|
-
else # FIXME: remove when 1.8 is dropped
|
834
|
-
def self.sort_by! list, &block
|
835
|
-
list.replace list.sort_by(&block)
|
836
|
-
end
|
808
|
+
def self.sort_by!(list, &block)
|
809
|
+
list.sort_by!(&block)
|
837
810
|
end
|
838
811
|
private_class_method :sort_by!
|
839
812
|
|
@@ -850,11 +823,11 @@ class Gem::Specification < Gem::BasicSpecification
|
|
850
823
|
def self.stubs
|
851
824
|
@@stubs ||= begin
|
852
825
|
pattern = "*.gemspec"
|
853
|
-
stubs = default_stubs(pattern)
|
826
|
+
stubs = Gem.loaded_specs.values + default_stubs(pattern) + installed_stubs(dirs, pattern)
|
854
827
|
stubs = uniq_by(stubs) { |stub| stub.full_name }
|
855
828
|
|
856
829
|
_resort!(stubs)
|
857
|
-
@@stubs_by_name = stubs.group_by(&:name)
|
830
|
+
@@stubs_by_name = stubs.select { |s| Gem::Platform.match s.platform }.group_by(&:name)
|
858
831
|
stubs
|
859
832
|
end
|
860
833
|
end
|
@@ -863,13 +836,15 @@ class Gem::Specification < Gem::BasicSpecification
|
|
863
836
|
|
864
837
|
##
|
865
838
|
# Returns a Gem::StubSpecification for installed gem named +name+
|
839
|
+
# only returns stubs that match Gem.platforms
|
866
840
|
|
867
|
-
def self.stubs_for
|
841
|
+
def self.stubs_for(name)
|
868
842
|
if @@stubs
|
869
843
|
@@stubs_by_name[name] || []
|
870
844
|
else
|
871
845
|
pattern = "#{name}-*.gemspec"
|
872
|
-
stubs = default_stubs(pattern) +
|
846
|
+
stubs = Gem.loaded_specs.values + default_stubs(pattern) +
|
847
|
+
installed_stubs(dirs, pattern).select { |s| Gem::Platform.match s.platform }
|
873
848
|
stubs = uniq_by(stubs) { |stub| stub.full_name }.group_by(&:name)
|
874
849
|
stubs.each_value { |v| _resort!(v) }
|
875
850
|
|
@@ -901,7 +876,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
901
876
|
# Adds +spec+ to the known specifications, keeping the collection
|
902
877
|
# properly sorted.
|
903
878
|
|
904
|
-
def self.add_spec
|
879
|
+
def self.add_spec(spec)
|
905
880
|
warn "Gem::Specification.add_spec is deprecated and will be removed in RubyGems 3.0" unless Gem::Deprecate.skip
|
906
881
|
# TODO: find all extraneous adds
|
907
882
|
# puts
|
@@ -926,7 +901,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
926
901
|
##
|
927
902
|
# Adds multiple specs to the known specifications.
|
928
903
|
|
929
|
-
def self.add_specs
|
904
|
+
def self.add_specs(*specs)
|
930
905
|
warn "Gem::Specification.add_specs is deprecated and will be removed in RubyGems 3.0" unless Gem::Deprecate.skip
|
931
906
|
|
932
907
|
raise "nil spec!" if specs.any?(&:nil?) # TODO: remove once we're happy
|
@@ -964,7 +939,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
964
939
|
#
|
965
940
|
# -- wilsonb
|
966
941
|
|
967
|
-
def self.all=
|
942
|
+
def self.all=(specs)
|
968
943
|
raise "nil spec!" if specs.any?(&:nil?) # TODO: remove once we're happy
|
969
944
|
@@stubs_by_name = specs.group_by(&:name)
|
970
945
|
@@all = @@stubs = specs
|
@@ -1008,7 +983,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1008
983
|
# Set the directories that Specification uses to find specs. Setting
|
1009
984
|
# this resets the list of known specs.
|
1010
985
|
|
1011
|
-
def self.dirs=
|
986
|
+
def self.dirs=(dirs)
|
1012
987
|
self.reset
|
1013
988
|
|
1014
989
|
@@dirs = Array(dirs).map { |dir| File.join dir, "specifications" }
|
@@ -1031,7 +1006,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1031
1006
|
##
|
1032
1007
|
# Returns every spec that matches +name+ and optional +requirements+.
|
1033
1008
|
|
1034
|
-
def self.find_all_by_name
|
1009
|
+
def self.find_all_by_name(name, *requirements)
|
1035
1010
|
requirements = Gem::Requirement.default if requirements.empty?
|
1036
1011
|
|
1037
1012
|
# TODO: maybe try: find_all { |s| spec === dep }
|
@@ -1050,7 +1025,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1050
1025
|
# Find the best specification matching a +name+ and +requirements+. Raises
|
1051
1026
|
# if the dependency doesn't resolve to a valid specification.
|
1052
1027
|
|
1053
|
-
def self.find_by_name
|
1028
|
+
def self.find_by_name(name, *requirements)
|
1054
1029
|
requirements = Gem::Requirement.default if requirements.empty?
|
1055
1030
|
|
1056
1031
|
# TODO: maybe try: find { |s| spec === dep }
|
@@ -1061,7 +1036,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1061
1036
|
##
|
1062
1037
|
# Return the best specification that contains the file matching +path+.
|
1063
1038
|
|
1064
|
-
def self.find_by_path
|
1039
|
+
def self.find_by_path(path)
|
1065
1040
|
path = path.dup.freeze
|
1066
1041
|
spec = @@spec_with_requirable_file[path] ||= (stubs.find { |s|
|
1067
1042
|
next unless Gem::BundlerVersionFinder.compatible?(s)
|
@@ -1074,7 +1049,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1074
1049
|
# Return the best specification that contains the file matching +path+
|
1075
1050
|
# amongst the specs that are not activated.
|
1076
1051
|
|
1077
|
-
def self.find_inactive_by_path
|
1052
|
+
def self.find_inactive_by_path(path)
|
1078
1053
|
stub = stubs.find { |s|
|
1079
1054
|
next if s.activated?
|
1080
1055
|
next unless Gem::BundlerVersionFinder.compatible?(s)
|
@@ -1083,7 +1058,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1083
1058
|
stub && stub.to_spec
|
1084
1059
|
end
|
1085
1060
|
|
1086
|
-
def self.find_active_stub_by_path
|
1061
|
+
def self.find_active_stub_by_path(path)
|
1087
1062
|
stub = @@active_stub_with_requirable_file[path] ||= (stubs.find { |s|
|
1088
1063
|
s.activated? and s.contains_requirable_file? path
|
1089
1064
|
} || NOT_FOUND)
|
@@ -1093,7 +1068,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1093
1068
|
##
|
1094
1069
|
# Return currently unresolved specs that contain the file matching +path+.
|
1095
1070
|
|
1096
|
-
def self.find_in_unresolved
|
1071
|
+
def self.find_in_unresolved(path)
|
1097
1072
|
# TODO: do we need these?? Kill it
|
1098
1073
|
specs = unresolved_deps.values.map { |dep| dep.to_specs }.flatten
|
1099
1074
|
|
@@ -1104,7 +1079,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1104
1079
|
# Search through all unresolved deps and sub-dependencies and return
|
1105
1080
|
# specs that contain the file matching +path+.
|
1106
1081
|
|
1107
|
-
def self.find_in_unresolved_tree
|
1082
|
+
def self.find_in_unresolved_tree(path)
|
1108
1083
|
specs = unresolved_deps.values.map { |dep| dep.to_specs }.flatten
|
1109
1084
|
|
1110
1085
|
specs.each do |spec|
|
@@ -1134,11 +1109,11 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1134
1109
|
input = normalize_yaml_input input
|
1135
1110
|
spec = Gem::SafeYAML.safe_load input
|
1136
1111
|
|
1137
|
-
if spec && spec.class == FalseClass
|
1112
|
+
if spec && spec.class == FalseClass
|
1138
1113
|
raise Gem::EndOfYAMLException
|
1139
1114
|
end
|
1140
1115
|
|
1141
|
-
unless Gem::Specification === spec
|
1116
|
+
unless Gem::Specification === spec
|
1142
1117
|
raise Gem::Exception, "YAML data doesn't evaluate to gem specification"
|
1143
1118
|
end
|
1144
1119
|
|
@@ -1152,11 +1127,11 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1152
1127
|
# Return the latest specs, optionally including prerelease specs if
|
1153
1128
|
# +prerelease+ is true.
|
1154
1129
|
|
1155
|
-
def self.latest_specs
|
1130
|
+
def self.latest_specs(prerelease = false)
|
1156
1131
|
_latest_specs Gem::Specification._all, prerelease
|
1157
1132
|
end
|
1158
1133
|
|
1159
|
-
def self._latest_specs
|
1134
|
+
def self._latest_specs(specs, prerelease = false) # :nodoc:
|
1160
1135
|
result = Hash.new { |h,k| h[k] = {} }
|
1161
1136
|
native = {}
|
1162
1137
|
|
@@ -1176,7 +1151,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1176
1151
|
##
|
1177
1152
|
# Loads Ruby format gemspec from +file+.
|
1178
1153
|
|
1179
|
-
def self.load
|
1154
|
+
def self.load(file)
|
1180
1155
|
return unless file
|
1181
1156
|
|
1182
1157
|
_spec = LOAD_CACHE[file]
|
@@ -1185,11 +1160,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1185
1160
|
file = file.dup.untaint
|
1186
1161
|
return unless File.file?(file)
|
1187
1162
|
|
1188
|
-
code =
|
1189
|
-
File.read file, :mode => 'r:UTF-8:-'
|
1190
|
-
else
|
1191
|
-
File.read file
|
1192
|
-
end
|
1163
|
+
code = File.read file, :mode => 'r:UTF-8:-'
|
1193
1164
|
|
1194
1165
|
code.untaint
|
1195
1166
|
|
@@ -1276,7 +1247,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1276
1247
|
##
|
1277
1248
|
# Removes +spec+ from the known specs.
|
1278
1249
|
|
1279
|
-
def self.remove_spec
|
1250
|
+
def self.remove_spec(spec)
|
1280
1251
|
warn "Gem::Specification.remove_spec is deprecated and will be removed in RubyGems 3.0" unless Gem::Deprecate.skip
|
1281
1252
|
_all.delete spec
|
1282
1253
|
stubs.delete_if { |s| s.full_name == spec.full_name }
|
@@ -1312,13 +1283,19 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1312
1283
|
@@active_stub_with_requirable_file = {}
|
1313
1284
|
_clear_load_cache
|
1314
1285
|
unresolved = unresolved_deps
|
1315
|
-
unless unresolved.empty?
|
1286
|
+
unless unresolved.empty?
|
1316
1287
|
w = "W" + "ARN"
|
1317
|
-
warn "#{w}: Unresolved specs during Gem::Specification.reset:"
|
1288
|
+
warn "#{w}: Unresolved or ambigious specs during Gem::Specification.reset:"
|
1318
1289
|
unresolved.values.each do |dep|
|
1319
1290
|
warn " #{dep}"
|
1291
|
+
|
1292
|
+
versions = find_all_by_name(dep.name)
|
1293
|
+
unless versions.empty?
|
1294
|
+
warn " Available/installed versions of this gem:"
|
1295
|
+
versions.each { |s| warn " - #{s.version}" }
|
1296
|
+
end
|
1320
1297
|
end
|
1321
|
-
warn "#{w}: Clearing out unresolved specs."
|
1298
|
+
warn "#{w}: Clearing out unresolved specs. Try 'gem cleanup <gem>'"
|
1322
1299
|
warn "Please report a bug if this causes problems."
|
1323
1300
|
unresolved.clear
|
1324
1301
|
end
|
@@ -1341,7 +1318,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1341
1318
|
|
1342
1319
|
current_version = CURRENT_SPECIFICATION_VERSION
|
1343
1320
|
|
1344
|
-
field_count = if spec.specification_version > current_version
|
1321
|
+
field_count = if spec.specification_version > current_version
|
1345
1322
|
spec.instance_variable_set :@specification_version,
|
1346
1323
|
current_version
|
1347
1324
|
MARSHAL_FIELDS[current_version]
|
@@ -1349,7 +1326,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1349
1326
|
MARSHAL_FIELDS[spec.specification_version]
|
1350
1327
|
end
|
1351
1328
|
|
1352
|
-
if array.size < field_count
|
1329
|
+
if array.size < field_count
|
1353
1330
|
raise TypeError, "invalid Gem::Specification format #{array.inspect}"
|
1354
1331
|
end
|
1355
1332
|
|
@@ -1368,7 +1345,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1368
1345
|
spec.instance_variable_set :@required_rubygems_version, array[7]
|
1369
1346
|
spec.instance_variable_set :@original_platform, array[8]
|
1370
1347
|
spec.instance_variable_set :@dependencies, array[9]
|
1371
|
-
|
1348
|
+
# offset due to rubyforge_project removal
|
1372
1349
|
spec.instance_variable_set :@email, array[11]
|
1373
1350
|
spec.instance_variable_set :@authors, array[12]
|
1374
1351
|
spec.instance_variable_set :@description, array[13]
|
@@ -1388,7 +1365,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1388
1365
|
sort_obj <=> other.sort_obj
|
1389
1366
|
end
|
1390
1367
|
|
1391
|
-
def ==
|
1368
|
+
def ==(other) # :nodoc:
|
1392
1369
|
self.class === other &&
|
1393
1370
|
name == other.name &&
|
1394
1371
|
version == other.version &&
|
@@ -1413,7 +1390,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1413
1390
|
@required_rubygems_version,
|
1414
1391
|
@original_platform,
|
1415
1392
|
@dependencies,
|
1416
|
-
|
1393
|
+
'', # rubyforge_project
|
1417
1394
|
@email,
|
1418
1395
|
@authors,
|
1419
1396
|
@description,
|
@@ -1433,7 +1410,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1433
1410
|
|
1434
1411
|
def activate
|
1435
1412
|
other = Gem.loaded_specs[self.name]
|
1436
|
-
if other
|
1413
|
+
if other
|
1437
1414
|
check_version_conflict other
|
1438
1415
|
return false
|
1439
1416
|
end
|
@@ -1471,7 +1448,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1471
1448
|
|
1472
1449
|
specs = spec_dep.to_specs
|
1473
1450
|
|
1474
|
-
if specs.size == 1
|
1451
|
+
if specs.size == 1
|
1475
1452
|
specs.first.activate
|
1476
1453
|
else
|
1477
1454
|
name = spec_dep.name
|
@@ -1533,7 +1510,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1533
1510
|
def add_bindir(executables)
|
1534
1511
|
return nil if executables.nil?
|
1535
1512
|
|
1536
|
-
if @bindir
|
1513
|
+
if @bindir
|
1537
1514
|
Array(executables).map { |e| File.join(@bindir, e) }
|
1538
1515
|
else
|
1539
1516
|
executables
|
@@ -1548,7 +1525,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1548
1525
|
# <tt>:development</tt>.
|
1549
1526
|
|
1550
1527
|
def add_dependency_with_type(dependency, type, requirements)
|
1551
|
-
requirements = if requirements.empty?
|
1528
|
+
requirements = if requirements.empty?
|
1552
1529
|
Gem::Requirement.default
|
1553
1530
|
else
|
1554
1531
|
requirements.flatten
|
@@ -1577,7 +1554,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1577
1554
|
# gem directories must come after -I and ENV['RUBYLIB']
|
1578
1555
|
insert_index = Gem.load_path_insert_index
|
1579
1556
|
|
1580
|
-
if insert_index
|
1557
|
+
if insert_index
|
1581
1558
|
# gem directories must come after -I and ENV['RUBYLIB']
|
1582
1559
|
$LOAD_PATH.insert(insert_index, *paths)
|
1583
1560
|
else
|
@@ -1615,7 +1592,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1615
1592
|
##
|
1616
1593
|
# Returns the full path to an executable named +name+ in this gem.
|
1617
1594
|
|
1618
|
-
def bin_file
|
1595
|
+
def bin_file(name)
|
1619
1596
|
File.join bin_dir, name
|
1620
1597
|
end
|
1621
1598
|
|
@@ -1681,16 +1658,6 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1681
1658
|
File.join build_info_dir, "#{full_name}.info"
|
1682
1659
|
end
|
1683
1660
|
|
1684
|
-
##
|
1685
|
-
# Used to detect if the gem is bundled in older version of Ruby, but not
|
1686
|
-
# detectable as default gem (see BasicSpecification#default_gem?).
|
1687
|
-
|
1688
|
-
def bundled_gem_in_old_ruby?
|
1689
|
-
!default_gem? &&
|
1690
|
-
RUBY_VERSION < "2.0.0" &&
|
1691
|
-
summary == "This #{name} is bundled with Ruby"
|
1692
|
-
end
|
1693
|
-
|
1694
1661
|
##
|
1695
1662
|
# Returns the full path to the cache directory containing this
|
1696
1663
|
# spec's cached gem.
|
@@ -1738,7 +1705,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1738
1705
|
def has_conflicts?
|
1739
1706
|
return true unless Gem.env_requirement(name).satisfied_by?(version)
|
1740
1707
|
self.dependencies.any? { |dep|
|
1741
|
-
if dep.runtime?
|
1708
|
+
if dep.runtime?
|
1742
1709
|
spec = Gem.loaded_specs[dep.name]
|
1743
1710
|
spec and not spec.satisfies_requirement? dep
|
1744
1711
|
else
|
@@ -1747,13 +1714,16 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1747
1714
|
}
|
1748
1715
|
end
|
1749
1716
|
|
1750
|
-
|
1751
|
-
# The date this gem was created. Lazily defaults to the current UTC date.
|
1717
|
+
# The date this gem was created.
|
1752
1718
|
#
|
1753
|
-
#
|
1719
|
+
# If SOURCE_DATE_EPOCH is set as an environment variable, use that to support
|
1720
|
+
# reproducible builds; otherwise, default to the current UTC date.
|
1721
|
+
#
|
1722
|
+
# Details on SOURCE_DATE_EPOCH:
|
1723
|
+
# https://reproducible-builds.org/specs/source-date-epoch/
|
1754
1724
|
|
1755
1725
|
def date
|
1756
|
-
@date ||= TODAY
|
1726
|
+
@date ||= ENV["SOURCE_DATE_EPOCH"] ? Time.utc(*Time.at(ENV["SOURCE_DATE_EPOCH"].to_i).utc.to_a[3..5].reverse) : TODAY
|
1757
1727
|
end
|
1758
1728
|
|
1759
1729
|
DateLike = Object.new # :nodoc:
|
@@ -1765,26 +1735,26 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1765
1735
|
/\A
|
1766
1736
|
(\d{4})-(\d{2})-(\d{2})
|
1767
1737
|
(\s+ \d{2}:\d{2}:\d{2}\.\d+ \s* (Z | [-+]\d\d:\d\d) )?
|
1768
|
-
\Z/x
|
1738
|
+
\Z/x.freeze
|
1769
1739
|
|
1770
1740
|
##
|
1771
1741
|
# The date this gem was created
|
1772
1742
|
#
|
1773
1743
|
# DO NOT set this, it is set automatically when the gem is packaged.
|
1774
1744
|
|
1775
|
-
def date=
|
1745
|
+
def date=(date)
|
1776
1746
|
# We want to end up with a Time object with one-day resolution.
|
1777
1747
|
# This is the cleanest, most-readable, faster-than-using-Date
|
1778
1748
|
# way to do it.
|
1779
1749
|
@date = case date
|
1780
1750
|
when String then
|
1781
|
-
if DateTimeFormat =~ date
|
1751
|
+
if DateTimeFormat =~ date
|
1782
1752
|
Time.utc($1.to_i, $2.to_i, $3.to_i)
|
1783
1753
|
|
1784
1754
|
# Workaround for where the date format output from psych isn't
|
1785
1755
|
# parsed as a Time object by syck and thus comes through as a
|
1786
1756
|
# string.
|
1787
|
-
elsif /\A(\d{4})-(\d{2})-(\d{2}) \d{2}:\d{2}:\d{2}\.\d+?Z\z/ =~ date
|
1757
|
+
elsif /\A(\d{4})-(\d{2})-(\d{2}) \d{2}:\d{2}:\d{2}\.\d+?Z\z/ =~ date
|
1788
1758
|
Time.utc($1.to_i, $2.to_i, $3.to_i)
|
1789
1759
|
else
|
1790
1760
|
raise(Gem::InvalidSpecificationException,
|
@@ -1818,7 +1788,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1818
1788
|
##
|
1819
1789
|
# The default value for specification attribute +name+
|
1820
1790
|
|
1821
|
-
def default_value
|
1791
|
+
def default_value(name)
|
1822
1792
|
@@default_value[name]
|
1823
1793
|
end
|
1824
1794
|
|
@@ -1842,7 +1812,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1842
1812
|
out = []
|
1843
1813
|
Gem::Specification.each do |spec|
|
1844
1814
|
spec.dependencies.each do |dep|
|
1845
|
-
if self.satisfies_requirement?(dep)
|
1815
|
+
if self.satisfies_requirement?(dep)
|
1846
1816
|
sats = []
|
1847
1817
|
find_all_satisfiers(dep) do |sat|
|
1848
1818
|
sats << sat
|
@@ -1864,7 +1834,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1864
1834
|
##
|
1865
1835
|
# A detailed description of this gem. See also #summary
|
1866
1836
|
|
1867
|
-
def description=
|
1837
|
+
def description=(str)
|
1868
1838
|
@description = str.to_s
|
1869
1839
|
end
|
1870
1840
|
|
@@ -1883,17 +1853,17 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1883
1853
|
#
|
1884
1854
|
# spec.doc_dir 'ri' # => "/path/to/gem_repo/doc/a-1/ri"
|
1885
1855
|
|
1886
|
-
def doc_dir
|
1856
|
+
def doc_dir(type = nil)
|
1887
1857
|
@doc_dir ||= File.join base_dir, 'doc', full_name
|
1888
1858
|
|
1889
|
-
if type
|
1859
|
+
if type
|
1890
1860
|
File.join @doc_dir, type
|
1891
1861
|
else
|
1892
1862
|
@doc_dir
|
1893
1863
|
end
|
1894
1864
|
end
|
1895
1865
|
|
1896
|
-
def encode_with
|
1866
|
+
def encode_with(coder) # :nodoc:
|
1897
1867
|
mark_version
|
1898
1868
|
|
1899
1869
|
coder.add 'name', @name
|
@@ -1914,7 +1884,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1914
1884
|
end
|
1915
1885
|
end
|
1916
1886
|
|
1917
|
-
def eql?
|
1887
|
+
def eql?(other) # :nodoc:
|
1918
1888
|
self.class === other && same_attributes?(other)
|
1919
1889
|
end
|
1920
1890
|
|
@@ -1928,7 +1898,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1928
1898
|
##
|
1929
1899
|
# Singular accessor for #executables
|
1930
1900
|
|
1931
|
-
def executable=o
|
1901
|
+
def executable=(o)
|
1932
1902
|
self.executables = [o]
|
1933
1903
|
end
|
1934
1904
|
|
@@ -1936,7 +1906,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1936
1906
|
# Sets executables to +value+, ensuring it is an array. Don't
|
1937
1907
|
# use this, push onto the array instead.
|
1938
1908
|
|
1939
|
-
def executables=
|
1909
|
+
def executables=(value)
|
1940
1910
|
# TODO: warn about setting instead of pushing
|
1941
1911
|
@executables = Array(value)
|
1942
1912
|
end
|
@@ -1945,7 +1915,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1945
1915
|
# Sets extensions to +extensions+, ensuring it is an array. Don't
|
1946
1916
|
# use this, push onto the array instead.
|
1947
1917
|
|
1948
|
-
def extensions=
|
1918
|
+
def extensions=(extensions)
|
1949
1919
|
# TODO: warn about setting instead of pushing
|
1950
1920
|
@extensions = Array extensions
|
1951
1921
|
end
|
@@ -1954,7 +1924,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1954
1924
|
# Sets extra_rdoc_files to +files+, ensuring it is an array. Don't
|
1955
1925
|
# use this, push onto the array instead.
|
1956
1926
|
|
1957
|
-
def extra_rdoc_files=
|
1927
|
+
def extra_rdoc_files=(files)
|
1958
1928
|
# TODO: warn about setting instead of pushing
|
1959
1929
|
@extra_rdoc_files = Array files
|
1960
1930
|
end
|
@@ -1971,14 +1941,14 @@ class Gem::Specification < Gem::BasicSpecification
|
|
1971
1941
|
##
|
1972
1942
|
# Sets files to +files+, ensuring it is an array.
|
1973
1943
|
|
1974
|
-
def files=
|
1944
|
+
def files=(files)
|
1975
1945
|
@files = Array files
|
1976
1946
|
end
|
1977
1947
|
|
1978
1948
|
##
|
1979
1949
|
# Finds all gems that satisfy +dep+
|
1980
1950
|
|
1981
|
-
def find_all_satisfiers
|
1951
|
+
def find_all_satisfiers(dep)
|
1982
1952
|
Gem::Specification.each do |spec|
|
1983
1953
|
yield spec if spec.satisfies_requirement? dep
|
1984
1954
|
end
|
@@ -2029,7 +1999,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2029
1999
|
#
|
2030
2000
|
# Formerly used to indicate this gem was RDoc-capable.
|
2031
2001
|
|
2032
|
-
def has_rdoc=
|
2002
|
+
def has_rdoc=(ignored) # :nodoc:
|
2033
2003
|
@has_rdoc = true
|
2034
2004
|
end
|
2035
2005
|
deprecate :has_rdoc=, :none, 2018, 12
|
@@ -2052,7 +2022,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2052
2022
|
name.hash ^ version.hash
|
2053
2023
|
end
|
2054
2024
|
|
2055
|
-
def init_with
|
2025
|
+
def init_with(coder) # :nodoc:
|
2056
2026
|
@installed_by_version ||= nil
|
2057
2027
|
yaml_initialize coder.tag, coder.map
|
2058
2028
|
end
|
@@ -2076,7 +2046,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2076
2046
|
# and yields itself for further initialization. Optionally takes +name+ and
|
2077
2047
|
# +version+.
|
2078
2048
|
|
2079
|
-
def initialize
|
2049
|
+
def initialize(name = nil, version = nil)
|
2080
2050
|
super()
|
2081
2051
|
@gems_dir = nil
|
2082
2052
|
@base_dir = nil
|
@@ -2100,14 +2070,14 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2100
2070
|
##
|
2101
2071
|
# Duplicates array_attributes from +other_spec+ so state isn't shared.
|
2102
2072
|
|
2103
|
-
def initialize_copy
|
2073
|
+
def initialize_copy(other_spec)
|
2104
2074
|
self.class.array_attributes.each do |name|
|
2105
2075
|
name = :"@#{name}"
|
2106
2076
|
next unless other_spec.instance_variable_defined? name
|
2107
2077
|
|
2108
2078
|
begin
|
2109
2079
|
val = other_spec.instance_variable_get(name)
|
2110
|
-
if val
|
2080
|
+
if val
|
2111
2081
|
instance_variable_set name, val.dup
|
2112
2082
|
elsif Gem.configuration.really_verbose
|
2113
2083
|
warn "WARNING: #{full_name} has an invalid nil value for #{name}"
|
@@ -2124,7 +2094,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2124
2094
|
|
2125
2095
|
def base_dir
|
2126
2096
|
return Gem.dir unless loaded_from
|
2127
|
-
@base_dir ||= if default_gem?
|
2097
|
+
@base_dir ||= if default_gem?
|
2128
2098
|
File.dirname File.dirname File.dirname loaded_from
|
2129
2099
|
else
|
2130
2100
|
File.dirname File.dirname loaded_from
|
@@ -2200,7 +2170,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2200
2170
|
|
2201
2171
|
def method_missing(sym, *a, &b) # :nodoc:
|
2202
2172
|
if @specification_version > CURRENT_SPECIFICATION_VERSION and
|
2203
|
-
sym.to_s =~ /=$/
|
2173
|
+
sym.to_s =~ /=$/
|
2204
2174
|
warn "ignoring #{sym} loading #{full_name}" if $DEBUG
|
2205
2175
|
else
|
2206
2176
|
super
|
@@ -2227,7 +2197,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2227
2197
|
# file list.
|
2228
2198
|
|
2229
2199
|
def normalize
|
2230
|
-
if defined?(@extra_rdoc_files) and @extra_rdoc_files
|
2200
|
+
if defined?(@extra_rdoc_files) and @extra_rdoc_files
|
2231
2201
|
@extra_rdoc_files.uniq!
|
2232
2202
|
@files ||= []
|
2233
2203
|
@files.concat(@extra_rdoc_files)
|
@@ -2252,7 +2222,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2252
2222
|
# platform. For use with legacy gems.
|
2253
2223
|
|
2254
2224
|
def original_name # :nodoc:
|
2255
|
-
if platform == Gem::Platform::RUBY or platform.nil?
|
2225
|
+
if platform == Gem::Platform::RUBY or platform.nil?
|
2256
2226
|
"#{@name}-#{@version}"
|
2257
2227
|
else
|
2258
2228
|
"#{@name}-#{@version}-#{@original_platform}"
|
@@ -2285,11 +2255,11 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2285
2255
|
attributes.each do |attr_name|
|
2286
2256
|
current_value = self.send attr_name
|
2287
2257
|
if current_value != default_value(attr_name) or
|
2288
|
-
self.class.required_attribute? attr_name
|
2258
|
+
self.class.required_attribute? attr_name
|
2289
2259
|
|
2290
2260
|
q.text "s.#{attr_name} = "
|
2291
2261
|
|
2292
|
-
if attr_name == :date
|
2262
|
+
if attr_name == :date
|
2293
2263
|
current_value = current_value.utc
|
2294
2264
|
|
2295
2265
|
q.text "Time.utc(#{current_value.year}, #{current_value.month}, #{current_value.day})"
|
@@ -2307,7 +2277,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2307
2277
|
# Raise an exception if the version of this spec conflicts with the one
|
2308
2278
|
# that is already loaded (+other+)
|
2309
2279
|
|
2310
|
-
def check_version_conflict
|
2280
|
+
def check_version_conflict(other) # :nodoc:
|
2311
2281
|
return if self.version == other.version
|
2312
2282
|
|
2313
2283
|
# This gem is already loaded. If the currently loaded gem is not in the
|
@@ -2328,7 +2298,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2328
2298
|
# Check the spec for possible conflicts and freak out if there are any.
|
2329
2299
|
|
2330
2300
|
def raise_if_conflicts # :nodoc:
|
2331
|
-
if has_conflicts?
|
2301
|
+
if has_conflicts?
|
2332
2302
|
raise Gem::ConflictError.new self, conflicts
|
2333
2303
|
end
|
2334
2304
|
end
|
@@ -2337,7 +2307,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2337
2307
|
# Sets rdoc_options to +value+, ensuring it is an array. Don't
|
2338
2308
|
# use this, push onto the array instead.
|
2339
2309
|
|
2340
|
-
def rdoc_options=
|
2310
|
+
def rdoc_options=(options)
|
2341
2311
|
# TODO: warn about setting instead of pushing
|
2342
2312
|
@rdoc_options = Array options
|
2343
2313
|
end
|
@@ -2352,7 +2322,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2352
2322
|
##
|
2353
2323
|
# Singular accessor for #require_paths
|
2354
2324
|
|
2355
|
-
def require_path=
|
2325
|
+
def require_path=(path)
|
2356
2326
|
self.require_paths = Array(path)
|
2357
2327
|
end
|
2358
2328
|
|
@@ -2360,12 +2330,12 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2360
2330
|
# Set requirements to +req+, ensuring it is an array. Don't
|
2361
2331
|
# use this, push onto the array instead.
|
2362
2332
|
|
2363
|
-
def requirements=
|
2333
|
+
def requirements=(req)
|
2364
2334
|
# TODO: warn about setting instead of pushing
|
2365
2335
|
@requirements = Array req
|
2366
2336
|
end
|
2367
2337
|
|
2368
|
-
def respond_to_missing?
|
2338
|
+
def respond_to_missing?(m, include_private = false) # :nodoc:
|
2369
2339
|
false
|
2370
2340
|
end
|
2371
2341
|
|
@@ -2412,7 +2382,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2412
2382
|
##
|
2413
2383
|
# True if this gem has the same attributes as +other+.
|
2414
2384
|
|
2415
|
-
def same_attributes?
|
2385
|
+
def same_attributes?(spec)
|
2416
2386
|
@@attributes.all? { |name, default| self.send(name) == spec.send(name) }
|
2417
2387
|
end
|
2418
2388
|
|
@@ -2421,7 +2391,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2421
2391
|
##
|
2422
2392
|
# Checks if this specification meets the requirement of +dependency+.
|
2423
2393
|
|
2424
|
-
def satisfies_requirement?
|
2394
|
+
def satisfies_requirement?(dependency)
|
2425
2395
|
return @name == dependency.name &&
|
2426
2396
|
dependency.requirement.satisfied_by?(@version)
|
2427
2397
|
end
|
@@ -2468,7 +2438,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2468
2438
|
##
|
2469
2439
|
# A short summary of this gem's description.
|
2470
2440
|
|
2471
|
-
def summary=
|
2441
|
+
def summary=(str)
|
2472
2442
|
@summary = str.to_s.strip.
|
2473
2443
|
gsub(/(\w-)\n[ \t]*(\w)/, '\1\2').gsub(/\n[ \t]*/, " ") # so. weird.
|
2474
2444
|
end
|
@@ -2483,7 +2453,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2483
2453
|
##
|
2484
2454
|
# Singular mutator for #test_files
|
2485
2455
|
|
2486
|
-
def test_file=
|
2456
|
+
def test_file=(file) # :nodoc:
|
2487
2457
|
self.test_files = [file]
|
2488
2458
|
end
|
2489
2459
|
|
@@ -2495,11 +2465,11 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2495
2465
|
# Handle the possibility that we have @test_suite_file but not
|
2496
2466
|
# @test_files. This will happen when an old gem is loaded via
|
2497
2467
|
# YAML.
|
2498
|
-
if defined? @test_suite_file
|
2468
|
+
if defined? @test_suite_file
|
2499
2469
|
@test_files = [@test_suite_file].flatten
|
2500
2470
|
@test_suite_file = nil
|
2501
2471
|
end
|
2502
|
-
if defined?(@test_files) and @test_files
|
2472
|
+
if defined?(@test_files) and @test_files
|
2503
2473
|
@test_files
|
2504
2474
|
else
|
2505
2475
|
@test_files = []
|
@@ -2523,7 +2493,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2523
2493
|
|
2524
2494
|
result << " s.name = #{ruby_code name}"
|
2525
2495
|
result << " s.version = #{ruby_code version}"
|
2526
|
-
unless platform.nil? or platform == Gem::Platform::RUBY
|
2496
|
+
unless platform.nil? or platform == Gem::Platform::RUBY
|
2527
2497
|
result << " s.platform = #{ruby_code original_platform}"
|
2528
2498
|
end
|
2529
2499
|
result << ""
|
@@ -2551,17 +2521,17 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2551
2521
|
next if handled.include? attr_name
|
2552
2522
|
current_value = self.send(attr_name)
|
2553
2523
|
if current_value != default_value(attr_name) or
|
2554
|
-
self.class.required_attribute? attr_name
|
2524
|
+
self.class.required_attribute? attr_name
|
2555
2525
|
result << " s.#{attr_name} = #{ruby_code current_value}"
|
2556
2526
|
end
|
2557
2527
|
end
|
2558
2528
|
|
2559
|
-
if @installed_by_version
|
2529
|
+
if @installed_by_version
|
2560
2530
|
result << nil
|
2561
2531
|
result << " s.installed_by_version = \"#{Gem::VERSION}\" if s.respond_to? :installed_by_version"
|
2562
2532
|
end
|
2563
2533
|
|
2564
|
-
unless dependencies.empty?
|
2534
|
+
unless dependencies.empty?
|
2565
2535
|
result << nil
|
2566
2536
|
result << " if s.respond_to? :specification_version then"
|
2567
2537
|
result << " s.specification_version = #{specification_version}"
|
@@ -2620,39 +2590,30 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2620
2590
|
end
|
2621
2591
|
|
2622
2592
|
def to_yaml(opts = {}) # :nodoc:
|
2623
|
-
|
2624
|
-
|
2625
|
-
|
2626
|
-
|
2627
|
-
|
2628
|
-
|
2629
|
-
require 'rubygems/psych_tree'
|
2630
|
-
end
|
2593
|
+
# Because the user can switch the YAML engine behind our
|
2594
|
+
# back, we have to check again here to make sure that our
|
2595
|
+
# psych code was properly loaded, and load it if not.
|
2596
|
+
unless Gem.const_defined?(:NoAliasYAMLTree)
|
2597
|
+
require 'rubygems/psych_tree'
|
2598
|
+
end
|
2631
2599
|
|
2632
|
-
|
2633
|
-
|
2634
|
-
|
2600
|
+
builder = Gem::NoAliasYAMLTree.create
|
2601
|
+
builder << self
|
2602
|
+
ast = builder.tree
|
2635
2603
|
|
2636
|
-
|
2637
|
-
|
2604
|
+
io = StringIO.new
|
2605
|
+
io.set_encoding Encoding::UTF_8
|
2638
2606
|
|
2639
|
-
|
2607
|
+
Psych::Visitors::Emitter.new(io).accept(ast)
|
2640
2608
|
|
2641
|
-
|
2642
|
-
else
|
2643
|
-
YAML.quick_emit object_id, opts do |out|
|
2644
|
-
out.map taguri, to_yaml_style do |map|
|
2645
|
-
encode_with map
|
2646
|
-
end
|
2647
|
-
end
|
2648
|
-
end
|
2609
|
+
io.string.gsub(/ !!null \n/, " \n")
|
2649
2610
|
end
|
2650
2611
|
|
2651
2612
|
##
|
2652
2613
|
# Recursively walk dependencies of this spec, executing the +block+ for each
|
2653
2614
|
# hop.
|
2654
2615
|
|
2655
|
-
def traverse
|
2616
|
+
def traverse(trail = [], visited = {}, &block)
|
2656
2617
|
trail.push(self)
|
2657
2618
|
begin
|
2658
2619
|
dependencies.each do |dep|
|
@@ -2685,336 +2646,40 @@ class Gem::Specification < Gem::BasicSpecification
|
|
2685
2646
|
# Raises InvalidSpecificationException if the spec does not pass the
|
2686
2647
|
# checks..
|
2687
2648
|
|
2688
|
-
def validate
|
2689
|
-
@warnings = 0
|
2649
|
+
def validate(packaging = true, strict = false)
|
2690
2650
|
require 'rubygems/user_interaction'
|
2691
2651
|
extend Gem::UserInteraction
|
2692
2652
|
normalize
|
2693
2653
|
|
2694
|
-
|
2695
|
-
|
2696
|
-
|
2697
|
-
|
2698
|
-
unless nil_attributes.empty? then
|
2699
|
-
raise Gem::InvalidSpecificationException,
|
2700
|
-
"#{nil_attributes.join ', '} must not be nil"
|
2701
|
-
end
|
2702
|
-
|
2703
|
-
if packaging and rubygems_version != Gem::VERSION then
|
2704
|
-
raise Gem::InvalidSpecificationException,
|
2705
|
-
"expected RubyGems version #{Gem::VERSION}, was #{rubygems_version}"
|
2706
|
-
end
|
2707
|
-
|
2708
|
-
@@required_attributes.each do |symbol|
|
2709
|
-
unless self.send symbol then
|
2710
|
-
raise Gem::InvalidSpecificationException,
|
2711
|
-
"missing value for attribute #{symbol}"
|
2712
|
-
end
|
2713
|
-
end
|
2714
|
-
|
2715
|
-
if !name.is_a?(String) then
|
2716
|
-
raise Gem::InvalidSpecificationException,
|
2717
|
-
"invalid value for attribute name: \"#{name.inspect}\" must be a string"
|
2718
|
-
elsif name !~ /[a-zA-Z]/ then
|
2719
|
-
raise Gem::InvalidSpecificationException,
|
2720
|
-
"invalid value for attribute name: #{name.dump} must include at least one letter"
|
2721
|
-
elsif name !~ VALID_NAME_PATTERN then
|
2722
|
-
raise Gem::InvalidSpecificationException,
|
2723
|
-
"invalid value for attribute name: #{name.dump} can only include letters, numbers, dashes, and underscores"
|
2724
|
-
end
|
2725
|
-
|
2726
|
-
if raw_require_paths.empty? then
|
2727
|
-
raise Gem::InvalidSpecificationException,
|
2728
|
-
'specification must have at least one require_path'
|
2729
|
-
end
|
2654
|
+
validation_policy = Gem::SpecificationPolicy.new(self)
|
2655
|
+
validation_policy.packaging = packaging
|
2656
|
+
validation_policy.validate(strict)
|
2657
|
+
end
|
2730
2658
|
|
2731
|
-
|
2732
|
-
@test_files.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
|
2659
|
+
def keep_only_files_and_directories
|
2733
2660
|
@executables.delete_if { |x| File.directory?(File.join(@bindir, x)) }
|
2734
|
-
@extra_rdoc_files.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
|
2735
2661
|
@extensions.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
|
2736
|
-
|
2737
|
-
|
2738
|
-
|
2739
|
-
unless not packaging or non_files.empty? then
|
2740
|
-
raise Gem::InvalidSpecificationException,
|
2741
|
-
"[\"#{non_files.join "\", \""}\"] are not files"
|
2742
|
-
end
|
2743
|
-
|
2744
|
-
if files.include? file_name then
|
2745
|
-
raise Gem::InvalidSpecificationException,
|
2746
|
-
"#{full_name} contains itself (#{file_name}), check your files list"
|
2747
|
-
end
|
2748
|
-
|
2749
|
-
unless specification_version.is_a?(Integer)
|
2750
|
-
raise Gem::InvalidSpecificationException,
|
2751
|
-
'specification_version must be an Integer (did you mean version?)'
|
2752
|
-
end
|
2753
|
-
|
2754
|
-
case platform
|
2755
|
-
when Gem::Platform, Gem::Platform::RUBY then # ok
|
2756
|
-
else
|
2757
|
-
raise Gem::InvalidSpecificationException,
|
2758
|
-
"invalid platform #{platform.inspect}, see Gem::Platform"
|
2759
|
-
end
|
2760
|
-
|
2761
|
-
self.class.array_attributes.each do |field|
|
2762
|
-
val = self.send field
|
2763
|
-
klass = case field
|
2764
|
-
when :dependencies
|
2765
|
-
Gem::Dependency
|
2766
|
-
else
|
2767
|
-
String
|
2768
|
-
end
|
2769
|
-
|
2770
|
-
unless Array === val and val.all? { |x| x.kind_of?(klass) } then
|
2771
|
-
raise(Gem::InvalidSpecificationException,
|
2772
|
-
"#{field} must be an Array of #{klass}")
|
2773
|
-
end
|
2774
|
-
end
|
2775
|
-
|
2776
|
-
[:authors].each do |field|
|
2777
|
-
val = self.send field
|
2778
|
-
raise Gem::InvalidSpecificationException, "#{field} may not be empty" if
|
2779
|
-
val.empty?
|
2780
|
-
end
|
2781
|
-
|
2782
|
-
unless Hash === metadata
|
2783
|
-
raise Gem::InvalidSpecificationException,
|
2784
|
-
'metadata must be a hash'
|
2785
|
-
end
|
2786
|
-
|
2787
|
-
validate_metadata
|
2788
|
-
|
2789
|
-
licenses.each { |license|
|
2790
|
-
if license.length > 64
|
2791
|
-
raise Gem::InvalidSpecificationException,
|
2792
|
-
"each license must be 64 characters or less"
|
2793
|
-
end
|
2794
|
-
|
2795
|
-
if !Gem::Licenses.match?(license)
|
2796
|
-
suggestions = Gem::Licenses.suggestions(license)
|
2797
|
-
message = <<-warning
|
2798
|
-
license value '#{license}' is invalid. Use a license identifier from
|
2799
|
-
http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license.
|
2800
|
-
warning
|
2801
|
-
message += "Did you mean #{suggestions.map { |s| "'#{s}'"}.join(', ')}?\n" unless suggestions.nil?
|
2802
|
-
warning(message)
|
2803
|
-
end
|
2804
|
-
}
|
2805
|
-
|
2806
|
-
warning <<-warning if licenses.empty?
|
2807
|
-
licenses is empty, but is recommended. Use a license identifier from
|
2808
|
-
http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard license.
|
2809
|
-
warning
|
2810
|
-
|
2811
|
-
validate_permissions
|
2812
|
-
|
2813
|
-
# reject lazy developers:
|
2814
|
-
|
2815
|
-
lazy = '"FIxxxXME" or "TOxxxDO"'.gsub(/xxx/, '')
|
2816
|
-
|
2817
|
-
unless authors.grep(/FI XME|TO DO/x).empty? then
|
2818
|
-
raise Gem::InvalidSpecificationException, "#{lazy} is not an author"
|
2819
|
-
end
|
2820
|
-
|
2821
|
-
unless Array(email).grep(/FI XME|TO DO/x).empty? then
|
2822
|
-
raise Gem::InvalidSpecificationException, "#{lazy} is not an email"
|
2823
|
-
end
|
2824
|
-
|
2825
|
-
if description =~ /FI XME|TO DO/x then
|
2826
|
-
raise Gem::InvalidSpecificationException, "#{lazy} is not a description"
|
2827
|
-
end
|
2828
|
-
|
2829
|
-
if summary =~ /FI XME|TO DO/x then
|
2830
|
-
raise Gem::InvalidSpecificationException, "#{lazy} is not a summary"
|
2831
|
-
end
|
2832
|
-
|
2833
|
-
# Make sure a homepage is valid HTTP/HTTPS URI
|
2834
|
-
if homepage and not homepage.empty?
|
2835
|
-
begin
|
2836
|
-
homepage_uri = URI.parse(homepage)
|
2837
|
-
unless [URI::HTTP, URI::HTTPS].member? homepage_uri.class
|
2838
|
-
raise Gem::InvalidSpecificationException, "\"#{homepage}\" is not a valid HTTP URI"
|
2839
|
-
end
|
2840
|
-
rescue URI::InvalidURIError
|
2841
|
-
raise Gem::InvalidSpecificationException, "\"#{homepage}\" is not a valid HTTP URI"
|
2842
|
-
end
|
2843
|
-
end
|
2844
|
-
|
2845
|
-
# Warnings
|
2846
|
-
|
2847
|
-
%w[author homepage summary files].each do |attribute|
|
2848
|
-
value = self.send attribute
|
2849
|
-
warning "no #{attribute} specified" if value.nil? or value.empty?
|
2850
|
-
end
|
2851
|
-
|
2852
|
-
if description == summary then
|
2853
|
-
warning 'description and summary are identical'
|
2854
|
-
end
|
2855
|
-
|
2856
|
-
# TODO: raise at some given date
|
2857
|
-
warning "deprecated autorequire specified" if autorequire
|
2858
|
-
|
2859
|
-
executables.each do |executable|
|
2860
|
-
executable_path = File.join(bindir, executable)
|
2861
|
-
shebang = File.read(executable_path, 2) == '#!'
|
2862
|
-
|
2863
|
-
warning "#{executable_path} is missing #! line" unless shebang
|
2864
|
-
end
|
2865
|
-
|
2866
|
-
files.each do |file|
|
2867
|
-
next unless File.symlink?(file)
|
2868
|
-
warning "#{file} is a symlink, which is not supported on all platforms"
|
2869
|
-
end
|
2870
|
-
|
2871
|
-
validate_dependencies
|
2872
|
-
|
2873
|
-
true
|
2874
|
-
ensure
|
2875
|
-
if $! or @warnings > 0 then
|
2876
|
-
alert_warning "See http://guides.rubygems.org/specification-reference/ for help"
|
2877
|
-
end
|
2662
|
+
@extra_rdoc_files.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
|
2663
|
+
@files.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
|
2664
|
+
@test_files.delete_if { |x| File.directory?(x) && !File.symlink?(x) }
|
2878
2665
|
end
|
2879
2666
|
|
2880
2667
|
def validate_metadata
|
2881
|
-
|
2882
|
-
link_keys = %w(
|
2883
|
-
bug_tracker_uri
|
2884
|
-
changelog_uri
|
2885
|
-
documentation_uri
|
2886
|
-
homepage_uri
|
2887
|
-
mailing_list_uri
|
2888
|
-
source_code_uri
|
2889
|
-
wiki_uri
|
2890
|
-
)
|
2891
|
-
|
2892
|
-
metadata.each do|key, value|
|
2893
|
-
if !key.kind_of?(String)
|
2894
|
-
raise Gem::InvalidSpecificationException,
|
2895
|
-
"metadata keys must be a String"
|
2896
|
-
end
|
2897
|
-
|
2898
|
-
if key.size > 128
|
2899
|
-
raise Gem::InvalidSpecificationException,
|
2900
|
-
"metadata key too large (#{key.size} > 128)"
|
2901
|
-
end
|
2902
|
-
|
2903
|
-
if !value.kind_of?(String)
|
2904
|
-
raise Gem::InvalidSpecificationException,
|
2905
|
-
"metadata values must be a String"
|
2906
|
-
end
|
2907
|
-
|
2908
|
-
if value.size > 1024
|
2909
|
-
raise Gem::InvalidSpecificationException,
|
2910
|
-
"metadata value too large (#{value.size} > 1024)"
|
2911
|
-
end
|
2912
|
-
|
2913
|
-
if link_keys.include? key
|
2914
|
-
if value !~ url_validation_regex
|
2915
|
-
raise Gem::InvalidSpecificationException,
|
2916
|
-
"metadata['#{key}'] has invalid link: #{value.inspect}"
|
2917
|
-
end
|
2918
|
-
end
|
2919
|
-
end
|
2668
|
+
Gem::SpecificationPolicy.new(self).validate_metadata
|
2920
2669
|
end
|
2921
2670
|
|
2922
2671
|
##
|
2923
2672
|
# Checks that dependencies use requirements as we recommend. Warnings are
|
2924
2673
|
# issued when dependencies are open-ended or overly strict for semantic
|
2925
2674
|
# versioning.
|
2926
|
-
|
2927
|
-
|
2928
|
-
# NOTE: see REFACTOR note in Gem::Dependency about types - this might be brittle
|
2929
|
-
seen = Gem::Dependency::TYPES.inject({}) { |types, type| types.merge({ type => {}}) }
|
2930
|
-
|
2931
|
-
error_messages = []
|
2932
|
-
warning_messages = []
|
2933
|
-
dependencies.each do |dep|
|
2934
|
-
if prev = seen[dep.type][dep.name] then
|
2935
|
-
error_messages << <<-MESSAGE
|
2936
|
-
duplicate dependency on #{dep}, (#{prev.requirement}) use:
|
2937
|
-
add_#{dep.type}_dependency '#{dep.name}', '#{dep.requirement}', '#{prev.requirement}'
|
2938
|
-
MESSAGE
|
2939
|
-
end
|
2940
|
-
|
2941
|
-
seen[dep.type][dep.name] = dep
|
2942
|
-
|
2943
|
-
prerelease_dep = dep.requirements_list.any? do |req|
|
2944
|
-
Gem::Requirement.new(req).prerelease?
|
2945
|
-
end
|
2946
|
-
|
2947
|
-
warning_messages << "prerelease dependency on #{dep} is not recommended" if
|
2948
|
-
prerelease_dep && !version.prerelease?
|
2949
|
-
|
2950
|
-
overly_strict = dep.requirement.requirements.length == 1 &&
|
2951
|
-
dep.requirement.requirements.any? do |op, version|
|
2952
|
-
op == '~>' and
|
2953
|
-
not version.prerelease? and
|
2954
|
-
version.segments.length > 2 and
|
2955
|
-
version.segments.first != 0
|
2956
|
-
end
|
2957
|
-
|
2958
|
-
if overly_strict then
|
2959
|
-
_, dep_version = dep.requirement.requirements.first
|
2960
|
-
|
2961
|
-
base = dep_version.segments.first 2
|
2962
|
-
|
2963
|
-
warning_messages << <<-WARNING
|
2964
|
-
pessimistic dependency on #{dep} may be overly strict
|
2965
|
-
if #{dep.name} is semantically versioned, use:
|
2966
|
-
add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}', '>= #{dep_version}'
|
2967
|
-
WARNING
|
2968
|
-
end
|
2969
|
-
|
2970
|
-
open_ended = dep.requirement.requirements.all? do |op, version|
|
2971
|
-
not version.prerelease? and (op == '>' or op == '>=')
|
2972
|
-
end
|
2973
|
-
|
2974
|
-
if open_ended then
|
2975
|
-
op, dep_version = dep.requirement.requirements.first
|
2976
|
-
|
2977
|
-
base = dep_version.segments.first 2
|
2978
|
-
|
2979
|
-
bugfix = if op == '>' then
|
2980
|
-
", '> #{dep_version}'"
|
2981
|
-
elsif op == '>=' and base != dep_version.segments then
|
2982
|
-
", '>= #{dep_version}'"
|
2983
|
-
end
|
2984
|
-
|
2985
|
-
warning_messages << <<-WARNING
|
2986
|
-
open-ended dependency on #{dep} is not recommended
|
2987
|
-
if #{dep.name} is semantically versioned, use:
|
2988
|
-
add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}'#{bugfix}
|
2989
|
-
WARNING
|
2990
|
-
end
|
2991
|
-
end
|
2992
|
-
if error_messages.any?
|
2993
|
-
raise Gem::InvalidSpecificationException, error_messages.join
|
2994
|
-
end
|
2995
|
-
if warning_messages.any?
|
2996
|
-
warning_messages.each { |warning_message| warning warning_message }
|
2997
|
-
end
|
2675
|
+
def validate_dependencies
|
2676
|
+
Gem::SpecificationPolicy.new(self).validate_dependencies
|
2998
2677
|
end
|
2999
2678
|
|
3000
2679
|
##
|
3001
2680
|
# Checks to see if the files to be packaged are world-readable.
|
3002
|
-
|
3003
2681
|
def validate_permissions
|
3004
|
-
|
3005
|
-
|
3006
|
-
files.each do |file|
|
3007
|
-
next unless File.file?(file)
|
3008
|
-
next if File.stat(file).mode & 0444 == 0444
|
3009
|
-
warning "#{file} is not world-readable"
|
3010
|
-
end
|
3011
|
-
|
3012
|
-
executables.each do |name|
|
3013
|
-
exec = File.join @bindir, name
|
3014
|
-
next unless File.file?(exec)
|
3015
|
-
next if File.stat(exec).executable?
|
3016
|
-
warning "#{exec} is not executable"
|
3017
|
-
end
|
2682
|
+
Gem::SpecificationPolicy.new(self).validate_permissions
|
3018
2683
|
end
|
3019
2684
|
|
3020
2685
|
##
|
@@ -3022,9 +2687,13 @@ open-ended dependency on #{dep} is not recommended
|
|
3022
2687
|
# required_rubygems_version if +version+ indicates it is a
|
3023
2688
|
# prerelease.
|
3024
2689
|
|
3025
|
-
def version=
|
2690
|
+
def version=(version)
|
3026
2691
|
@version = Gem::Version.create(version)
|
3027
|
-
|
2692
|
+
# skip to set required_ruby_version when pre-released rubygems.
|
2693
|
+
# It caused to raise CircularDependencyError
|
2694
|
+
if @version.prerelease? && (@name.nil? || @name.strip != "rubygems")
|
2695
|
+
self.required_rubygems_version = '> 1.3.1'
|
2696
|
+
end
|
3028
2697
|
invalidate_memoized_attributes
|
3029
2698
|
|
3030
2699
|
return @version
|
@@ -3071,12 +2740,6 @@ open-ended dependency on #{dep} is not recommended
|
|
3071
2740
|
@installed_by_version ||= nil
|
3072
2741
|
end
|
3073
2742
|
|
3074
|
-
def warning statement # :nodoc:
|
3075
|
-
@warnings += 1
|
3076
|
-
|
3077
|
-
alert_warning statement
|
3078
|
-
end
|
3079
|
-
|
3080
2743
|
def raw_require_paths # :nodoc:
|
3081
2744
|
@require_paths
|
3082
2745
|
end
|