vendor/bundle/ruby/1.8/gems/io-reactor-1.0.4/rake/helpers.rb
### Prompt the user with the given <tt>prompt_string</tt> via #prompt,
### substituting the given <tt>default</tt> if the user doesn't input
### anything.  If a test is provided, the prompt will repeat until the test
### returns true.  An optional failure message can also be passed in.
Prompt the user with the given prompt_string via #prompt,
substituting the given default if the user doesn't input
anything.  If a test is provided, the prompt will repeat until the test
returns true.  An optional failure message can also be passed in.
Prompt the user with the given prompt_string via #prompt substituting the given default if the user doesn ' t input anything . If a test is provided the prompt will repeat until the test returns true . An optional failure message can also be passed in .
def prompt_with_default( prompt_string, default, failure_msg="Try again." )
	response = nil
	begin
		default ||= '~'
		response = prompt( "%s [%s]" % [ prompt_string, default ] )
		response = default.to_s if !response.nil? && response.empty? 
		trace "Validating reponse %p" % [ response ]
		if block_given? && response != '~' && ! yield( response )
			error_message( failure_msg + "\n\n" )
			response = nil
		end
	end while response.nil?
	return nil if response == '~'
	return response
end
def prompt_with_default ( prompt_string , default , failure_msg = "Try again." ) response = nil begin default ||= '~' response = prompt ( "%s [%s]" % [ prompt_string , default ] ) response = default . to_s if ! response . nil? && response . empty? trace "Validating reponse %p" % [ response ] if block_given? && response != '~' && ! yield ( response ) error_message ( failure_msg + "\n\n" ) response = nil end end while response . nil? return nil if response == '~' return response end
Prompt the user with the given <tt>prompt_string</tt> via #prompt,
substituting the given <tt>default</tt> if the user doesn't input
anything.
Prompt the user with the given <tt > prompt_string< / tt > via #prompt substituting the given <tt > default< / tt > if the user doesn ' t input anything .
# the block is a validator.  We need to make sure that the user didn't # enter '~', because if they did, it's nil and we should move on.  If # they didn't, then call the block.
prompt_string
default
failure_msg