Class: Elasticdns::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Config

Returns a new instance of Config.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/config.rb', line 5

def initialize(options={})
  @config_from_file = from_file(options[:config_file])

  @test = options[:test]
  @slave =options[:slave]

  @debug = options[:debug] || (@config_from_file['debug'] if @config_from_file)

  @ec2_access_key_id = options[:ec2_access_key_id] || (@config_from_file['ec2']['access_key_id'] if @config_from_file)
  @ec2_secret_access_key = options[:ec2_secret_access_key] || (@config_from_file['ec2']['secret_access_key'] if @config_from_file)
  @ec2_region = options[:ec2_region] || (@config_from_file['ec2']['region'] if @config_from_file)
  @ec2_tag_attribute = options[:ec2_tag_attribute] || (@config_from_file['ec2']['tag_attribute'] if @config_from_file)
  @ec2_ip_attribute = options[:ec2_ip_attribute] || (@config_from_file['ec2']['ip_attribute'] if @config_from_file)

  @bind9_notify_file = options[:bind9_notify_file] || (@config_from_file['bind9']['notify_file'] if @config_from_file)
  @bind9_acl_masters_file = options[:bind9_acl_masters_file] || (@config_from_file['bind9']['acl_masters_file'] if @config_from_file)
  @bind9_named_conf_file = options[:bind9_named_conf_file] || (@config_from_file['bind9']['named_conf_file'] if @config_from_file)
  @bind9_zone_files = split(options[:bind9_zone_files]) || (@config_from_file['bind9']['zone_files'] if @config_from_file)
  @bind9_checkconf_path = options[:bind9_checkconf_path] || (@config_from_file['bind9']['checkconf_path'] if @config_from_file)
  @bind9_checkzone_path = options[:bind9_checkzone_path] || (@config_from_file['bind9']['checkzone_path'] if @config_from_file)
  @bind9_init_cmd = options[:bind9_init_cmd] || (@config_from_file['bind9']['init_cmd'] if @config_from_file)
  @bind9_masters = split(options[:bind9_masters]) || (@config_from_file['bind9']['masters'] if @config_from_file)
end

Instance Attribute Details

#bind9_acl_masters_fileObject

Returns the value of attribute bind9_acl_masters_file.



3
4
5
# File 'lib/config.rb', line 3

def bind9_acl_masters_file
  @bind9_acl_masters_file
end

#bind9_checkconf_pathObject

Returns the value of attribute bind9_checkconf_path.



3
4
5
# File 'lib/config.rb', line 3

def bind9_checkconf_path
  @bind9_checkconf_path
end

#bind9_checkzone_pathObject

Returns the value of attribute bind9_checkzone_path.



3
4
5
# File 'lib/config.rb', line 3

def bind9_checkzone_path
  @bind9_checkzone_path
end

#bind9_init_cmdObject

Returns the value of attribute bind9_init_cmd.



3
4
5
# File 'lib/config.rb', line 3

def bind9_init_cmd
  @bind9_init_cmd
end

#bind9_mastersObject

Returns the value of attribute bind9_masters.



3
4
5
# File 'lib/config.rb', line 3

def bind9_masters
  @bind9_masters
end

#bind9_named_conf_fileObject

Returns the value of attribute bind9_named_conf_file.



3
4
5
# File 'lib/config.rb', line 3

def bind9_named_conf_file
  @bind9_named_conf_file
end

#bind9_notify_fileObject

Returns the value of attribute bind9_notify_file.



3
4
5
# File 'lib/config.rb', line 3

def bind9_notify_file
  @bind9_notify_file
end

#bind9_zone_filesObject

Returns the value of attribute bind9_zone_files.



3
4
5
# File 'lib/config.rb', line 3

def bind9_zone_files
  @bind9_zone_files
end

#ec2_access_key_idObject

Returns the value of attribute ec2_access_key_id.



3
4
5
# File 'lib/config.rb', line 3

def ec2_access_key_id
  @ec2_access_key_id
end

#ec2_attributeObject

Returns the value of attribute ec2_attribute.



3
4
5
# File 'lib/config.rb', line 3

def ec2_attribute
  @ec2_attribute
end

#ec2_secret_access_keyObject

Returns the value of attribute ec2_secret_access_key.



3
4
5
# File 'lib/config.rb', line 3

def ec2_secret_access_key
  @ec2_secret_access_key
end

Instance Method Details

#from_file(config_file) ⇒ Object



41
42
43
44
45
# File 'lib/config.rb', line 41

def from_file(config_file)
  if config_file && File.exists?(config_file)
   YAML.load_file(config_file)
  end      
end

#split(param) ⇒ Object



29
30
31
32
33
# File 'lib/config.rb', line 29

def split(param)
  if param
    param.split(',')
  end
end

#to_hashObject



35
36
37
38
39
# File 'lib/config.rb', line 35

def to_hash
  hash = {}
  self.instance_variables.each {|var| hash[var.to_s.delete("@").to_sym] = self.instance_variable_get(var) }
  return hash
end