bundler 2.0.0 → 2.1.2
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 +4 -4
- data/CHANGELOG.md +778 -572
- data/LICENSE.md +18 -19
- data/README.md +9 -8
- data/bundler.gemspec +8 -25
- data/exe/bundle +19 -3
- data/lib/bundler.rb +202 -87
- data/lib/bundler/build_metadata.rb +3 -3
- data/lib/bundler/capistrano.rb +5 -5
- data/lib/bundler/cli.rb +182 -144
- data/lib/bundler/cli/add.rb +28 -16
- data/lib/bundler/cli/cache.rb +25 -13
- data/lib/bundler/cli/common.rb +11 -12
- data/lib/bundler/cli/config.rb +161 -86
- data/lib/bundler/cli/console.rb +2 -2
- data/lib/bundler/cli/doctor.rb +4 -4
- data/lib/bundler/cli/exec.rb +4 -16
- data/lib/bundler/cli/gem.rb +5 -5
- data/lib/bundler/cli/info.rb +17 -5
- data/lib/bundler/cli/init.rb +1 -1
- data/lib/bundler/cli/install.rb +12 -11
- data/lib/bundler/cli/issue.rb +3 -3
- data/lib/bundler/cli/open.rb +10 -6
- data/lib/bundler/cli/outdated.rb +85 -81
- data/lib/bundler/cli/plugin.rb +9 -2
- data/lib/bundler/cli/pristine.rb +1 -1
- data/lib/bundler/cli/show.rb +1 -1
- data/lib/bundler/cli/update.rb +31 -11
- data/lib/bundler/compact_index_client.rb +25 -9
- data/lib/bundler/compact_index_client/updater.rb +2 -6
- data/lib/bundler/current_ruby.rb +8 -7
- data/lib/bundler/definition.rb +36 -27
- data/lib/bundler/dependency.rb +16 -4
- data/lib/bundler/deployment.rb +2 -2
- data/lib/bundler/dsl.rb +19 -43
- data/lib/bundler/env.rb +8 -13
- data/lib/bundler/environment_preserver.rb +0 -1
- data/lib/bundler/feature_flag.rb +2 -14
- data/lib/bundler/fetcher.rb +16 -13
- data/lib/bundler/fetcher/compact_index.rb +26 -12
- data/lib/bundler/fetcher/dependency.rb +1 -1
- data/lib/bundler/fetcher/downloader.rb +5 -2
- data/lib/bundler/fetcher/index.rb +5 -3
- data/lib/bundler/friendly_errors.rb +6 -7
- data/lib/bundler/gem_helper.rb +40 -25
- data/lib/bundler/gem_helpers.rb +2 -4
- data/lib/bundler/gem_tasks.rb +1 -1
- data/lib/bundler/gem_version_promoter.rb +3 -3
- data/lib/bundler/graph.rb +2 -2
- data/lib/bundler/injector.rb +10 -8
- data/lib/bundler/inline.rb +40 -30
- data/lib/bundler/installer.rb +7 -14
- data/lib/bundler/installer/gem_installer.rb +5 -1
- data/lib/bundler/installer/parallel_installer.rb +4 -8
- data/lib/bundler/installer/standalone.rb +1 -2
- data/lib/bundler/lazy_specification.rb +2 -3
- data/lib/bundler/lockfile_parser.rb +14 -21
- data/lib/bundler/match_platform.rb +1 -1
- data/lib/bundler/mirror.rb +3 -3
- data/lib/bundler/plugin.rb +42 -29
- data/lib/bundler/plugin/api.rb +1 -1
- data/lib/bundler/plugin/api/source.rb +4 -6
- data/lib/bundler/plugin/index.rb +14 -3
- data/lib/bundler/plugin/installer.rb +28 -15
- data/lib/bundler/psyched_yaml.rb +1 -1
- data/lib/bundler/remote_specification.rb +0 -2
- data/lib/bundler/resolver.rb +72 -24
- data/lib/bundler/resolver/spec_group.rb +3 -2
- data/lib/bundler/retry.rb +2 -2
- data/lib/bundler/ruby_version.rb +4 -19
- data/lib/bundler/rubygems_ext.rb +11 -67
- data/lib/bundler/rubygems_gem_installer.rb +1 -1
- data/lib/bundler/rubygems_integration.rb +148 -398
- data/lib/bundler/runtime.rb +2 -9
- data/lib/bundler/settings.rb +22 -52
- data/lib/bundler/setup.rb +11 -12
- data/lib/bundler/shared_helpers.rb +51 -77
- data/lib/bundler/similarity_detector.rb +2 -2
- data/lib/bundler/source.rb +5 -5
- data/lib/bundler/source/git.rb +24 -17
- data/lib/bundler/source/git/git_proxy.rb +38 -41
- data/lib/bundler/source/metadata.rb +7 -2
- data/lib/bundler/source/path.rb +13 -8
- data/lib/bundler/source/rubygems.rb +14 -8
- data/lib/bundler/source/rubygems/remote.rb +2 -3
- data/lib/bundler/source_list.rb +9 -12
- data/lib/bundler/spec_set.rb +1 -6
- data/lib/bundler/stub_specification.rb +18 -30
- data/lib/bundler/templates/Executable.bundler +23 -14
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +3 -3
- data/lib/bundler/templates/newgem/Gemfile.tt +8 -0
- data/lib/bundler/templates/newgem/README.md.tt +4 -3
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +6 -27
- data/lib/bundler/templates/newgem/test/test_helper.rb.tt +1 -1
- data/lib/bundler/templates/newgem/travis.yml.tt +0 -1
- data/lib/bundler/ui.rb +3 -3
- data/lib/bundler/ui/rg_proxy.rb +1 -1
- data/lib/bundler/ui/shell.rb +4 -8
- data/lib/bundler/uri_credentials_filter.rb +7 -3
- data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +161 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +66 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +176 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +273 -147
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +6 -6
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +2 -2
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +1 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +6 -6
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +1 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +30 -8
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +1 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +4 -4
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +2 -2
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +273 -304
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +40 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +53 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
- data/lib/bundler/vendor/thor/lib/thor.rb +19 -4
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +27 -12
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +7 -17
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +16 -7
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +19 -8
- data/lib/bundler/vendor/thor/lib/thor/base.rb +54 -43
- data/lib/bundler/vendor/thor/lib/thor/command.rb +21 -14
- data/lib/bundler/vendor/thor/lib/thor/error.rb +78 -0
- data/lib/bundler/vendor/thor/lib/thor/group.rb +3 -3
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +6 -6
- data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
- data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +20 -7
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +20 -5
- data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +1 -0
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +15 -14
- data/lib/bundler/vendor/thor/lib/thor/shell.rb +4 -4
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +62 -8
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +6 -2
- data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +3 -3
- data/lib/bundler/vendor/thor/lib/thor/util.rb +18 -2
- data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
- data/lib/bundler/vendor/uri/lib/uri.rb +104 -0
- data/lib/bundler/vendor/uri/lib/uri/common.rb +744 -0
- data/lib/bundler/vendor/uri/lib/uri/file.rb +94 -0
- data/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
- data/lib/bundler/vendor/uri/lib/uri/generic.rb +1568 -0
- data/lib/bundler/vendor/uri/lib/uri/http.rb +88 -0
- data/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
- data/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
- data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +21 -0
- data/lib/bundler/vendor/uri/lib/uri/mailto.rb +294 -0
- data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +546 -0
- data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +125 -0
- data/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
- data/lib/bundler/vendored_fileutils.rb +1 -6
- data/lib/bundler/vendored_molinillo.rb +1 -1
- data/lib/bundler/vendored_persistent.rb +7 -5
- data/lib/bundler/vendored_thor.rb +2 -2
- data/lib/bundler/vendored_uri.rb +4 -0
- data/lib/bundler/version.rb +1 -20
- data/lib/bundler/version_ranges.rb +51 -5
- data/lib/bundler/vlad.rb +3 -3
- data/lib/bundler/worker.rb +1 -3
- data/lib/bundler/yaml_serializer.rb +2 -3
- data/man/bundle-add.1 +10 -2
- data/man/bundle-add.1.txt +11 -5
- data/man/bundle-add.ronn +7 -1
- data/man/bundle-binstubs.1 +2 -2
- data/man/bundle-binstubs.1.txt +2 -2
- data/man/bundle-binstubs.ronn +1 -1
- data/man/bundle-cache.1 +55 -0
- data/man/bundle-cache.1.txt +78 -0
- data/man/{bundle-package.ronn → bundle-cache.ronn} +15 -15
- data/man/bundle-check.1 +1 -1
- data/man/bundle-check.1.txt +6 -6
- data/man/bundle-clean.1 +1 -1
- data/man/bundle-clean.1.txt +1 -1
- data/man/bundle-config.1 +36 -36
- data/man/bundle-config.1.txt +66 -67
- data/man/bundle-config.ronn +42 -40
- data/man/bundle-doctor.1 +1 -1
- data/man/bundle-doctor.1.txt +1 -1
- data/man/bundle-exec.1 +2 -2
- data/man/bundle-exec.1.txt +2 -2
- data/man/bundle-exec.ronn +1 -1
- data/man/bundle-gem.1 +1 -1
- data/man/bundle-gem.1.txt +3 -3
- data/man/bundle-info.1 +1 -1
- data/man/bundle-info.1.txt +1 -1
- data/man/bundle-init.1 +2 -2
- data/man/bundle-init.1.txt +2 -2
- data/man/bundle-init.ronn +1 -1
- data/man/bundle-inject.1 +1 -1
- data/man/bundle-inject.1.txt +1 -1
- data/man/bundle-install.1 +8 -5
- data/man/bundle-install.1.txt +56 -51
- data/man/bundle-install.ronn +9 -4
- data/man/bundle-list.1 +1 -1
- data/man/bundle-list.1.txt +1 -1
- data/man/bundle-lock.1 +1 -1
- data/man/bundle-lock.1.txt +16 -16
- data/man/bundle-open.1 +1 -1
- data/man/bundle-open.1.txt +1 -1
- data/man/bundle-outdated.1 +1 -1
- data/man/bundle-outdated.1.txt +1 -1
- data/man/bundle-platform.1 +1 -1
- data/man/bundle-platform.1.txt +1 -1
- data/man/bundle-pristine.1 +1 -1
- data/man/bundle-pristine.1.txt +1 -1
- data/man/bundle-remove.1 +1 -1
- data/man/bundle-remove.1.txt +1 -1
- data/man/bundle-show.1 +1 -1
- data/man/bundle-show.1.txt +1 -1
- data/man/bundle-update.1 +4 -4
- data/man/bundle-update.1.txt +64 -65
- data/man/bundle-update.ronn +3 -3
- data/man/bundle-viz.1 +1 -1
- data/man/bundle-viz.1.txt +1 -1
- data/man/bundle.1 +3 -3
- data/man/bundle.1.txt +8 -8
- data/man/bundle.ronn +2 -2
- data/man/gemfile.5 +13 -16
- data/man/gemfile.5.ronn +10 -14
- data/man/gemfile.5.txt +104 -108
- data/man/index.txt +1 -1
- metadata +33 -108
- data/exe/bundle_ruby +0 -60
- data/lib/bundler/cli/package.rb +0 -49
- data/lib/bundler/compatibility_guard.rb +0 -14
- data/lib/bundler/gem_remote_fetcher.rb +0 -43
- data/lib/bundler/ssl_certs/.document +0 -1
- data/lib/bundler/ssl_certs/certificate_manager.rb +0 -66
- data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +0 -21
- data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
- data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +0 -27
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +0 -129
- data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -12
- data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -129
- data/man/bundle-package.1 +0 -55
- data/man/bundle-package.1.txt +0 -79
@@ -1,4 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require_relative "parser/argument"
|
2
|
+
require_relative "parser/arguments"
|
3
|
+
require_relative "parser/option"
|
4
|
+
require_relative "parser/options"
|
@@ -9,7 +9,7 @@ class Bundler::Thor
|
|
9
9
|
arguments = []
|
10
10
|
|
11
11
|
args.each do |item|
|
12
|
-
break if item =~ /^-/
|
12
|
+
break if item.is_a?(String) && item =~ /^-/
|
13
13
|
arguments << item
|
14
14
|
end
|
15
15
|
|
@@ -82,7 +82,7 @@ class Bundler::Thor
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def current_is_value?
|
85
|
-
peek && peek.to_s !~
|
85
|
+
peek && peek.to_s !~ /^-{1,2}\S+/
|
86
86
|
end
|
87
87
|
|
88
88
|
# Runs through the argument array getting strings that contains ":" and
|
@@ -1,17 +1,18 @@
|
|
1
1
|
class Bundler::Thor
|
2
2
|
class Option < Argument #:nodoc:
|
3
|
-
attr_reader :aliases, :group, :lazy_default, :hide
|
3
|
+
attr_reader :aliases, :group, :lazy_default, :hide, :repeatable
|
4
4
|
|
5
5
|
VALID_TYPES = [:boolean, :numeric, :hash, :array, :string]
|
6
6
|
|
7
7
|
def initialize(name, options = {})
|
8
8
|
@check_default_type = options[:check_default_type]
|
9
9
|
options[:required] = false unless options.key?(:required)
|
10
|
+
@repeatable = options.fetch(:repeatable, false)
|
10
11
|
super
|
11
|
-
@lazy_default
|
12
|
-
@group
|
13
|
-
@aliases
|
14
|
-
@hide
|
12
|
+
@lazy_default = options[:lazy_default]
|
13
|
+
@group = options[:group].to_s.capitalize if options[:group]
|
14
|
+
@aliases = Array(options[:aliases])
|
15
|
+
@hide = options[:hide]
|
15
16
|
end
|
16
17
|
|
17
18
|
# This parse quick options given as method_options. It makes several
|
@@ -111,7 +112,7 @@ class Bundler::Thor
|
|
111
112
|
|
112
113
|
def validate!
|
113
114
|
raise ArgumentError, "An option cannot be boolean and required." if boolean? && required?
|
114
|
-
validate_default_type!
|
115
|
+
validate_default_type!
|
115
116
|
end
|
116
117
|
|
117
118
|
def validate_default_type!
|
@@ -128,7 +129,19 @@ class Bundler::Thor
|
|
128
129
|
@default.class.name.downcase.to_sym
|
129
130
|
end
|
130
131
|
|
131
|
-
|
132
|
+
expected_type = (@repeatable && @type != :hash) ? :array : @type
|
133
|
+
|
134
|
+
if default_type != expected_type
|
135
|
+
err = "Expected #{expected_type} default value for '#{switch_name}'; got #{@default.inspect} (#{default_type})"
|
136
|
+
|
137
|
+
if @check_default_type
|
138
|
+
raise ArgumentError, err
|
139
|
+
elsif @check_default_type == nil
|
140
|
+
Bundler::Thor.deprecation_warning "#{err}.\n" +
|
141
|
+
'This will be rejected in the future unless you explicitly pass the options `check_default_type: false`' +
|
142
|
+
' or call `allow_incompatible_default_type!` in your code'
|
143
|
+
end
|
144
|
+
end
|
132
145
|
end
|
133
146
|
|
134
147
|
def dasherized?
|
@@ -44,6 +44,7 @@ class Bundler::Thor
|
|
44
44
|
@shorts = {}
|
45
45
|
@switches = {}
|
46
46
|
@extra = []
|
47
|
+
@stopped_parsing_after_extra_index = nil
|
47
48
|
|
48
49
|
options.each do |option|
|
49
50
|
@switches[option.switch_name] = option
|
@@ -66,6 +67,7 @@ class Bundler::Thor
|
|
66
67
|
if result == OPTS_END
|
67
68
|
shift
|
68
69
|
@parsing_options = false
|
70
|
+
@stopped_parsing_after_extra_index ||= @extra.size
|
69
71
|
super
|
70
72
|
else
|
71
73
|
result
|
@@ -95,10 +97,12 @@ class Bundler::Thor
|
|
95
97
|
|
96
98
|
switch = normalize_switch(switch)
|
97
99
|
option = switch_option(switch)
|
98
|
-
|
100
|
+
result = parse_peek(switch, option)
|
101
|
+
assign_result!(option, result)
|
99
102
|
elsif @stop_on_unknown
|
100
103
|
@parsing_options = false
|
101
104
|
@extra << shifted
|
105
|
+
@stopped_parsing_after_extra_index ||= @extra.size
|
102
106
|
@extra << shift while peek
|
103
107
|
break
|
104
108
|
elsif match
|
@@ -120,13 +124,24 @@ class Bundler::Thor
|
|
120
124
|
end
|
121
125
|
|
122
126
|
def check_unknown!
|
127
|
+
to_check = @stopped_parsing_after_extra_index ? @extra[0...@stopped_parsing_after_extra_index] : @extra
|
128
|
+
|
123
129
|
# an unknown option starts with - or -- and has no more --'s afterward.
|
124
|
-
unknown =
|
125
|
-
raise UnknownArgumentError
|
130
|
+
unknown = to_check.select { |str| str =~ /^--?(?:(?!--).)*$/ }
|
131
|
+
raise UnknownArgumentError.new(@switches.keys, unknown) unless unknown.empty?
|
126
132
|
end
|
127
133
|
|
128
134
|
protected
|
129
135
|
|
136
|
+
def assign_result!(option, result)
|
137
|
+
if option.repeatable && option.type == :hash
|
138
|
+
(@assigns[option.human_name] ||= {}).merge!(result)
|
139
|
+
elsif option.repeatable
|
140
|
+
(@assigns[option.human_name] ||= []) << result
|
141
|
+
else
|
142
|
+
@assigns[option.human_name] = result
|
143
|
+
end
|
144
|
+
end
|
130
145
|
# Check if the current value in peek is a registered switch.
|
131
146
|
#
|
132
147
|
# Two booleans are returned. The first is true if the current value
|
@@ -156,7 +171,7 @@ class Bundler::Thor
|
|
156
171
|
end
|
157
172
|
|
158
173
|
def switch?(arg)
|
159
|
-
switch_option(normalize_switch(arg))
|
174
|
+
!switch_option(normalize_switch(arg)).nil?
|
160
175
|
end
|
161
176
|
|
162
177
|
def switch_option(arg)
|
@@ -189,7 +204,7 @@ class Bundler::Thor
|
|
189
204
|
shift
|
190
205
|
false
|
191
206
|
else
|
192
|
-
!no_or_skip?(switch)
|
207
|
+
@switches.key?(switch) || !no_or_skip?(switch)
|
193
208
|
end
|
194
209
|
else
|
195
210
|
@switches.key?(switch) || !no_or_skip?(switch)
|
@@ -25,6 +25,7 @@ class Bundler::Thor
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.included(base)
|
28
|
+
super(base)
|
28
29
|
# Hack. Make rakefile point to invoker, so rdoc task is generated properly.
|
29
30
|
rakefile = File.basename(caller[0].match(/(.*):\d+/)[1])
|
30
31
|
Rake.application.instance_variable_set(:@rakefile, rakefile)
|
@@ -1,12 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require "bundler/vendor/thor/lib/thor/core_ext/io_binary_read"
|
1
|
+
require_relative "../thor"
|
2
|
+
require_relative "group"
|
4
3
|
|
5
4
|
require "yaml"
|
6
|
-
require "digest"
|
5
|
+
require "digest/md5"
|
7
6
|
require "pathname"
|
8
7
|
|
9
8
|
class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLength
|
9
|
+
autoload :OpenURI, "open-uri"
|
10
|
+
|
10
11
|
map "-T" => :list, "-i" => :install, "-u" => :update, "-v" => :version
|
11
12
|
|
12
13
|
def self.banner(command, all = false, subcommand = false)
|
@@ -65,7 +66,7 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
|
|
65
66
|
raise Error, "Error opening file '#{name}'"
|
66
67
|
end
|
67
68
|
|
68
|
-
say "Your
|
69
|
+
say "Your Thorfile contains:"
|
69
70
|
say contents
|
70
71
|
|
71
72
|
unless options["force"]
|
@@ -90,7 +91,7 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
|
|
90
91
|
end
|
91
92
|
|
92
93
|
thor_yaml[as] = {
|
93
|
-
:filename => Digest
|
94
|
+
:filename => Digest::MD5.hexdigest(name + as),
|
94
95
|
:location => location,
|
95
96
|
:namespaces => Bundler::Thor::Util.namespaces_in_content(contents, base)
|
96
97
|
}
|
@@ -111,7 +112,7 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
|
|
111
112
|
|
112
113
|
desc "version", "Show Bundler::Thor version"
|
113
114
|
def version
|
114
|
-
|
115
|
+
require_relative "version"
|
115
116
|
say "Bundler::Thor #{Bundler::Thor::VERSION}"
|
116
117
|
end
|
117
118
|
|
@@ -204,7 +205,7 @@ private
|
|
204
205
|
File.open(yaml_file, "w") { |f| f.puts yaml.to_yaml }
|
205
206
|
end
|
206
207
|
|
207
|
-
# Load the
|
208
|
+
# Load the Thorfiles. If relevant_to is supplied, looks for specific files
|
208
209
|
# in the thor_root instead of loading them all.
|
209
210
|
#
|
210
211
|
# By default, it also traverses the current path until find Bundler::Thor files, as
|
@@ -217,11 +218,11 @@ private
|
|
217
218
|
end
|
218
219
|
end
|
219
220
|
|
220
|
-
# Finds
|
221
|
+
# Finds Thorfiles by traversing from your current directory down to the root
|
221
222
|
# directory of your system. If at any time we find a Bundler::Thor file, we stop.
|
222
223
|
#
|
223
|
-
# We also ensure that system-wide
|
224
|
-
#
|
224
|
+
# We also ensure that system-wide Thorfiles are loaded first, so local
|
225
|
+
# Thorfiles can override them.
|
225
226
|
#
|
226
227
|
# ==== Example
|
227
228
|
#
|
@@ -229,7 +230,7 @@ private
|
|
229
230
|
#
|
230
231
|
# 1. /Users/wycats/dev/thor
|
231
232
|
# 2. /Users/wycats/dev
|
232
|
-
# 3. /Users/wycats <-- we find a
|
233
|
+
# 3. /Users/wycats <-- we find a Thorfile here, so we stop
|
233
234
|
#
|
234
235
|
# Suppose we start at c:\Documents and Settings\james\dev\thor ...
|
235
236
|
#
|
@@ -237,7 +238,7 @@ private
|
|
237
238
|
# 2. c:\Documents and Settings\james\dev
|
238
239
|
# 3. c:\Documents and Settings\james
|
239
240
|
# 4. c:\Documents and Settings
|
240
|
-
# 5. c:\ <-- no
|
241
|
+
# 5. c:\ <-- no Thorfiles found!
|
241
242
|
#
|
242
243
|
def thorfiles(relevant_to = nil, skip_lookup = false)
|
243
244
|
thorfiles = []
|
@@ -258,7 +259,7 @@ private
|
|
258
259
|
end
|
259
260
|
end
|
260
261
|
|
261
|
-
# Load
|
262
|
+
# Load Thorfiles relevant to the given method. If you provide "foo:bar" it
|
262
263
|
# will load all thor files in the thor.yaml that has "foo" e "foo:bar"
|
263
264
|
# namespaces registered.
|
264
265
|
#
|
@@ -24,9 +24,9 @@ class Bundler::Thor
|
|
24
24
|
SHELL_DELEGATED_METHODS = [:ask, :error, :set_color, :yes?, :no?, :say, :say_status, :print_in_columns, :print_table, :print_wrapped, :file_collision, :terminal_width]
|
25
25
|
attr_writer :shell
|
26
26
|
|
27
|
-
autoload :Basic, "
|
28
|
-
autoload :Color, "
|
29
|
-
autoload :HTML, "
|
27
|
+
autoload :Basic, File.expand_path("shell/basic", __dir__)
|
28
|
+
autoload :Color, File.expand_path("shell/color", __dir__)
|
29
|
+
autoload :HTML, File.expand_path("shell/html", __dir__)
|
30
30
|
|
31
31
|
# Add shell to initialize config values.
|
32
32
|
#
|
@@ -55,7 +55,7 @@ class Bundler::Thor
|
|
55
55
|
|
56
56
|
# Common methods that are delegated to the shell.
|
57
57
|
SHELL_DELEGATED_METHODS.each do |method|
|
58
|
-
module_eval <<-METHOD, __FILE__, __LINE__
|
58
|
+
module_eval <<-METHOD, __FILE__, __LINE__ + 1
|
59
59
|
def #{method}(*args,&block)
|
60
60
|
shell.#{method}(*args,&block)
|
61
61
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
class Bundler::Thor
|
2
2
|
module Shell
|
3
3
|
class Basic
|
4
|
+
DEFAULT_TERMINAL_WIDTH = 80
|
5
|
+
|
4
6
|
attr_accessor :base
|
5
7
|
attr_reader :padding
|
6
8
|
|
@@ -45,6 +47,10 @@ class Bundler::Thor
|
|
45
47
|
|
46
48
|
# Asks something to the user and receives a response.
|
47
49
|
#
|
50
|
+
# If a default value is specified it will be presented to the user
|
51
|
+
# and allows them to select that value with an empty response. This
|
52
|
+
# option is ignored when limited answers are supplied.
|
53
|
+
#
|
48
54
|
# If asked to limit the correct responses, you can pass in an
|
49
55
|
# array of acceptable answers. If one of those is not supplied,
|
50
56
|
# they will be shown a message stating that one of those answers
|
@@ -61,6 +67,8 @@ class Bundler::Thor
|
|
61
67
|
# ==== Example
|
62
68
|
# ask("What is your name?")
|
63
69
|
#
|
70
|
+
# ask("What is the planet furthest from the sun?", :default => "Pluto")
|
71
|
+
#
|
64
72
|
# ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"])
|
65
73
|
#
|
66
74
|
# ask("What is your password?", :echo => false)
|
@@ -222,8 +230,20 @@ class Bundler::Thor
|
|
222
230
|
paras = message.split("\n\n")
|
223
231
|
|
224
232
|
paras.map! do |unwrapped|
|
225
|
-
|
226
|
-
|
233
|
+
counter = 0
|
234
|
+
unwrapped.split(" ").inject do |memo, word|
|
235
|
+
word = word.gsub(/\n\005/, "\n").gsub(/\005/, "\n")
|
236
|
+
counter = 0 if word.include? "\n"
|
237
|
+
if (counter + word.length + 1) < width
|
238
|
+
memo = "#{memo} #{word}"
|
239
|
+
counter += (word.length + 1)
|
240
|
+
else
|
241
|
+
memo = "#{memo}\n#{word}"
|
242
|
+
counter = word.length
|
243
|
+
end
|
244
|
+
memo
|
245
|
+
end
|
246
|
+
end.compact!
|
227
247
|
|
228
248
|
paras.each do |para|
|
229
249
|
para.split("\n").each do |line|
|
@@ -239,11 +259,11 @@ class Bundler::Thor
|
|
239
259
|
#
|
240
260
|
# ==== Parameters
|
241
261
|
# destination<String>:: the destination file to solve conflicts
|
242
|
-
# block<Proc>:: an optional block that returns the value to be used in diff
|
262
|
+
# block<Proc>:: an optional block that returns the value to be used in diff and merge
|
243
263
|
#
|
244
264
|
def file_collision(destination)
|
245
265
|
return true if @always_force
|
246
|
-
options = block_given? ? "[
|
266
|
+
options = block_given? ? "[Ynaqdhm]" : "[Ynaqh]"
|
247
267
|
|
248
268
|
loop do
|
249
269
|
answer = ask(
|
@@ -267,6 +287,13 @@ class Bundler::Thor
|
|
267
287
|
when is?(:diff)
|
268
288
|
show_diff(destination, yield) if block_given?
|
269
289
|
say "Retrying..."
|
290
|
+
when is?(:merge)
|
291
|
+
if block_given? && !merge_tool.empty?
|
292
|
+
merge(destination, yield)
|
293
|
+
return nil
|
294
|
+
end
|
295
|
+
|
296
|
+
say "Please specify merge tool to `THOR_MERGE` env."
|
270
297
|
else
|
271
298
|
say file_collision_help
|
272
299
|
end
|
@@ -279,11 +306,11 @@ class Bundler::Thor
|
|
279
306
|
result = if ENV["THOR_COLUMNS"]
|
280
307
|
ENV["THOR_COLUMNS"].to_i
|
281
308
|
else
|
282
|
-
unix? ? dynamic_width :
|
309
|
+
unix? ? dynamic_width : DEFAULT_TERMINAL_WIDTH
|
283
310
|
end
|
284
|
-
result < 10 ?
|
311
|
+
result < 10 ? DEFAULT_TERMINAL_WIDTH : result
|
285
312
|
rescue
|
286
|
-
|
313
|
+
DEFAULT_TERMINAL_WIDTH
|
287
314
|
end
|
288
315
|
|
289
316
|
# Called if something goes wrong during the execution. This is used by Bundler::Thor
|
@@ -344,6 +371,7 @@ class Bundler::Thor
|
|
344
371
|
q - quit, abort
|
345
372
|
d - diff, show the differences between the old and the new
|
346
373
|
h - help, show this help
|
374
|
+
m - merge, run merge tool
|
347
375
|
HELP
|
348
376
|
end
|
349
377
|
|
@@ -423,15 +451,41 @@ class Bundler::Thor
|
|
423
451
|
|
424
452
|
def ask_filtered(statement, color, options)
|
425
453
|
answer_set = options[:limited_to]
|
454
|
+
case_insensitive = options.fetch(:case_insensitive, false)
|
426
455
|
correct_answer = nil
|
427
456
|
until correct_answer
|
428
457
|
answers = answer_set.join(", ")
|
429
458
|
answer = ask_simply("#{statement} [#{answers}]", color, options)
|
430
|
-
correct_answer = answer_set
|
459
|
+
correct_answer = answer_match(answer_set, answer, case_insensitive)
|
431
460
|
say("Your response must be one of: [#{answers}]. Please try again.") unless correct_answer
|
432
461
|
end
|
433
462
|
correct_answer
|
434
463
|
end
|
464
|
+
|
465
|
+
def answer_match(possibilities, answer, case_insensitive)
|
466
|
+
if case_insensitive
|
467
|
+
possibilities.detect{ |possibility| possibility.downcase == answer.downcase }
|
468
|
+
else
|
469
|
+
possibilities.detect{ |possibility| possibility == answer }
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
473
|
+
def merge(destination, content) #:nodoc:
|
474
|
+
require "tempfile"
|
475
|
+
Tempfile.open([File.basename(destination), File.extname(destination)], File.dirname(destination)) do |temp|
|
476
|
+
temp.write content
|
477
|
+
temp.rewind
|
478
|
+
system %(#{merge_tool} "#{temp.path}" "#{destination}")
|
479
|
+
end
|
480
|
+
end
|
481
|
+
|
482
|
+
def merge_tool #:nodoc:
|
483
|
+
@merge_tool ||= ENV["THOR_MERGE"] || git_merge_tool
|
484
|
+
end
|
485
|
+
|
486
|
+
def git_merge_tool #:nodoc:
|
487
|
+
`git config merge.tool`.rstrip rescue ""
|
488
|
+
end
|
435
489
|
end
|
436
490
|
end
|
437
491
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative "basic"
|
2
2
|
|
3
3
|
class Bundler::Thor
|
4
4
|
module Shell
|
@@ -97,7 +97,11 @@ class Bundler::Thor
|
|
97
97
|
protected
|
98
98
|
|
99
99
|
def can_display_colors?
|
100
|
-
stdout.tty?
|
100
|
+
stdout.tty? && !are_colors_disabled?
|
101
|
+
end
|
102
|
+
|
103
|
+
def are_colors_disabled?
|
104
|
+
!ENV['NO_COLOR'].nil?
|
101
105
|
end
|
102
106
|
|
103
107
|
# Overwrite show_diff to show diff with colors if Diff::LCS is
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative "basic"
|
2
2
|
|
3
3
|
class Bundler::Thor
|
4
4
|
module Shell
|
@@ -51,13 +51,13 @@ class Bundler::Thor
|
|
51
51
|
def set_color(string, *colors)
|
52
52
|
if colors.all? { |color| color.is_a?(Symbol) || color.is_a?(String) }
|
53
53
|
html_colors = colors.map { |color| lookup_color(color) }
|
54
|
-
"<span style=\"#{html_colors.join('; ')};\">#{string}</span>"
|
54
|
+
"<span style=\"#{html_colors.join('; ')};\">#{Bundler::Thor::Util.escape_html(string)}</span>"
|
55
55
|
else
|
56
56
|
color, bold = colors
|
57
57
|
html_color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol)
|
58
58
|
styles = [html_color]
|
59
59
|
styles << BOLD if bold
|
60
|
-
"<span style=\"#{styles.join('; ')};\">#{string}</span>"
|
60
|
+
"<span style=\"#{styles.join('; ')};\">#{Bundler::Thor::Util.escape_html(string)}</span>"
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|