Module: Getch

Defined in:
lib/getch.rb,
lib/getch/disk.rb,
lib/getch/states.rb,
lib/getch/options.rb,
lib/getch/version.rb

Defined Under Namespace

Classes: Disk, Options, States

Constant Summary collapse

DEFAULT_OPTIONS =
{
  language: 'en_US',
  location: 'US/Eastern',
  keyboard: 'us',
  disk: 'sda',
  fs: 'ext4',
  username: nil
}
STATES =
{
  :partition => false,
  :format => false,
  :mount => false,
  :gentoo_base => false
}
VERSION =
'0.0.2'.freeze

Class Method Summary collapse

Class Method Details

.format(disk, fs) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/getch.rb', line 41

def self.format(disk, fs)
  return if STATES[:format] and STATES[:partition]
  puts
  print "Partition and format disk #{disk}, this will erase all data, continue? (n,y) "
  case gets.chomp
  when /^y|^Y/
    disk = Getch::Disk.new(disk, fs)
    disk.cleaning
    disk.partition
    disk.format
  else
    exit 1
  end
end

.main(argv) ⇒ Object



56
57
58
59
60
61
# File 'lib/getch.rb', line 56

def self.main(argv)
  options = Options.new(DEFAULT_OPTIONS, argv)
  resume_options(options)
  Getch::States.new() # Update States
  format(options.disk, options.fs)
end

.resume_options(opts) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/getch.rb', line 23

def self.resume_options(opts)
  puts "\nBuild Gentoo with the following args:\n"
  puts "lang: #{opts.language}"
  puts "zoneinfo: #{opts.zoneinfo}"
  puts "keyboard: #{opts.keyboard}"
  puts "disk: #{opts.disk}"
  puts "fs: #{opts.fs}"
  puts "username: #{opts.username}"
  puts
  print "Continue? (n,y) "
  case gets.chomp
  when /^y|^Y/
    return
  else
    exit 1
  end
end