bundler 1.0.15 → 1.0.17
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 +28 -0
- data/ISSUES.md +1 -0
- data/Rakefile +3 -3
- data/UPGRADING.md +2 -2
- data/lib/bundler/cli.rb +5 -7
- data/lib/bundler/gem_helper.rb +6 -3
- data/lib/bundler/index.rb +9 -4
- data/lib/bundler/lazy_specification.rb +9 -6
- data/lib/bundler/resolver.rb +4 -10
- data/lib/bundler/rubygems_ext.rb +1 -0
- data/lib/bundler/rubygems_integration.rb +23 -3
- data/lib/bundler/source.rb +4 -4
- data/lib/bundler/spec_set.rb +9 -8
- data/lib/bundler/templates/newgem/Rakefile.tt +1 -1
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +4 -0
- data/lib/bundler/vendor/thor.rb +43 -4
- data/lib/bundler/vendor/thor/actions.rb +28 -11
- data/lib/bundler/vendor/thor/actions/create_file.rb +2 -2
- data/lib/bundler/vendor/thor/actions/create_link.rb +57 -0
- 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 +56 -15
- data/lib/bundler/vendor/thor/actions/inject_into_file.rb +15 -10
- data/lib/bundler/vendor/thor/base.rb +24 -4
- 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/group.rb +273 -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 +17 -16
- data/lib/bundler/vendor/thor/rake_compat.rb +66 -0
- data/lib/bundler/vendor/thor/runner.rb +309 -0
- data/lib/bundler/vendor/thor/shell.rb +0 -0
- data/lib/bundler/vendor/thor/shell/basic.rb +40 -13
- data/lib/bundler/vendor/thor/shell/color.rb +0 -0
- data/lib/bundler/vendor/thor/task.rb +3 -4
- data/lib/bundler/vendor/thor/util.rb +2 -2
- data/lib/bundler/vendor/thor/version.rb +1 -1
- data/lib/bundler/vendored_thor.rb +7 -0
- data/lib/bundler/version.rb +1 -1
- data/man/gemfile.5.ronn +3 -0
- data/spec/cache/git_spec.rb +5 -2
- data/spec/install/git_spec.rb +1 -1
- data/spec/other/exec_spec.rb +2 -2
- data/spec/other/gem_helper_spec.rb +1 -1
- data/spec/quality_spec.rb +4 -0
- data/spec/runtime/setup_spec.rb +1 -1
- data/spec/support/helpers.rb +1 -1
- metadata +21 -74
- data/spec/pack/gems_spec.rb +0 -22
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,31 @@
|
|
1
|
+
## 1.0.17 (Aug 8, 2011)
|
2
|
+
|
3
|
+
Bugfixes:
|
4
|
+
|
5
|
+
- Fix rake issues with rubygems 1.3.x (#1342)
|
6
|
+
- Fixed invalid byte sequence error while installing gem on Ruby 1.9 (#1341)
|
7
|
+
|
8
|
+
## 1.0.16 (Aug 8, 2011)
|
9
|
+
|
10
|
+
Features:
|
11
|
+
|
12
|
+
- Performance fix for MRI 1.9 (@efficientcloud, #1288)
|
13
|
+
- Shortcuts (like `bundle i`) for all commands (@amatsuda)
|
14
|
+
- Correcly identify missing child dependency in error message
|
15
|
+
|
16
|
+
Bugfixes:
|
17
|
+
|
18
|
+
- Allow Windows network share paths with forward slashes (@mtscout6, #1253)
|
19
|
+
- Check for rubygems.org credentials so `rake release` doesn't hang (#980)
|
20
|
+
- Find cached prerelease gems on rubygems 1.3.x (@dburt, #1202)
|
21
|
+
- Fix `bundle install --without` on kiji (@tmm1, #1287)
|
22
|
+
- Get rid of warning in ruby 1.9.3 (@smartinez87, #1231)
|
23
|
+
|
24
|
+
Documentation:
|
25
|
+
|
26
|
+
- Documentation for `gem ..., :require => false` (@kmayer, #1292)
|
27
|
+
- Gems provide "executables", they are rarely also binaries (@fxn, #1242)
|
28
|
+
|
1
29
|
## 1.0.15 (June 9, 2011)
|
2
30
|
|
3
31
|
Features:
|
data/ISSUES.md
CHANGED
@@ -50,6 +50,7 @@ Instructions that allow the Bundler team to reproduce your issue are vitally imp
|
|
50
50
|
- What version of Rubygems you are using (run `gem -v`)
|
51
51
|
- Whether you are using RVM, and if so what version (run `rvm -v`)
|
52
52
|
- Whether you have the `rubygems-bundler` gem, which can break gem binares
|
53
|
+
- Whether you have the `open_gem` gem, which can cause rake activation conflicts
|
53
54
|
|
54
55
|
|
55
56
|
If you are using Rails 2.3, please also include:
|
data/Rakefile
CHANGED
@@ -40,9 +40,9 @@ begin
|
|
40
40
|
end
|
41
41
|
|
42
42
|
namespace :rubygems do
|
43
|
-
# Rubygems
|
43
|
+
# Rubygems specs by version
|
44
44
|
rubyopt = ENV["RUBYOPT"]
|
45
|
-
%w(master v1.3.6 v1.3.7 v1.4.2 v1.5.3 v1.6.2 v1.7.2 v1.8.
|
45
|
+
%w(master v1.3.6 v1.3.7 v1.4.2 v1.5.3 v1.6.2 v1.7.2 v1.8.7).each do |rg|
|
46
46
|
desc "Run specs with Rubygems #{rg}"
|
47
47
|
RSpec::Core::RakeTask.new(rg) do |t|
|
48
48
|
t.rspec_opts = %w(-fs --color)
|
@@ -95,7 +95,7 @@ begin
|
|
95
95
|
raise "RVM is not available" unless File.exist?(File.expand_path("~/.rvm/scripts/rvm"))
|
96
96
|
end
|
97
97
|
|
98
|
-
%w(1.8.6-
|
98
|
+
%w(1.8.6-p420 1.8.7-p334 1.9.2-p180).each do |ruby|
|
99
99
|
ruby_cmd = File.expand_path("~/.rvm/bin/ruby-#{ruby}")
|
100
100
|
|
101
101
|
desc "Run specs on Ruby #{ruby}"
|
data/UPGRADING.md
CHANGED
@@ -61,8 +61,8 @@ Bundler 0.9 removes the following Bundler 0.8 Gemfile APIs:
|
|
61
61
|
via `bundle install /path/to/bundle`. Bundler will remember
|
62
62
|
where you installed the dependencies to on a particular
|
63
63
|
machine for future installs, loads, setups, etc.
|
64
|
-
5. `bin_path`: Bundler no longer generates
|
65
|
-
of your app. You should use `bundle exec` to execute
|
64
|
+
5. `bin_path`: Bundler no longer generates executables in the root
|
65
|
+
of your app. You should use `bundle exec` to execute executables
|
66
66
|
in the current context.
|
67
67
|
|
68
68
|
### Gemfile Changes
|
data/lib/bundler/cli.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'thor'
|
3
|
-
require 'thor/actions'
|
1
|
+
require 'bundler/vendored_thor'
|
4
2
|
require 'rubygems/user_interaction'
|
5
3
|
require 'rubygems/config_file'
|
6
4
|
|
@@ -16,7 +14,7 @@ module Bundler
|
|
16
14
|
Bundler.rubygems.ui = UI::RGProxy.new(Bundler.ui)
|
17
15
|
end
|
18
16
|
|
19
|
-
check_unknown_options!
|
17
|
+
check_unknown_options!
|
20
18
|
|
21
19
|
default_task :install
|
22
20
|
class_option "no-color", :type => :boolean, :banner => "Disable colorization in output"
|
@@ -154,10 +152,10 @@ module Bundler
|
|
154
152
|
opts = options.dup
|
155
153
|
opts[:without] ||= []
|
156
154
|
if opts[:without].size == 1
|
157
|
-
opts[:without].map
|
155
|
+
opts[:without] = opts[:without].map{|g| g.split(" ") }
|
158
156
|
opts[:without].flatten!
|
159
157
|
end
|
160
|
-
opts[:without].map
|
158
|
+
opts[:without] = opts[:without].map{|g| g.to_sym }
|
161
159
|
|
162
160
|
# Can't use Bundler.settings for this because settings needs gemfile.dirname
|
163
161
|
ENV['BUNDLE_GEMFILE'] = File.expand_path(opts[:gemfile]) if opts[:gemfile]
|
@@ -349,7 +347,7 @@ module Bundler
|
|
349
347
|
exit 126
|
350
348
|
rescue Errno::ENOENT
|
351
349
|
Bundler.ui.error "bundler: command not found: #{ARGV.first}"
|
352
|
-
Bundler.ui.warn "Install missing gem
|
350
|
+
Bundler.ui.warn "Install missing gem executables with `bundle install`"
|
353
351
|
exit 127
|
354
352
|
end
|
355
353
|
end
|
data/lib/bundler/gem_helper.rb
CHANGED
@@ -70,9 +70,12 @@ module Bundler
|
|
70
70
|
|
71
71
|
protected
|
72
72
|
def rubygem_push(path)
|
73
|
-
|
74
|
-
|
75
|
-
|
73
|
+
if Pathname.new("~/.gem/credentials").expand_path.exist?
|
74
|
+
sh("gem push '#{path}'")
|
75
|
+
Bundler.ui.confirm "Pushed #{name} #{version} to rubygems.org"
|
76
|
+
else
|
77
|
+
raise "Your rubygems.org credentials aren't set. Run `gem push` to set them."
|
78
|
+
end
|
76
79
|
end
|
77
80
|
|
78
81
|
def built_gem_path
|
data/lib/bundler/index.rb
CHANGED
@@ -101,10 +101,15 @@ module Bundler
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
104
|
+
if RUBY_VERSION < '1.9'
|
105
|
+
def same_version?(a, b)
|
106
|
+
regex = /^(.*?)(?:\.0)*$/
|
107
|
+
a.to_s[regex, 1] == b.to_s[regex, 1]
|
108
|
+
end
|
109
|
+
else
|
110
|
+
def same_version?(a, b)
|
111
|
+
a == b
|
112
|
+
end
|
108
113
|
end
|
109
114
|
|
110
115
|
def spec_satisfies_dependency?(spec, dep)
|
@@ -58,13 +58,16 @@ module Bundler
|
|
58
58
|
|
59
59
|
private
|
60
60
|
|
61
|
+
def to_ary
|
62
|
+
nil
|
63
|
+
end
|
64
|
+
|
61
65
|
def method_missing(method, *args, &blk)
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
66
|
+
raise "LazySpecification has not been materialized yet (calling :#{method} #{args.inspect})" unless @specification
|
67
|
+
|
68
|
+
return super unless respond_to?(method)
|
69
|
+
|
70
|
+
@specification.send(method, *args, &blk)
|
68
71
|
end
|
69
72
|
|
70
73
|
end
|
data/lib/bundler/resolver.rb
CHANGED
@@ -279,14 +279,6 @@ module Bundler
|
|
279
279
|
end
|
280
280
|
raise GemNotFound, message
|
281
281
|
else
|
282
|
-
if @missing_gems[current] >= 5
|
283
|
-
message = "Bundler could not find find gem #{current.required_by.last},"
|
284
|
-
message << "which is required by gem #{current}."
|
285
|
-
raise GemNotFound, message
|
286
|
-
end
|
287
|
-
@missing_gems[current] += 1
|
288
|
-
|
289
|
-
debug { " Could not find #{current} by #{current.required_by.last}" }
|
290
282
|
@errors[current.name] = [nil, current]
|
291
283
|
end
|
292
284
|
end
|
@@ -356,7 +348,8 @@ module Bundler
|
|
356
348
|
|
357
349
|
def search(dep)
|
358
350
|
if base = @base[dep.name] and base.any?
|
359
|
-
|
351
|
+
reqs = [dep.requirement.as_list, base.first.version.to_s].flatten.compact
|
352
|
+
d = Gem::Dependency.new(base.first.name, *reqs)
|
360
353
|
else
|
361
354
|
d = dep.dep
|
362
355
|
end
|
@@ -456,7 +449,8 @@ module Bundler
|
|
456
449
|
# the rest of the time, the gem cannot be found because it does not exist in the known sources
|
457
450
|
else
|
458
451
|
if requirement.required_by.first
|
459
|
-
o << "Could not find gem '#{clean_req(requirement)}', required by
|
452
|
+
o << "Could not find gem '#{clean_req(requirement)}', which is required by "
|
453
|
+
o << "gem '#{clean_req(requirement.required_by.first)}', in any of the sources."
|
460
454
|
else
|
461
455
|
o << "Could not find gem '#{clean_req(requirement)} in any of the sources\n"
|
462
456
|
end
|
data/lib/bundler/rubygems_ext.rb
CHANGED
@@ -123,7 +123,7 @@ module Bundler
|
|
123
123
|
if executables.include? File.basename(caller.first.split(':').first)
|
124
124
|
return
|
125
125
|
end
|
126
|
-
|
126
|
+
reqs.pop if reqs.last.is_a?(Hash)
|
127
127
|
|
128
128
|
unless dep.respond_to?(:name) && dep.respond_to?(:requirement)
|
129
129
|
dep = Gem::Dependency.new(dep, reqs)
|
@@ -250,7 +250,17 @@ module Bundler
|
|
250
250
|
Gem.clear_paths
|
251
251
|
end
|
252
252
|
|
253
|
-
#
|
253
|
+
# This backports the correct segment generation code from Rubygems 1.4+
|
254
|
+
# by monkeypatching it into the method in Rubygems 1.3.6 and 1.3.7.
|
255
|
+
def backport_segment_generation
|
256
|
+
Gem::Version.send(:define_method, :segments) do
|
257
|
+
@segments ||= @version.scan(/[0-9]+|[a-z]+/i).map do |s|
|
258
|
+
/^\d+$/ =~ s ? s.to_i : s
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
# Rubygems 1.4 through 1.6
|
254
264
|
class Legacy < RubygemsIntegration
|
255
265
|
def stub_rubygems(specs)
|
256
266
|
stub_source_index137(specs)
|
@@ -265,6 +275,14 @@ module Bundler
|
|
265
275
|
end
|
266
276
|
end
|
267
277
|
|
278
|
+
# Rubygems versions 1.3.6 and 1.3.7
|
279
|
+
class Ancient < Legacy
|
280
|
+
def initialize
|
281
|
+
super
|
282
|
+
backport_segment_generation
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
268
286
|
# Rubygems 1.7
|
269
287
|
class Transitional < Legacy
|
270
288
|
def stub_rubygems(specs)
|
@@ -313,8 +331,10 @@ module Bundler
|
|
313
331
|
@rubygems = RubygemsIntegration::AlmostModern.new
|
314
332
|
elsif Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.7.0')
|
315
333
|
@rubygems = RubygemsIntegration::Transitional.new
|
316
|
-
|
334
|
+
elsif Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.4.0')
|
317
335
|
@rubygems = RubygemsIntegration::Legacy.new
|
336
|
+
else # Rubygems 1.3.6 and 1.3.7
|
337
|
+
@rubygems = RubygemsIntegration::Ancient.new
|
318
338
|
end
|
319
339
|
|
320
340
|
class << self
|
data/lib/bundler/source.rb
CHANGED
@@ -362,9 +362,9 @@ module Bundler
|
|
362
362
|
s.relative_loaded_from = "#{@name}.gemspec"
|
363
363
|
s.authors = ["no one"]
|
364
364
|
if expanded_path.join("bin").exist?
|
365
|
-
|
366
|
-
|
367
|
-
s.executables =
|
365
|
+
executables = expanded_path.join("bin").children
|
366
|
+
executables.reject!{|p| File.directory?(p) }
|
367
|
+
s.executables = executables.map{|c| c.basename.to_s }
|
368
368
|
end
|
369
369
|
end
|
370
370
|
end
|
@@ -585,7 +585,7 @@ module Bundler
|
|
585
585
|
end
|
586
586
|
|
587
587
|
def base_name
|
588
|
-
File.basename(uri.sub(%r{^(\w+://)?([^/:]+:)},''),
|
588
|
+
File.basename(uri.sub(%r{^(\w+://)?([^/:]+:)?(//\w*/)?(\w*/)*},''),".git")
|
589
589
|
end
|
590
590
|
|
591
591
|
def shortref_for_display(ref)
|
data/lib/bundler/spec_set.rb
CHANGED
@@ -1,21 +1,18 @@
|
|
1
1
|
require 'tsort'
|
2
|
+
require 'forwardable'
|
2
3
|
|
3
4
|
module Bundler
|
4
5
|
class SpecSet
|
6
|
+
extend Forwardable
|
5
7
|
include TSort, Enumerable
|
6
8
|
|
9
|
+
def_delegators :@specs, :<<, :length, :add, :remove
|
10
|
+
def_delegators :sorted, :each
|
11
|
+
|
7
12
|
def initialize(specs)
|
8
13
|
@specs = specs.sort_by { |s| s.name }
|
9
14
|
end
|
10
15
|
|
11
|
-
def each
|
12
|
-
sorted.each { |s| yield s }
|
13
|
-
end
|
14
|
-
|
15
|
-
def length
|
16
|
-
@specs.length
|
17
|
-
end
|
18
|
-
|
19
16
|
def for(dependencies, skip = [], check = false, match_current_platform = false)
|
20
17
|
handled, deps, specs = {}, dependencies.dup, []
|
21
18
|
skip << 'bundler'
|
@@ -68,6 +65,10 @@ module Bundler
|
|
68
65
|
value
|
69
66
|
end
|
70
67
|
|
68
|
+
def sort!
|
69
|
+
self
|
70
|
+
end
|
71
|
+
|
71
72
|
def to_a
|
72
73
|
sorted.dup
|
73
74
|
end
|
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require "bundler/gem_tasks"
|
@@ -17,4 +17,8 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
20
24
|
end
|
data/lib/bundler/vendor/thor.rb
CHANGED
@@ -18,6 +18,23 @@ 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
|
+
|
21
38
|
# Defines the usage and the description of the next task.
|
22
39
|
#
|
23
40
|
# ==== Parameters
|
@@ -252,8 +269,7 @@ class Thor
|
|
252
269
|
# the namespace should be displayed as arguments.
|
253
270
|
#
|
254
271
|
def banner(task, namespace = nil, subcommand = false)
|
255
|
-
|
256
|
-
"#{base} #{task.formatted_usage(self, $thor_runner, subcommand)}"
|
272
|
+
"#{basename} #{task.formatted_usage(self, $thor_runner, subcommand)}"
|
257
273
|
end
|
258
274
|
|
259
275
|
def baseclass #:nodoc:
|
@@ -295,17 +311,40 @@ class Thor
|
|
295
311
|
# Receives a task name (can be nil), and try to get a map from it.
|
296
312
|
# If a map can't be found use the sent name or the default task.
|
297
313
|
def normalize_task_name(meth) #:nodoc:
|
298
|
-
meth = map[meth.to_s] || meth || default_task
|
314
|
+
meth = map[meth.to_s] || find_subcommand_and_update_argv(meth) || meth || default_task
|
299
315
|
meth.to_s.gsub('-','_') # treat foo-bar > foo_bar
|
300
316
|
end
|
301
317
|
|
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
|
+
|
302
342
|
def subcommand_help(cmd)
|
303
343
|
desc "help [COMMAND]", "Describe subcommands or one specific subcommand"
|
304
344
|
class_eval <<-RUBY
|
305
345
|
def help(task = nil, subcommand = true); super; end
|
306
346
|
RUBY
|
307
347
|
end
|
308
|
-
|
309
348
|
end
|
310
349
|
|
311
350
|
include Thor::Base
|
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'uri'
|
3
3
|
require 'thor/core_ext/file_binary_read'
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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'
|
8
10
|
|
9
11
|
class Thor
|
10
12
|
module Actions
|
@@ -158,13 +160,23 @@ class Thor
|
|
158
160
|
#
|
159
161
|
def inside(dir='', config={}, &block)
|
160
162
|
verbose = config.fetch(:verbose, false)
|
163
|
+
pretend = options[:pretend]
|
161
164
|
|
162
165
|
say_status :inside, dir, verbose
|
163
166
|
shell.padding += 1 if verbose
|
164
167
|
@destination_stack.push File.expand_path(dir, destination_root)
|
165
168
|
|
166
|
-
|
167
|
-
|
169
|
+
# If the directory doesnt exist and we're not pretending
|
170
|
+
if !File.exist?(destination_root) && !pretend
|
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
|
168
180
|
|
169
181
|
@destination_stack.pop
|
170
182
|
shell.padding -= 1 if verbose
|
@@ -210,7 +222,7 @@ class Thor
|
|
210
222
|
#
|
211
223
|
# ==== Parameters
|
212
224
|
# command<String>:: the command to be executed.
|
213
|
-
# config<Hash>:: give :verbose => false to not log the status. Specify :with
|
225
|
+
# config<Hash>:: give :verbose => false to not log the status, :capture => true to hide to output. Specify :with
|
214
226
|
# to append an executable to command executation.
|
215
227
|
#
|
216
228
|
# ==== Example
|
@@ -231,7 +243,10 @@ class Thor
|
|
231
243
|
end
|
232
244
|
|
233
245
|
say_status :run, desc, config.fetch(:verbose, true)
|
234
|
-
|
246
|
+
|
247
|
+
unless options[:pretend]
|
248
|
+
config[:capture] ? `#{command}` : system("#{command}")
|
249
|
+
end
|
235
250
|
end
|
236
251
|
|
237
252
|
# Executes a ruby script (taking into account WIN32 platform quirks).
|
@@ -251,8 +266,9 @@ class Thor
|
|
251
266
|
# ==== Parameters
|
252
267
|
# task<String>:: the task to be invoked
|
253
268
|
# args<Array>:: arguments to the task
|
254
|
-
# config<Hash>:: give :verbose => false to not log the status
|
255
|
-
# are given as parameter to Thor.
|
269
|
+
# config<Hash>:: give :verbose => false to not log the status, :capture => true to hide to output.
|
270
|
+
# Other options are given as parameter to Thor.
|
271
|
+
#
|
256
272
|
#
|
257
273
|
# ==== Examples
|
258
274
|
#
|
@@ -266,12 +282,13 @@ class Thor
|
|
266
282
|
config = args.last.is_a?(Hash) ? args.pop : {}
|
267
283
|
verbose = config.key?(:verbose) ? config.delete(:verbose) : true
|
268
284
|
pretend = config.key?(:pretend) ? config.delete(:pretend) : false
|
285
|
+
capture = config.key?(:capture) ? config.delete(:capture) : false
|
269
286
|
|
270
287
|
args.unshift task
|
271
288
|
args.push Thor::Options.to_switches(config)
|
272
289
|
command = args.join(' ').strip
|
273
290
|
|
274
|
-
run command, :with => :thor, :verbose => verbose, :pretend => pretend
|
291
|
+
run command, :with => :thor, :verbose => verbose, :pretend => pretend, :capture => capture
|
275
292
|
end
|
276
293
|
|
277
294
|
protected
|