class Ironment::CL::Prompter
Public Class Methods
new(options = {})
click to toggle source
# File lib/ironment/cl/prompter.rb, line 4 def initialize(options = {}) @in = options[:in] || $stdin @out = options[:out] || $stdout @truster = options[:truster] || Truster.new end
Public Instance Methods
modified(runcom)
click to toggle source
# File lib/ironment/cl/prompter.rb, line 15 def modified(runcom) prompt_modified(runcom) request_user_action(runcom) end
not_trusted(runcom)
click to toggle source
# File lib/ironment/cl/prompter.rb, line 10 def not_trusted(runcom) prompt_not_trusted(runcom) request_user_action(runcom) end
request_user_action(runcom)
click to toggle source
# File lib/ironment/cl/prompter.rb, line 20 def request_user_action(runcom) prompt_question case @in.gets.strip.to_sym when :y @truster.trust(runcom) true when :v prompt_content(runcom) request_user_action(runcom) when :n false else request_user_action(runcom) end end
Private Instance Methods
prompt_content(runcom)
click to toggle source
# File lib/ironment/cl/prompter.rb, line 66 def prompt_content(runcom) @out.write "\n#{runcom.content.gsub(/^/, " ")}\n" end
prompt_modified(runcom)
click to toggle source
# File lib/ironment/cl/prompter.rb, line 49 def prompt_modified(runcom) @out.write <<-PROMPT Ironment has encountered a trusted, but modified .envrc file. This may contain untrusted content and should be examined manually. #{runcom.file} (#{runcom.sha1sum}) PROMPT end
prompt_not_trusted(runcom)
click to toggle source
# File lib/ironment/cl/prompter.rb, line 39 def prompt_not_trusted(runcom) @out.write <<-PROMPT Ironment has encountered a new and untrusted .envrc file. This may contain untrusted content and should be examined manually. #{runcom.file} (#{runcom.sha1sum}) PROMPT end
prompt_question()
click to toggle source
# File lib/ironment/cl/prompter.rb, line 59 def prompt_question @out.write <<-PROMPT.gsub(/\n$/, "") Do you wish to trust this .envrc file? y[es], n[o], v[iew]> PROMPT end