Class: CryptReboot::CryptTab::EntryDeserializer

Inherits:
Object
  • Object
show all
Defined in:
lib/crypt_reboot/crypt_tab/entry_deserializer.rb

Overview

Deserialize crypttab line into value object

Constant Summary collapse

InvalidFormat =
Class.new StandardError

Instance Method Summary collapse

Instance Method Details

#call(line) ⇒ Object

Raises:



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/crypt_reboot/crypt_tab/entry_deserializer.rb', line 9

def call(line)
  target, source, key_file, raw_floptions = columns = line.split
  raise InvalidFormat if columns.size < 3

  floptions = raw_floptions.to_s.split(',')
  flags = extract_flags(floptions)
  options = extract_options(floptions)
  entry_class.new(
    target: target, source: source, key_file: key_file,
    options: options, flags: flags
  )
end