bundler 0.9.10 → 0.9.11
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/ROADMAP.textile +51 -0
- data/lib/bundler.rb +2 -1
- data/lib/bundler/cli.rb +48 -15
- data/lib/bundler/dsl.rb +5 -5
- data/lib/bundler/environment.rb +1 -1
- data/lib/bundler/index.rb +1 -8
- data/lib/bundler/installer.rb +10 -5
- data/lib/bundler/remote_specification.rb +0 -7
- data/lib/bundler/resolver.rb +7 -13
- data/lib/bundler/rubygems_ext.rb +6 -12
- data/lib/bundler/source.rb +23 -9
- data/lib/bundler/templates/environment.erb +1 -1
- data/lib/bundler/vendor/thor/invocation.rb +5 -0
- data/lib/bundler/vendor/thor/parser/arguments.rb +4 -0
- data/lib/bundler/vendor/thor/parser/options.rb +19 -5
- data/lib/bundler/vendor/thor/shell.rb +8 -3
- data/lib/bundler/vendor/thor/version.rb +1 -1
- metadata +4 -3
data/ROADMAP.textile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
We will be releasing one more point release (0.10.x) followed by 1.0. While
|
2
|
+
the following reflects our current thinking, critical bugs may alter it
|
3
|
+
somewhat.
|
4
|
+
|
5
|
+
h1. 0.10
|
6
|
+
|
7
|
+
* No breaking changes to the Gemfile are expected
|
8
|
+
* We expect to modify the format of Gemfile.lock.
|
9
|
+
** This should be the final change; it will not change for 1.0
|
10
|
+
** The Gemfile.lock generated by 0.9 will continue to work until 1.0
|
11
|
+
** If you use Bundler 0.10, we will transparently update the format
|
12
|
+
** This means: you will not be able to upgrade a locked app
|
13
|
+
directly from 0.9 to 1.0.
|
14
|
+
* Bundler 0.10 will automatically generate Gemfile.lock when any
|
15
|
+
resolve is successful.
|
16
|
+
* bundle install will conservatively update Gemfile.lock from the
|
17
|
+
last successful resolve if the Gemfile has been modified since
|
18
|
+
the last use of bundler.
|
19
|
+
** This means that adding a new gem to the Gemfile that does not
|
20
|
+
conflict with existing gems will not force an update of other
|
21
|
+
gems.
|
22
|
+
** This also means that we will not force an update to previously
|
23
|
+
resolved dependencies as long as they are compatible with some
|
24
|
+
valid version of the new dependency.
|
25
|
+
** When removing a gem, bundle install will simply remove it, without
|
26
|
+
recalculating all dependencies.
|
27
|
+
* We will be adding `bundle update` for the case where you *do*
|
28
|
+
wish to re-resolve all dependencies and update everything to the
|
29
|
+
latest version.
|
30
|
+
** bundle update will also take a gem name, if you want to force
|
31
|
+
an update to just a single gem (and its dependencies).
|
32
|
+
* Add a way to install dependencies that require build options
|
33
|
+
* Add a way to specify groups that are opt-in at install-time,
|
34
|
+
rather than opt-out.
|
35
|
+
* Some additional features that we have tagged for 0.10. For up
|
36
|
+
to date information, please visit
|
37
|
+
http://github.com/carlhuda/bundler/issues/labels/0.10
|
38
|
+
|
39
|
+
h1. 1.0
|
40
|
+
|
41
|
+
* No breaking changes to the Gemfile are expected
|
42
|
+
* No breaking changes to the Gemfile.lock are expected
|
43
|
+
* No major changes to the workflow are expected
|
44
|
+
* Reduce open bug count to 0
|
45
|
+
* Some additional features that require more thought. For details,
|
46
|
+
see http://github.com/carlhuda/bundler/issues/labels/1.0
|
47
|
+
|
48
|
+
h1. No Breaking changes
|
49
|
+
|
50
|
+
We expect no breaking changes of the Gemfile, Gemfile.lock, or
|
51
|
+
basic workflow for 1.x releases.
|
data/lib/bundler.rb
CHANGED
@@ -4,7 +4,7 @@ require 'yaml'
|
|
4
4
|
require 'bundler/rubygems_ext'
|
5
5
|
|
6
6
|
module Bundler
|
7
|
-
VERSION = "0.9.
|
7
|
+
VERSION = "0.9.11"
|
8
8
|
|
9
9
|
autoload :Definition, 'bundler/definition'
|
10
10
|
autoload :Dependency, 'bundler/dependency'
|
@@ -36,6 +36,7 @@ module Bundler
|
|
36
36
|
class GemNotFound < BundlerError; status_code(7) ; end
|
37
37
|
class VersionConflict < BundlerError; status_code(6) ; end
|
38
38
|
class GemfileError < BundlerError; status_code(4) ; end
|
39
|
+
class PathError < BundlerError; status_code(13) ; end
|
39
40
|
class GitError < BundlerError; status_code(11) ; end
|
40
41
|
class DeprecatedMethod < BundlerError; status_code(12) ; end
|
41
42
|
class DeprecatedOption < BundlerError; status_code(12) ; end
|
data/lib/bundler/cli.rb
CHANGED
@@ -7,7 +7,7 @@ Gem.configuration
|
|
7
7
|
|
8
8
|
module Bundler
|
9
9
|
class CLI < Thor
|
10
|
-
|
10
|
+
check_unknown_options! unless ARGV.include?("exec")
|
11
11
|
|
12
12
|
desc "init", "Generates a Gemfile into the current working directory"
|
13
13
|
def init
|
@@ -31,14 +31,21 @@ module Bundler
|
|
31
31
|
# Check top level dependencies
|
32
32
|
missing = env.dependencies.select { |d| env.index.search(d).empty? }
|
33
33
|
if missing.any?
|
34
|
-
|
34
|
+
Bundler.ui.error "The following dependencies are missing"
|
35
35
|
missing.each do |d|
|
36
|
-
|
36
|
+
Bundler.ui.error " * #{d}"
|
37
37
|
end
|
38
|
+
Bundler.ui.error "Try running `bundle install`"
|
38
39
|
exit 1
|
39
40
|
else
|
40
|
-
env.specs
|
41
|
-
|
41
|
+
not_installed = env.specs.select { |spec| !spec.loaded_from }
|
42
|
+
|
43
|
+
if not_installed.any?
|
44
|
+
not_installed.each { |s| Bundler.ui.error "#{s.name} (#{s.version}) is cached, but not installed" }
|
45
|
+
Bundler.ui.error "Try running `bundle install`"
|
46
|
+
else
|
47
|
+
Bundler.ui.info "The Gemfile's dependencies are satisfied"
|
48
|
+
end
|
42
49
|
end
|
43
50
|
end
|
44
51
|
|
@@ -46,11 +53,14 @@ module Bundler
|
|
46
53
|
method_option "without", :type => :array, :banner => "Exclude gems that are part of the specified named group."
|
47
54
|
method_option "relock", :type => :boolean, :banner => "Unlock, install the gems, and relock."
|
48
55
|
method_option "disable-shared-gems", :type => :boolean, :banner => "Do not use any shared gems, such as the system gem repository."
|
56
|
+
method_option "gemfile", :type => :string, :banner => "Use the specified gemfile instead of Gemfile"
|
49
57
|
def install(path = nil)
|
50
58
|
opts = options.dup
|
51
59
|
opts[:without] ||= []
|
52
60
|
opts[:without].map! { |g| g.to_sym }
|
53
61
|
|
62
|
+
# Can't use Bundler.settings for this because settings needs gemfile.dirname
|
63
|
+
ENV['BUNDLE_GEMFILE'] = opts[:gemfile] if opts[:gemfile]
|
54
64
|
Bundler.settings[:path] = path if path
|
55
65
|
Bundler.settings[:disable_shared_gems] = '1' if options["disable-shared-gems"]
|
56
66
|
Bundler.settings.without = opts[:without]
|
@@ -90,12 +100,16 @@ module Bundler
|
|
90
100
|
end
|
91
101
|
end
|
92
102
|
|
93
|
-
desc "show", "Shows all gems that are part of the bundle
|
94
|
-
def show
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
103
|
+
desc "show GEM", "Shows all gems that are part of the bundle, or the path to a given gem"
|
104
|
+
def show(gem_name = nil)
|
105
|
+
if gem_name
|
106
|
+
Bundler.ui.info locate_gem(gem_name)
|
107
|
+
else
|
108
|
+
environment = Bundler.load
|
109
|
+
Bundler.ui.info "Gems included by the bundle:"
|
110
|
+
environment.specs.sort_by { |s| s.name }.each do |s|
|
111
|
+
Bundler.ui.info " * #{s.name} (#{s.version})"
|
112
|
+
end
|
99
113
|
end
|
100
114
|
end
|
101
115
|
|
@@ -129,15 +143,28 @@ module Bundler
|
|
129
143
|
ENV['BUNDLE_GEMFILE'] = Bundler::SharedHelpers.default_gemfile.to_s
|
130
144
|
|
131
145
|
# Set RUBYOPT
|
146
|
+
locked_env = Bundler.root.join(".bundle/environment.rb")
|
132
147
|
rubyopt = [ENV["RUBYOPT"]].compact
|
133
|
-
|
134
|
-
|
148
|
+
if locked_env.exist?
|
149
|
+
rubyopt.unshift "-r#{locked_env.to_s}"
|
150
|
+
else
|
151
|
+
rubyopt.unshift "-rbundler/setup"
|
152
|
+
rubyopt.unshift "-I#{File.expand_path('../..', __FILE__)}"
|
153
|
+
end
|
135
154
|
ENV["RUBYOPT"] = rubyopt.join(' ')
|
136
155
|
|
137
156
|
# Run
|
138
157
|
Kernel.exec *ARGV
|
139
158
|
end
|
140
159
|
|
160
|
+
desc "open GEM", "Opens the source directory of the given bundled gem"
|
161
|
+
def open(name)
|
162
|
+
editor = ENV['EDITOR']
|
163
|
+
return Bundler.ui.info("To open a bundled gem, set $EDITOR") if editor.nil? || editor.empty?
|
164
|
+
command = "#{editor} #{locate_gem(name)}"
|
165
|
+
Bundler.ui.info "Could not run '#{command}'" unless system(command)
|
166
|
+
end
|
167
|
+
|
141
168
|
desc "version", "Prints the bundler's version information"
|
142
169
|
def version
|
143
170
|
Bundler.ui.info "Bundler version #{Bundler::VERSION}"
|
@@ -155,11 +182,17 @@ module Bundler
|
|
155
182
|
FileUtils.rm_f "#{Bundler.root}/.bundle/environment.rb"
|
156
183
|
end
|
157
184
|
|
185
|
+
def locate_gem(name)
|
186
|
+
spec = Bundler.load.specs.find{|s| s.name == name }
|
187
|
+
raise GemNotFound, "Could not find gem '#{name}' in the current bundle." unless spec
|
188
|
+
spec.full_gem_path
|
189
|
+
end
|
190
|
+
|
158
191
|
def self.printable_tasks
|
159
192
|
tasks = super.dup
|
160
|
-
|
193
|
+
nodoc = /^bundle (cache)/
|
194
|
+
tasks.reject!{|t| t.first =~ nodoc }
|
161
195
|
tasks
|
162
196
|
end
|
163
|
-
|
164
197
|
end
|
165
198
|
end
|
data/lib/bundler/dsl.rb
CHANGED
@@ -12,14 +12,14 @@ module Bundler
|
|
12
12
|
@source = nil
|
13
13
|
@sources = []
|
14
14
|
@dependencies = []
|
15
|
-
@group =
|
15
|
+
@group = [:default]
|
16
16
|
end
|
17
17
|
|
18
18
|
def gem(name, *args)
|
19
19
|
options = Hash === args.last ? args.pop : {}
|
20
20
|
version = args.last || ">= 0"
|
21
|
-
if options[:group]
|
22
|
-
options[:group] =
|
21
|
+
if group = options[:groups] || options[:group]
|
22
|
+
options[:group] = group
|
23
23
|
end
|
24
24
|
|
25
25
|
_deprecated_options(options)
|
@@ -55,8 +55,8 @@ module Bundler
|
|
55
55
|
Definition.new(@dependencies, @sources)
|
56
56
|
end
|
57
57
|
|
58
|
-
def group(
|
59
|
-
old, @group = @group,
|
58
|
+
def group(*args, &blk)
|
59
|
+
old, @group = @group, args
|
60
60
|
yield
|
61
61
|
ensure
|
62
62
|
@group = old
|
data/lib/bundler/environment.rb
CHANGED
@@ -22,7 +22,7 @@ module Bundler
|
|
22
22
|
def group_spec(specs, spec, groups)
|
23
23
|
spec.groups.concat(groups)
|
24
24
|
spec.groups.uniq!
|
25
|
-
spec.
|
25
|
+
spec.dependencies.select { |d| d.type != :development }.each do |d|
|
26
26
|
spec = specs.find { |s| s.name == d.name }
|
27
27
|
group_spec(specs, spec, groups)
|
28
28
|
end
|
data/lib/bundler/index.rb
CHANGED
@@ -5,14 +5,7 @@ module Bundler
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.from_cached_specs(path)
|
8
|
-
|
9
|
-
|
10
|
-
Dir["#{path}/*.gem"].each do |gemfile|
|
11
|
-
spec = Gem::Format.from_file_by_path(gemfile).spec
|
12
|
-
index << spec
|
13
|
-
end
|
14
|
-
|
15
|
-
index
|
8
|
+
Source::GemCache.new("path" => path).specs
|
16
9
|
end
|
17
10
|
|
18
11
|
def initialize
|
data/lib/bundler/installer.rb
CHANGED
@@ -15,7 +15,10 @@ module Bundler
|
|
15
15
|
# Ensure that BUNDLE_PATH exists
|
16
16
|
FileUtils.mkdir_p(Bundler.bundle_path)
|
17
17
|
|
18
|
-
|
18
|
+
# Must install gems in the order that the resolver provides
|
19
|
+
# as dependencies might actually affect the installation of
|
20
|
+
# the gem.
|
21
|
+
specs.each do |spec|
|
19
22
|
spec.source.fetch(spec) if spec.source.respond_to?(:fetch)
|
20
23
|
|
21
24
|
if spec.groups & Bundler.settings.without == spec.groups
|
@@ -68,9 +71,8 @@ module Bundler
|
|
68
71
|
|
69
72
|
# Simple logic for now. Can improve later.
|
70
73
|
specs.length == actual_dependencies.length && specs
|
71
|
-
rescue
|
74
|
+
rescue GemNotFound, PathError => e
|
72
75
|
nil
|
73
|
-
raise if ENV["OMG"]
|
74
76
|
end
|
75
77
|
|
76
78
|
def resolve_remotely
|
@@ -100,10 +102,11 @@ module Bundler
|
|
100
102
|
other_sources.each do |source|
|
101
103
|
i = source.specs
|
102
104
|
Bundler.ui.debug "Source: Processing index"
|
103
|
-
index = i.merge(index)
|
105
|
+
index = i.merge(index)
|
104
106
|
end
|
105
107
|
|
106
108
|
index = Index.from_installed_gems.merge(index)
|
109
|
+
index = Index.from_cached_specs("#{Bundler.bundle_path}/cache").merge(index)
|
107
110
|
|
108
111
|
if File.directory?("#{root}/vendor/cache")
|
109
112
|
index = cache_source.specs.merge(index)
|
@@ -128,11 +131,13 @@ module Bundler
|
|
128
131
|
index = source.local_specs.merge(index)
|
129
132
|
end
|
130
133
|
|
134
|
+
index = Index.from_installed_gems.merge(index)
|
135
|
+
|
131
136
|
if File.directory?("#{root}/vendor/cache")
|
132
137
|
index = cache_source.specs.merge(index).freeze
|
133
138
|
end
|
134
139
|
|
135
|
-
Index.
|
140
|
+
Index.from_cached_specs("#{Bundler.bundle_path}/cache").merge(index)
|
136
141
|
end
|
137
142
|
end
|
138
143
|
|
@@ -34,13 +34,6 @@ module Bundler
|
|
34
34
|
|
35
35
|
private
|
36
36
|
|
37
|
-
def _remote_uri
|
38
|
-
# "#{@source_uri}/quick/Marshal.4.8/#{@name}-#{@version}.gemspec.rz"
|
39
|
-
tuple = [@name, @version, @platform]
|
40
|
-
tuple = tuple - [nil, 'ruby', '']
|
41
|
-
"#{@source_uri}/quick/Marshal.4.8/#{tuple.join("-")}.gemspec.rz"
|
42
|
-
end
|
43
|
-
|
44
37
|
def _remote_specification
|
45
38
|
@specification ||= begin
|
46
39
|
Gem::SpecFetcher.new.fetch_spec([@name, @version, @platform], URI(@source_uri.to_s))
|
data/lib/bundler/resolver.rb
CHANGED
@@ -53,19 +53,13 @@ module Bundler
|
|
53
53
|
nil
|
54
54
|
end
|
55
55
|
if result
|
56
|
-
#
|
57
|
-
# a smaller index in the array.
|
56
|
+
# Dependency ordering was busted anyway. This will be revisted in 0.10
|
58
57
|
ordered = []
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
place ?
|
65
|
-
ordered.insert(ordered.index(place), spec1) :
|
66
|
-
ordered << spec1
|
67
|
-
end
|
68
|
-
ordered.reverse
|
58
|
+
ordered << result['rake']
|
59
|
+
ordered.concat result.values
|
60
|
+
ordered.compact!
|
61
|
+
ordered.uniq!
|
62
|
+
ordered
|
69
63
|
end
|
70
64
|
end
|
71
65
|
|
@@ -204,7 +198,7 @@ module Bundler
|
|
204
198
|
# Now, we have to loop through all child dependencies and add them to our
|
205
199
|
# array of requirements.
|
206
200
|
debug { " Dependencies"}
|
207
|
-
spec.
|
201
|
+
spec.dependencies.each do |dep|
|
208
202
|
next if dep.type == :development
|
209
203
|
debug { " * #{dep.name} (#{dep.requirement})" }
|
210
204
|
dep.required_by.replace(requirement.required_by)
|
data/lib/bundler/rubygems_ext.rb
CHANGED
@@ -16,21 +16,15 @@ module Gem
|
|
16
16
|
def groups
|
17
17
|
@groups ||= []
|
18
18
|
end
|
19
|
-
|
20
|
-
def bundler_dependencies
|
21
|
-
original = dependencies
|
22
|
-
original << Dependency.new("rake", ">= 0") if implicit_rake_dependency?
|
23
|
-
original
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def implicit_rake_dependency?
|
29
|
-
extensions.any? { |e| e =~ /rakefile|mkrf_conf/i }
|
30
|
-
end
|
31
19
|
end
|
32
20
|
|
33
21
|
class Dependency
|
34
22
|
attr_accessor :source, :groups
|
23
|
+
|
24
|
+
alias :to_yaml_properties_before_crazy to_yaml_properties
|
25
|
+
|
26
|
+
def to_yaml_properties
|
27
|
+
to_yaml_properties_before_crazy.reject { |p| ["@source", "@groups"].include?(p.to_s) }
|
28
|
+
end
|
35
29
|
end
|
36
30
|
end
|
data/lib/bundler/source.rb
CHANGED
@@ -107,9 +107,15 @@ module Bundler
|
|
107
107
|
|
108
108
|
def specs
|
109
109
|
@specs ||= begin
|
110
|
-
|
111
|
-
|
112
|
-
|
110
|
+
index = Index.new
|
111
|
+
|
112
|
+
Dir["#{@path}/*.gem"].each do |gemfile|
|
113
|
+
spec = Gem::Format.from_file_by_path(gemfile).spec
|
114
|
+
spec.source = self
|
115
|
+
index << spec
|
116
|
+
end
|
117
|
+
|
118
|
+
index
|
113
119
|
end
|
114
120
|
end
|
115
121
|
|
@@ -161,7 +167,7 @@ module Bundler
|
|
161
167
|
Dir["#{path}/#{@glob}"].each do |file|
|
162
168
|
file = Pathname.new(file)
|
163
169
|
# Eval the gemspec from its parent directory
|
164
|
-
if spec = Dir.chdir(file.dirname) { eval(File.read(file.basename)) }
|
170
|
+
if spec = Dir.chdir(file.dirname) { eval(File.read(file.basename), binding, file.expand_path.to_s) }
|
165
171
|
spec = Specification.from_gemspec(spec)
|
166
172
|
spec.loaded_from = file.to_s
|
167
173
|
spec.source = self
|
@@ -170,6 +176,8 @@ module Bundler
|
|
170
176
|
end
|
171
177
|
|
172
178
|
index << default_spec if default_spec && index.empty?
|
179
|
+
else
|
180
|
+
raise PathError, "The path `#{path}` does not exist."
|
173
181
|
end
|
174
182
|
|
175
183
|
index.freeze
|
@@ -211,9 +219,9 @@ module Bundler
|
|
211
219
|
"This prevents bundler from installing bins or native extensions, but " \
|
212
220
|
"that may not affect its functionality."
|
213
221
|
|
214
|
-
if !spec.extensions.empty? && !spec.
|
222
|
+
if !spec.extensions.empty? && !spec.email.empty?
|
215
223
|
Bundler.ui.warn "If you need to use this package without installing it from a gem " \
|
216
|
-
"repository, please contact #{spec.
|
224
|
+
"repository, please contact #{spec.email} and ask them " \
|
217
225
|
"to modify their .gemspec so it can work with `gem build`."
|
218
226
|
end
|
219
227
|
|
@@ -228,7 +236,7 @@ module Bundler
|
|
228
236
|
def initialize(options)
|
229
237
|
super
|
230
238
|
@uri = options["uri"]
|
231
|
-
@ref = options["ref"] || options["branch"] || 'master'
|
239
|
+
@ref = options["ref"] || options["branch"] || options["tag"] || 'master'
|
232
240
|
end
|
233
241
|
|
234
242
|
def to_s
|
@@ -265,6 +273,12 @@ module Bundler
|
|
265
273
|
checkout
|
266
274
|
end
|
267
275
|
|
276
|
+
def load_spec_files
|
277
|
+
super
|
278
|
+
rescue PathError
|
279
|
+
raise PathError, "#{to_s} is not checked out. Please run `bundle install`"
|
280
|
+
end
|
281
|
+
|
268
282
|
private
|
269
283
|
|
270
284
|
def git(command)
|
@@ -276,7 +290,7 @@ module Bundler
|
|
276
290
|
end
|
277
291
|
|
278
292
|
def base_name
|
279
|
-
File.basename(uri, ".git")
|
293
|
+
File.basename(uri.sub(%r{^(\w+://)?([^/:]+:)},''), ".git")
|
280
294
|
end
|
281
295
|
|
282
296
|
def uri_hash
|
@@ -308,7 +322,7 @@ module Bundler
|
|
308
322
|
|
309
323
|
def checkout
|
310
324
|
unless File.exist?("#{path}/.git")
|
311
|
-
%x(git clone --no-checkout
|
325
|
+
%x(git clone --no-checkout file://#{cache_path} #{path})
|
312
326
|
end
|
313
327
|
Dir.chdir(path) do
|
314
328
|
git "fetch --quiet"
|
@@ -42,7 +42,7 @@ module Bundler
|
|
42
42
|
def self.require(*groups)
|
43
43
|
groups = [:default] if groups.empty?
|
44
44
|
groups.each do |group|
|
45
|
-
(AUTOREQUIRES[group] || []).each do |file, explicit|
|
45
|
+
(AUTOREQUIRES[group.to_sym] || []).each do |file, explicit|
|
46
46
|
if explicit
|
47
47
|
Kernel.require file
|
48
48
|
else
|
@@ -3,9 +3,9 @@ class Thor
|
|
3
3
|
# under Ruby's license.
|
4
4
|
#
|
5
5
|
class Options < Arguments #:nodoc:
|
6
|
-
LONG_RE = /^(--\w+
|
6
|
+
LONG_RE = /^(--\w+(?:-\w+)*)$/
|
7
7
|
SHORT_RE = /^(-[a-z])$/i
|
8
|
-
EQ_RE = /^(--\w+
|
8
|
+
EQ_RE = /^(--\w+(?:-\w+)*|-[a-z])=(.*)$/i
|
9
9
|
SHORT_SQ_RE = /^-([a-z]{2,})$/i # Allow either -x -v or -xv style for single char args
|
10
10
|
SHORT_NUM = /^(-[a-z])#{NUMERIC}$/i
|
11
11
|
|
@@ -68,7 +68,7 @@ class Thor
|
|
68
68
|
switch = normalize_switch(switch)
|
69
69
|
option = switch_option(switch)
|
70
70
|
@assigns[option.human_name] = parse_peek(switch, option)
|
71
|
-
elsif
|
71
|
+
elsif current_is_switch_formatted?
|
72
72
|
@unknown << shift
|
73
73
|
else
|
74
74
|
shift
|
@@ -99,6 +99,19 @@ class Thor
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
+
def switch_formatted?(arg)
|
103
|
+
case arg
|
104
|
+
when LONG_RE, SHORT_RE, EQ_RE, SHORT_NUM, SHORT_SQ_RE
|
105
|
+
true
|
106
|
+
else
|
107
|
+
false
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def current_is_switch_formatted?
|
112
|
+
switch_formatted? peek
|
113
|
+
end
|
114
|
+
|
102
115
|
def switch?(arg)
|
103
116
|
switch_option(arg) || @shorts.key?(arg)
|
104
117
|
end
|
@@ -135,13 +148,14 @@ class Thor
|
|
135
148
|
# Parse the value at the peek analyzing if it requires an input or not.
|
136
149
|
#
|
137
150
|
def parse_peek(switch, option)
|
138
|
-
|
151
|
+
if current_is_switch_formatted? || last?
|
139
152
|
if option.boolean?
|
140
153
|
# No problem for boolean types
|
141
154
|
elsif no_or_skip?(switch)
|
142
155
|
return nil # User set value to nil
|
143
156
|
elsif option.string? && !option.required?
|
144
|
-
|
157
|
+
# Return the default if there is one, else the human name
|
158
|
+
return option.default || option.human_name
|
145
159
|
else
|
146
160
|
raise MalformattedArgumentError, "No value provided for option '#{switch}'"
|
147
161
|
end
|
@@ -45,19 +45,16 @@ class Thor
|
|
45
45
|
|
46
46
|
# Holds the shell for the given Thor instance. If no shell is given,
|
47
47
|
# it gets a default shell from Thor::Base.shell.
|
48
|
-
#
|
49
48
|
def shell
|
50
49
|
@shell ||= Thor::Base.shell.new
|
51
50
|
end
|
52
51
|
|
53
52
|
# Sets the shell for this thor class.
|
54
|
-
#
|
55
53
|
def shell=(shell)
|
56
54
|
@shell = shell
|
57
55
|
end
|
58
56
|
|
59
57
|
# Common methods that are delegated to the shell.
|
60
|
-
#
|
61
58
|
SHELL_DELEGATED_METHODS.each do |method|
|
62
59
|
module_eval <<-METHOD, __FILE__, __LINE__
|
63
60
|
def #{method}(*args)
|
@@ -66,6 +63,14 @@ class Thor
|
|
66
63
|
METHOD
|
67
64
|
end
|
68
65
|
|
66
|
+
# Yields the given block with padding.
|
67
|
+
def with_padding
|
68
|
+
shell.padding += 1
|
69
|
+
yield
|
70
|
+
ensure
|
71
|
+
shell.padding -= 1
|
72
|
+
end
|
73
|
+
|
69
74
|
protected
|
70
75
|
|
71
76
|
# Allow shell to be shared between invocations.
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 9
|
8
|
-
-
|
9
|
-
version: 0.9.
|
8
|
+
- 11
|
9
|
+
version: 0.9.11
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Carl Lerche
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-03-
|
18
|
+
date: 2010-03-09 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- lib/bundler.rb
|
71
71
|
- LICENSE
|
72
72
|
- README.markdown
|
73
|
+
- ROADMAP.textile
|
73
74
|
has_rdoc: true
|
74
75
|
homepage: http://github.com/carlhuda/bundler
|
75
76
|
licenses: []
|