bundler 1.8.9 → 1.9.0.pre
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/.travis.yml +9 -7
- data/CHANGELOG.md +8 -33
- data/Rakefile +51 -8
- data/lib/bundler/cli/gem.rb +20 -1
- data/lib/bundler/cli/install.rb +1 -1
- data/lib/bundler/definition.rb +8 -12
- data/lib/bundler/dep_proxy.rb +2 -2
- data/lib/bundler/installer.rb +12 -18
- data/lib/bundler/resolver.rb +168 -383
- data/lib/bundler/rubygems_ext.rb +1 -1
- data/lib/bundler/rubygems_integration.rb +6 -14
- data/lib/bundler/runtime.rb +3 -0
- data/lib/bundler/shared_helpers.rb +12 -7
- data/lib/bundler/source.rb +0 -5
- data/lib/bundler/source/path.rb +2 -1
- data/lib/bundler/source/path/installer.rb +0 -2
- data/lib/bundler/source/rubygems.rb +9 -11
- data/lib/bundler/templates/newgem/Rakefile.tt +0 -1
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +1 -1
- data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo.rb +5 -0
- data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/dependency_graph.rb +266 -0
- data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/errors.rb +69 -0
- data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/gem_metadata.rb +3 -0
- data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/modules/specification_provider.rb +90 -0
- data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/modules/ui.rb +63 -0
- data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/resolution.rb +412 -0
- data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/resolver.rb +43 -0
- data/lib/bundler/vendor/Molinillo-0.2.1/lib/molinillo/state.rb +43 -0
- data/lib/bundler/vendor/{thor.rb → thor-0.19.1/lib/thor.rb} +57 -53
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/actions.rb +34 -34
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/actions/create_file.rb +7 -7
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/actions/create_link.rb +2 -2
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/actions/directory.rb +11 -11
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/actions/empty_directory.rb +2 -2
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/actions/file_manipulation.rb +14 -14
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/actions/inject_into_file.rb +24 -24
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/base.rb +71 -71
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/command.rb +8 -8
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/core_ext/hash_with_indifferent_access.rb +2 -2
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/core_ext/io_binary_read.rb +1 -1
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/core_ext/ordered_hash.rb +2 -2
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/error.rb +3 -3
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/group.rb +27 -27
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/invocation.rb +16 -11
- data/lib/bundler/vendor/thor-0.19.1/lib/thor/line_editor.rb +17 -0
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/line_editor/basic.rb +2 -2
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/line_editor/readline.rb +7 -7
- data/lib/bundler/vendor/thor-0.19.1/lib/thor/parser.rb +4 -0
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/parser/argument.rb +7 -7
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/parser/arguments.rb +10 -10
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/parser/option.rb +14 -10
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/parser/options.rb +12 -12
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/rake_compat.rb +14 -14
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/runner.rb +76 -76
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/shell.rb +18 -18
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/shell/basic.rb +31 -30
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/shell/color.rb +10 -10
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/shell/html.rb +28 -28
- data/lib/bundler/vendor/{thor → thor-0.19.1/lib/thor}/util.rb +61 -61
- data/lib/bundler/vendor/thor-0.19.1/lib/thor/version.rb +3 -0
- data/lib/bundler/vendored_molinillo.rb +5 -0
- data/lib/bundler/vendored_thor.rb +3 -6
- data/lib/bundler/version.rb +1 -1
- metadata +44 -35
- data/lib/bundler/vendor/.document +0 -0
- data/lib/bundler/vendor/thor/line_editor.rb +0 -17
- data/lib/bundler/vendor/thor/parser.rb +0 -4
- data/lib/bundler/vendor/thor/version.rb +0 -3
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'molinillo/dependency_graph'
|
2
|
+
|
3
|
+
module Bundler::Molinillo
|
4
|
+
# This class encapsulates a dependency resolver.
|
5
|
+
# The resolver is responsible for determining which set of dependencies to
|
6
|
+
# activate, with feedback from the the {#specification_provider}
|
7
|
+
#
|
8
|
+
#
|
9
|
+
class Resolver
|
10
|
+
require 'molinillo/resolution'
|
11
|
+
|
12
|
+
# @return [SpecificationProvider] the specification provider used
|
13
|
+
# in the resolution process
|
14
|
+
attr_reader :specification_provider
|
15
|
+
|
16
|
+
# @return [UI] the UI module used to communicate back to the user
|
17
|
+
# during the resolution process
|
18
|
+
attr_reader :resolver_ui
|
19
|
+
|
20
|
+
# @param [SpecificationProvider] specification_provider
|
21
|
+
# see {#specification_provider}
|
22
|
+
# @param [UI] resolver_ui
|
23
|
+
# see {#resolver_ui}
|
24
|
+
def initialize(specification_provider, resolver_ui)
|
25
|
+
@specification_provider = specification_provider
|
26
|
+
@resolver_ui = resolver_ui
|
27
|
+
end
|
28
|
+
|
29
|
+
# Resolves the requested dependencies into a {DependencyGraph},
|
30
|
+
# locking to the base dependency graph (if specified)
|
31
|
+
# @param [Array] requested an array of 'requested' dependencies that the
|
32
|
+
# {#specification_provider} can understand
|
33
|
+
# @param [DependencyGraph,nil] base the base dependency graph to which
|
34
|
+
# dependencies should be 'locked'
|
35
|
+
def resolve(requested, base = DependencyGraph.new)
|
36
|
+
Resolution.new(specification_provider,
|
37
|
+
resolver_ui,
|
38
|
+
requested,
|
39
|
+
base).
|
40
|
+
resolve
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Bundler::Molinillo
|
2
|
+
# A state that a {Resolution} can be in
|
3
|
+
# @attr [String] name
|
4
|
+
# @attr [Array<Object>] requirements
|
5
|
+
# @attr [DependencyGraph] activated
|
6
|
+
# @attr [Object] requirement
|
7
|
+
# @attr [Object] possibility
|
8
|
+
# @attr [Integer] depth
|
9
|
+
# @attr [Set<Object>] conflicts
|
10
|
+
ResolutionState = Struct.new(
|
11
|
+
:name,
|
12
|
+
:requirements,
|
13
|
+
:activated,
|
14
|
+
:requirement,
|
15
|
+
:possibilities,
|
16
|
+
:depth,
|
17
|
+
:conflicts
|
18
|
+
)
|
19
|
+
|
20
|
+
# A state that encapsulates a set of {#requirements} with an {Array} of
|
21
|
+
# possibilities
|
22
|
+
class DependencyState < ResolutionState
|
23
|
+
# Removes a possibility from `self`
|
24
|
+
# @return [PossibilityState] a state with a single possibility,
|
25
|
+
# the possibility that was removed from `self`
|
26
|
+
def pop_possibility_state
|
27
|
+
PossibilityState.new(
|
28
|
+
name,
|
29
|
+
requirements.dup,
|
30
|
+
activated.dup,
|
31
|
+
requirement,
|
32
|
+
[possibilities.pop],
|
33
|
+
depth + 1,
|
34
|
+
conflicts.dup
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# A state that encapsulates a single possibility to fulfill the given
|
40
|
+
# {#requirement}
|
41
|
+
class PossibilityState < ResolutionState
|
42
|
+
end
|
43
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "set"
|
2
|
+
require "thor/base"
|
3
3
|
|
4
|
-
class Thor # rubocop:disable ClassLength
|
4
|
+
class Bundler::Thor # rubocop:disable ClassLength
|
5
5
|
class << self
|
6
6
|
# Allows for custom "Command" package naming.
|
7
7
|
#
|
@@ -10,7 +10,7 @@ class Thor # rubocop:disable ClassLength
|
|
10
10
|
# options<Hash>
|
11
11
|
#
|
12
12
|
def package_name(name, options = {})
|
13
|
-
@package_name = name.nil? || name ==
|
13
|
+
@package_name = name.nil? || name == "" ? nil : name
|
14
14
|
end
|
15
15
|
|
16
16
|
# Sets the default command when thor is executed without an explicit command to be called.
|
@@ -20,22 +20,22 @@ class Thor # rubocop:disable ClassLength
|
|
20
20
|
#
|
21
21
|
def default_command(meth = nil)
|
22
22
|
if meth
|
23
|
-
@default_command = meth == :none ?
|
23
|
+
@default_command = meth == :none ? "help" : meth.to_s
|
24
24
|
else
|
25
|
-
@default_command ||= from_superclass(:default_command,
|
25
|
+
@default_command ||= from_superclass(:default_command, "help")
|
26
26
|
end
|
27
27
|
end
|
28
28
|
alias_method :default_task, :default_command
|
29
29
|
|
30
|
-
# Registers another Thor subclass as a command.
|
30
|
+
# Registers another Bundler::Thor subclass as a command.
|
31
31
|
#
|
32
32
|
# ==== Parameters
|
33
|
-
# klass<Class>:: Thor subclass to register
|
33
|
+
# klass<Class>:: Bundler::Thor subclass to register
|
34
34
|
# command<String>:: Subcommand name to use
|
35
35
|
# usage<String>:: Short usage for the subcommand
|
36
36
|
# description<String>:: Description for the subcommand
|
37
37
|
def register(klass, subcommand_name, usage, description, options = {})
|
38
|
-
if klass <= Thor::Group
|
38
|
+
if klass <= Bundler::Thor::Group
|
39
39
|
desc usage, description, options
|
40
40
|
define_method(subcommand_name) { |*args| invoke(klass, args) }
|
41
41
|
else
|
@@ -147,10 +147,10 @@ class Thor # rubocop:disable ClassLength
|
|
147
147
|
#
|
148
148
|
def method_option(name, options = {})
|
149
149
|
scope = if options[:for]
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
150
|
+
find_and_refresh_command(options[:for]).options
|
151
|
+
else
|
152
|
+
method_options
|
153
|
+
end
|
154
154
|
|
155
155
|
build_option(name, options, scope)
|
156
156
|
end
|
@@ -159,7 +159,7 @@ class Thor # rubocop:disable ClassLength
|
|
159
159
|
# Prints help information for the given command.
|
160
160
|
#
|
161
161
|
# ==== Parameters
|
162
|
-
# shell<Thor::Shell>
|
162
|
+
# shell<Bundler::Thor::Shell>
|
163
163
|
# command_name<String>
|
164
164
|
#
|
165
165
|
def command_help(shell, command_name)
|
@@ -167,12 +167,12 @@ class Thor # rubocop:disable ClassLength
|
|
167
167
|
command = all_commands[meth]
|
168
168
|
handle_no_command_error(meth) unless command
|
169
169
|
|
170
|
-
shell.say
|
170
|
+
shell.say "Usage:"
|
171
171
|
shell.say " #{banner(command)}"
|
172
172
|
shell.say
|
173
173
|
class_options_help(shell, nil => command.options.map { |_, o| o })
|
174
174
|
if command.long_description
|
175
|
-
shell.say
|
175
|
+
shell.say "Description:"
|
176
176
|
shell.print_wrapped(command.long_description, :indent => 2)
|
177
177
|
else
|
178
178
|
shell.say command.description
|
@@ -183,11 +183,11 @@ class Thor # rubocop:disable ClassLength
|
|
183
183
|
# Prints help information for this class.
|
184
184
|
#
|
185
185
|
# ==== Parameters
|
186
|
-
# shell<Thor::Shell>
|
186
|
+
# shell<Bundler::Thor::Shell>
|
187
187
|
#
|
188
188
|
def help(shell, subcommand = false)
|
189
189
|
list = printable_commands(true, subcommand)
|
190
|
-
Thor::Util.thor_classes_in(self).each do |klass|
|
190
|
+
Bundler::Thor::Util.thor_classes_in(self).each do |klass|
|
191
191
|
list += klass.printable_commands(false)
|
192
192
|
end
|
193
193
|
list.sort! { |a, b| a[0] <=> b[0] }
|
@@ -195,7 +195,7 @@ class Thor # rubocop:disable ClassLength
|
|
195
195
|
if defined?(@package_name) && @package_name
|
196
196
|
shell.say "#{@package_name} commands:"
|
197
197
|
else
|
198
|
-
shell.say
|
198
|
+
shell.say "Commands:"
|
199
199
|
end
|
200
200
|
|
201
201
|
shell.print_table(list, :indent => 2, :truncate => true)
|
@@ -209,7 +209,7 @@ class Thor # rubocop:disable ClassLength
|
|
209
209
|
next if command.hidden?
|
210
210
|
item = []
|
211
211
|
item << banner(command, false, subcommand)
|
212
|
-
item << (command.description ? "# #{command.description.gsub(/\s+/m, ' ')}" :
|
212
|
+
item << (command.description ? "# #{command.description.gsub(/\s+/m, ' ')}" : "")
|
213
213
|
item
|
214
214
|
end.compact
|
215
215
|
end
|
@@ -220,12 +220,17 @@ class Thor # rubocop:disable ClassLength
|
|
220
220
|
end
|
221
221
|
alias_method :subtasks, :subcommands
|
222
222
|
|
223
|
+
def subcommand_classes
|
224
|
+
@subcommand_classes ||= {}
|
225
|
+
end
|
226
|
+
|
223
227
|
def subcommand(subcommand, subcommand_class)
|
224
228
|
subcommands << subcommand.to_s
|
225
229
|
subcommand_class.subcommand_help subcommand
|
230
|
+
subcommand_classes[subcommand.to_s] = subcommand_class
|
226
231
|
|
227
232
|
define_method(subcommand) do |*args|
|
228
|
-
args, opts = Thor::Arguments.split(args)
|
233
|
+
args, opts = Bundler::Thor::Arguments.split(args)
|
229
234
|
args.unshift("help") if opts.include? "--help" or opts.include? "-h"
|
230
235
|
invoke subcommand_class, args, opts, :invoked_via_subcommand => true, :class_options => options
|
231
236
|
end
|
@@ -273,14 +278,14 @@ class Thor # rubocop:disable ClassLength
|
|
273
278
|
# argument is encountered. All remaining arguments are passed to the command.
|
274
279
|
# This is useful if you have a command that can receive arbitrary additional
|
275
280
|
# options, and where those additional options should not be handled by
|
276
|
-
# Thor.
|
281
|
+
# Bundler::Thor.
|
277
282
|
#
|
278
283
|
# ==== Example
|
279
284
|
#
|
280
285
|
# To better understand how this is useful, let's consider a command that calls
|
281
286
|
# an external command. A user may want to pass arbitrary options and
|
282
287
|
# arguments to that command. The command itself also accepts some options,
|
283
|
-
# which should be handled by Thor.
|
288
|
+
# which should be handled by Bundler::Thor.
|
284
289
|
#
|
285
290
|
# class_option "verbose", :type => :boolean
|
286
291
|
# stop_on_unknown_option! :exec
|
@@ -321,27 +326,18 @@ class Thor # rubocop:disable ClassLength
|
|
321
326
|
|
322
327
|
# The method responsible for dispatching given the args.
|
323
328
|
def dispatch(meth, given_args, given_opts, config) #:nodoc: # rubocop:disable MethodLength
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
# a command then use the default command. The given_args will be
|
333
|
-
# intact later since dup was used.
|
334
|
-
if config[:invoked_via_subcommand] && given_args.size >= 1 && default_command != 'help' && given_args.first != default_command
|
335
|
-
meth ||= retrieve_command_name(given_args.dup)
|
336
|
-
command = all_commands[normalize_command_name(meth)]
|
337
|
-
command ||= all_commands[normalize_command_name(default_command)]
|
338
|
-
else
|
339
|
-
meth ||= retrieve_command_name(given_args)
|
340
|
-
command = all_commands[normalize_command_name(meth)]
|
329
|
+
meth ||= retrieve_command_name(given_args)
|
330
|
+
command = all_commands[normalize_command_name(meth)]
|
331
|
+
|
332
|
+
if !command && config[:invoked_via_subcommand]
|
333
|
+
# We're a subcommand and our first argument didn't match any of our
|
334
|
+
# commands. So we put it back and call our default command.
|
335
|
+
given_args.unshift(meth)
|
336
|
+
command = all_commands[normalize_command_name(default_command)]
|
341
337
|
end
|
342
338
|
|
343
339
|
if command
|
344
|
-
args, opts = Thor::Options.split(given_args)
|
340
|
+
args, opts = Bundler::Thor::Options.split(given_args)
|
345
341
|
if stop_on_unknown_option?(command) && !args.empty?
|
346
342
|
# given_args starts with a non-option, so we treat everything as
|
347
343
|
# ordinary arguments
|
@@ -364,7 +360,7 @@ class Thor # rubocop:disable ClassLength
|
|
364
360
|
end
|
365
361
|
|
366
362
|
# The banner for this class. You can customize it if you are invoking the
|
367
|
-
# thor class by another ways which is not the Thor::Runner. It receives
|
363
|
+
# thor class by another ways which is not the Bundler::Thor::Runner. It receives
|
368
364
|
# the command that is going to be invoked and a boolean which indicates if
|
369
365
|
# the namespace should be displayed as arguments.
|
370
366
|
#
|
@@ -373,11 +369,11 @@ class Thor # rubocop:disable ClassLength
|
|
373
369
|
end
|
374
370
|
|
375
371
|
def baseclass #:nodoc:
|
376
|
-
Thor
|
372
|
+
Bundler::Thor
|
377
373
|
end
|
378
374
|
|
379
375
|
def dynamic_command_class #:nodoc:
|
380
|
-
Thor::DynamicCommand
|
376
|
+
Bundler::Thor::DynamicCommand
|
381
377
|
end
|
382
378
|
|
383
379
|
def create_command(meth) #:nodoc:
|
@@ -386,15 +382,15 @@ class Thor # rubocop:disable ClassLength
|
|
386
382
|
@long_desc ||= nil
|
387
383
|
|
388
384
|
if @usage && @desc
|
389
|
-
base_class = @hide ? Thor::HiddenCommand : Thor::Command
|
385
|
+
base_class = @hide ? Bundler::Thor::HiddenCommand : Bundler::Thor::Command
|
390
386
|
commands[meth] = base_class.new(meth, @desc, @long_desc, @usage, method_options)
|
391
387
|
@usage, @desc, @long_desc, @method_options, @hide = nil
|
392
388
|
true
|
393
|
-
elsif all_commands[meth] || meth ==
|
389
|
+
elsif all_commands[meth] || meth == "method_missing"
|
394
390
|
true
|
395
391
|
else
|
396
392
|
puts "[WARNING] Attempted to create command #{meth.inspect} without usage or description. " <<
|
397
|
-
|
393
|
+
"Call desc if you want this method to be available as command or declare it inside a " <<
|
398
394
|
"no_commands{} block. Invoked from #{caller[1].inspect}."
|
399
395
|
false
|
400
396
|
end
|
@@ -425,7 +421,7 @@ class Thor # rubocop:disable ClassLength
|
|
425
421
|
# +normalize_command_name+ also converts names like +animal-prison+
|
426
422
|
# into +animal_prison+.
|
427
423
|
def normalize_command_name(meth) #:nodoc:
|
428
|
-
return default_command.to_s.gsub(
|
424
|
+
return default_command.to_s.gsub("-", "_") unless meth
|
429
425
|
|
430
426
|
possibilities = find_command_possibilities(meth)
|
431
427
|
if possibilities.size > 1
|
@@ -438,7 +434,7 @@ class Thor # rubocop:disable ClassLength
|
|
438
434
|
meth = possibilities.first
|
439
435
|
end
|
440
436
|
|
441
|
-
meth.to_s.gsub(
|
437
|
+
meth.to_s.gsub("-", "_") # treat foo-bar as foo_bar
|
442
438
|
end
|
443
439
|
alias_method :normalize_task_name, :normalize_command_name
|
444
440
|
|
@@ -461,7 +457,7 @@ class Thor # rubocop:disable ClassLength
|
|
461
457
|
alias_method :find_task_possibilities, :find_command_possibilities
|
462
458
|
|
463
459
|
def subcommand_help(cmd)
|
464
|
-
desc
|
460
|
+
desc "help [COMMAND]", "Describe subcommands or one specific subcommand"
|
465
461
|
class_eval "
|
466
462
|
def help(command = nil, subcommand = true); super; end
|
467
463
|
"
|
@@ -469,12 +465,20 @@ class Thor # rubocop:disable ClassLength
|
|
469
465
|
alias_method :subtask_help, :subcommand_help
|
470
466
|
end
|
471
467
|
|
472
|
-
include Thor::Base
|
468
|
+
include Bundler::Thor::Base
|
473
469
|
|
474
470
|
map HELP_MAPPINGS => :help
|
475
471
|
|
476
|
-
desc
|
472
|
+
desc "help [COMMAND]", "Describe available commands or one specific command"
|
477
473
|
def help(command = nil, subcommand = false)
|
478
|
-
|
474
|
+
if command
|
475
|
+
if self.class.subcommands.include? command
|
476
|
+
self.class.subcommand_classes[command].help(shell, true)
|
477
|
+
else
|
478
|
+
self.class.command_help(shell, command)
|
479
|
+
end
|
480
|
+
else
|
481
|
+
self.class.help(shell, subcommand)
|
482
|
+
end
|
479
483
|
end
|
480
484
|
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
|
11
|
-
class Thor
|
1
|
+
require "fileutils"
|
2
|
+
require "uri"
|
3
|
+
require "thor/core_ext/io_binary_read"
|
4
|
+
require "thor/actions/create_file"
|
5
|
+
require "thor/actions/create_link"
|
6
|
+
require "thor/actions/directory"
|
7
|
+
require "thor/actions/empty_directory"
|
8
|
+
require "thor/actions/file_manipulation"
|
9
|
+
require "thor/actions/inject_into_file"
|
10
|
+
|
11
|
+
class Bundler::Thor
|
12
12
|
module Actions
|
13
13
|
attr_accessor :behavior
|
14
14
|
|
@@ -17,7 +17,7 @@ class Thor
|
|
17
17
|
end
|
18
18
|
|
19
19
|
module ClassMethods
|
20
|
-
# Hold source paths for one Thor instance. source_paths_for_search is the
|
20
|
+
# Hold source paths for one Bundler::Thor instance. source_paths_for_search is the
|
21
21
|
# method responsible to gather source_paths from this current class,
|
22
22
|
# inherited paths and the source root.
|
23
23
|
#
|
@@ -48,17 +48,17 @@ class Thor
|
|
48
48
|
# Add runtime options that help actions execution.
|
49
49
|
#
|
50
50
|
def add_runtime_options!
|
51
|
-
class_option :force, :type => :boolean, :aliases =>
|
52
|
-
:desc =>
|
51
|
+
class_option :force, :type => :boolean, :aliases => "-f", :group => :runtime,
|
52
|
+
:desc => "Overwrite files that already exist"
|
53
53
|
|
54
|
-
class_option :pretend, :type => :boolean, :aliases =>
|
55
|
-
:desc =>
|
54
|
+
class_option :pretend, :type => :boolean, :aliases => "-p", :group => :runtime,
|
55
|
+
:desc => "Run but do not make any changes"
|
56
56
|
|
57
|
-
class_option :quiet, :type => :boolean, :aliases =>
|
58
|
-
:desc =>
|
57
|
+
class_option :quiet, :type => :boolean, :aliases => "-q", :group => :runtime,
|
58
|
+
:desc => "Suppress status output"
|
59
59
|
|
60
|
-
class_option :skip, :type => :boolean, :aliases =>
|
61
|
-
:desc =>
|
60
|
+
class_option :skip, :type => :boolean, :aliases => "-s", :group => :runtime,
|
61
|
+
:desc => "Skip files that already exist"
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -73,10 +73,10 @@ class Thor
|
|
73
73
|
#
|
74
74
|
def initialize(args = [], options = {}, config = {})
|
75
75
|
self.behavior = case config[:behavior].to_s
|
76
|
-
when
|
76
|
+
when "force", "skip"
|
77
77
|
_cleanup_options_and_set(options, config[:behavior])
|
78
78
|
:invoke
|
79
|
-
when
|
79
|
+
when "revoke"
|
80
80
|
:revoke
|
81
81
|
else
|
82
82
|
:invoke
|
@@ -106,7 +106,7 @@ class Thor
|
|
106
106
|
#
|
107
107
|
def destination_root=(root)
|
108
108
|
@destination_stack ||= []
|
109
|
-
@destination_stack[0] = File.expand_path(root ||
|
109
|
+
@destination_stack[0] = File.expand_path(root || "")
|
110
110
|
end
|
111
111
|
|
112
112
|
# Returns the given path relative to the absolute root (ie, root where
|
@@ -114,8 +114,8 @@ class Thor
|
|
114
114
|
#
|
115
115
|
def relative_to_original_destination_root(path, remove_dot = true)
|
116
116
|
path = path.dup
|
117
|
-
if path.gsub!(@destination_stack[0],
|
118
|
-
remove_dot ? (path[2..-1] ||
|
117
|
+
if path.gsub!(@destination_stack[0], ".")
|
118
|
+
remove_dot ? (path[2..-1] || "") : path
|
119
119
|
else
|
120
120
|
path
|
121
121
|
end
|
@@ -147,7 +147,7 @@ class Thor
|
|
147
147
|
end
|
148
148
|
|
149
149
|
if source_paths.empty?
|
150
|
-
message <<
|
150
|
+
message << "Currently you have no source paths."
|
151
151
|
else
|
152
152
|
message << "Your current source paths are: \n#{source_paths.join("\n")}"
|
153
153
|
end
|
@@ -164,7 +164,7 @@ class Thor
|
|
164
164
|
# dir<String>:: the directory to move to.
|
165
165
|
# config<Hash>:: give :verbose => true to log and use padding.
|
166
166
|
#
|
167
|
-
def inside(dir =
|
167
|
+
def inside(dir = "", config = {}, &block)
|
168
168
|
verbose = config.fetch(:verbose, false)
|
169
169
|
pretend = options[:pretend]
|
170
170
|
|
@@ -215,7 +215,7 @@ class Thor
|
|
215
215
|
shell.padding += 1 if verbose
|
216
216
|
|
217
217
|
if is_uri
|
218
|
-
contents = open(path,
|
218
|
+
contents = open(path, "Accept" => "application/x-thor-template") { |io| io.read }
|
219
219
|
else
|
220
220
|
contents = open(path) { |io| io.read }
|
221
221
|
end
|
@@ -263,7 +263,7 @@ class Thor
|
|
263
263
|
#
|
264
264
|
def run_ruby_script(command, config = {})
|
265
265
|
return unless behavior == :invoke
|
266
|
-
run command, config.merge(:with => Thor::Util.ruby_command)
|
266
|
+
run command, config.merge(:with => Bundler::Thor::Util.ruby_command)
|
267
267
|
end
|
268
268
|
|
269
269
|
# Run a thor command. A hash of options can be given and it's converted to
|
@@ -273,7 +273,7 @@ class Thor
|
|
273
273
|
# command<String>:: the command to be invoked
|
274
274
|
# args<Array>:: arguments to the command
|
275
275
|
# config<Hash>:: give :verbose => false to not log the status, :capture => true to hide to output.
|
276
|
-
# Other options are given as parameter to Thor.
|
276
|
+
# Other options are given as parameter to Bundler::Thor.
|
277
277
|
#
|
278
278
|
#
|
279
279
|
# ==== Examples
|
@@ -291,8 +291,8 @@ class Thor
|
|
291
291
|
capture = config.key?(:capture) ? config.delete(:capture) : false
|
292
292
|
|
293
293
|
args.unshift(command)
|
294
|
-
args.push Thor::Options.to_switches(config)
|
295
|
-
command = args.join(
|
294
|
+
args.push Bundler::Thor::Options.to_switches(config)
|
295
|
+
command = args.join(" ").strip
|
296
296
|
|
297
297
|
run command, :with => :thor, :verbose => verbose, :pretend => pretend, :capture => capture
|
298
298
|
end
|
@@ -308,10 +308,10 @@ class Thor
|
|
308
308
|
def _cleanup_options_and_set(options, key) #:nodoc:
|
309
309
|
case options
|
310
310
|
when Array
|
311
|
-
%w
|
311
|
+
%w[--force -f --skip -s].each { |i| options.delete(i) }
|
312
312
|
options << "--#{key}"
|
313
313
|
when Hash
|
314
|
-
[:force, :skip,
|
314
|
+
[:force, :skip, "force", "skip"].each { |i| options.delete(i) }
|
315
315
|
options.merge!(key => true)
|
316
316
|
end
|
317
317
|
end
|