Class: SimpleSshBackup::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_ssh_backup/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



8
9
10
11
# File 'lib/simple_ssh_backup/config.rb', line 8

def initialize
  @targets = nil
  @backup_dir = nil
end

Instance Attribute Details

#backup_dirObject (readonly)

Returns the value of attribute backup_dir.



6
7
8
# File 'lib/simple_ssh_backup/config.rb', line 6

def backup_dir
  @backup_dir
end

#targetsObject (readonly)

Returns the value of attribute targets.



6
7
8
# File 'lib/simple_ssh_backup/config.rb', line 6

def targets
  @targets
end

Instance Method Details

#load(config_file) ⇒ Object

Raises:

  • (ArgumentError)


13
14
15
16
17
18
19
20
21
22
# File 'lib/simple_ssh_backup/config.rb', line 13

def load(config_file)
  raise ArgumentError, 'Config file does not exist' unless File.exists?(config_file)
  raise ArgumentError, 'Config not readable' unless File.readable?(config_file)

  file_contents = File.read(config_file)
  props = YAML.load(file_contents)

  @backup_dir = props['backup_dir']
  @targets = props['targets']
end