bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb in rubygems-update-3.1.0.pre3 vs bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb in rubygems-update-3.1.0
- old
+ new
@@ -449,17 +449,26 @@
end
end
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|