Class: Lockness::MasterKey

Inherits:
Object
  • Object
show all
Defined in:
lib/lockness/master_key.rb

Instance Method Summary collapse

Instance Method Details

#exist?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/lockness/master_key.rb', line 24

def exist?
  File.exist?(path)
end

#generateObject



10
11
12
13
14
15
16
17
18
# File 'lib/lockness/master_key.rb', line 10

def generate
  ensure_does_not_exist

  master_key = SecureRandom.hex

  File.write(path, master_key)

  puts "Generated master key and saved at #{path}"
end

#pathObject



20
21
22
# File 'lib/lockness/master_key.rb', line 20

def path
  "#{Dir.pwd}/master.key"
end

#readObject



4
5
6
7
8
# File 'lib/lockness/master_key.rb', line 4

def read
  ensure_exists

  File.read(path).strip
end