Class: UKCloud::Vcloud::Ipsec::Configuration
- Inherits:
-
Object
- Object
- UKCloud::Vcloud::Ipsec::Configuration
- Defined in:
- lib/configuration.rb
Instance Attribute Summary collapse
-
#file_location ⇒ Object
Returns the value of attribute file_location.
-
#firewalls ⇒ Object
Returns the value of attribute firewalls.
-
#full_config ⇒ Object
Returns the value of attribute full_config.
Instance Method Summary collapse
-
#initialize(file_location = "#{Dir.pwd}/firewalls.yml") ⇒ Configuration
constructor
A new instance of Configuration.
- #load_yaml ⇒ Object
- #parse_config ⇒ Object
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_location ⇒ Object
Returns the value of attribute file_location.
7 8 9 |
# File 'lib/configuration.rb', line 7 def file_location @file_location end |
#firewalls ⇒ Object
Returns the value of attribute firewalls.
7 8 9 |
# File 'lib/configuration.rb', line 7 def firewalls @firewalls end |
#full_config ⇒ Object
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_yaml ⇒ Object
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_config ⇒ Object
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 |