bundler 1.13.6 → 1.17.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bundler might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/CHANGELOG.md +554 -9
- data/README.md +28 -5
- data/bundler.gemspec +40 -11
- data/exe/bundle +4 -8
- data/exe/bundle_ruby +4 -3
- data/lib/bundler.rb +162 -68
- data/lib/bundler/build_metadata.rb +53 -0
- data/lib/bundler/capistrano.rb +5 -0
- data/lib/bundler/cli.rb +360 -118
- data/lib/bundler/cli/add.rb +35 -0
- data/lib/bundler/cli/binstubs.rb +18 -10
- data/lib/bundler/cli/cache.rb +6 -5
- data/lib/bundler/cli/check.rb +4 -6
- data/lib/bundler/cli/clean.rb +6 -7
- data/lib/bundler/cli/common.rb +47 -1
- data/lib/bundler/cli/config.rb +26 -7
- data/lib/bundler/cli/console.rb +2 -1
- data/lib/bundler/cli/doctor.rb +63 -18
- data/lib/bundler/cli/exec.rb +12 -5
- data/lib/bundler/cli/gem.rb +59 -21
- data/lib/bundler/cli/info.rb +50 -0
- data/lib/bundler/cli/init.rb +21 -7
- data/lib/bundler/cli/inject.rb +13 -4
- data/lib/bundler/cli/install.rb +72 -101
- data/lib/bundler/cli/issue.rb +40 -0
- data/lib/bundler/cli/list.rb +58 -0
- data/lib/bundler/cli/lock.rb +9 -6
- data/lib/bundler/cli/open.rb +4 -3
- data/lib/bundler/cli/outdated.rb +175 -60
- data/lib/bundler/cli/package.rb +9 -6
- data/lib/bundler/cli/platform.rb +2 -1
- data/lib/bundler/cli/plugin.rb +1 -0
- data/lib/bundler/cli/pristine.rb +47 -0
- data/lib/bundler/cli/remove.rb +18 -0
- data/lib/bundler/cli/show.rb +2 -2
- data/lib/bundler/cli/update.rb +44 -34
- data/lib/bundler/cli/viz.rb +5 -1
- data/lib/bundler/compact_index_client.rb +109 -0
- data/lib/bundler/compact_index_client/cache.rb +118 -0
- data/lib/bundler/compact_index_client/updater.rb +116 -0
- data/lib/bundler/compatibility_guard.rb +14 -0
- data/lib/bundler/constants.rb +1 -0
- data/lib/bundler/current_ruby.rb +17 -8
- data/lib/bundler/definition.rb +353 -182
- data/lib/bundler/dep_proxy.rb +3 -1
- data/lib/bundler/dependency.rb +22 -10
- data/lib/bundler/deployment.rb +1 -1
- data/lib/bundler/deprecate.rb +15 -3
- data/lib/bundler/dsl.rb +122 -64
- data/lib/bundler/endpoint_specification.rb +13 -3
- data/lib/bundler/env.rb +110 -38
- data/lib/bundler/environment_preserver.rb +27 -6
- data/lib/bundler/errors.rb +24 -0
- data/lib/bundler/feature_flag.rb +74 -0
- data/lib/bundler/fetcher.rb +18 -11
- data/lib/bundler/fetcher/base.rb +1 -0
- data/lib/bundler/fetcher/compact_index.rb +7 -5
- data/lib/bundler/fetcher/dependency.rb +3 -2
- data/lib/bundler/fetcher/downloader.rb +25 -7
- data/lib/bundler/fetcher/index.rb +3 -2
- data/lib/bundler/friendly_errors.rb +33 -7
- data/lib/bundler/gem_helper.rb +25 -11
- data/lib/bundler/gem_helpers.rb +70 -1
- data/lib/bundler/gem_remote_fetcher.rb +1 -0
- data/lib/bundler/gem_tasks.rb +1 -0
- data/lib/bundler/gem_version_promoter.rb +17 -2
- data/lib/bundler/gemdeps.rb +29 -0
- data/lib/bundler/graph.rb +1 -0
- data/lib/bundler/index.rb +28 -15
- data/lib/bundler/injector.rb +216 -33
- data/lib/bundler/inline.rb +12 -12
- data/lib/bundler/installer.rb +139 -53
- data/lib/bundler/installer/gem_installer.rb +15 -5
- data/lib/bundler/installer/parallel_installer.rb +113 -28
- data/lib/bundler/installer/standalone.rb +1 -0
- data/lib/bundler/lazy_specification.rb +31 -3
- data/lib/bundler/lockfile_generator.rb +95 -0
- data/lib/bundler/lockfile_parser.rb +50 -37
- data/lib/bundler/match_platform.rb +13 -3
- data/lib/bundler/mirror.rb +10 -5
- data/lib/bundler/plugin.rb +22 -8
- data/lib/bundler/plugin/api.rb +2 -1
- data/lib/bundler/plugin/api/source.rb +17 -4
- data/lib/bundler/plugin/events.rb +61 -0
- data/lib/bundler/plugin/index.rb +9 -2
- data/lib/bundler/plugin/installer.rb +7 -6
- data/lib/bundler/plugin/source_list.rb +7 -8
- data/lib/bundler/process_lock.rb +24 -0
- data/lib/bundler/psyched_yaml.rb +10 -0
- data/lib/bundler/remote_specification.rb +30 -1
- data/lib/bundler/resolver.rb +187 -194
- data/lib/bundler/resolver/spec_group.rb +106 -0
- data/lib/bundler/retry.rb +5 -1
- data/lib/bundler/ruby_dsl.rb +1 -0
- data/lib/bundler/ruby_version.rb +12 -2
- data/lib/bundler/rubygems_ext.rb +23 -8
- data/lib/bundler/rubygems_gem_installer.rb +90 -0
- data/lib/bundler/rubygems_integration.rb +193 -70
- data/lib/bundler/runtime.rb +39 -22
- data/lib/bundler/settings.rb +245 -85
- data/lib/bundler/settings/validator.rb +102 -0
- data/lib/bundler/setup.rb +4 -7
- data/lib/bundler/shared_helpers.rb +183 -40
- data/lib/bundler/similarity_detector.rb +1 -0
- data/lib/bundler/source.rb +58 -1
- data/lib/bundler/source/gemspec.rb +1 -0
- data/lib/bundler/source/git.rb +52 -23
- data/lib/bundler/source/git/git_proxy.rb +30 -14
- data/lib/bundler/source/metadata.rb +62 -0
- data/lib/bundler/source/path.rb +42 -16
- data/lib/bundler/source/path/installer.rb +4 -2
- data/lib/bundler/source/rubygems.rb +171 -82
- data/lib/bundler/source/rubygems/remote.rb +12 -2
- data/lib/bundler/source_list.rb +75 -15
- data/lib/bundler/spec_set.rb +67 -32
- data/lib/bundler/ssl_certs/certificate_manager.rb +2 -1
- data/lib/bundler/stub_specification.rb +86 -2
- data/lib/bundler/templates/.document +1 -0
- data/lib/bundler/templates/Executable +13 -1
- data/lib/bundler/templates/Executable.bundler +105 -0
- data/lib/bundler/templates/Executable.standalone +5 -5
- data/lib/bundler/templates/Gemfile +3 -0
- data/lib/bundler/templates/gems.rb +8 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +4 -2
- data/lib/bundler/templates/newgem/LICENSE.txt.tt +1 -1
- data/lib/bundler/templates/newgem/README.md.tt +14 -8
- data/lib/bundler/templates/newgem/Rakefile.tt +5 -5
- data/lib/bundler/templates/newgem/bin/console.tt +1 -1
- data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +4 -4
- data/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +3 -3
- data/lib/bundler/templates/newgem/gitignore.tt +5 -1
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +7 -6
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +4 -4
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +21 -12
- data/lib/bundler/templates/newgem/rspec.tt +1 -0
- data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +1 -3
- data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +13 -1
- data/lib/bundler/templates/newgem/test/newgem_test.rb.tt +1 -1
- data/lib/bundler/templates/newgem/test/test_helper.rb.tt +3 -3
- data/lib/bundler/templates/newgem/{.travis.yml.tt → travis.yml.tt} +2 -0
- data/lib/bundler/ui.rb +1 -0
- data/lib/bundler/ui/rg_proxy.rb +1 -0
- data/lib/bundler/ui/shell.rb +30 -10
- data/lib/bundler/ui/silent.rb +21 -1
- data/lib/bundler/uri_credentials_filter.rb +1 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1638 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +2 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +26 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +7 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +1 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +26 -6
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +2 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +12 -4
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +3 -2
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +63 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +11 -3
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +13 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +3 -2
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +3 -2
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +18 -5
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +75 -7
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +2 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +1 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +3 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +499 -128
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +1 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +8 -4
- data/lib/bundler/vendor/{net → net-http-persistent/lib/net}/http/faster.rb +1 -0
- data/lib/bundler/vendor/{net → net-http-persistent/lib/net}/http/persistent.rb +27 -24
- data/lib/bundler/vendor/{net → net-http-persistent/lib/net}/http/persistent/ssl_reuse.rb +2 -1
- data/lib/bundler/vendor/thor/lib/thor.rb +46 -21
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +24 -22
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +2 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +2 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +16 -8
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +66 -18
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +17 -15
- data/lib/bundler/vendor/thor/lib/thor/base.rb +55 -32
- data/lib/bundler/vendor/thor/lib/thor/command.rb +13 -11
- data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +21 -1
- data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +7 -5
- data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +94 -63
- data/lib/bundler/vendor/thor/lib/thor/error.rb +3 -3
- data/lib/bundler/vendor/thor/lib/thor/group.rb +13 -13
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +4 -5
- data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +2 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +4 -7
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +16 -16
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +42 -21
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +13 -10
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +31 -29
- data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +49 -33
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +4 -4
- data/lib/bundler/vendor/thor/lib/thor/util.rb +8 -7
- data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
- data/lib/bundler/vendored_fileutils.rb +9 -0
- data/lib/bundler/vendored_molinillo.rb +1 -0
- data/lib/bundler/vendored_persistent.rb +43 -3
- data/lib/bundler/vendored_thor.rb +6 -2
- data/lib/bundler/version.rb +19 -2
- data/lib/bundler/version_ranges.rb +76 -0
- data/lib/bundler/vlad.rb +5 -0
- data/lib/bundler/worker.rb +30 -6
- data/lib/bundler/yaml_serializer.rb +4 -4
- data/man/bundle-add.1 +58 -0
- data/man/bundle-add.1.txt +52 -0
- data/man/bundle-add.ronn +40 -0
- data/{lib/bundler/man/bundle-binstubs → man/bundle-binstubs.1} +11 -1
- data/man/bundle-binstubs.1.txt +48 -0
- data/man/bundle-binstubs.ronn +15 -1
- data/man/bundle-check.1 +31 -0
- data/man/bundle-check.1.txt +33 -0
- data/man/bundle-check.ronn +26 -0
- data/man/bundle-clean.1 +24 -0
- data/man/bundle-clean.1.txt +26 -0
- data/man/bundle-clean.ronn +18 -0
- data/man/bundle-config.1 +497 -0
- data/man/bundle-config.1.txt +529 -0
- data/man/bundle-config.ronn +233 -61
- data/man/bundle-doctor.1 +44 -0
- data/man/bundle-doctor.1.txt +44 -0
- data/man/bundle-doctor.ronn +33 -0
- data/{lib/bundler/man/bundle-exec → man/bundle-exec.1} +6 -3
- data/man/bundle-exec.1.txt +178 -0
- data/man/bundle-exec.ronn +10 -3
- data/{lib/bundler/man/bundle-gem → man/bundle-gem.1} +4 -4
- data/man/bundle-gem.1.txt +91 -0
- data/man/bundle-gem.ronn +3 -2
- data/man/bundle-info.1 +20 -0
- data/man/bundle-info.1.txt +21 -0
- data/man/bundle-info.ronn +17 -0
- data/man/bundle-init.1 +25 -0
- data/man/bundle-init.1.txt +34 -0
- data/man/bundle-init.ronn +29 -0
- data/man/bundle-inject.1 +33 -0
- data/man/bundle-inject.1.txt +32 -0
- data/man/bundle-inject.ronn +22 -0
- data/{lib/bundler/man/bundle-install → man/bundle-install.1} +32 -29
- data/man/bundle-install.1.txt +396 -0
- data/man/bundle-install.ronn +45 -36
- data/man/bundle-list.1 +50 -0
- data/man/bundle-list.1.txt +43 -0
- data/man/bundle-list.ronn +33 -0
- data/{lib/bundler/man/bundle-lock → man/bundle-lock.1} +43 -2
- data/man/bundle-lock.1.txt +93 -0
- data/man/bundle-lock.ronn +47 -0
- data/man/bundle-open.1 +32 -0
- data/man/bundle-open.1.txt +29 -0
- data/man/bundle-open.ronn +19 -0
- data/man/bundle-outdated.1 +155 -0
- data/man/bundle-outdated.1.txt +131 -0
- data/man/bundle-outdated.ronn +111 -0
- data/{lib/bundler/man/bundle-package → man/bundle-package.1} +6 -3
- data/man/bundle-package.1.txt +79 -0
- data/man/bundle-package.ronn +7 -2
- data/{lib/bundler/man/bundle-platform → man/bundle-platform.1} +1 -1
- data/man/bundle-platform.1.txt +57 -0
- data/man/bundle-pristine.1 +34 -0
- data/man/bundle-pristine.1.txt +44 -0
- data/man/bundle-pristine.ronn +34 -0
- data/man/bundle-remove.1 +31 -0
- data/man/bundle-remove.1.txt +34 -0
- data/man/bundle-remove.ronn +23 -0
- data/man/bundle-show.1 +23 -0
- data/man/bundle-show.1.txt +27 -0
- data/man/bundle-show.ronn +21 -0
- data/man/bundle-update.1 +394 -0
- data/man/bundle-update.1.txt +391 -0
- data/man/bundle-update.ronn +172 -16
- data/man/bundle-viz.1 +39 -0
- data/man/bundle-viz.1.txt +39 -0
- data/man/bundle-viz.ronn +30 -0
- data/{lib/bundler/man/bundle → man/bundle.1} +44 -28
- data/man/bundle.1.txt +116 -0
- data/man/bundle.ronn +39 -27
- data/{lib/bundler/man → man}/gemfile.5 +67 -84
- data/man/gemfile.5.ronn +77 -55
- data/man/gemfile.5.txt +653 -0
- data/man/index.txt +25 -8
- metadata +118 -58
- data/.codeclimate.yml +0 -25
- data/.gitignore +0 -16
- data/.rspec +0 -3
- data/.rubocop.yml +0 -128
- data/.rubocop_todo.yml +0 -248
- data/.travis.yml +0 -108
- data/CODE_OF_CONDUCT.md +0 -42
- data/CONTRIBUTING.md +0 -36
- data/DEVELOPMENT.md +0 -148
- data/ISSUES.md +0 -100
- data/Rakefile +0 -333
- data/bin/rake +0 -19
- data/bin/rspec +0 -15
- data/bin/rubocop +0 -17
- data/bin/with_rubygems +0 -39
- data/lib/bundler/man/bundle-binstubs.txt +0 -33
- data/lib/bundler/man/bundle-config +0 -254
- data/lib/bundler/man/bundle-config.txt +0 -282
- data/lib/bundler/man/bundle-exec.txt +0 -171
- data/lib/bundler/man/bundle-gem.txt +0 -90
- data/lib/bundler/man/bundle-install.txt +0 -385
- data/lib/bundler/man/bundle-lock.txt +0 -52
- data/lib/bundler/man/bundle-package.txt +0 -74
- data/lib/bundler/man/bundle-platform.txt +0 -57
- data/lib/bundler/man/bundle-update +0 -221
- data/lib/bundler/man/bundle-update.txt +0 -227
- data/lib/bundler/man/bundle.txt +0 -104
- data/lib/bundler/man/gemfile.5.txt +0 -636
- data/lib/bundler/postit_trampoline.rb +0 -68
- data/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb +0 -79
- data/lib/bundler/vendor/compact_index_client/lib/compact_index_client/cache.rb +0 -112
- data/lib/bundler/vendor/compact_index_client/lib/compact_index_client/updater.rb +0 -80
- data/lib/bundler/vendor/compact_index_client/lib/compact_index_client/version.rb +0 -4
- data/lib/bundler/vendor/postit/lib/postit.rb +0 -15
- data/lib/bundler/vendor/postit/lib/postit/environment.rb +0 -44
- data/lib/bundler/vendor/postit/lib/postit/installer.rb +0 -28
- data/lib/bundler/vendor/postit/lib/postit/parser.rb +0 -21
- data/lib/bundler/vendor/postit/lib/postit/setup.rb +0 -12
- data/lib/bundler/vendor/postit/lib/postit/version.rb +0 -3
@@ -58,6 +58,7 @@ class Bundler::Thor
|
|
58
58
|
|
59
59
|
def invoke!
|
60
60
|
invoke_with_conflict_check do
|
61
|
+
require "fileutils"
|
61
62
|
FileUtils.mkdir_p(File.dirname(destination))
|
62
63
|
File.open(destination, "wb") { |f| f.write render }
|
63
64
|
end
|
@@ -84,7 +85,7 @@ class Bundler::Thor
|
|
84
85
|
def force_or_skip_or_conflict(force, skip, &block)
|
85
86
|
if force
|
86
87
|
say_status :force, :yellow
|
87
|
-
|
88
|
+
yield unless pretend?
|
88
89
|
elsif skip
|
89
90
|
say_status :skip, :yellow
|
90
91
|
else
|
@@ -14,7 +14,7 @@ class Bundler::Thor
|
|
14
14
|
#
|
15
15
|
# create_link "config/apache.conf", "/etc/apache.conf"
|
16
16
|
#
|
17
|
-
def create_link(destination, *args
|
17
|
+
def create_link(destination, *args)
|
18
18
|
config = args.last.is_a?(Hash) ? args.pop : {}
|
19
19
|
source = args.first
|
20
20
|
action CreateLink.new(self, destination, source, config)
|
@@ -38,6 +38,7 @@ class Bundler::Thor
|
|
38
38
|
|
39
39
|
def invoke!
|
40
40
|
invoke_with_conflict_check do
|
41
|
+
require "fileutils"
|
41
42
|
FileUtils.mkdir_p(File.dirname(destination))
|
42
43
|
# Create a symlink by default
|
43
44
|
config[:symbolic] = true if config[:symbolic].nil?
|
@@ -72,7 +72,7 @@ class Bundler::Thor
|
|
72
72
|
|
73
73
|
protected
|
74
74
|
|
75
|
-
def execute!
|
75
|
+
def execute!
|
76
76
|
lookup = Util.escape_globs(source)
|
77
77
|
lookup = config[:recursive] ? File.join(lookup, "**") : lookup
|
78
78
|
lookup = file_level_lookup(lookup)
|
@@ -85,7 +85,7 @@ class Bundler::Thor
|
|
85
85
|
|
86
86
|
case file_source
|
87
87
|
when /\.empty_directory$/
|
88
|
-
dirname = File.dirname(file_destination).gsub(
|
88
|
+
dirname = File.dirname(file_destination).gsub(%r{/\.$}, "")
|
89
89
|
next if dirname == given_destination
|
90
90
|
base.empty_directory(dirname, config)
|
91
91
|
when /#{TEMPLATE_EXTNAME}$/
|
@@ -32,7 +32,8 @@ class Bundler::Thor
|
|
32
32
|
# config<Hash>:: give :verbose => false to not log the status.
|
33
33
|
#
|
34
34
|
def initialize(base, destination, config = {})
|
35
|
-
@base
|
35
|
+
@base = base
|
36
|
+
@config = {:verbose => true}.merge(config)
|
36
37
|
self.destination = destination
|
37
38
|
end
|
38
39
|
|
@@ -47,12 +48,14 @@ class Bundler::Thor
|
|
47
48
|
|
48
49
|
def invoke!
|
49
50
|
invoke_with_conflict_check do
|
51
|
+
require "fileutils"
|
50
52
|
::FileUtils.mkdir_p(destination)
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
54
56
|
def revoke!
|
55
57
|
say_status :remove, :red
|
58
|
+
require "fileutils"
|
56
59
|
::FileUtils.rm_rf(destination) if !pretend? && exists?
|
57
60
|
given_destination
|
58
61
|
end
|
@@ -80,11 +83,10 @@ class Bundler::Thor
|
|
80
83
|
# given_destination #=> baz
|
81
84
|
#
|
82
85
|
def destination=(destination)
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end
|
86
|
+
return unless destination
|
87
|
+
@given_destination = convert_encoded_instructions(destination.to_s)
|
88
|
+
@destination = ::File.expand_path(@given_destination, base.destination_root)
|
89
|
+
@relative_destination = base.relative_to_original_destination_root(@destination)
|
88
90
|
end
|
89
91
|
|
90
92
|
# Filenames in the encoded form are converted. If you have a file:
|
@@ -112,16 +114,22 @@ class Bundler::Thor
|
|
112
114
|
if exists?
|
113
115
|
on_conflict_behavior(&block)
|
114
116
|
else
|
117
|
+
yield unless pretend?
|
115
118
|
say_status :create, :green
|
116
|
-
block.call unless pretend?
|
117
119
|
end
|
118
120
|
|
119
121
|
destination
|
122
|
+
rescue Errno::EISDIR, Errno::EEXIST
|
123
|
+
on_file_clash_behavior
|
124
|
+
end
|
125
|
+
|
126
|
+
def on_file_clash_behavior
|
127
|
+
say_status :file_clash, :red
|
120
128
|
end
|
121
129
|
|
122
130
|
# What to do when the destination file already exists.
|
123
131
|
#
|
124
|
-
def on_conflict_behavior
|
132
|
+
def on_conflict_behavior
|
125
133
|
say_status :exist, :blue
|
126
134
|
end
|
127
135
|
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require "erb"
|
2
|
-
require "open-uri"
|
3
2
|
|
4
3
|
class Bundler::Thor
|
5
4
|
module Actions
|
@@ -26,7 +25,7 @@ class Bundler::Thor
|
|
26
25
|
|
27
26
|
create_file destination, nil, config do
|
28
27
|
content = File.binread(source)
|
29
|
-
content =
|
28
|
+
content = yield(content) if block
|
30
29
|
content
|
31
30
|
end
|
32
31
|
if config[:mode] == :preserve
|
@@ -49,7 +48,7 @@ class Bundler::Thor
|
|
49
48
|
#
|
50
49
|
# link_file "doc/README"
|
51
50
|
#
|
52
|
-
def link_file(source, *args
|
51
|
+
def link_file(source, *args)
|
53
52
|
config = args.last.is_a?(Hash) ? args.pop : {}
|
54
53
|
destination = args.first || source
|
55
54
|
source = File.expand_path(find_in_source_paths(source.to_s))
|
@@ -78,11 +77,16 @@ class Bundler::Thor
|
|
78
77
|
config = args.last.is_a?(Hash) ? args.pop : {}
|
79
78
|
destination = args.first
|
80
79
|
|
81
|
-
|
80
|
+
if source =~ %r{^https?\://}
|
81
|
+
require "open-uri"
|
82
|
+
else
|
83
|
+
source = File.expand_path(find_in_source_paths(source.to_s))
|
84
|
+
end
|
85
|
+
|
82
86
|
render = open(source) { |input| input.binmode.read }
|
83
87
|
|
84
88
|
destination ||= if block_given?
|
85
|
-
block.arity == 1 ?
|
89
|
+
block.arity == 1 ? yield(render) : yield
|
86
90
|
else
|
87
91
|
File.basename(source)
|
88
92
|
end
|
@@ -110,11 +114,13 @@ class Bundler::Thor
|
|
110
114
|
destination = args.first || source.sub(/#{TEMPLATE_EXTNAME}$/, "")
|
111
115
|
|
112
116
|
source = File.expand_path(find_in_source_paths(source.to_s))
|
113
|
-
context = instance_eval("binding")
|
117
|
+
context = config.delete(:context) || instance_eval("binding")
|
114
118
|
|
115
119
|
create_file destination, nil, config do
|
116
|
-
content =
|
117
|
-
|
120
|
+
content = CapturableERB.new(::File.binread(source), nil, "-", "@output_buffer").tap do |erb|
|
121
|
+
erb.filename = source
|
122
|
+
end.result(context)
|
123
|
+
content = yield(content) if block
|
118
124
|
content
|
119
125
|
end
|
120
126
|
end
|
@@ -134,7 +140,10 @@ class Bundler::Thor
|
|
134
140
|
return unless behavior == :invoke
|
135
141
|
path = File.expand_path(path, destination_root)
|
136
142
|
say_status :chmod, relative_to_original_destination_root(path), config.fetch(:verbose, true)
|
137
|
-
|
143
|
+
unless options[:pretend]
|
144
|
+
require "fileutils"
|
145
|
+
FileUtils.chmod_R(mode, path)
|
146
|
+
end
|
138
147
|
end
|
139
148
|
|
140
149
|
# Prepend text to a file. Since it depends on insert_into_file, it's reversible.
|
@@ -154,7 +163,7 @@ class Bundler::Thor
|
|
154
163
|
#
|
155
164
|
def prepend_to_file(path, *args, &block)
|
156
165
|
config = args.last.is_a?(Hash) ? args.pop : {}
|
157
|
-
config
|
166
|
+
config[:after] = /\A/
|
158
167
|
insert_into_file(path, *(args << config), &block)
|
159
168
|
end
|
160
169
|
alias_method :prepend_file, :prepend_to_file
|
@@ -176,7 +185,7 @@ class Bundler::Thor
|
|
176
185
|
#
|
177
186
|
def append_to_file(path, *args, &block)
|
178
187
|
config = args.last.is_a?(Hash) ? args.pop : {}
|
179
|
-
config
|
188
|
+
config[:before] = /\z/
|
180
189
|
insert_into_file(path, *(args << config), &block)
|
181
190
|
end
|
182
191
|
alias_method :append_file, :append_to_file
|
@@ -200,7 +209,30 @@ class Bundler::Thor
|
|
200
209
|
#
|
201
210
|
def inject_into_class(path, klass, *args, &block)
|
202
211
|
config = args.last.is_a?(Hash) ? args.pop : {}
|
203
|
-
config
|
212
|
+
config[:after] = /class #{klass}\n|class #{klass} .*\n/
|
213
|
+
insert_into_file(path, *(args << config), &block)
|
214
|
+
end
|
215
|
+
|
216
|
+
# Injects text right after the module definition. Since it depends on
|
217
|
+
# insert_into_file, it's reversible.
|
218
|
+
#
|
219
|
+
# ==== Parameters
|
220
|
+
# path<String>:: path of the file to be changed
|
221
|
+
# module_name<String|Class>:: the module to be manipulated
|
222
|
+
# data<String>:: the data to append to the class, can be also given as a block.
|
223
|
+
# config<Hash>:: give :verbose => false to not log the status.
|
224
|
+
#
|
225
|
+
# ==== Examples
|
226
|
+
#
|
227
|
+
# inject_into_module "app/helpers/application_helper.rb", ApplicationHelper, " def help; 'help'; end\n"
|
228
|
+
#
|
229
|
+
# inject_into_module "app/helpers/application_helper.rb", ApplicationHelper do
|
230
|
+
# " def help; 'help'; end\n"
|
231
|
+
# end
|
232
|
+
#
|
233
|
+
def inject_into_module(path, module_name, *args, &block)
|
234
|
+
config = args.last.is_a?(Hash) ? args.pop : {}
|
235
|
+
config[:after] = /module #{module_name}\n|module #{module_name} .*\n/
|
204
236
|
insert_into_file(path, *(args << config), &block)
|
205
237
|
end
|
206
238
|
|
@@ -285,10 +317,13 @@ class Bundler::Thor
|
|
285
317
|
#
|
286
318
|
def remove_file(path, config = {})
|
287
319
|
return unless behavior == :invoke
|
288
|
-
path
|
320
|
+
path = File.expand_path(path, destination_root)
|
289
321
|
|
290
322
|
say_status :remove, relative_to_original_destination_root(path), config.fetch(:verbose, true)
|
291
|
-
|
323
|
+
if !options[:pretend] && File.exist?(path)
|
324
|
+
require "fileutils"
|
325
|
+
::FileUtils.rm_rf(path)
|
326
|
+
end
|
292
327
|
end
|
293
328
|
alias_method :remove_dir, :remove_file
|
294
329
|
|
@@ -301,16 +336,29 @@ class Bundler::Thor
|
|
301
336
|
@output_buffer.concat(string)
|
302
337
|
end
|
303
338
|
|
304
|
-
def capture(*args
|
305
|
-
with_output_buffer {
|
339
|
+
def capture(*args)
|
340
|
+
with_output_buffer { yield(*args) }
|
306
341
|
end
|
307
342
|
|
308
|
-
def with_output_buffer(buf = "") #:nodoc:
|
309
|
-
|
343
|
+
def with_output_buffer(buf = "".dup) #:nodoc:
|
344
|
+
raise ArgumentError, "Buffer can not be a frozen object" if buf.frozen?
|
345
|
+
old_buffer = output_buffer
|
346
|
+
self.output_buffer = buf
|
310
347
|
yield
|
311
348
|
output_buffer
|
312
349
|
ensure
|
313
350
|
self.output_buffer = old_buffer
|
314
351
|
end
|
352
|
+
|
353
|
+
# Bundler::Thor::Actions#capture depends on what kind of buffer is used in ERB.
|
354
|
+
# Thus CapturableERB fixes ERB to use String buffer.
|
355
|
+
class CapturableERB < ERB
|
356
|
+
def set_eoutvar(compiler, eoutvar = "_erbout")
|
357
|
+
compiler.put_cmd = "#{eoutvar}.concat"
|
358
|
+
compiler.insert_cmd = "#{eoutvar}.concat"
|
359
|
+
compiler.pre_cmd = ["#{eoutvar} = ''.dup"]
|
360
|
+
compiler.post_cmd = [eoutvar]
|
361
|
+
end
|
362
|
+
end
|
315
363
|
end
|
316
364
|
end
|
@@ -22,11 +22,8 @@ class Bundler::Thor
|
|
22
22
|
# end
|
23
23
|
#
|
24
24
|
def insert_into_file(destination, *args, &block)
|
25
|
-
|
26
|
-
|
27
|
-
else
|
28
|
-
data, config = args.shift, args.shift
|
29
|
-
end
|
25
|
+
data = block_given? ? block : args.shift
|
26
|
+
config = args.shift
|
30
27
|
action InjectIntoFile.new(self, destination, data, config)
|
31
28
|
end
|
32
29
|
alias_method :inject_into_file, :insert_into_file
|
@@ -39,9 +36,9 @@ class Bundler::Thor
|
|
39
36
|
|
40
37
|
@behavior, @flag = if @config.key?(:after)
|
41
38
|
[:after, @config.delete(:after)]
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
else
|
40
|
+
[:before, @config.delete(:before)]
|
41
|
+
end
|
45
42
|
|
46
43
|
@replacement = data.is_a?(Proc) ? data.call : data
|
47
44
|
@flag = Regexp.escape(@flag) unless @flag.is_a?(Regexp)
|
@@ -56,7 +53,13 @@ class Bundler::Thor
|
|
56
53
|
replacement + '\0'
|
57
54
|
end
|
58
55
|
|
59
|
-
|
56
|
+
if exists?
|
57
|
+
replace!(/#{flag}/, content, config[:force])
|
58
|
+
else
|
59
|
+
unless pretend?
|
60
|
+
raise Bundler::Thor::Error, "The file #{ destination } does not appear to exist"
|
61
|
+
end
|
62
|
+
end
|
60
63
|
end
|
61
64
|
|
62
65
|
def revoke!
|
@@ -94,12 +97,11 @@ class Bundler::Thor
|
|
94
97
|
# Adds the content to the file.
|
95
98
|
#
|
96
99
|
def replace!(regexp, string, force)
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
end
|
100
|
+
return if pretend?
|
101
|
+
content = File.read(destination)
|
102
|
+
if force || !content.include?(replacement)
|
103
|
+
content.gsub!(regexp, string)
|
104
|
+
File.open(destination, "wb") { |file| file.write(content) }
|
103
105
|
end
|
104
106
|
end
|
105
107
|
end
|
@@ -14,11 +14,11 @@ class Bundler::Thor
|
|
14
14
|
autoload :Group, "bundler/vendor/thor/lib/thor/group"
|
15
15
|
|
16
16
|
# Shortcuts for help.
|
17
|
-
HELP_MAPPINGS = %w
|
17
|
+
HELP_MAPPINGS = %w(-h -? --help -D)
|
18
18
|
|
19
19
|
# Bundler::Thor methods that should not be overwritten by the user.
|
20
|
-
THOR_RESERVED_WORDS = %w
|
21
|
-
action add_file create_file in_root inside run run_ruby_script
|
20
|
+
THOR_RESERVED_WORDS = %w(invoke shell options behavior root destination_root relative_root
|
21
|
+
action add_file create_file in_root inside run run_ruby_script)
|
22
22
|
|
23
23
|
TEMPLATE_EXTNAME = ".tt"
|
24
24
|
|
@@ -41,7 +41,7 @@ class Bundler::Thor
|
|
41
41
|
#
|
42
42
|
# config<Hash>:: Configuration for this Bundler::Thor class.
|
43
43
|
#
|
44
|
-
def initialize(args = [], local_options = {}, config = {})
|
44
|
+
def initialize(args = [], local_options = {}, config = {})
|
45
45
|
parse_options = self.class.class_options
|
46
46
|
|
47
47
|
# The start method splits inbound arguments at the first argument
|
@@ -52,18 +52,21 @@ class Bundler::Thor
|
|
52
52
|
command_options = config.delete(:command_options) # hook for start
|
53
53
|
parse_options = parse_options.merge(command_options) if command_options
|
54
54
|
if local_options.is_a?(Array)
|
55
|
-
array_options
|
55
|
+
array_options = local_options
|
56
|
+
hash_options = {}
|
56
57
|
else
|
57
58
|
# Handle the case where the class was explicitly instantiated
|
58
59
|
# with pre-parsed options.
|
59
|
-
array_options
|
60
|
+
array_options = []
|
61
|
+
hash_options = local_options
|
60
62
|
end
|
61
63
|
|
62
64
|
# Let Bundler::Thor::Options parse the options first, so it can remove
|
63
65
|
# declared options from the array. This will leave us with
|
64
66
|
# a list of arguments that weren't declared.
|
65
67
|
stop_on_unknown = self.class.stop_on_unknown_option? config[:current_command]
|
66
|
-
|
68
|
+
disable_required_check = self.class.disable_required_check? config[:current_command]
|
69
|
+
opts = Bundler::Thor::Options.new(parse_options, hash_options, stop_on_unknown, disable_required_check)
|
67
70
|
self.options = opts.parse(array_options)
|
68
71
|
self.options = config[:class_options].merge(options) if config[:class_options]
|
69
72
|
|
@@ -148,6 +151,21 @@ class Bundler::Thor
|
|
148
151
|
!!check_unknown_options
|
149
152
|
end
|
150
153
|
|
154
|
+
# If you want to raise an error when the default value of an option does not match
|
155
|
+
# the type call check_default_type!
|
156
|
+
# This is disabled by default for compatibility.
|
157
|
+
def check_default_type!
|
158
|
+
@check_default_type = true
|
159
|
+
end
|
160
|
+
|
161
|
+
def check_default_type #:nodoc:
|
162
|
+
@check_default_type ||= from_superclass(:check_default_type, false)
|
163
|
+
end
|
164
|
+
|
165
|
+
def check_default_type? #:nodoc:
|
166
|
+
!!check_default_type
|
167
|
+
end
|
168
|
+
|
151
169
|
# If true, option parsing is suspended as soon as an unknown option or a
|
152
170
|
# regular argument is encountered. All remaining arguments are passed to
|
153
171
|
# the command as regular arguments.
|
@@ -155,6 +173,12 @@ class Bundler::Thor
|
|
155
173
|
false
|
156
174
|
end
|
157
175
|
|
176
|
+
# If true, option set will not suspend the execution of the command when
|
177
|
+
# a required option is not provided.
|
178
|
+
def disable_required_check?(command_name) #:nodoc:
|
179
|
+
false
|
180
|
+
end
|
181
|
+
|
158
182
|
# If you want only strict string args (useful when cascading thor classes),
|
159
183
|
# call strict_args_position! This is disabled by default to allow dynamic
|
160
184
|
# invocations.
|
@@ -205,7 +229,7 @@ class Bundler::Thor
|
|
205
229
|
# ==== Errors
|
206
230
|
# ArgumentError:: Raised if you supply a required argument after a non required one.
|
207
231
|
#
|
208
|
-
def argument(name, options = {})
|
232
|
+
def argument(name, options = {})
|
209
233
|
is_thor_reserved_word?(name, :argument)
|
210
234
|
no_commands { attr_accessor name }
|
211
235
|
|
@@ -219,11 +243,13 @@ class Bundler::Thor
|
|
219
243
|
|
220
244
|
remove_argument name
|
221
245
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
246
|
+
if required
|
247
|
+
arguments.each do |argument|
|
248
|
+
next if argument.required?
|
249
|
+
raise ArgumentError, "You cannot have #{name.to_s.inspect} as required argument after " \
|
250
|
+
"the non-required argument #{argument.human_name.inspect}."
|
251
|
+
end
|
252
|
+
end
|
227
253
|
|
228
254
|
options[:required] = required
|
229
255
|
|
@@ -343,7 +369,7 @@ class Bundler::Thor
|
|
343
369
|
#
|
344
370
|
def all_commands
|
345
371
|
@all_commands ||= from_superclass(:all_commands, Bundler::Thor::CoreExt::OrderedHash.new)
|
346
|
-
@all_commands.merge(commands)
|
372
|
+
@all_commands.merge!(commands)
|
347
373
|
end
|
348
374
|
alias_method :all_tasks, :all_commands
|
349
375
|
|
@@ -467,20 +493,18 @@ class Bundler::Thor
|
|
467
493
|
alias_method :public_task, :public_command
|
468
494
|
|
469
495
|
def handle_no_command_error(command, has_namespace = $thor_runner) #:nodoc:
|
470
|
-
if has_namespace
|
471
|
-
|
472
|
-
else
|
473
|
-
fail UndefinedCommandError, "Could not find command #{command.inspect}."
|
474
|
-
end
|
496
|
+
raise UndefinedCommandError, "Could not find command #{command.inspect} in #{namespace.inspect} namespace." if has_namespace
|
497
|
+
raise UndefinedCommandError, "Could not find command #{command.inspect}."
|
475
498
|
end
|
476
499
|
alias_method :handle_no_task_error, :handle_no_command_error
|
477
500
|
|
478
501
|
def handle_argument_error(command, error, args, arity) #:nodoc:
|
479
|
-
|
502
|
+
name = [command.ancestor_name, command.name].compact.join(" ")
|
503
|
+
msg = "ERROR: \"#{basename} #{name}\" was called with ".dup
|
480
504
|
msg << "no arguments" if args.empty?
|
481
505
|
msg << "arguments " << args.inspect unless args.empty?
|
482
506
|
msg << "\nUsage: #{banner(command).inspect}"
|
483
|
-
|
507
|
+
raise InvocationError, msg
|
484
508
|
end
|
485
509
|
|
486
510
|
protected
|
@@ -513,14 +537,13 @@ class Bundler::Thor
|
|
513
537
|
padding = options.map { |o| o.aliases.size }.max.to_i * 4
|
514
538
|
|
515
539
|
options.each do |option|
|
516
|
-
|
517
|
-
|
518
|
-
|
540
|
+
next if option.hide
|
541
|
+
item = [option.usage(padding)]
|
542
|
+
item.push(option.description ? "# #{option.description}" : "")
|
519
543
|
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
end
|
544
|
+
list << item
|
545
|
+
list << ["", "# Default: #{option.default}"] if option.show_default?
|
546
|
+
list << ["", "# Possible values: #{option.enum.join(', ')}"] if option.enum
|
524
547
|
end
|
525
548
|
|
526
549
|
shell.say(group_name ? "#{group_name} options:" : "Options:")
|
@@ -531,7 +554,7 @@ class Bundler::Thor
|
|
531
554
|
# Raises an error if the word given is a Bundler::Thor reserved word.
|
532
555
|
def is_thor_reserved_word?(word, type) #:nodoc:
|
533
556
|
return false unless THOR_RESERVED_WORDS.include?(word.to_s)
|
534
|
-
|
557
|
+
raise "#{word.inspect} is a Bundler::Thor reserved word and cannot be defined as #{type}"
|
535
558
|
end
|
536
559
|
|
537
560
|
# Build an option and adds it to the given scope.
|
@@ -541,7 +564,7 @@ class Bundler::Thor
|
|
541
564
|
# options<Hash>:: Described in both class_option and method_option.
|
542
565
|
# scope<Hash>:: Options hash that is being built up
|
543
566
|
def build_option(name, options, scope) #:nodoc:
|
544
|
-
scope[name] = Bundler::Thor::Option.new(name, options)
|
567
|
+
scope[name] = Bundler::Thor::Option.new(name, options.merge(:check_default_type => check_default_type?))
|
545
568
|
end
|
546
569
|
|
547
570
|
# Receives a hash of options, parse them and add to the scope. This is a
|
@@ -566,7 +589,7 @@ class Bundler::Thor
|
|
566
589
|
elsif command = all_commands[name.to_s] # rubocop:disable AssignmentInCondition
|
567
590
|
commands[name.to_s] = command.clone
|
568
591
|
else
|
569
|
-
|
592
|
+
raise ArgumentError, "You supplied :for => #{name.inspect}, but the command #{name.inspect} could not be found."
|
570
593
|
end
|
571
594
|
end
|
572
595
|
alias_method :find_and_refresh_task, :find_and_refresh_command
|
@@ -649,7 +672,7 @@ class Bundler::Thor
|
|
649
672
|
|
650
673
|
# SIGNATURE: The hook invoked by start.
|
651
674
|
def dispatch(command, given_args, given_opts, config) #:nodoc:
|
652
|
-
|
675
|
+
raise NotImplementedError
|
653
676
|
end
|
654
677
|
end
|
655
678
|
end
|