Sha256: a5c9e059a507621ff577d7f665e5870651c022ec01a2af1bc78785115318215c

Contents?: true

Size: 929 Bytes

Versions: 12

Compression:

Stored size: 929 Bytes

Contents

require 'yaml'

module Getch
  class States
    def initialize
      @file = File.join('/tmp/install_gentoo.yaml')
      load_state
    end

    def partition
      STATES[:partition] = true
      save
    end

    def format
      STATES[:format] = true
      save
    end

    def mount
      STATES[:mount] = true
      save
    end

    def stage3
      STATES[:gentoo_base] = true
      save
    end

    def config
      STATES[:gentoo_config] = true
      save
    end

    def update
      STATES[:gentoo_update] = true
      save
    end

    def kernel
      STATES[:gentoo_kernel] = true
      save
    end

    private

    def save
      File.open(@file, 'w') { |f| YAML::dump(STATES, f) }
    end

    def load_state()
      if File.exist? @file
        state_file = YAML.load_file(@file)
        STATES.merge!(state_file)
      else
        save
        STDERR.puts "Initialize states"
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
getch-0.1.6 lib/getch/states.rb
getch-0.1.5 lib/getch/states.rb
getch-0.1.3 lib/getch/states.rb
getch-0.1.2 lib/getch/states.rb
getch-0.1.1 lib/getch/states.rb
getch-0.1.0 lib/getch/states.rb
getch-0.0.9 lib/getch/states.rb
getch-0.0.8 lib/getch/states.rb
getch-0.0.7 lib/getch/states.rb
getch-0.0.6 lib/getch/states.rb
getch-0.0.5 lib/getch/states.rb
getch-0.0.4 lib/getch/states.rb