bundler 2.2.27 → 2.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1328 -4
- data/README.md +4 -8
- data/bundler.gemspec +11 -11
- data/exe/bundle +5 -26
- data/exe/bundler +1 -1
- data/lib/bundler/.document +1 -0
- data/lib/bundler/build_metadata.rb +4 -4
- data/lib/bundler/capistrano.rb +1 -1
- data/lib/bundler/checksum.rb +254 -0
- data/lib/bundler/ci_detector.rb +75 -0
- data/lib/bundler/cli/add.rb +7 -5
- data/lib/bundler/cli/binstubs.rb +10 -6
- data/lib/bundler/cli/cache.rb +1 -1
- data/lib/bundler/cli/check.rb +4 -4
- data/lib/bundler/cli/common.rb +13 -3
- data/lib/bundler/cli/config.rb +18 -8
- data/lib/bundler/cli/console.rb +2 -5
- data/lib/bundler/cli/doctor.rb +16 -9
- data/lib/bundler/cli/exec.rb +2 -1
- data/lib/bundler/cli/fund.rb +1 -1
- data/lib/bundler/cli/gem.rb +153 -40
- data/lib/bundler/cli/info.rb +27 -17
- data/lib/bundler/cli/init.rb +6 -2
- data/lib/bundler/cli/inject.rb +1 -1
- data/lib/bundler/cli/install.rb +34 -42
- data/lib/bundler/cli/issue.rb +5 -4
- data/lib/bundler/cli/lock.rb +54 -28
- data/lib/bundler/cli/open.rb +9 -9
- data/lib/bundler/cli/outdated.rb +34 -29
- data/lib/bundler/cli/platform.rb +8 -6
- data/lib/bundler/cli/plugin.rb +9 -15
- data/lib/bundler/cli/pristine.rb +38 -30
- data/lib/bundler/cli/remove.rb +1 -2
- data/lib/bundler/cli/show.rb +5 -5
- data/lib/bundler/cli/update.rb +12 -7
- data/lib/bundler/cli/viz.rb +1 -1
- data/lib/bundler/cli.rb +265 -313
- data/lib/bundler/compact_index_client/cache.rb +53 -67
- data/lib/bundler/compact_index_client/cache_file.rb +148 -0
- data/lib/bundler/compact_index_client/gem_parser.rb +7 -3
- data/lib/bundler/compact_index_client/parser.rb +84 -0
- data/lib/bundler/compact_index_client/updater.rb +73 -77
- data/lib/bundler/compact_index_client.rb +59 -87
- data/lib/bundler/constants.rb +9 -2
- data/lib/bundler/current_ruby.rb +12 -16
- data/lib/bundler/definition.rb +604 -347
- data/lib/bundler/dependency.rb +33 -71
- data/lib/bundler/digest.rb +71 -0
- data/lib/bundler/dsl.rb +136 -102
- data/lib/bundler/endpoint_specification.rb +42 -16
- data/lib/bundler/env.rb +5 -7
- data/lib/bundler/environment_preserver.rb +8 -22
- data/lib/bundler/errors.rb +113 -13
- data/lib/bundler/feature_flag.rb +1 -2
- data/lib/bundler/fetcher/base.rb +11 -11
- data/lib/bundler/fetcher/compact_index.rb +32 -52
- data/lib/bundler/fetcher/dependency.rb +3 -7
- data/lib/bundler/fetcher/downloader.rb +17 -16
- data/lib/bundler/fetcher/gem_remote_fetcher.rb +16 -0
- data/lib/bundler/fetcher/index.rb +2 -29
- data/lib/bundler/fetcher.rb +98 -83
- data/lib/bundler/force_platform.rb +16 -0
- data/lib/bundler/friendly_errors.rb +29 -40
- data/lib/bundler/gem_helper.rb +12 -24
- data/lib/bundler/gem_helpers.rb +47 -7
- data/lib/bundler/gem_version_promoter.rb +68 -109
- data/lib/bundler/graph.rb +9 -9
- data/lib/bundler/index.rb +71 -79
- data/lib/bundler/injector.rb +25 -13
- data/lib/bundler/inline.rb +41 -28
- data/lib/bundler/installer/gem_installer.rb +22 -13
- data/lib/bundler/installer/parallel_installer.rb +19 -66
- data/lib/bundler/installer/standalone.rb +58 -17
- data/lib/bundler/installer.rb +31 -93
- data/lib/bundler/lazy_specification.rb +151 -72
- data/lib/bundler/lockfile_generator.rb +13 -4
- data/lib/bundler/lockfile_parser.rb +146 -71
- data/lib/bundler/man/bundle-add.1 +54 -44
- data/lib/bundler/man/bundle-add.1.ronn +62 -21
- data/lib/bundler/man/bundle-binstubs.1 +10 -19
- data/lib/bundler/man/bundle-binstubs.1.ronn +6 -3
- data/lib/bundler/man/bundle-cache.1 +38 -25
- data/lib/bundler/man/bundle-cache.1.ronn +40 -4
- data/lib/bundler/man/bundle-check.1 +7 -14
- data/lib/bundler/man/bundle-check.1.ronn +7 -2
- data/lib/bundler/man/bundle-clean.1 +4 -11
- data/lib/bundler/man/bundle-clean.1.ronn +1 -1
- data/lib/bundler/man/bundle-config.1 +48 -227
- data/lib/bundler/man/bundle-config.1.ronn +41 -34
- data/lib/bundler/man/bundle-console.1 +33 -0
- data/lib/bundler/man/bundle-console.1.ronn +39 -0
- data/lib/bundler/man/bundle-doctor.1 +5 -19
- data/lib/bundler/man/bundle-doctor.1.ronn +1 -1
- data/lib/bundler/man/bundle-env.1 +9 -0
- data/lib/bundler/man/bundle-env.1.ronn +10 -0
- data/lib/bundler/man/bundle-exec.1 +20 -78
- data/lib/bundler/man/bundle-exec.1.ronn +12 -10
- data/lib/bundler/man/bundle-fund.1 +22 -0
- data/lib/bundler/man/bundle-fund.1.ronn +25 -0
- data/lib/bundler/man/bundle-gem.1 +57 -72
- data/lib/bundler/man/bundle-gem.1.ronn +57 -9
- data/lib/bundler/man/bundle-help.1 +9 -0
- data/lib/bundler/man/bundle-help.1.ronn +12 -0
- data/lib/bundler/man/bundle-info.1 +8 -11
- data/lib/bundler/man/bundle-info.1.ronn +9 -5
- data/lib/bundler/man/bundle-init.1 +7 -12
- data/lib/bundler/man/bundle-init.1.ronn +4 -1
- data/lib/bundler/man/bundle-inject.1 +17 -19
- data/lib/bundler/man/bundle-inject.1.ronn +12 -2
- data/lib/bundler/man/bundle-install.1 +43 -163
- data/lib/bundler/man/bundle-install.1.ronn +33 -51
- data/lib/bundler/man/bundle-issue.1 +45 -0
- data/lib/bundler/man/bundle-issue.1.ronn +37 -0
- data/lib/bundler/man/bundle-licenses.1 +9 -0
- data/lib/bundler/man/bundle-licenses.1.ronn +10 -0
- data/lib/bundler/man/bundle-list.1 +4 -19
- data/lib/bundler/man/bundle-list.1.ronn +4 -1
- data/lib/bundler/man/bundle-lock.1 +25 -34
- data/lib/bundler/man/bundle-lock.1.ronn +25 -4
- data/lib/bundler/man/bundle-open.1 +18 -18
- data/lib/bundler/man/bundle-open.1.ronn +10 -1
- data/lib/bundler/man/bundle-outdated.1 +23 -75
- data/lib/bundler/man/bundle-outdated.1.ronn +21 -22
- data/lib/bundler/man/bundle-platform.1 +16 -28
- data/lib/bundler/man/bundle-platform.1.ronn +14 -7
- data/lib/bundler/man/bundle-plugin.1 +58 -0
- data/lib/bundler/man/bundle-plugin.1.ronn +63 -0
- data/lib/bundler/man/bundle-pristine.1 +5 -16
- data/lib/bundler/man/bundle-pristine.1.ronn +1 -1
- data/lib/bundler/man/bundle-remove.1 +4 -14
- data/lib/bundler/man/bundle-remove.1.ronn +1 -1
- data/lib/bundler/man/bundle-show.1 +7 -11
- data/lib/bundler/man/bundle-show.1.ronn +4 -0
- data/lib/bundler/man/bundle-update.1 +31 -144
- data/lib/bundler/man/bundle-update.1.ronn +16 -7
- data/lib/bundler/man/bundle-version.1 +22 -0
- data/lib/bundler/man/bundle-version.1.ronn +24 -0
- data/lib/bundler/man/bundle-viz.1 +9 -18
- data/lib/bundler/man/bundle-viz.1.ronn +9 -3
- data/lib/bundler/man/bundle.1 +17 -51
- data/lib/bundler/man/bundle.1.ronn +12 -7
- data/lib/bundler/man/gemfile.5 +132 -346
- data/lib/bundler/man/gemfile.5.ronn +127 -86
- data/lib/bundler/man/index.txt +8 -0
- data/lib/bundler/match_metadata.rb +17 -0
- data/lib/bundler/match_platform.rb +1 -2
- data/lib/bundler/match_remote_metadata.rb +29 -0
- data/lib/bundler/materialization.rb +59 -0
- data/lib/bundler/mirror.rb +8 -10
- data/lib/bundler/plugin/api/source.rb +11 -14
- data/lib/bundler/plugin/events.rb +24 -0
- data/lib/bundler/plugin/index.rb +13 -5
- data/lib/bundler/plugin/installer/git.rb +0 -4
- data/lib/bundler/plugin/installer/path.rb +18 -0
- data/lib/bundler/plugin/installer/rubygems.rb +0 -8
- data/lib/bundler/plugin/installer.rb +43 -20
- data/lib/bundler/plugin/source_list.rb +4 -4
- data/lib/bundler/plugin.rb +35 -7
- data/lib/bundler/process_lock.rb +10 -14
- data/lib/bundler/remote_specification.rb +17 -6
- data/lib/bundler/resolver/base.rb +117 -0
- data/lib/bundler/resolver/candidate.rb +82 -0
- data/lib/bundler/resolver/incompatibility.rb +15 -0
- data/lib/bundler/resolver/package.rb +90 -0
- data/lib/bundler/resolver/root.rb +25 -0
- data/lib/bundler/resolver/spec_group.rb +54 -66
- data/lib/bundler/resolver.rb +440 -306
- data/lib/bundler/retry.rb +2 -2
- data/lib/bundler/ruby_dsl.rb +42 -7
- data/lib/bundler/ruby_version.rb +22 -22
- data/lib/bundler/rubygems_ext.rb +323 -84
- data/lib/bundler/rubygems_gem_installer.rb +93 -65
- data/lib/bundler/rubygems_integration.rb +89 -237
- data/lib/bundler/runtime.rb +30 -20
- data/lib/bundler/safe_marshal.rb +31 -0
- data/lib/bundler/self_manager.rb +205 -0
- data/lib/bundler/settings.rb +145 -58
- data/lib/bundler/setup.rb +13 -1
- data/lib/bundler/shared_helpers.rb +94 -51
- data/lib/bundler/source/git/git_proxy.rb +283 -82
- data/lib/bundler/source/git.rb +187 -78
- data/lib/bundler/source/metadata.rb +16 -16
- data/lib/bundler/source/path/installer.rb +1 -22
- data/lib/bundler/source/path.rb +17 -27
- data/lib/bundler/source/rubygems/remote.rb +1 -1
- data/lib/bundler/source/rubygems.rb +165 -245
- data/lib/bundler/source/rubygems_aggregate.rb +1 -1
- data/lib/bundler/source.rb +7 -6
- data/lib/bundler/source_list.rb +41 -33
- data/lib/bundler/source_map.rb +15 -2
- data/lib/bundler/spec_set.rb +193 -58
- data/lib/bundler/stub_specification.rb +39 -7
- data/lib/bundler/templates/Executable +3 -5
- data/lib/bundler/templates/Executable.bundler +7 -12
- data/lib/bundler/templates/Executable.standalone +4 -4
- data/lib/bundler/templates/Gemfile +0 -2
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +77 -29
- data/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +5 -2
- data/lib/bundler/templates/newgem/README.md.tt +12 -12
- data/lib/bundler/templates/newgem/Rakefile.tt +28 -4
- data/lib/bundler/templates/newgem/bin/console.tt +0 -4
- data/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
- data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +1 -1
- data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
- data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +20 -10
- data/lib/bundler/templates/newgem/gitignore.tt +3 -0
- data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +13 -4
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +26 -18
- data/lib/bundler/templates/newgem/rubocop.yml.tt +0 -5
- data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
- data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
- data/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
- data/lib/bundler/ui/rg_proxy.rb +1 -1
- data/lib/bundler/ui/shell.rb +61 -16
- data/lib/bundler/ui/silent.rb +33 -6
- data/lib/bundler/uri_credentials_filter.rb +3 -3
- data/lib/bundler/uri_normalizer.rb +23 -0
- data/lib/bundler/vendor/.document +1 -0
- data/lib/bundler/vendor/connection_pool/.document +1 -0
- data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +56 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +92 -78
- data/lib/bundler/vendor/fileutils/.document +1 -0
- data/lib/bundler/vendor/fileutils/COPYING +56 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1350 -418
- data/lib/bundler/vendor/net-http-persistent/.document +1 -0
- data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +4 -3
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +23 -11
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +1 -1
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +102 -64
- data/lib/bundler/vendor/pub_grub/.document +1 -0
- data/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +150 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +61 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +411 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +248 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
- data/lib/bundler/vendor/securerandom/.document +1 -0
- data/lib/bundler/vendor/securerandom/COPYING +56 -0
- data/lib/bundler/vendor/securerandom/lib/securerandom.rb +102 -0
- data/lib/bundler/vendor/thor/.document +1 -0
- data/lib/bundler/vendor/thor/LICENSE.md +20 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +3 -2
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +15 -19
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +16 -6
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +21 -17
- data/lib/bundler/vendor/thor/lib/thor/base.rb +140 -14
- data/lib/bundler/vendor/thor/lib/thor/command.rb +13 -4
- data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +10 -0
- data/lib/bundler/vendor/thor/lib/thor/error.rb +16 -20
- data/lib/bundler/vendor/thor/lib/thor/group.rb +12 -1
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +17 -1
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +33 -17
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +28 -9
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +65 -8
- data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +40 -30
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +56 -162
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +1 -46
- data/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +1 -46
- data/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +118 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb +42 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb +38 -0
- data/lib/bundler/vendor/thor/lib/thor/shell.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/util.rb +9 -8
- data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor.rb +166 -8
- data/lib/bundler/vendor/tsort/.document +1 -0
- data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
- data/lib/bundler/vendor/tsort/lib/tsort.rb +455 -0
- data/lib/bundler/vendor/uri/.document +1 -0
- data/lib/bundler/vendor/uri/COPYING +56 -0
- data/lib/bundler/vendor/uri/lib/uri/common.rb +351 -219
- data/lib/bundler/vendor/uri/lib/uri/file.rb +10 -4
- data/lib/bundler/vendor/uri/lib/uri/ftp.rb +3 -3
- data/lib/bundler/vendor/uri/lib/uri/generic.rb +49 -39
- data/lib/bundler/vendor/uri/lib/uri/http.rb +40 -3
- data/lib/bundler/vendor/uri/lib/uri/https.rb +2 -2
- data/lib/bundler/vendor/uri/lib/uri/ldap.rb +2 -2
- data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +2 -1
- data/lib/bundler/vendor/uri/lib/uri/mailto.rb +2 -3
- data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +26 -26
- data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +131 -50
- data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
- data/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
- data/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
- data/lib/bundler/vendor/uri/lib/uri.rb +12 -12
- data/lib/bundler/vendored_net_http.rb +23 -0
- data/lib/bundler/vendored_persistent.rb +0 -36
- data/lib/bundler/{vendored_molinillo.rb → vendored_pub_grub.rb} +1 -1
- data/lib/bundler/vendored_securerandom.rb +12 -0
- data/lib/bundler/vendored_timeout.rb +12 -0
- data/lib/bundler/{vendored_tmpdir.rb → vendored_tsort.rb} +1 -1
- data/lib/bundler/vendored_uri.rb +18 -1
- data/lib/bundler/version.rb +5 -1
- data/lib/bundler/vlad.rb +1 -1
- data/lib/bundler/worker.rb +7 -9
- data/lib/bundler/yaml_serializer.rb +22 -13
- data/lib/bundler.rb +176 -151
- metadata +98 -41
- data/lib/bundler/dep_proxy.rb +0 -55
- data/lib/bundler/gemdeps.rb +0 -29
- data/lib/bundler/psyched_yaml.rb +0 -22
- data/lib/bundler/templates/gems.rb +0 -8
- data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +0 -5
- data/lib/bundler/templates/newgem/travis.yml.tt +0 -6
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -88
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -164
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -255
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -143
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -112
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -839
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -11
- data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +0 -154
- data/lib/bundler/version_ranges.rb +0 -122
@@ -3,7 +3,6 @@
|
|
3
3
|
# = uri/common.rb
|
4
4
|
#
|
5
5
|
# Author:: Akira Yamada <akira@ruby-lang.org>
|
6
|
-
# Revision:: $Id$
|
7
6
|
# License::
|
8
7
|
# You can redistribute it and/or modify it under the same term as Ruby.
|
9
8
|
#
|
@@ -14,19 +13,46 @@ require_relative "rfc2396_parser"
|
|
14
13
|
require_relative "rfc3986_parser"
|
15
14
|
|
16
15
|
module Bundler::URI
|
17
|
-
|
18
|
-
|
16
|
+
RFC2396_PARSER = RFC2396_Parser.new
|
17
|
+
Ractor.make_shareable(RFC2396_PARSER) if defined?(Ractor)
|
18
|
+
|
19
19
|
RFC3986_PARSER = RFC3986_Parser.new
|
20
|
+
Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor)
|
21
|
+
|
22
|
+
DEFAULT_PARSER = RFC3986_PARSER
|
23
|
+
Ractor.make_shareable(DEFAULT_PARSER) if defined?(Ractor)
|
24
|
+
|
25
|
+
def self.parser=(parser = RFC3986_PARSER)
|
26
|
+
remove_const(:Parser) if defined?(::Bundler::URI::Parser)
|
27
|
+
const_set("Parser", parser.class)
|
28
|
+
|
29
|
+
remove_const(:REGEXP) if defined?(::Bundler::URI::REGEXP)
|
30
|
+
remove_const(:PATTERN) if defined?(::Bundler::URI::PATTERN)
|
31
|
+
if Parser == RFC2396_Parser
|
32
|
+
const_set("REGEXP", Bundler::URI::RFC2396_REGEXP)
|
33
|
+
const_set("PATTERN", Bundler::URI::RFC2396_REGEXP::PATTERN)
|
34
|
+
end
|
20
35
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
unless REGEXP::PATTERN.const_defined?(sym)
|
25
|
-
REGEXP::PATTERN.const_set(sym, str)
|
36
|
+
Parser.new.regexp.each_pair do |sym, str|
|
37
|
+
remove_const(sym) if const_defined?(sym, false)
|
38
|
+
const_set(sym, str)
|
26
39
|
end
|
27
40
|
end
|
28
|
-
|
29
|
-
|
41
|
+
self.parser = RFC3986_PARSER
|
42
|
+
|
43
|
+
def self.const_missing(const)
|
44
|
+
if const == :REGEXP
|
45
|
+
warn "Bundler::URI::REGEXP is obsolete. Use Bundler::URI::RFC2396_REGEXP explicitly.", uplevel: 1 if $VERBOSE
|
46
|
+
Bundler::URI::RFC2396_REGEXP
|
47
|
+
elsif value = RFC2396_PARSER.regexp[const]
|
48
|
+
warn "Bundler::URI::#{const} is obsolete. Use RFC2396_PARSER.regexp[#{const.inspect}] explicitly.", uplevel: 1 if $VERBOSE
|
49
|
+
value
|
50
|
+
elsif value = RFC2396_Parser.const_get(const)
|
51
|
+
warn "Bundler::URI::#{const} is obsolete. Use RFC2396_Parser::#{const} explicitly.", uplevel: 1 if $VERBOSE
|
52
|
+
value
|
53
|
+
else
|
54
|
+
super
|
55
|
+
end
|
30
56
|
end
|
31
57
|
|
32
58
|
module Util # :nodoc:
|
@@ -61,88 +87,72 @@ module Bundler::URI
|
|
61
87
|
module_function :make_components_hash
|
62
88
|
end
|
63
89
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
# == Synopsis
|
68
|
-
#
|
69
|
-
# Bundler::URI.escape(str [, unsafe])
|
70
|
-
#
|
71
|
-
# == Args
|
72
|
-
#
|
73
|
-
# +str+::
|
74
|
-
# String to replaces in.
|
75
|
-
# +unsafe+::
|
76
|
-
# Regexp that matches all symbols that must be replaced with codes.
|
77
|
-
# By default uses <tt>UNSAFE</tt>.
|
78
|
-
# When this argument is a String, it represents a character set.
|
79
|
-
#
|
80
|
-
# == Description
|
81
|
-
#
|
82
|
-
# Escapes the string, replacing all unsafe characters with codes.
|
83
|
-
#
|
84
|
-
# This method is obsolete and should not be used. Instead, use
|
85
|
-
# CGI.escape, Bundler::URI.encode_www_form or Bundler::URI.encode_www_form_component
|
86
|
-
# depending on your specific use case.
|
87
|
-
#
|
88
|
-
# == Usage
|
89
|
-
#
|
90
|
-
# require 'bundler/vendor/uri/lib/uri'
|
91
|
-
#
|
92
|
-
# enc_uri = Bundler::URI.escape("http://example.com/?a=\11\15")
|
93
|
-
# # => "http://example.com/?a=%09%0D"
|
94
|
-
#
|
95
|
-
# Bundler::URI.unescape(enc_uri)
|
96
|
-
# # => "http://example.com/?a=\t\r"
|
97
|
-
#
|
98
|
-
# Bundler::URI.escape("@?@!", "!?")
|
99
|
-
# # => "@%3F@%21"
|
100
|
-
#
|
101
|
-
def escape(*arg)
|
102
|
-
warn "Bundler::URI.escape is obsolete", uplevel: 1
|
103
|
-
DEFAULT_PARSER.escape(*arg)
|
104
|
-
end
|
105
|
-
alias encode escape
|
106
|
-
#
|
107
|
-
# == Synopsis
|
108
|
-
#
|
109
|
-
# Bundler::URI.unescape(str)
|
110
|
-
#
|
111
|
-
# == Args
|
112
|
-
#
|
113
|
-
# +str+::
|
114
|
-
# String to unescape.
|
115
|
-
#
|
116
|
-
# == Description
|
117
|
-
#
|
118
|
-
# This method is obsolete and should not be used. Instead, use
|
119
|
-
# CGI.unescape, Bundler::URI.decode_www_form or Bundler::URI.decode_www_form_component
|
120
|
-
# depending on your specific use case.
|
121
|
-
#
|
122
|
-
# == Usage
|
123
|
-
#
|
124
|
-
# require 'bundler/vendor/uri/lib/uri'
|
125
|
-
#
|
126
|
-
# enc_uri = Bundler::URI.escape("http://example.com/?a=\11\15")
|
127
|
-
# # => "http://example.com/?a=%09%0D"
|
128
|
-
#
|
129
|
-
# Bundler::URI.unescape(enc_uri)
|
130
|
-
# # => "http://example.com/?a=\t\r"
|
131
|
-
#
|
132
|
-
def unescape(*arg)
|
133
|
-
warn "Bundler::URI.unescape is obsolete", uplevel: 1
|
134
|
-
DEFAULT_PARSER.unescape(*arg)
|
135
|
-
end
|
136
|
-
alias decode unescape
|
137
|
-
end # module Escape
|
90
|
+
module Schemes
|
91
|
+
end
|
92
|
+
private_constant :Schemes
|
138
93
|
|
139
|
-
|
140
|
-
|
94
|
+
# Registers the given +klass+ as the class to be instantiated
|
95
|
+
# when parsing a \Bundler::URI with the given +scheme+:
|
96
|
+
#
|
97
|
+
# Bundler::URI.register_scheme('MS_SEARCH', Bundler::URI::Generic) # => Bundler::URI::Generic
|
98
|
+
# Bundler::URI.scheme_list['MS_SEARCH'] # => Bundler::URI::Generic
|
99
|
+
#
|
100
|
+
# Note that after calling String#upcase on +scheme+, it must be a valid
|
101
|
+
# constant name.
|
102
|
+
def self.register_scheme(scheme, klass)
|
103
|
+
Schemes.const_set(scheme.to_s.upcase, klass)
|
104
|
+
end
|
141
105
|
|
142
|
-
|
143
|
-
#
|
106
|
+
# Returns a hash of the defined schemes:
|
107
|
+
#
|
108
|
+
# Bundler::URI.scheme_list
|
109
|
+
# # =>
|
110
|
+
# {"MAILTO"=>Bundler::URI::MailTo,
|
111
|
+
# "LDAPS"=>Bundler::URI::LDAPS,
|
112
|
+
# "WS"=>Bundler::URI::WS,
|
113
|
+
# "HTTP"=>Bundler::URI::HTTP,
|
114
|
+
# "HTTPS"=>Bundler::URI::HTTPS,
|
115
|
+
# "LDAP"=>Bundler::URI::LDAP,
|
116
|
+
# "FILE"=>Bundler::URI::File,
|
117
|
+
# "FTP"=>Bundler::URI::FTP}
|
118
|
+
#
|
119
|
+
# Related: Bundler::URI.register_scheme.
|
144
120
|
def self.scheme_list
|
145
|
-
|
121
|
+
Schemes.constants.map { |name|
|
122
|
+
[name.to_s.upcase, Schemes.const_get(name)]
|
123
|
+
}.to_h
|
124
|
+
end
|
125
|
+
|
126
|
+
INITIAL_SCHEMES = scheme_list
|
127
|
+
private_constant :INITIAL_SCHEMES
|
128
|
+
Ractor.make_shareable(INITIAL_SCHEMES) if defined?(Ractor)
|
129
|
+
|
130
|
+
# Returns a new object constructed from the given +scheme+, +arguments+,
|
131
|
+
# and +default+:
|
132
|
+
#
|
133
|
+
# - The new object is an instance of <tt>Bundler::URI.scheme_list[scheme.upcase]</tt>.
|
134
|
+
# - The object is initialized by calling the class initializer
|
135
|
+
# using +scheme+ and +arguments+.
|
136
|
+
# See Bundler::URI::Generic.new.
|
137
|
+
#
|
138
|
+
# Examples:
|
139
|
+
#
|
140
|
+
# values = ['john.doe', 'www.example.com', '123', nil, '/forum/questions/', nil, 'tag=networking&order=newest', 'top']
|
141
|
+
# Bundler::URI.for('https', *values)
|
142
|
+
# # => #<Bundler::URI::HTTPS https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
|
143
|
+
# Bundler::URI.for('foo', *values, default: Bundler::URI::HTTP)
|
144
|
+
# # => #<Bundler::URI::HTTP foo://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
|
145
|
+
#
|
146
|
+
def self.for(scheme, *arguments, default: Generic)
|
147
|
+
const_name = scheme.to_s.upcase
|
148
|
+
|
149
|
+
uri_class = INITIAL_SCHEMES[const_name]
|
150
|
+
uri_class ||= if /\A[A-Z]\w*\z/.match?(const_name) && Schemes.const_defined?(const_name, false)
|
151
|
+
Schemes.const_get(const_name, false)
|
152
|
+
end
|
153
|
+
uri_class ||= default
|
154
|
+
|
155
|
+
return uri_class.new(scheme, *arguments)
|
146
156
|
end
|
147
157
|
|
148
158
|
#
|
@@ -162,95 +172,49 @@ module Bundler::URI
|
|
162
172
|
#
|
163
173
|
class BadURIError < Error; end
|
164
174
|
|
165
|
-
#
|
166
|
-
#
|
167
|
-
#
|
168
|
-
#
|
169
|
-
#
|
170
|
-
#
|
171
|
-
#
|
172
|
-
#
|
173
|
-
#
|
174
|
-
#
|
175
|
-
#
|
176
|
-
#
|
177
|
-
#
|
178
|
-
#
|
179
|
-
#
|
180
|
-
#
|
181
|
-
#
|
182
|
-
# * Port
|
183
|
-
# * Registry
|
184
|
-
# * Path
|
185
|
-
# * Opaque
|
186
|
-
# * Query
|
187
|
-
# * Fragment
|
188
|
-
#
|
189
|
-
# == Usage
|
190
|
-
#
|
191
|
-
# require 'bundler/vendor/uri/lib/uri'
|
192
|
-
#
|
193
|
-
# Bundler::URI.split("http://www.ruby-lang.org/")
|
194
|
-
# # => ["http", nil, "www.ruby-lang.org", nil, nil, "/", nil, nil, nil]
|
175
|
+
# Returns a 9-element array representing the parts of the \Bundler::URI
|
176
|
+
# formed from the string +uri+;
|
177
|
+
# each array element is a string or +nil+:
|
178
|
+
#
|
179
|
+
# names = %w[scheme userinfo host port registry path opaque query fragment]
|
180
|
+
# values = Bundler::URI.split('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
|
181
|
+
# names.zip(values)
|
182
|
+
# # =>
|
183
|
+
# [["scheme", "https"],
|
184
|
+
# ["userinfo", "john.doe"],
|
185
|
+
# ["host", "www.example.com"],
|
186
|
+
# ["port", "123"],
|
187
|
+
# ["registry", nil],
|
188
|
+
# ["path", "/forum/questions/"],
|
189
|
+
# ["opaque", nil],
|
190
|
+
# ["query", "tag=networking&order=newest"],
|
191
|
+
# ["fragment", "top"]]
|
195
192
|
#
|
196
193
|
def self.split(uri)
|
197
|
-
|
194
|
+
DEFAULT_PARSER.split(uri)
|
198
195
|
end
|
199
196
|
|
197
|
+
# Returns a new \Bundler::URI object constructed from the given string +uri+:
|
200
198
|
#
|
201
|
-
#
|
202
|
-
#
|
203
|
-
# Bundler::URI
|
199
|
+
# Bundler::URI.parse('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
|
200
|
+
# # => #<Bundler::URI::HTTPS https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
|
201
|
+
# Bundler::URI.parse('http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
|
202
|
+
# # => #<Bundler::URI::HTTP http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
|
204
203
|
#
|
205
|
-
#
|
206
|
-
#
|
207
|
-
# +uri_str+::
|
208
|
-
# String with Bundler::URI.
|
209
|
-
#
|
210
|
-
# == Description
|
211
|
-
#
|
212
|
-
# Creates one of the Bundler::URI's subclasses instance from the string.
|
213
|
-
#
|
214
|
-
# == Raises
|
215
|
-
#
|
216
|
-
# Bundler::URI::InvalidURIError::
|
217
|
-
# Raised if Bundler::URI given is not a correct one.
|
218
|
-
#
|
219
|
-
# == Usage
|
220
|
-
#
|
221
|
-
# require 'bundler/vendor/uri/lib/uri'
|
222
|
-
#
|
223
|
-
# uri = Bundler::URI.parse("http://www.ruby-lang.org/")
|
224
|
-
# # => #<Bundler::URI::HTTP http://www.ruby-lang.org/>
|
225
|
-
# uri.scheme
|
226
|
-
# # => "http"
|
227
|
-
# uri.host
|
228
|
-
# # => "www.ruby-lang.org"
|
229
|
-
#
|
230
|
-
# It's recommended to first ::escape the provided +uri_str+ if there are any
|
231
|
-
# invalid Bundler::URI characters.
|
204
|
+
# It's recommended to first ::escape string +uri+
|
205
|
+
# if it may contain invalid Bundler::URI characters.
|
232
206
|
#
|
233
207
|
def self.parse(uri)
|
234
|
-
|
208
|
+
DEFAULT_PARSER.parse(uri)
|
235
209
|
end
|
236
210
|
|
211
|
+
# Merges the given Bundler::URI strings +str+
|
212
|
+
# per {RFC 2396}[https://www.rfc-editor.org/rfc/rfc2396.html].
|
237
213
|
#
|
238
|
-
#
|
239
|
-
#
|
240
|
-
# Bundler::URI::join(str[, str, ...])
|
241
|
-
#
|
242
|
-
# == Args
|
243
|
-
#
|
244
|
-
# +str+::
|
245
|
-
# String(s) to work with, will be converted to RFC3986 URIs before merging.
|
246
|
-
#
|
247
|
-
# == Description
|
248
|
-
#
|
249
|
-
# Joins URIs.
|
250
|
-
#
|
251
|
-
# == Usage
|
214
|
+
# Each string in +str+ is converted to an
|
215
|
+
# {RFC3986 Bundler::URI}[https://www.rfc-editor.org/rfc/rfc3986.html] before being merged.
|
252
216
|
#
|
253
|
-
#
|
217
|
+
# Examples:
|
254
218
|
#
|
255
219
|
# Bundler::URI.join("http://example.com/","main.rbx")
|
256
220
|
# # => #<Bundler::URI::HTTP http://example.com/main.rbx>
|
@@ -268,7 +232,7 @@ module Bundler::URI
|
|
268
232
|
# # => #<Bundler::URI::HTTP http://example.com/foo/bar>
|
269
233
|
#
|
270
234
|
def self.join(*str)
|
271
|
-
|
235
|
+
DEFAULT_PARSER.join(*str)
|
272
236
|
end
|
273
237
|
|
274
238
|
#
|
@@ -295,7 +259,7 @@ module Bundler::URI
|
|
295
259
|
# Bundler::URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.")
|
296
260
|
# # => ["http://foo.example.com/bla", "mailto:test@example.com"]
|
297
261
|
#
|
298
|
-
def self.extract(str, schemes = nil, &block)
|
262
|
+
def self.extract(str, schemes = nil, &block) # :nodoc:
|
299
263
|
warn "Bundler::URI.extract is obsolete", uplevel: 1 if $VERBOSE
|
300
264
|
DEFAULT_PARSER.extract(str, schemes, &block)
|
301
265
|
end
|
@@ -315,7 +279,7 @@ module Bundler::URI
|
|
315
279
|
#
|
316
280
|
# Returns a Regexp object which matches to Bundler::URI-like strings.
|
317
281
|
# The Regexp object returned by this method includes arbitrary
|
318
|
-
# number of capture group (parentheses). Never rely on
|
282
|
+
# number of capture group (parentheses). Never rely on its number.
|
319
283
|
#
|
320
284
|
# == Usage
|
321
285
|
#
|
@@ -332,7 +296,7 @@ module Bundler::URI
|
|
332
296
|
# p $&
|
333
297
|
# end
|
334
298
|
#
|
335
|
-
def self.regexp(schemes = nil)
|
299
|
+
def self.regexp(schemes = nil)# :nodoc:
|
336
300
|
warn "Bundler::URI.regexp is obsolete", uplevel: 1 if $VERBOSE
|
337
301
|
DEFAULT_PARSER.make_regexp(schemes)
|
338
302
|
end
|
@@ -341,6 +305,7 @@ module Bundler::URI
|
|
341
305
|
256.times do |i|
|
342
306
|
TBLENCWWWCOMP_[-i.chr] = -('%%%02X' % i)
|
343
307
|
end
|
308
|
+
TBLENCURICOMP_ = TBLENCWWWCOMP_.dup.freeze
|
344
309
|
TBLENCWWWCOMP_[' '] = '+'
|
345
310
|
TBLENCWWWCOMP_.freeze
|
346
311
|
TBLDECWWWCOMP_ = {} # :nodoc:
|
@@ -354,18 +319,91 @@ module Bundler::URI
|
|
354
319
|
TBLDECWWWCOMP_['+'] = ' '
|
355
320
|
TBLDECWWWCOMP_.freeze
|
356
321
|
|
357
|
-
#
|
322
|
+
# Returns a URL-encoded string derived from the given string +str+.
|
358
323
|
#
|
359
|
-
#
|
360
|
-
# (ASCII space) to + and converts others to %XX.
|
324
|
+
# The returned string:
|
361
325
|
#
|
362
|
-
#
|
326
|
+
# - Preserves:
|
363
327
|
#
|
364
|
-
#
|
365
|
-
#
|
328
|
+
# - Characters <tt>'*'</tt>, <tt>'.'</tt>, <tt>'-'</tt>, and <tt>'_'</tt>.
|
329
|
+
# - Character in ranges <tt>'a'..'z'</tt>, <tt>'A'..'Z'</tt>,
|
330
|
+
# and <tt>'0'..'9'</tt>.
|
366
331
|
#
|
367
|
-
#
|
332
|
+
# Example:
|
333
|
+
#
|
334
|
+
# Bundler::URI.encode_www_form_component('*.-_azAZ09')
|
335
|
+
# # => "*.-_azAZ09"
|
336
|
+
#
|
337
|
+
# - Converts:
|
338
|
+
#
|
339
|
+
# - Character <tt>' '</tt> to character <tt>'+'</tt>.
|
340
|
+
# - Any other character to "percent notation";
|
341
|
+
# the percent notation for character <i>c</i> is <tt>'%%%X' % c.ord</tt>.
|
342
|
+
#
|
343
|
+
# Example:
|
344
|
+
#
|
345
|
+
# Bundler::URI.encode_www_form_component('Here are some punctuation characters: ,;?:')
|
346
|
+
# # => "Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A"
|
347
|
+
#
|
348
|
+
# Encoding:
|
349
|
+
#
|
350
|
+
# - If +str+ has encoding Encoding::ASCII_8BIT, argument +enc+ is ignored.
|
351
|
+
# - Otherwise +str+ is converted first to Encoding::UTF_8
|
352
|
+
# (with suitable character replacements),
|
353
|
+
# and then to encoding +enc+.
|
354
|
+
#
|
355
|
+
# In either case, the returned string has forced encoding Encoding::US_ASCII.
|
356
|
+
#
|
357
|
+
# Related: Bundler::URI.encode_uri_component (encodes <tt>' '</tt> as <tt>'%20'</tt>).
|
368
358
|
def self.encode_www_form_component(str, enc=nil)
|
359
|
+
_encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_, str, enc)
|
360
|
+
end
|
361
|
+
|
362
|
+
# Returns a string decoded from the given \URL-encoded string +str+.
|
363
|
+
#
|
364
|
+
# The given string is first encoded as Encoding::ASCII-8BIT (using String#b),
|
365
|
+
# then decoded (as below), and finally force-encoded to the given encoding +enc+.
|
366
|
+
#
|
367
|
+
# The returned string:
|
368
|
+
#
|
369
|
+
# - Preserves:
|
370
|
+
#
|
371
|
+
# - Characters <tt>'*'</tt>, <tt>'.'</tt>, <tt>'-'</tt>, and <tt>'_'</tt>.
|
372
|
+
# - Character in ranges <tt>'a'..'z'</tt>, <tt>'A'..'Z'</tt>,
|
373
|
+
# and <tt>'0'..'9'</tt>.
|
374
|
+
#
|
375
|
+
# Example:
|
376
|
+
#
|
377
|
+
# Bundler::URI.decode_www_form_component('*.-_azAZ09')
|
378
|
+
# # => "*.-_azAZ09"
|
379
|
+
#
|
380
|
+
# - Converts:
|
381
|
+
#
|
382
|
+
# - Character <tt>'+'</tt> to character <tt>' '</tt>.
|
383
|
+
# - Each "percent notation" to an ASCII character.
|
384
|
+
#
|
385
|
+
# Example:
|
386
|
+
#
|
387
|
+
# Bundler::URI.decode_www_form_component('Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A')
|
388
|
+
# # => "Here are some punctuation characters: ,;?:"
|
389
|
+
#
|
390
|
+
# Related: Bundler::URI.decode_uri_component (preserves <tt>'+'</tt>).
|
391
|
+
def self.decode_www_form_component(str, enc=Encoding::UTF_8)
|
392
|
+
_decode_uri_component(/\+|%\h\h/, str, enc)
|
393
|
+
end
|
394
|
+
|
395
|
+
# Like Bundler::URI.encode_www_form_component, except that <tt>' '</tt> (space)
|
396
|
+
# is encoded as <tt>'%20'</tt> (instead of <tt>'+'</tt>).
|
397
|
+
def self.encode_uri_component(str, enc=nil)
|
398
|
+
_encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCURICOMP_, str, enc)
|
399
|
+
end
|
400
|
+
|
401
|
+
# Like Bundler::URI.decode_www_form_component, except that <tt>'+'</tt> is preserved.
|
402
|
+
def self.decode_uri_component(str, enc=Encoding::UTF_8)
|
403
|
+
_decode_uri_component(/%\h\h/, str, enc)
|
404
|
+
end
|
405
|
+
|
406
|
+
def self._encode_uri_component(regexp, table, str, enc)
|
369
407
|
str = str.to_s.dup
|
370
408
|
if str.encoding != Encoding::ASCII_8BIT
|
371
409
|
if enc && enc != Encoding::ASCII_8BIT
|
@@ -374,47 +412,115 @@ module Bundler::URI
|
|
374
412
|
end
|
375
413
|
str.force_encoding(Encoding::ASCII_8BIT)
|
376
414
|
end
|
377
|
-
str.gsub!(
|
415
|
+
str.gsub!(regexp, table)
|
378
416
|
str.force_encoding(Encoding::US_ASCII)
|
379
417
|
end
|
418
|
+
private_class_method :_encode_uri_component
|
380
419
|
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
#
|
385
|
-
# See Bundler::URI.encode_www_form_component, Bundler::URI.decode_www_form.
|
386
|
-
def self.decode_www_form_component(str, enc=Encoding::UTF_8)
|
387
|
-
raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/ =~ str
|
388
|
-
str.b.gsub(/\+|%\h\h/, TBLDECWWWCOMP_).force_encoding(enc)
|
420
|
+
def self._decode_uri_component(regexp, str, enc)
|
421
|
+
raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/.match?(str)
|
422
|
+
str.b.gsub(regexp, TBLDECWWWCOMP_).force_encoding(enc)
|
389
423
|
end
|
424
|
+
private_class_method :_decode_uri_component
|
390
425
|
|
391
|
-
#
|
426
|
+
# Returns a URL-encoded string derived from the given
|
427
|
+
# {Enumerable}[https://docs.ruby-lang.org/en/master/Enumerable.html#module-Enumerable-label-Enumerable+in+Ruby+Classes]
|
428
|
+
# +enum+.
|
429
|
+
#
|
430
|
+
# The result is suitable for use as form data
|
431
|
+
# for an \HTTP request whose <tt>Content-Type</tt> is
|
432
|
+
# <tt>'application/x-www-form-urlencoded'</tt>.
|
392
433
|
#
|
393
|
-
#
|
394
|
-
#
|
434
|
+
# The returned string consists of the elements of +enum+,
|
435
|
+
# each converted to one or more URL-encoded strings,
|
436
|
+
# and all joined with character <tt>'&'</tt>.
|
395
437
|
#
|
396
|
-
#
|
438
|
+
# Simple examples:
|
397
439
|
#
|
398
|
-
#
|
399
|
-
#
|
400
|
-
#
|
401
|
-
#
|
440
|
+
# Bundler::URI.encode_www_form([['foo', 0], ['bar', 1], ['baz', 2]])
|
441
|
+
# # => "foo=0&bar=1&baz=2"
|
442
|
+
# Bundler::URI.encode_www_form({foo: 0, bar: 1, baz: 2})
|
443
|
+
# # => "foo=0&bar=1&baz=2"
|
402
444
|
#
|
403
|
-
#
|
404
|
-
#
|
445
|
+
# The returned string is formed using method Bundler::URI.encode_www_form_component,
|
446
|
+
# which converts certain characters:
|
405
447
|
#
|
406
|
-
#
|
448
|
+
# Bundler::URI.encode_www_form('f#o': '/', 'b-r': '$', 'b z': '@')
|
449
|
+
# # => "f%23o=%2F&b-r=%24&b+z=%40"
|
407
450
|
#
|
408
|
-
#
|
409
|
-
#
|
410
|
-
#
|
411
|
-
#
|
412
|
-
#
|
413
|
-
#
|
414
|
-
#
|
415
|
-
#
|
451
|
+
# When +enum+ is Array-like, each element +ele+ is converted to a field:
|
452
|
+
#
|
453
|
+
# - If +ele+ is an array of two or more elements,
|
454
|
+
# the field is formed from its first two elements
|
455
|
+
# (and any additional elements are ignored):
|
456
|
+
#
|
457
|
+
# name = Bundler::URI.encode_www_form_component(ele[0], enc)
|
458
|
+
# value = Bundler::URI.encode_www_form_component(ele[1], enc)
|
459
|
+
# "#{name}=#{value}"
|
460
|
+
#
|
461
|
+
# Examples:
|
462
|
+
#
|
463
|
+
# Bundler::URI.encode_www_form([%w[foo bar], %w[baz bat bah]])
|
464
|
+
# # => "foo=bar&baz=bat"
|
465
|
+
# Bundler::URI.encode_www_form([['foo', 0], ['bar', :baz, 'bat']])
|
466
|
+
# # => "foo=0&bar=baz"
|
467
|
+
#
|
468
|
+
# - If +ele+ is an array of one element,
|
469
|
+
# the field is formed from <tt>ele[0]</tt>:
|
470
|
+
#
|
471
|
+
# Bundler::URI.encode_www_form_component(ele[0])
|
472
|
+
#
|
473
|
+
# Example:
|
474
|
+
#
|
475
|
+
# Bundler::URI.encode_www_form([['foo'], [:bar], [0]])
|
476
|
+
# # => "foo&bar&0"
|
477
|
+
#
|
478
|
+
# - Otherwise the field is formed from +ele+:
|
479
|
+
#
|
480
|
+
# Bundler::URI.encode_www_form_component(ele)
|
481
|
+
#
|
482
|
+
# Example:
|
483
|
+
#
|
484
|
+
# Bundler::URI.encode_www_form(['foo', :bar, 0])
|
485
|
+
# # => "foo&bar&0"
|
486
|
+
#
|
487
|
+
# The elements of an Array-like +enum+ may be mixture:
|
488
|
+
#
|
489
|
+
# Bundler::URI.encode_www_form([['foo', 0], ['bar', 1, 2], ['baz'], :bat])
|
490
|
+
# # => "foo=0&bar=1&baz&bat"
|
491
|
+
#
|
492
|
+
# When +enum+ is Hash-like,
|
493
|
+
# each +key+/+value+ pair is converted to one or more fields:
|
494
|
+
#
|
495
|
+
# - If +value+ is
|
496
|
+
# {Array-convertible}[https://docs.ruby-lang.org/en/master/implicit_conversion_rdoc.html#label-Array-Convertible+Objects],
|
497
|
+
# each element +ele+ in +value+ is paired with +key+ to form a field:
|
498
|
+
#
|
499
|
+
# name = Bundler::URI.encode_www_form_component(key, enc)
|
500
|
+
# value = Bundler::URI.encode_www_form_component(ele, enc)
|
501
|
+
# "#{name}=#{value}"
|
502
|
+
#
|
503
|
+
# Example:
|
504
|
+
#
|
505
|
+
# Bundler::URI.encode_www_form({foo: [:bar, 1], baz: [:bat, :bam, 2]})
|
506
|
+
# # => "foo=bar&foo=1&baz=bat&baz=bam&baz=2"
|
507
|
+
#
|
508
|
+
# - Otherwise, +key+ and +value+ are paired to form a field:
|
509
|
+
#
|
510
|
+
# name = Bundler::URI.encode_www_form_component(key, enc)
|
511
|
+
# value = Bundler::URI.encode_www_form_component(value, enc)
|
512
|
+
# "#{name}=#{value}"
|
513
|
+
#
|
514
|
+
# Example:
|
515
|
+
#
|
516
|
+
# Bundler::URI.encode_www_form({foo: 0, bar: 1, baz: 2})
|
517
|
+
# # => "foo=0&bar=1&baz=2"
|
518
|
+
#
|
519
|
+
# The elements of a Hash-like +enum+ may be mixture:
|
520
|
+
#
|
521
|
+
# Bundler::URI.encode_www_form({foo: [0, 1], bar: 2})
|
522
|
+
# # => "foo=0&foo=1&bar=2"
|
416
523
|
#
|
417
|
-
# See Bundler::URI.encode_www_form_component, Bundler::URI.decode_www_form.
|
418
524
|
def self.encode_www_form(enum, enc=nil)
|
419
525
|
enum.map do |k,v|
|
420
526
|
if v.nil?
|
@@ -435,22 +541,39 @@ module Bundler::URI
|
|
435
541
|
end.join('&')
|
436
542
|
end
|
437
543
|
|
438
|
-
#
|
544
|
+
# Returns name/value pairs derived from the given string +str+,
|
545
|
+
# which must be an ASCII string.
|
439
546
|
#
|
440
|
-
#
|
441
|
-
#
|
547
|
+
# The method may be used to decode the body of Net::HTTPResponse object +res+
|
548
|
+
# for which <tt>res['Content-Type']</tt> is <tt>'application/x-www-form-urlencoded'</tt>.
|
442
549
|
#
|
443
|
-
#
|
444
|
-
#
|
550
|
+
# The returned data is an array of 2-element subarrays;
|
551
|
+
# each subarray is a name/value pair (both are strings).
|
552
|
+
# Each returned string has encoding +enc+,
|
553
|
+
# and has had invalid characters removed via
|
554
|
+
# {String#scrub}[https://docs.ruby-lang.org/en/master/String.html#method-i-scrub].
|
445
555
|
#
|
446
|
-
#
|
447
|
-
#
|
448
|
-
#
|
449
|
-
#
|
450
|
-
#
|
451
|
-
#
|
556
|
+
# A simple example:
|
557
|
+
#
|
558
|
+
# Bundler::URI.decode_www_form('foo=0&bar=1&baz')
|
559
|
+
# # => [["foo", "0"], ["bar", "1"], ["baz", ""]]
|
560
|
+
#
|
561
|
+
# The returned strings have certain conversions,
|
562
|
+
# similar to those performed in Bundler::URI.decode_www_form_component:
|
563
|
+
#
|
564
|
+
# Bundler::URI.decode_www_form('f%23o=%2F&b-r=%24&b+z=%40')
|
565
|
+
# # => [["f#o", "/"], ["b-r", "$"], ["b z", "@"]]
|
566
|
+
#
|
567
|
+
# The given string may contain consecutive separators:
|
568
|
+
#
|
569
|
+
# Bundler::URI.decode_www_form('foo=0&&bar=1&&baz=2')
|
570
|
+
# # => [["foo", "0"], ["", ""], ["bar", "1"], ["", ""], ["baz", "2"]]
|
571
|
+
#
|
572
|
+
# A different separator may be specified:
|
573
|
+
#
|
574
|
+
# Bundler::URI.decode_www_form('foo=0--bar=1--baz', separator: '--')
|
575
|
+
# # => [["foo", "0"], ["bar", "1"], ["baz", ""]]
|
452
576
|
#
|
453
|
-
# See Bundler::URI.decode_www_form_component, Bundler::URI.encode_www_form.
|
454
577
|
def self.decode_www_form(str, enc=Encoding::UTF_8, separator: '&', use__charset_: false, isindex: false)
|
455
578
|
raise ArgumentError, "the input of #{self.name}.#{__method__} must be ASCII only string" unless str.ascii_only?
|
456
579
|
ary = []
|
@@ -716,6 +839,7 @@ module Bundler::URI
|
|
716
839
|
"utf-16"=>"utf-16le",
|
717
840
|
"utf-16le"=>"utf-16le",
|
718
841
|
} # :nodoc:
|
842
|
+
Ractor.make_shareable(WEB_ENCODINGS_) if defined?(Ractor)
|
719
843
|
|
720
844
|
# :nodoc:
|
721
845
|
# return encoding or nil
|
@@ -728,7 +852,15 @@ end # module Bundler::URI
|
|
728
852
|
module Bundler
|
729
853
|
|
730
854
|
#
|
731
|
-
# Returns
|
855
|
+
# Returns a \Bundler::URI object derived from the given +uri+,
|
856
|
+
# which may be a \Bundler::URI string or an existing \Bundler::URI object:
|
857
|
+
#
|
858
|
+
# # Returns a new Bundler::URI.
|
859
|
+
# uri = Bundler::URI('http://github.com/ruby/ruby')
|
860
|
+
# # => #<Bundler::URI::HTTP http://github.com/ruby/ruby>
|
861
|
+
# # Returns the given Bundler::URI.
|
862
|
+
# Bundler::URI(uri)
|
863
|
+
# # => #<Bundler::URI::HTTP http://github.com/ruby/ruby>
|
732
864
|
#
|
733
865
|
def URI(uri)
|
734
866
|
if uri.is_a?(Bundler::URI::Generic)
|