bundler 1.0.22 → 1.1.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.
- data/CHANGELOG.md +15 -181
- data/ISSUES.md +11 -26
- data/LICENSE +0 -2
- data/Rakefile +67 -116
- data/UPGRADING.md +4 -4
- data/bin/bundle +10 -10
- data/bundler.gemspec +5 -5
- data/lib/bundler.rb +15 -25
- data/lib/bundler/capistrano.rb +2 -2
- data/lib/bundler/cli.rb +41 -72
- data/lib/bundler/definition.rb +11 -37
- data/lib/bundler/dependency.rb +9 -13
- data/lib/bundler/deployment.rb +3 -8
- data/lib/bundler/dsl.rb +10 -24
- data/lib/bundler/fetcher.rb +101 -0
- data/lib/bundler/gem_helper.rb +6 -11
- data/lib/bundler/index.rb +8 -15
- data/lib/bundler/installer.rb +55 -35
- data/lib/bundler/lazy_specification.rb +7 -10
- data/lib/bundler/remote_specification.rb +6 -8
- data/lib/bundler/resolver.rb +18 -12
- data/lib/bundler/rubygems_ext.rb +3 -20
- data/lib/bundler/runtime.rb +57 -8
- data/lib/bundler/settings.rb +6 -4
- data/lib/bundler/setup.rb +5 -12
- data/lib/bundler/shared_helpers.rb +100 -4
- data/lib/bundler/source.rb +61 -106
- data/lib/bundler/spec_set.rb +8 -9
- data/lib/bundler/templates/newgem/Rakefile.tt +2 -1
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +0 -2
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +3 -6
- data/lib/bundler/ui.rb +1 -4
- data/lib/bundler/vendor/net/http/faster.rb +27 -0
- data/lib/bundler/vendor/net/http/persistent.rb +464 -0
- data/lib/bundler/vendor/thor.rb +4 -43
- data/lib/bundler/vendor/thor/actions.rb +11 -28
- data/lib/bundler/vendor/thor/actions/create_file.rb +2 -2
- data/lib/bundler/vendor/thor/actions/directory.rb +2 -2
- data/lib/bundler/vendor/thor/actions/empty_directory.rb +0 -0
- data/lib/bundler/vendor/thor/actions/file_manipulation.rb +15 -56
- data/lib/bundler/vendor/thor/actions/inject_into_file.rb +10 -15
- data/lib/bundler/vendor/thor/base.rb +4 -24
- data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +0 -0
- data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +0 -0
- data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +0 -0
- data/lib/bundler/vendor/thor/error.rb +0 -0
- data/lib/bundler/vendor/thor/invocation.rb +0 -0
- data/lib/bundler/vendor/thor/parser.rb +0 -0
- data/lib/bundler/vendor/thor/parser/argument.rb +0 -0
- data/lib/bundler/vendor/thor/parser/arguments.rb +2 -2
- data/lib/bundler/vendor/thor/parser/option.rb +1 -1
- data/lib/bundler/vendor/thor/parser/options.rb +16 -17
- data/lib/bundler/vendor/thor/shell.rb +0 -0
- data/lib/bundler/vendor/thor/shell/basic.rb +13 -40
- data/lib/bundler/vendor/thor/shell/color.rb +0 -0
- data/lib/bundler/vendor/thor/task.rb +4 -3
- data/lib/bundler/vendor/thor/util.rb +2 -2
- data/lib/bundler/vendor/thor/version.rb +1 -1
- data/lib/bundler/version.rb +1 -1
- data/lib/bundler/vlad.rb +0 -2
- data/man/bundle-install.ronn +3 -6
- data/man/gemfile.5.ronn +2 -7
- data/spec/cache/gems_spec.rb +0 -11
- data/spec/cache/git_spec.rb +2 -5
- data/spec/install/deploy_spec.rb +8 -8
- data/spec/install/gems/dependency_api_spec.rb +85 -0
- data/spec/install/gems/flex_spec.rb +4 -4
- data/spec/install/gems/groups_spec.rb +3 -17
- data/spec/install/gems/platform_spec.rb +16 -0
- data/spec/install/gems/simple_case_spec.rb +24 -88
- data/spec/install/gems/standalone_spec.rb +162 -0
- data/spec/install/gems/sudo_spec.rb +2 -3
- data/spec/install/gemspec_spec.rb +0 -38
- data/spec/install/git_spec.rb +4 -3
- data/spec/install/invalid_spec.rb +0 -18
- data/spec/install/path_spec.rb +1 -53
- data/spec/lock/git_spec.rb +1 -1
- data/spec/lock/lockfile_spec.rb +16 -72
- data/spec/other/check_spec.rb +6 -6
- data/spec/other/clean_spec.rb +202 -0
- data/spec/other/exec_spec.rb +7 -14
- data/spec/other/ext_spec.rb +0 -21
- data/spec/{bundler → other}/gem_helper_spec.rb +1 -16
- data/spec/other/help_spec.rb +1 -2
- data/spec/other/init_spec.rb +3 -3
- data/spec/other/newgem_spec.rb +1 -23
- data/spec/pack/gems_spec.rb +22 -0
- data/spec/quality_spec.rb +2 -6
- data/spec/runtime/require_spec.rb +10 -10
- data/spec/runtime/setup_spec.rb +12 -54
- data/spec/spec_helper.rb +7 -14
- data/spec/support/artifice/endpoint.rb +50 -0
- data/spec/support/artifice/endpoint_fallback.rb +22 -0
- data/spec/support/artifice/endpoint_marshal_fail.rb +11 -0
- data/spec/support/artifice/endpoint_redirect.rb +11 -0
- data/spec/support/builders.rb +2 -25
- data/spec/support/fakeweb/rack-1.0.0.marshal +2 -0
- data/spec/support/fakeweb/windows.rb +23 -0
- data/spec/support/helpers.rb +12 -5
- data/spec/support/matchers.rb +16 -4
- data/spec/support/path.rb +2 -0
- data/spec/support/rubygems_ext.rb +2 -6
- data/spec/update/gems_spec.rb +2 -3
- data/spec/update/git_spec.rb +2 -2
- metadata +41 -24
- data/.travis.yml +0 -31
- data/lib/bundler/gem_installer.rb +0 -9
- data/lib/bundler/gem_tasks.rb +0 -2
- data/lib/bundler/rubygems_integration.rb +0 -344
- data/lib/bundler/vendor/thor/actions/create_link.rb +0 -57
- data/lib/bundler/vendor/thor/group.rb +0 -273
- data/lib/bundler/vendor/thor/rake_compat.rb +0 -66
- data/lib/bundler/vendor/thor/runner.rb +0 -309
- data/lib/bundler/vendored_thor.rb +0 -7
data/lib/bundler/vendor/thor.rb
CHANGED
@@ -18,23 +18,6 @@ class Thor
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
# Registers another Thor subclass as a command.
|
22
|
-
#
|
23
|
-
# ==== Parameters
|
24
|
-
# klass<Class>:: Thor subclass to register
|
25
|
-
# command<String>:: Subcommand name to use
|
26
|
-
# usage<String>:: Short usage for the subcommand
|
27
|
-
# description<String>:: Description for the subcommand
|
28
|
-
def register(klass, subcommand_name, usage, description, options={})
|
29
|
-
if klass <= Thor::Group
|
30
|
-
desc usage, description, options
|
31
|
-
define_method(subcommand_name) { invoke klass }
|
32
|
-
else
|
33
|
-
desc usage, description, options
|
34
|
-
subcommand subcommand_name, klass
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
21
|
# Defines the usage and the description of the next task.
|
39
22
|
#
|
40
23
|
# ==== Parameters
|
@@ -269,7 +252,8 @@ class Thor
|
|
269
252
|
# the namespace should be displayed as arguments.
|
270
253
|
#
|
271
254
|
def banner(task, namespace = nil, subcommand = false)
|
272
|
-
|
255
|
+
base = File.basename($0).split(" ").first
|
256
|
+
"#{base} #{task.formatted_usage(self, $thor_runner, subcommand)}"
|
273
257
|
end
|
274
258
|
|
275
259
|
def baseclass #:nodoc:
|
@@ -311,40 +295,17 @@ class Thor
|
|
311
295
|
# Receives a task name (can be nil), and try to get a map from it.
|
312
296
|
# If a map can't be found use the sent name or the default task.
|
313
297
|
def normalize_task_name(meth) #:nodoc:
|
314
|
-
meth = map[meth.to_s] ||
|
298
|
+
meth = map[meth.to_s] || meth || default_task
|
315
299
|
meth.to_s.gsub('-','_') # treat foo-bar > foo_bar
|
316
300
|
end
|
317
301
|
|
318
|
-
# terrible hack that overwrites ARGV
|
319
|
-
def find_subcommand_and_update_argv(subcmd_name) #:nodoc:
|
320
|
-
return unless subcmd_name
|
321
|
-
cmd = find_subcommand(subcmd_name)
|
322
|
-
ARGV[0] = cmd if cmd
|
323
|
-
cmd
|
324
|
-
end
|
325
|
-
|
326
|
-
def find_subcommand(subcmd_name)
|
327
|
-
possibilities = find_subcommand_possibilities subcmd_name
|
328
|
-
if possibilities.size > 1
|
329
|
-
raise "Ambiguous subcommand #{subcmd_name} matches [#{possibilities.join(', ')}]"
|
330
|
-
elsif possibilities.size < 1
|
331
|
-
return nil
|
332
|
-
end
|
333
|
-
|
334
|
-
possibilities.first
|
335
|
-
end
|
336
|
-
|
337
|
-
def find_subcommand_possibilities(subcmd_name)
|
338
|
-
len = subcmd_name.length
|
339
|
-
all_tasks.map {|t| t.first}.select { |n| subcmd_name == n[0, len] }
|
340
|
-
end
|
341
|
-
|
342
302
|
def subcommand_help(cmd)
|
343
303
|
desc "help [COMMAND]", "Describe subcommands or one specific subcommand"
|
344
304
|
class_eval <<-RUBY
|
345
305
|
def help(task = nil, subcommand = true); super; end
|
346
306
|
RUBY
|
347
307
|
end
|
308
|
+
|
348
309
|
end
|
349
310
|
|
350
311
|
include Thor::Base
|
@@ -1,12 +1,10 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'uri'
|
3
3
|
require 'thor/core_ext/file_binary_read'
|
4
|
-
|
5
|
-
|
6
|
-
require
|
7
|
-
|
8
|
-
require 'thor/actions/file_manipulation'
|
9
|
-
require 'thor/actions/inject_into_file'
|
4
|
+
|
5
|
+
Dir[File.join(File.dirname(__FILE__), "actions", "*.rb")].each do |action|
|
6
|
+
require action
|
7
|
+
end
|
10
8
|
|
11
9
|
class Thor
|
12
10
|
module Actions
|
@@ -160,23 +158,13 @@ class Thor
|
|
160
158
|
#
|
161
159
|
def inside(dir='', config={}, &block)
|
162
160
|
verbose = config.fetch(:verbose, false)
|
163
|
-
pretend = options[:pretend]
|
164
161
|
|
165
162
|
say_status :inside, dir, verbose
|
166
163
|
shell.padding += 1 if verbose
|
167
164
|
@destination_stack.push File.expand_path(dir, destination_root)
|
168
165
|
|
169
|
-
|
170
|
-
|
171
|
-
FileUtils.mkdir_p(destination_root)
|
172
|
-
end
|
173
|
-
|
174
|
-
if pretend
|
175
|
-
# In pretend mode, just yield down to the block
|
176
|
-
block.arity == 1 ? yield(destination_root) : yield
|
177
|
-
else
|
178
|
-
FileUtils.cd(destination_root) { block.arity == 1 ? yield(destination_root) : yield }
|
179
|
-
end
|
166
|
+
FileUtils.mkdir_p(destination_root) unless File.exist?(destination_root)
|
167
|
+
FileUtils.cd(destination_root) { block.arity == 1 ? yield(destination_root) : yield }
|
180
168
|
|
181
169
|
@destination_stack.pop
|
182
170
|
shell.padding -= 1 if verbose
|
@@ -222,7 +210,7 @@ class Thor
|
|
222
210
|
#
|
223
211
|
# ==== Parameters
|
224
212
|
# command<String>:: the command to be executed.
|
225
|
-
# config<Hash>:: give :verbose => false to not log the status
|
213
|
+
# config<Hash>:: give :verbose => false to not log the status. Specify :with
|
226
214
|
# to append an executable to command executation.
|
227
215
|
#
|
228
216
|
# ==== Example
|
@@ -243,10 +231,7 @@ class Thor
|
|
243
231
|
end
|
244
232
|
|
245
233
|
say_status :run, desc, config.fetch(:verbose, true)
|
246
|
-
|
247
|
-
unless options[:pretend]
|
248
|
-
config[:capture] ? `#{command}` : system("#{command}")
|
249
|
-
end
|
234
|
+
`#{command}` unless options[:pretend]
|
250
235
|
end
|
251
236
|
|
252
237
|
# Executes a ruby script (taking into account WIN32 platform quirks).
|
@@ -266,9 +251,8 @@ class Thor
|
|
266
251
|
# ==== Parameters
|
267
252
|
# task<String>:: the task to be invoked
|
268
253
|
# args<Array>:: arguments to the task
|
269
|
-
# config<Hash>:: give :verbose => false to not log the status
|
270
|
-
#
|
271
|
-
#
|
254
|
+
# config<Hash>:: give :verbose => false to not log the status. Other options
|
255
|
+
# are given as parameter to Thor.
|
272
256
|
#
|
273
257
|
# ==== Examples
|
274
258
|
#
|
@@ -282,13 +266,12 @@ class Thor
|
|
282
266
|
config = args.last.is_a?(Hash) ? args.pop : {}
|
283
267
|
verbose = config.key?(:verbose) ? config.delete(:verbose) : true
|
284
268
|
pretend = config.key?(:pretend) ? config.delete(:pretend) : false
|
285
|
-
capture = config.key?(:capture) ? config.delete(:capture) : false
|
286
269
|
|
287
270
|
args.unshift task
|
288
271
|
args.push Thor::Options.to_switches(config)
|
289
272
|
command = args.join(' ').strip
|
290
273
|
|
291
|
-
run command, :with => :thor, :verbose => verbose, :pretend => pretend
|
274
|
+
run command, :with => :thor, :verbose => verbose, :pretend => pretend
|
292
275
|
end
|
293
276
|
|
294
277
|
protected
|
@@ -18,7 +18,7 @@ class Thor
|
|
18
18
|
# "vhost.name = #{hostname}"
|
19
19
|
# end
|
20
20
|
#
|
21
|
-
# create_file "config/
|
21
|
+
# create_file "config/apach.conf", "your apache config"
|
22
22
|
#
|
23
23
|
def create_file(destination, *args, &block)
|
24
24
|
config = args.last.is_a?(Hash) ? args.pop : {}
|
@@ -27,7 +27,7 @@ class Thor
|
|
27
27
|
end
|
28
28
|
alias :add_file :create_file
|
29
29
|
|
30
|
-
#
|
30
|
+
# AddFile is a subset of Template, which instead of rendering a file with
|
31
31
|
# ERB, it gets the content from the user.
|
32
32
|
#
|
33
33
|
class CreateFile < EmptyDirectory #:nodoc:
|
@@ -21,7 +21,7 @@ class Thor
|
|
21
21
|
# directory "doc"
|
22
22
|
#
|
23
23
|
# It will create a doc directory in the destination with the following
|
24
|
-
# files (assuming that the
|
24
|
+
# files (assuming that the app_name is "blog"):
|
25
25
|
#
|
26
26
|
# doc/
|
27
27
|
# components/
|
@@ -70,7 +70,7 @@ class Thor
|
|
70
70
|
lookup = config[:recursive] ? File.join(source, '**') : source
|
71
71
|
lookup = File.join(lookup, '{*,.[a-z]*}')
|
72
72
|
|
73
|
-
Dir[lookup].
|
73
|
+
Dir[lookup].each do |file_source|
|
74
74
|
next if File.directory?(file_source)
|
75
75
|
file_destination = File.join(given_destination, file_source.gsub(source, '.'))
|
76
76
|
file_destination.gsub!('/./', '/')
|
File without changes
|
@@ -30,28 +30,6 @@ class Thor
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
# Links the file from the relative source to the relative destination. If
|
34
|
-
# the destination is not given it's assumed to be equal to the source.
|
35
|
-
#
|
36
|
-
# ==== Parameters
|
37
|
-
# source<String>:: the relative path to the source root.
|
38
|
-
# destination<String>:: the relative path to the destination root.
|
39
|
-
# config<Hash>:: give :verbose => false to not log the status.
|
40
|
-
#
|
41
|
-
# ==== Examples
|
42
|
-
#
|
43
|
-
# link_file "README", "doc/README"
|
44
|
-
#
|
45
|
-
# link_file "doc/README"
|
46
|
-
#
|
47
|
-
def link_file(source, *args, &block)
|
48
|
-
config = args.last.is_a?(Hash) ? args.pop : {}
|
49
|
-
destination = args.first || source
|
50
|
-
source = File.expand_path(find_in_source_paths(source.to_s))
|
51
|
-
|
52
|
-
create_link destination, source, config
|
53
|
-
end
|
54
|
-
|
55
33
|
# Gets the content at the given address and places it at the given relative
|
56
34
|
# destination. If a block is given instead of destination, the content of
|
57
35
|
# the url is yielded and used as location.
|
@@ -73,7 +51,7 @@ class Thor
|
|
73
51
|
config = args.last.is_a?(Hash) ? args.pop : {}
|
74
52
|
destination = args.first
|
75
53
|
|
76
|
-
source = File.expand_path(find_in_source_paths(source.to_s)) unless source =~ /^
|
54
|
+
source = File.expand_path(find_in_source_paths(source.to_s)) unless source =~ /^http\:\/\//
|
77
55
|
render = open(source) {|input| input.binmode.read }
|
78
56
|
|
79
57
|
destination ||= if block_given?
|
@@ -102,13 +80,13 @@ class Thor
|
|
102
80
|
#
|
103
81
|
def template(source, *args, &block)
|
104
82
|
config = args.last.is_a?(Hash) ? args.pop : {}
|
105
|
-
destination = args.first || source
|
83
|
+
destination = args.first || source
|
106
84
|
|
107
85
|
source = File.expand_path(find_in_source_paths(source.to_s))
|
108
86
|
context = instance_eval('binding')
|
109
87
|
|
110
88
|
create_file destination, nil, config do
|
111
|
-
content = ERB.new(::File.binread(source), nil, '-'
|
89
|
+
content = ERB.new(::File.binread(source), nil, '-').result(context)
|
112
90
|
content = block.call(content) if block
|
113
91
|
content
|
114
92
|
end
|
@@ -132,7 +110,7 @@ class Thor
|
|
132
110
|
FileUtils.chmod_R(mode, path) unless options[:pretend]
|
133
111
|
end
|
134
112
|
|
135
|
-
# Prepend text to a file. Since it depends on
|
113
|
+
# Prepend text to a file. Since it depends on inject_into_file, it's reversible.
|
136
114
|
#
|
137
115
|
# ==== Parameters
|
138
116
|
# path<String>:: path of the file to be changed
|
@@ -141,20 +119,19 @@ class Thor
|
|
141
119
|
#
|
142
120
|
# ==== Example
|
143
121
|
#
|
144
|
-
#
|
122
|
+
# prepend_file 'config/environments/test.rb', 'config.gem "rspec"'
|
145
123
|
#
|
146
|
-
#
|
124
|
+
# prepend_file 'config/environments/test.rb' do
|
147
125
|
# 'config.gem "rspec"'
|
148
126
|
# end
|
149
127
|
#
|
150
|
-
def
|
128
|
+
def prepend_file(path, *args, &block)
|
151
129
|
config = args.last.is_a?(Hash) ? args.pop : {}
|
152
130
|
config.merge!(:after => /\A/)
|
153
|
-
|
131
|
+
inject_into_file(path, *(args << config), &block)
|
154
132
|
end
|
155
|
-
alias_method :prepend_file, :prepend_to_file
|
156
133
|
|
157
|
-
# Append text to a file. Since it depends on
|
134
|
+
# Append text to a file. Since it depends on inject_into_file, it's reversible.
|
158
135
|
#
|
159
136
|
# ==== Parameters
|
160
137
|
# path<String>:: path of the file to be changed
|
@@ -163,21 +140,20 @@ class Thor
|
|
163
140
|
#
|
164
141
|
# ==== Example
|
165
142
|
#
|
166
|
-
#
|
143
|
+
# append_file 'config/environments/test.rb', 'config.gem "rspec"'
|
167
144
|
#
|
168
|
-
#
|
145
|
+
# append_file 'config/environments/test.rb' do
|
169
146
|
# 'config.gem "rspec"'
|
170
147
|
# end
|
171
148
|
#
|
172
|
-
def
|
149
|
+
def append_file(path, *args, &block)
|
173
150
|
config = args.last.is_a?(Hash) ? args.pop : {}
|
174
151
|
config.merge!(:before => /\z/)
|
175
|
-
|
152
|
+
inject_into_file(path, *(args << config), &block)
|
176
153
|
end
|
177
|
-
alias_method :append_file, :append_to_file
|
178
154
|
|
179
155
|
# Injects text right after the class definition. Since it depends on
|
180
|
-
#
|
156
|
+
# inject_into_file, it's reversible.
|
181
157
|
#
|
182
158
|
# ==== Parameters
|
183
159
|
# path<String>:: path of the file to be changed
|
@@ -196,7 +172,7 @@ class Thor
|
|
196
172
|
def inject_into_class(path, klass, *args, &block)
|
197
173
|
config = args.last.is_a?(Hash) ? args.pop : {}
|
198
174
|
config.merge!(:after => /class #{klass}\n|class #{klass} .*\n/)
|
199
|
-
|
175
|
+
inject_into_file(path, *(args << config), &block)
|
200
176
|
end
|
201
177
|
|
202
178
|
# Run a regular expression replacement on a file.
|
@@ -249,22 +225,5 @@ class Thor
|
|
249
225
|
end
|
250
226
|
alias :remove_dir :remove_file
|
251
227
|
|
252
|
-
private
|
253
|
-
attr_accessor :output_buffer
|
254
|
-
def concat(string)
|
255
|
-
@output_buffer.concat(string)
|
256
|
-
end
|
257
|
-
|
258
|
-
def capture(*args, &block)
|
259
|
-
with_output_buffer { block.call(*args) }
|
260
|
-
end
|
261
|
-
|
262
|
-
def with_output_buffer(buf = '') #:nodoc:
|
263
|
-
self.output_buffer, old_buffer = buf, output_buffer
|
264
|
-
yield
|
265
|
-
output_buffer
|
266
|
-
ensure
|
267
|
-
self.output_buffer = old_buffer
|
268
|
-
end
|
269
228
|
end
|
270
229
|
end
|
@@ -10,19 +10,19 @@ class Thor
|
|
10
10
|
# destination<String>:: Relative path to the destination root
|
11
11
|
# data<String>:: Data to add to the file. Can be given as a block.
|
12
12
|
# config<Hash>:: give :verbose => false to not log the status and the flag
|
13
|
-
# for injection (:after or :before) or :force => true for
|
13
|
+
# for injection (:after or :before) or :force => true for
|
14
14
|
# insert two or more times the same content.
|
15
|
-
#
|
15
|
+
#
|
16
16
|
# ==== Examples
|
17
17
|
#
|
18
|
-
#
|
18
|
+
# inject_into_file "config/environment.rb", "config.gem :thor", :after => "Rails::Initializer.run do |config|\n"
|
19
19
|
#
|
20
|
-
#
|
20
|
+
# inject_into_file "config/environment.rb", :after => "Rails::Initializer.run do |config|\n" do
|
21
21
|
# gems = ask "Which gems would you like to add?"
|
22
22
|
# gems.split(" ").map{ |gem| " config.gem :#{gem}" }.join("\n")
|
23
23
|
# end
|
24
24
|
#
|
25
|
-
def
|
25
|
+
def inject_into_file(destination, *args, &block)
|
26
26
|
if block_given?
|
27
27
|
data, config = block, args.shift
|
28
28
|
else
|
@@ -30,7 +30,6 @@ class Thor
|
|
30
30
|
end
|
31
31
|
action InjectIntoFile.new(self, destination, data, config)
|
32
32
|
end
|
33
|
-
alias_method :inject_into_file, :insert_into_file
|
34
33
|
|
35
34
|
class InjectIntoFile < EmptyDirectory #:nodoc:
|
36
35
|
attr_reader :replacement, :flag, :behavior
|
@@ -77,16 +76,12 @@ class Thor
|
|
77
76
|
protected
|
78
77
|
|
79
78
|
def say_status(behavior)
|
80
|
-
status = if
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
:append
|
85
|
-
else
|
86
|
-
:insert
|
87
|
-
end
|
79
|
+
status = if flag == /\A/
|
80
|
+
behavior == :invoke ? :prepend : :unprepend
|
81
|
+
elsif flag == /\z/
|
82
|
+
behavior == :invoke ? :append : :unappend
|
88
83
|
else
|
89
|
-
:
|
84
|
+
behavior == :invoke ? :inject : :deinject
|
90
85
|
end
|
91
86
|
|
92
87
|
super(status, config[:verbose])
|
@@ -94,6 +94,8 @@ class Thor
|
|
94
94
|
end
|
95
95
|
|
96
96
|
module ClassMethods
|
97
|
+
attr_accessor :debugging
|
98
|
+
|
97
99
|
def attr_reader(*) #:nodoc:
|
98
100
|
no_tasks { super }
|
99
101
|
end
|
@@ -382,29 +384,14 @@ class Thor
|
|
382
384
|
# script.invoke(:task, first_arg, second_arg, third_arg)
|
383
385
|
#
|
384
386
|
def start(given_args=ARGV, config={})
|
387
|
+
self.debugging = given_args.delete("--debug")
|
385
388
|
config[:shell] ||= Thor::Base.shell.new
|
386
389
|
dispatch(nil, given_args.dup, nil, config)
|
387
390
|
rescue Thor::Error => e
|
388
|
-
|
391
|
+
debugging ? (raise e) : config[:shell].error(e.message)
|
389
392
|
exit(1) if exit_on_failure?
|
390
393
|
end
|
391
394
|
|
392
|
-
# Allows to use private methods from parent in child classes as tasks.
|
393
|
-
#
|
394
|
-
# ==== Paremeters
|
395
|
-
# names<Array>:: Method names to be used as tasks
|
396
|
-
#
|
397
|
-
# ==== Examples
|
398
|
-
#
|
399
|
-
# public_task :foo
|
400
|
-
# public_task :foo, :bar, :baz
|
401
|
-
#
|
402
|
-
def public_task(*names)
|
403
|
-
names.each do |name|
|
404
|
-
class_eval "def #{name}(*); super end"
|
405
|
-
end
|
406
|
-
end
|
407
|
-
|
408
395
|
def handle_no_task_error(task) #:nodoc:
|
409
396
|
if $thor_runner
|
410
397
|
raise UndefinedTaskError, "Could not find task #{task.inspect} in #{namespace.inspect} namespace."
|
@@ -544,13 +531,6 @@ class Thor
|
|
544
531
|
false
|
545
532
|
end
|
546
533
|
|
547
|
-
#
|
548
|
-
# The basename of the program invoking the thor class.
|
549
|
-
#
|
550
|
-
def basename
|
551
|
-
File.basename($0).split(' ').first
|
552
|
-
end
|
553
|
-
|
554
534
|
# SIGNATURE: Sets the baseclass. This is where the superclass lookup
|
555
535
|
# finishes.
|
556
536
|
def baseclass #:nodoc:
|