class Danger::Interviewer
Attributes
no_delay[RW]
no_waiting[RW]
ui[RW]
Public Class Methods
new(cork_board)
click to toggle source
# File lib/danger/commands/init_helpers/interviewer.rb, line 5 def initialize(cork_board) @ui = cork_board end
Public Instance Methods
ask_with_answers(question, possible_answers)
click to toggle source
# File lib/danger/commands/init_helpers/interviewer.rb, line 55 def ask_with_answers(question, possible_answers) ui.print "\n#{question}? [" print_info = proc do possible_answers.each_with_index do |answer, i| the_answer = i.zero? ? answer.underlined : answer ui.print " " + the_answer ui.print(" /") if i != possible_answers.length - 1 end ui.print " ]\n" end print_info.call answer = "" loop do show_prompt answer = @no_waiting ? possible_answers[0].downcase : STDIN.gets.downcase.chomp answer = "yes" if answer == "y" answer = "no" if answer == "n" # default to first answer if answer == "" answer = possible_answers[0].downcase ui.puts "Using: " + answer.yellow end break if possible_answers.map(&:downcase).include? answer ui.print "\nPossible answers are [" print_info.call end answer end
green_bang()
click to toggle source
# File lib/danger/commands/init_helpers/interviewer.rb, line 17 def green_bang "! ".green end
header(title)
click to toggle source
# File lib/danger/commands/init_helpers/interviewer.rb, line 29 def header(title) say title.yellow say "" pause 0.6 end
link(url)
click to toggle source
# File lib/danger/commands/init_helpers/interviewer.rb, line 35 def link(url) say " -> " + url.underlined + "\n" end
pause(time)
click to toggle source
# File lib/danger/commands/init_helpers/interviewer.rb, line 39 def pause(time) sleep(time) unless @no_waiting end
red_bang()
click to toggle source
# File lib/danger/commands/init_helpers/interviewer.rb, line 21 def red_bang "! ".red end
run_command(command, output_command = nil)
click to toggle source
# File lib/danger/commands/init_helpers/interviewer.rb, line 49 def run_command(command, output_command = nil) output_command ||= command ui.puts " " + output_command.magenta system command end
say(output)
click to toggle source
# File lib/danger/commands/init_helpers/interviewer.rb, line 25 def say(output) ui.puts output end
show_prompt()
click to toggle source
# File lib/danger/commands/init_helpers/interviewer.rb, line 9 def show_prompt ui.print "> ".bold.green end
wait_for_return()
click to toggle source
# File lib/danger/commands/init_helpers/interviewer.rb, line 43 def wait_for_return STDOUT.flush STDIN.gets unless @no_delay ui.puts end
yellow_bang()
click to toggle source
# File lib/danger/commands/init_helpers/interviewer.rb, line 13 def yellow_bang "! ".yellow end