Class: Kafo::Wizard

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/kafo/wizard.rb

Constant Summary collapse

OK =
utf_support? ? '' : 'y'
NO =
utf_support? ? '' : 'n'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kafo, input = $stdin, output = $stdout) ⇒ Wizard

Returns a new instance of Wizard.



18
19
20
21
22
23
# File 'lib/kafo/wizard.rb', line 18

def initialize(kafo, input = $stdin, output = $stdout)
  @kafo   = kafo
  @config = kafo.config
  @name   = @config.app[:name] || 'Kafo'
  @highline = setup_terminal(input, output)
end

Class Method Details

.utf_support?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/kafo/wizard.rb', line 8

def self.utf_support?
  Kafo::ENV::LANG =~ /UTF-8\z/
end

Instance Method Details

#runObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/kafo/wizard.rb', line 25

def run
  message = "Welcome to the #{@name} installer!"
  say(HighLine.color(message, :headline))
  say(HighLine.color('-' * message.size, :horizontal_line))
  say(<<END)

This wizard will gather all required information. You can change any parameter to your needs.

END

  exit 0 unless agree("\n<%= color('Ready to start?', :question) %> (y/n)", false)

  main_menu
rescue Interrupt
  puts "Got interrupt, exiting"
  KafoConfigure.exit(130)
end