Class: KTools::Setup

Inherits:
Object
  • Object
show all
Defined in:
lib/ktools/setup.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSetup

Returns a new instance of Setup.



26
# File 'lib/ktools/setup.rb', line 26

def initialize; end

Class Method Details

.done?Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/ktools/setup.rb', line 3

def self.done?
  KDB.read ? true : false
end

.loadObject



7
8
9
# File 'lib/ktools/setup.rb', line 7

def self.load
  KDB.read
end

.performObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ktools/setup.rb', line 11

def self.perform
  secrets_path = self.new.get_secrets_path
  KDB.write({"secrets" => secrets_path})

  puts "Your 'secrets' path was saved as:"
  puts secrets_path

  puts ""
  puts "For redefining it you can run:"
  puts "$ kt setup"
  puts ""

  exit
end

Instance Method Details

#get_secrets_pathObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/ktools/setup.rb', line 28

def get_secrets_path
  path = String.new

  loop do
    puts "Insert the path for your 'secrets' repository:"
    puts ""
    print "#{Dir.home}/"

    input = STDIN.gets.chomp.chomp('/')
    path = "#{Dir.home}/#{input}"
    ima_secret_path = "#{path}/.ima_secret"

    puts ""

    if File.file?(ima_secret_path)
      break
    else
      puts "That's a invalid path, try again."
    end
  end

  path
end