summaryrefslogtreecommitdiff
path: root/lib/bundler/vendor/thor/lib/thor/shell/basic.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bundler/vendor/thor/lib/thor/shell/basic.rb')
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell/basic.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/bundler/vendor/thor/lib/thor/shell/basic.rb b/lib/bundler/vendor/thor/lib/thor/shell/basic.rb
index 52648fee8f..be48358cb1 100644
--- a/lib/bundler/vendor/thor/lib/thor/shell/basic.rb
+++ b/lib/bundler/vendor/thor/lib/thor/shell/basic.rb
@@ -451,16 +451,25 @@ class Bundler::Thor
def ask_filtered(statement, color, options)
answer_set = options[:limited_to]
+ case_insensitive = options.fetch(:case_insensitive, false)
correct_answer = nil
until correct_answer
answers = answer_set.join(", ")
answer = ask_simply("#{statement} [#{answers}]", color, options)
- correct_answer = answer_set.include?(answer) ? answer : nil
+ correct_answer = answer_match(answer_set, answer, case_insensitive)
say("Your response must be one of: [#{answers}]. Please try again.") unless correct_answer
end
correct_answer
end
+ def answer_match(possibilities, answer, case_insensitive)
+ if case_insensitive
+ possibilities.detect{ |possibility| possibility.downcase == answer.downcase }
+ else
+ possibilities.detect{ |possibility| possibility == answer }
+ end
+ end
+
def merge(destination, content) #:nodoc:
require "tempfile"
Tempfile.open([File.basename(destination), File.extname(destination)], File.dirname(destination)) do |temp|