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
@@ -1,8 +1,10 @@
|
|
1
|
+
require_relative "column_printer"
|
2
|
+
require_relative "table_printer"
|
3
|
+
require_relative "wrapped_printer"
|
4
|
+
|
1
5
|
class Bundler::Thor
|
2
6
|
module Shell
|
3
7
|
class Basic
|
4
|
-
DEFAULT_TERMINAL_WIDTH = 80
|
5
|
-
|
6
8
|
attr_accessor :base
|
7
9
|
attr_reader :padding
|
8
10
|
|
@@ -65,15 +67,15 @@ class Bundler::Thor
|
|
65
67
|
# Readline.
|
66
68
|
#
|
67
69
|
# ==== Example
|
68
|
-
#
|
70
|
+
# ask("What is your name?")
|
69
71
|
#
|
70
|
-
#
|
72
|
+
# ask("What is the planet furthest from the sun?", :default => "Neptune")
|
71
73
|
#
|
72
|
-
#
|
74
|
+
# ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"])
|
73
75
|
#
|
74
|
-
#
|
76
|
+
# ask("What is your password?", :echo => false)
|
75
77
|
#
|
76
|
-
#
|
78
|
+
# ask("Where should the file be saved?", :path => true)
|
77
79
|
#
|
78
80
|
def ask(statement, *args)
|
79
81
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
@@ -91,7 +93,7 @@ class Bundler::Thor
|
|
91
93
|
# are passed straight to puts (behavior got from Highline).
|
92
94
|
#
|
93
95
|
# ==== Example
|
94
|
-
#
|
96
|
+
# say("I know you knew that.")
|
95
97
|
#
|
96
98
|
def say(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
|
97
99
|
return if quiet?
|
@@ -103,6 +105,23 @@ class Bundler::Thor
|
|
103
105
|
stdout.flush
|
104
106
|
end
|
105
107
|
|
108
|
+
# Say (print) an error to the user. If the sentence ends with a whitespace
|
109
|
+
# or tab character, a new line is not appended (print + flush). Otherwise
|
110
|
+
# are passed straight to puts (behavior got from Highline).
|
111
|
+
#
|
112
|
+
# ==== Example
|
113
|
+
# say_error("error: something went wrong")
|
114
|
+
#
|
115
|
+
def say_error(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
|
116
|
+
return if quiet?
|
117
|
+
|
118
|
+
buffer = prepare_message(message, *color)
|
119
|
+
buffer << "\n" if force_new_line && !message.to_s.end_with?("\n")
|
120
|
+
|
121
|
+
stderr.print(buffer)
|
122
|
+
stderr.flush
|
123
|
+
end
|
124
|
+
|
106
125
|
# Say a status with the given color and appends the message. Since this
|
107
126
|
# method is used frequently by actions, it allows nil or false to be given
|
108
127
|
# in log_status, avoiding the message from being shown. If a Symbol is
|
@@ -111,30 +130,31 @@ class Bundler::Thor
|
|
111
130
|
def say_status(status, message, log_status = true)
|
112
131
|
return if quiet? || log_status == false
|
113
132
|
spaces = " " * (padding + 1)
|
114
|
-
color = log_status.is_a?(Symbol) ? log_status : :green
|
115
|
-
|
116
133
|
status = status.to_s.rjust(12)
|
134
|
+
margin = " " * status.length + spaces
|
135
|
+
|
136
|
+
color = log_status.is_a?(Symbol) ? log_status : :green
|
117
137
|
status = set_color status, color, true if color
|
118
138
|
|
119
|
-
|
120
|
-
buffer = "#{
|
139
|
+
message = message.to_s.chomp.gsub(/(?<!\A)^/, margin)
|
140
|
+
buffer = "#{status}#{spaces}#{message}\n"
|
121
141
|
|
122
142
|
stdout.print(buffer)
|
123
143
|
stdout.flush
|
124
144
|
end
|
125
145
|
|
126
|
-
#
|
146
|
+
# Asks the user a question and returns true if the user replies "y" or
|
127
147
|
# "yes".
|
128
148
|
#
|
129
149
|
def yes?(statement, color = nil)
|
130
|
-
!!(ask(statement, color, :
|
150
|
+
!!(ask(statement, color, add_to_history: false) =~ is?(:yes))
|
131
151
|
end
|
132
152
|
|
133
|
-
#
|
153
|
+
# Asks the user a question and returns true if the user replies "n" or
|
134
154
|
# "no".
|
135
155
|
#
|
136
156
|
def no?(statement, color = nil)
|
137
|
-
!!(ask(statement, color, :
|
157
|
+
!!(ask(statement, color, add_to_history: false) =~ is?(:no))
|
138
158
|
end
|
139
159
|
|
140
160
|
# Prints values in columns
|
@@ -143,16 +163,8 @@ class Bundler::Thor
|
|
143
163
|
# Array[String, String, ...]
|
144
164
|
#
|
145
165
|
def print_in_columns(array)
|
146
|
-
|
147
|
-
|
148
|
-
array.each_with_index do |value, index|
|
149
|
-
# Don't output trailing spaces when printing the last column
|
150
|
-
if ((((index + 1) % (terminal_width / colwidth))).zero? && !index.zero?) || index + 1 == array.length
|
151
|
-
stdout.puts value
|
152
|
-
else
|
153
|
-
stdout.printf("%-#{colwidth}s", value)
|
154
|
-
end
|
155
|
-
end
|
166
|
+
printer = ColumnPrinter.new(stdout)
|
167
|
+
printer.print(array)
|
156
168
|
end
|
157
169
|
|
158
170
|
# Prints a table.
|
@@ -163,58 +175,11 @@ class Bundler::Thor
|
|
163
175
|
# ==== Options
|
164
176
|
# indent<Integer>:: Indent the first column by indent value.
|
165
177
|
# colwidth<Integer>:: Force the first column to colwidth spaces wide.
|
178
|
+
# borders<Boolean>:: Adds ascii borders.
|
166
179
|
#
|
167
|
-
def print_table(array, options = {}) # rubocop:disable MethodLength
|
168
|
-
|
169
|
-
|
170
|
-
formats = []
|
171
|
-
indent = options[:indent].to_i
|
172
|
-
colwidth = options[:colwidth]
|
173
|
-
options[:truncate] = terminal_width if options[:truncate] == true
|
174
|
-
|
175
|
-
formats << "%-#{colwidth + 2}s".dup if colwidth
|
176
|
-
start = colwidth ? 1 : 0
|
177
|
-
|
178
|
-
colcount = array.max { |a, b| a.size <=> b.size }.size
|
179
|
-
|
180
|
-
maximas = []
|
181
|
-
|
182
|
-
start.upto(colcount - 1) do |index|
|
183
|
-
maxima = array.map { |row| row[index] ? row[index].to_s.size : 0 }.max
|
184
|
-
maximas << maxima
|
185
|
-
formats << if index == colcount - 1
|
186
|
-
# Don't output 2 trailing spaces when printing the last column
|
187
|
-
"%-s".dup
|
188
|
-
else
|
189
|
-
"%-#{maxima + 2}s".dup
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
formats[0] = formats[0].insert(0, " " * indent)
|
194
|
-
formats << "%s"
|
195
|
-
|
196
|
-
array.each do |row|
|
197
|
-
sentence = "".dup
|
198
|
-
|
199
|
-
row.each_with_index do |column, index|
|
200
|
-
maxima = maximas[index]
|
201
|
-
|
202
|
-
f = if column.is_a?(Numeric)
|
203
|
-
if index == row.size - 1
|
204
|
-
# Don't output 2 trailing spaces when printing the last column
|
205
|
-
"%#{maxima}s"
|
206
|
-
else
|
207
|
-
"%#{maxima}s "
|
208
|
-
end
|
209
|
-
else
|
210
|
-
formats[index]
|
211
|
-
end
|
212
|
-
sentence << f % column.to_s
|
213
|
-
end
|
214
|
-
|
215
|
-
sentence = truncate(sentence, options[:truncate]) if options[:truncate]
|
216
|
-
stdout.puts sentence
|
217
|
-
end
|
180
|
+
def print_table(array, options = {}) # rubocop:disable Metrics/MethodLength
|
181
|
+
printer = TablePrinter.new(stdout, options)
|
182
|
+
printer.print(array)
|
218
183
|
end
|
219
184
|
|
220
185
|
# Prints a long string, word-wrapping the text to the current width of the
|
@@ -227,33 +192,8 @@ class Bundler::Thor
|
|
227
192
|
# indent<Integer>:: Indent each line of the printed paragraph by indent value.
|
228
193
|
#
|
229
194
|
def print_wrapped(message, options = {})
|
230
|
-
|
231
|
-
|
232
|
-
paras = message.split("\n\n")
|
233
|
-
|
234
|
-
paras.map! do |unwrapped|
|
235
|
-
words = unwrapped.split(" ")
|
236
|
-
counter = words.first.length
|
237
|
-
words.inject do |memo, word|
|
238
|
-
word = word.gsub(/\n\005/, "\n").gsub(/\005/, "\n")
|
239
|
-
counter = 0 if word.include? "\n"
|
240
|
-
if (counter + word.length + 1) < width
|
241
|
-
memo = "#{memo} #{word}"
|
242
|
-
counter += (word.length + 1)
|
243
|
-
else
|
244
|
-
memo = "#{memo}\n#{word}"
|
245
|
-
counter = word.length
|
246
|
-
end
|
247
|
-
memo
|
248
|
-
end
|
249
|
-
end.compact!
|
250
|
-
|
251
|
-
paras.each do |para|
|
252
|
-
para.split("\n").each do |line|
|
253
|
-
stdout.puts line.insert(0, " " * indent)
|
254
|
-
end
|
255
|
-
stdout.puts unless para == paras.last
|
256
|
-
end
|
195
|
+
printer = WrappedPrinter.new(stdout, options)
|
196
|
+
printer.print(message)
|
257
197
|
end
|
258
198
|
|
259
199
|
# Deals with file collision and returns true if the file should be
|
@@ -271,7 +211,7 @@ class Bundler::Thor
|
|
271
211
|
loop do
|
272
212
|
answer = ask(
|
273
213
|
%[Overwrite #{destination}? (enter "h" for help) #{options}],
|
274
|
-
:
|
214
|
+
add_to_history: false
|
275
215
|
)
|
276
216
|
|
277
217
|
case answer
|
@@ -298,24 +238,11 @@ class Bundler::Thor
|
|
298
238
|
|
299
239
|
say "Please specify merge tool to `THOR_MERGE` env."
|
300
240
|
else
|
301
|
-
say file_collision_help
|
241
|
+
say file_collision_help(block_given?)
|
302
242
|
end
|
303
243
|
end
|
304
244
|
end
|
305
245
|
|
306
|
-
# This code was copied from Rake, available under MIT-LICENSE
|
307
|
-
# Copyright (c) 2003, 2004 Jim Weirich
|
308
|
-
def terminal_width
|
309
|
-
result = if ENV["THOR_COLUMNS"]
|
310
|
-
ENV["THOR_COLUMNS"].to_i
|
311
|
-
else
|
312
|
-
unix? ? dynamic_width : DEFAULT_TERMINAL_WIDTH
|
313
|
-
end
|
314
|
-
result < 10 ? DEFAULT_TERMINAL_WIDTH : result
|
315
|
-
rescue
|
316
|
-
DEFAULT_TERMINAL_WIDTH
|
317
|
-
end
|
318
|
-
|
319
246
|
# Called if something goes wrong during the execution. This is used by Bundler::Thor
|
320
247
|
# internally and should not be used inside your scripts. If something went
|
321
248
|
# wrong, you can always raise an exception. If you raise a Bundler::Thor::Error, it
|
@@ -366,16 +293,21 @@ class Bundler::Thor
|
|
366
293
|
end
|
367
294
|
end
|
368
295
|
|
369
|
-
def file_collision_help #:nodoc:
|
370
|
-
<<-HELP
|
296
|
+
def file_collision_help(block_given) #:nodoc:
|
297
|
+
help = <<-HELP
|
371
298
|
Y - yes, overwrite
|
372
299
|
n - no, do not overwrite
|
373
300
|
a - all, overwrite this and all others
|
374
301
|
q - quit, abort
|
375
|
-
d - diff, show the differences between the old and the new
|
376
302
|
h - help, show this help
|
377
|
-
m - merge, run merge tool
|
378
303
|
HELP
|
304
|
+
if block_given
|
305
|
+
help << <<-HELP
|
306
|
+
d - diff, show the differences between the old and the new
|
307
|
+
m - merge, run merge tool
|
308
|
+
HELP
|
309
|
+
end
|
310
|
+
help
|
379
311
|
end
|
380
312
|
|
381
313
|
def show_diff(destination, content) #:nodoc:
|
@@ -393,46 +325,8 @@ class Bundler::Thor
|
|
393
325
|
mute? || (base && base.options[:quiet])
|
394
326
|
end
|
395
327
|
|
396
|
-
# Calculate the dynamic width of the terminal
|
397
|
-
def dynamic_width
|
398
|
-
@dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
|
399
|
-
end
|
400
|
-
|
401
|
-
def dynamic_width_stty
|
402
|
-
`stty size 2>/dev/null`.split[1].to_i
|
403
|
-
end
|
404
|
-
|
405
|
-
def dynamic_width_tput
|
406
|
-
`tput cols 2>/dev/null`.to_i
|
407
|
-
end
|
408
|
-
|
409
328
|
def unix?
|
410
|
-
|
411
|
-
end
|
412
|
-
|
413
|
-
def truncate(string, width)
|
414
|
-
as_unicode do
|
415
|
-
chars = string.chars.to_a
|
416
|
-
if chars.length <= width
|
417
|
-
chars.join
|
418
|
-
else
|
419
|
-
chars[0, width - 3].join + "..."
|
420
|
-
end
|
421
|
-
end
|
422
|
-
end
|
423
|
-
|
424
|
-
if "".respond_to?(:encode)
|
425
|
-
def as_unicode
|
426
|
-
yield
|
427
|
-
end
|
428
|
-
else
|
429
|
-
def as_unicode
|
430
|
-
old = $KCODE
|
431
|
-
$KCODE = "U"
|
432
|
-
yield
|
433
|
-
ensure
|
434
|
-
$KCODE = old
|
435
|
-
end
|
329
|
+
Terminal.unix?
|
436
330
|
end
|
437
331
|
|
438
332
|
def ask_simply(statement, color, options)
|
@@ -105,52 +105,7 @@ class Bundler::Thor
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def are_colors_disabled?
|
108
|
-
!ENV[
|
109
|
-
end
|
110
|
-
|
111
|
-
# Overwrite show_diff to show diff with colors if Diff::LCS is
|
112
|
-
# available.
|
113
|
-
#
|
114
|
-
def show_diff(destination, content) #:nodoc:
|
115
|
-
if diff_lcs_loaded? && ENV["THOR_DIFF"].nil? && ENV["RAILS_DIFF"].nil?
|
116
|
-
actual = File.binread(destination).to_s.split("\n")
|
117
|
-
content = content.to_s.split("\n")
|
118
|
-
|
119
|
-
Diff::LCS.sdiff(actual, content).each do |diff|
|
120
|
-
output_diff_line(diff)
|
121
|
-
end
|
122
|
-
else
|
123
|
-
super
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
def output_diff_line(diff) #:nodoc:
|
128
|
-
case diff.action
|
129
|
-
when "-"
|
130
|
-
say "- #{diff.old_element.chomp}", :red, true
|
131
|
-
when "+"
|
132
|
-
say "+ #{diff.new_element.chomp}", :green, true
|
133
|
-
when "!"
|
134
|
-
say "- #{diff.old_element.chomp}", :red, true
|
135
|
-
say "+ #{diff.new_element.chomp}", :green, true
|
136
|
-
else
|
137
|
-
say " #{diff.old_element.chomp}", nil, true
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
# Check if Diff::LCS is loaded. If it is, use it to create pretty output
|
142
|
-
# for diff.
|
143
|
-
#
|
144
|
-
def diff_lcs_loaded? #:nodoc:
|
145
|
-
return true if defined?(Diff::LCS)
|
146
|
-
return @diff_lcs_loaded unless @diff_lcs_loaded.nil?
|
147
|
-
|
148
|
-
@diff_lcs_loaded = begin
|
149
|
-
require "diff/lcs"
|
150
|
-
true
|
151
|
-
rescue LoadError
|
152
|
-
false
|
153
|
-
end
|
108
|
+
!ENV["NO_COLOR"].nil? && !ENV["NO_COLOR"].empty?
|
154
109
|
end
|
155
110
|
end
|
156
111
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative "terminal"
|
2
|
+
|
3
|
+
class Bundler::Thor
|
4
|
+
module Shell
|
5
|
+
class ColumnPrinter
|
6
|
+
attr_reader :stdout, :options
|
7
|
+
|
8
|
+
def initialize(stdout, options = {})
|
9
|
+
@stdout = stdout
|
10
|
+
@options = options
|
11
|
+
@indent = options[:indent].to_i
|
12
|
+
end
|
13
|
+
|
14
|
+
def print(array)
|
15
|
+
return if array.empty?
|
16
|
+
colwidth = (array.map { |el| el.to_s.size }.max || 0) + 2
|
17
|
+
array.each_with_index do |value, index|
|
18
|
+
# Don't output trailing spaces when printing the last column
|
19
|
+
if ((((index + 1) % (Terminal.terminal_width / colwidth))).zero? && !index.zero?) || index + 1 == array.length
|
20
|
+
stdout.puts value
|
21
|
+
else
|
22
|
+
stdout.printf("%-#{colwidth}s", value)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -64,7 +64,7 @@ class Bundler::Thor
|
|
64
64
|
# Ask something to the user and receives a response.
|
65
65
|
#
|
66
66
|
# ==== Example
|
67
|
-
#
|
67
|
+
# ask("What is your name?")
|
68
68
|
#
|
69
69
|
# TODO: Implement #ask for Bundler::Thor::Shell::HTML
|
70
70
|
def ask(statement, color = nil)
|
@@ -76,51 +76,6 @@ class Bundler::Thor
|
|
76
76
|
def can_display_colors?
|
77
77
|
true
|
78
78
|
end
|
79
|
-
|
80
|
-
# Overwrite show_diff to show diff with colors if Diff::LCS is
|
81
|
-
# available.
|
82
|
-
#
|
83
|
-
def show_diff(destination, content) #:nodoc:
|
84
|
-
if diff_lcs_loaded? && ENV["THOR_DIFF"].nil? && ENV["RAILS_DIFF"].nil?
|
85
|
-
actual = File.binread(destination).to_s.split("\n")
|
86
|
-
content = content.to_s.split("\n")
|
87
|
-
|
88
|
-
Diff::LCS.sdiff(actual, content).each do |diff|
|
89
|
-
output_diff_line(diff)
|
90
|
-
end
|
91
|
-
else
|
92
|
-
super
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def output_diff_line(diff) #:nodoc:
|
97
|
-
case diff.action
|
98
|
-
when "-"
|
99
|
-
say "- #{diff.old_element.chomp}", :red, true
|
100
|
-
when "+"
|
101
|
-
say "+ #{diff.new_element.chomp}", :green, true
|
102
|
-
when "!"
|
103
|
-
say "- #{diff.old_element.chomp}", :red, true
|
104
|
-
say "+ #{diff.new_element.chomp}", :green, true
|
105
|
-
else
|
106
|
-
say " #{diff.old_element.chomp}", nil, true
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
# Check if Diff::LCS is loaded. If it is, use it to create pretty output
|
111
|
-
# for diff.
|
112
|
-
#
|
113
|
-
def diff_lcs_loaded? #:nodoc:
|
114
|
-
return true if defined?(Diff::LCS)
|
115
|
-
return @diff_lcs_loaded unless @diff_lcs_loaded.nil?
|
116
|
-
|
117
|
-
@diff_lcs_loaded = begin
|
118
|
-
require "diff/lcs"
|
119
|
-
true
|
120
|
-
rescue LoadError
|
121
|
-
false
|
122
|
-
end
|
123
|
-
end
|
124
79
|
end
|
125
80
|
end
|
126
81
|
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require_relative "column_printer"
|
2
|
+
require_relative "terminal"
|
3
|
+
|
4
|
+
class Bundler::Thor
|
5
|
+
module Shell
|
6
|
+
class TablePrinter < ColumnPrinter
|
7
|
+
BORDER_SEPARATOR = :separator
|
8
|
+
|
9
|
+
def initialize(stdout, options = {})
|
10
|
+
super
|
11
|
+
@formats = []
|
12
|
+
@maximas = []
|
13
|
+
@colwidth = options[:colwidth]
|
14
|
+
@truncate = options[:truncate] == true ? Terminal.terminal_width : options[:truncate]
|
15
|
+
@padding = 1
|
16
|
+
end
|
17
|
+
|
18
|
+
def print(array)
|
19
|
+
return if array.empty?
|
20
|
+
|
21
|
+
prepare(array)
|
22
|
+
|
23
|
+
print_border_separator if options[:borders]
|
24
|
+
|
25
|
+
array.each do |row|
|
26
|
+
if options[:borders] && row == BORDER_SEPARATOR
|
27
|
+
print_border_separator
|
28
|
+
next
|
29
|
+
end
|
30
|
+
|
31
|
+
sentence = "".dup
|
32
|
+
|
33
|
+
row.each_with_index do |column, index|
|
34
|
+
sentence << format_cell(column, row.size, index)
|
35
|
+
end
|
36
|
+
|
37
|
+
sentence = truncate(sentence)
|
38
|
+
sentence << "|" if options[:borders]
|
39
|
+
stdout.puts indentation + sentence
|
40
|
+
|
41
|
+
end
|
42
|
+
print_border_separator if options[:borders]
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def prepare(array)
|
48
|
+
array = array.reject{|row| row == BORDER_SEPARATOR }
|
49
|
+
|
50
|
+
@formats << "%-#{@colwidth + 2}s".dup if @colwidth
|
51
|
+
start = @colwidth ? 1 : 0
|
52
|
+
|
53
|
+
colcount = array.max { |a, b| a.size <=> b.size }.size
|
54
|
+
|
55
|
+
start.upto(colcount - 1) do |index|
|
56
|
+
maxima = array.map { |row| row[index] ? row[index].to_s.size : 0 }.max
|
57
|
+
|
58
|
+
@maximas << maxima
|
59
|
+
@formats << if options[:borders]
|
60
|
+
"%-#{maxima}s".dup
|
61
|
+
elsif index == colcount - 1
|
62
|
+
# Don't output 2 trailing spaces when printing the last column
|
63
|
+
"%-s".dup
|
64
|
+
else
|
65
|
+
"%-#{maxima + 2}s".dup
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
@formats << "%s"
|
70
|
+
end
|
71
|
+
|
72
|
+
def format_cell(column, row_size, index)
|
73
|
+
maxima = @maximas[index]
|
74
|
+
|
75
|
+
f = if column.is_a?(Numeric)
|
76
|
+
if options[:borders]
|
77
|
+
# With borders we handle padding separately
|
78
|
+
"%#{maxima}s"
|
79
|
+
elsif index == row_size - 1
|
80
|
+
# Don't output 2 trailing spaces when printing the last column
|
81
|
+
"%#{maxima}s"
|
82
|
+
else
|
83
|
+
"%#{maxima}s "
|
84
|
+
end
|
85
|
+
else
|
86
|
+
@formats[index]
|
87
|
+
end
|
88
|
+
|
89
|
+
cell = "".dup
|
90
|
+
cell << "|" + " " * @padding if options[:borders]
|
91
|
+
cell << f % column.to_s
|
92
|
+
cell << " " * @padding if options[:borders]
|
93
|
+
cell
|
94
|
+
end
|
95
|
+
|
96
|
+
def print_border_separator
|
97
|
+
separator = @maximas.map do |maxima|
|
98
|
+
"+" + "-" * (maxima + 2 * @padding)
|
99
|
+
end
|
100
|
+
stdout.puts indentation + separator.join + "+"
|
101
|
+
end
|
102
|
+
|
103
|
+
def truncate(string)
|
104
|
+
return string unless @truncate
|
105
|
+
chars = string.chars.to_a
|
106
|
+
if chars.length <= @truncate
|
107
|
+
chars.join
|
108
|
+
else
|
109
|
+
chars[0, @truncate - 3 - @indent].join + "..."
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def indentation
|
114
|
+
" " * @indent
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class Bundler::Thor
|
2
|
+
module Shell
|
3
|
+
module Terminal
|
4
|
+
DEFAULT_TERMINAL_WIDTH = 80
|
5
|
+
|
6
|
+
class << self
|
7
|
+
# This code was copied from Rake, available under MIT-LICENSE
|
8
|
+
# Copyright (c) 2003, 2004 Jim Weirich
|
9
|
+
def terminal_width
|
10
|
+
result = if ENV["THOR_COLUMNS"]
|
11
|
+
ENV["THOR_COLUMNS"].to_i
|
12
|
+
else
|
13
|
+
unix? ? dynamic_width : DEFAULT_TERMINAL_WIDTH
|
14
|
+
end
|
15
|
+
result < 10 ? DEFAULT_TERMINAL_WIDTH : result
|
16
|
+
rescue
|
17
|
+
DEFAULT_TERMINAL_WIDTH
|
18
|
+
end
|
19
|
+
|
20
|
+
def unix?
|
21
|
+
RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris)/i
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
# Calculate the dynamic width of the terminal
|
27
|
+
def dynamic_width
|
28
|
+
@dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
|
29
|
+
end
|
30
|
+
|
31
|
+
def dynamic_width_stty
|
32
|
+
`stty size 2>/dev/null`.split[1].to_i
|
33
|
+
end
|
34
|
+
|
35
|
+
def dynamic_width_tput
|
36
|
+
`tput cols 2>/dev/null`.to_i
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative "column_printer"
|
2
|
+
require_relative "terminal"
|
3
|
+
|
4
|
+
class Bundler::Thor
|
5
|
+
module Shell
|
6
|
+
class WrappedPrinter < ColumnPrinter
|
7
|
+
def print(message)
|
8
|
+
width = Terminal.terminal_width - @indent
|
9
|
+
paras = message.split("\n\n")
|
10
|
+
|
11
|
+
paras.map! do |unwrapped|
|
12
|
+
words = unwrapped.split(" ")
|
13
|
+
counter = words.first.length
|
14
|
+
words.inject do |memo, word|
|
15
|
+
word = word.gsub(/\n\005/, "\n").gsub(/\005/, "\n")
|
16
|
+
counter = 0 if word.include? "\n"
|
17
|
+
if (counter + word.length + 1) < width
|
18
|
+
memo = "#{memo} #{word}"
|
19
|
+
counter += (word.length + 1)
|
20
|
+
else
|
21
|
+
memo = "#{memo}\n#{word}"
|
22
|
+
counter = word.length
|
23
|
+
end
|
24
|
+
memo
|
25
|
+
end
|
26
|
+
end.compact!
|
27
|
+
|
28
|
+
paras.each do |para|
|
29
|
+
para.split("\n").each do |line|
|
30
|
+
stdout.puts line.insert(0, " " * @indent)
|
31
|
+
end
|
32
|
+
stdout.puts unless para == paras.last
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -21,7 +21,7 @@ class Bundler::Thor
|
|
21
21
|
end
|
22
22
|
|
23
23
|
module Shell
|
24
|
-
SHELL_DELEGATED_METHODS = [:ask, :error, :set_color, :yes?, :no?, :say, :say_status, :print_in_columns, :print_table, :print_wrapped, :file_collision, :terminal_width]
|
24
|
+
SHELL_DELEGATED_METHODS = [:ask, :error, :set_color, :yes?, :no?, :say, :say_error, :say_status, :print_in_columns, :print_table, :print_wrapped, :file_collision, :terminal_width]
|
25
25
|
attr_writer :shell
|
26
26
|
|
27
27
|
autoload :Basic, File.expand_path("shell/basic", __dir__)
|
@@ -75,7 +75,7 @@ class Bundler::Thor
|
|
75
75
|
# Allow shell to be shared between invocations.
|
76
76
|
#
|
77
77
|
def _shared_configuration #:nodoc:
|
78
|
-
super.merge!(:
|
78
|
+
super.merge!(shell: shell)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|