Class: UKCloud::Vcloud::Ipsec::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_location = "#{Dir.pwd}/firewalls.yml") ⇒ Configuration

Returns a new instance of Configuration.



8
9
10
11
12
13
14
# File 'lib/configuration.rb', line 8

def initialize(file_location = "#{Dir.pwd}/firewalls.yml")
  @file_location = file_location
  raise("Configuration File Not Found At #{file_location}") unless File.exists?(file_location)
  
  @full_config = load_yaml
  @firewalls = parse_config
end

Instance Attribute Details

#file_locationObject

Returns the value of attribute file_location.



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

def file_location
  @file_location
end

#firewallsObject

Returns the value of attribute firewalls.



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

def firewalls
  @firewalls
end

#full_configObject

Returns the value of attribute full_config.



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

def full_config
  @full_config
end

Instance Method Details

#load_yamlObject



16
17
18
19
20
21
22
# File 'lib/configuration.rb', line 16

def load_yaml
  file = File.open(@file_location)
  conf = YAML.load(file)
  file.close
  
  symbolize(conf) unless conf == false
end

#parse_configObject



24
25
26
27
28
29
30
31
# File 'lib/configuration.rb', line 24

def parse_config
  raise("No firewalls In Config File: #{@file_location}") unless @full_config.is_a?(Hash) && @full_config[:Firewalls]
  raise("No firewalls In Config File: #{@file_location}") unless @full_config[:Firewalls].is_a?(Array) && @full_config[:Firewalls].length > 0
  #To Do: Add Config Schema?  
  @full_config[:Firewalls]
  
  
end