Module: LeapCA::Config

Extended by:
Config
Included in:
Config
Defined in:
lib/leap_ca/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#ca_cert_pathObject

Returns the value of attribute ca_cert_path.



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

def ca_cert_path
  @ca_cert_path
end

#ca_key_passwordObject

Returns the value of attribute ca_key_password.



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

def ca_key_password
  @ca_key_password
end

#ca_key_pathObject

Returns the value of attribute ca_key_path.



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

def ca_key_path
  @ca_key_path
end

#client_cert_bit_sizeObject

Returns the value of attribute client_cert_bit_size.



13
14
15
# File 'lib/leap_ca/config.rb', line 13

def client_cert_bit_size
  @client_cert_bit_size
end

#client_cert_hashObject

Returns the value of attribute client_cert_hash.



14
15
16
# File 'lib/leap_ca/config.rb', line 14

def client_cert_hash
  @client_cert_hash
end

#client_cert_lifespanObject

Returns the value of attribute client_cert_lifespan.



12
13
14
# File 'lib/leap_ca/config.rb', line 12

def client_cert_lifespan
  @client_cert_lifespan
end

#couch_connectionObject

Returns the value of attribute couch_connection.



17
18
19
# File 'lib/leap_ca/config.rb', line 17

def couch_connection
  @couch_connection
end

#db_nameObject

Returns the value of attribute db_name.



16
17
18
# File 'lib/leap_ca/config.rb', line 16

def db_name
  @db_name
end

#max_pool_sizeObject

Returns the value of attribute max_pool_size.



11
12
13
# File 'lib/leap_ca/config.rb', line 11

def max_pool_size
  @max_pool_size
end

Class Method Details

.load(base_dir, *configs) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/leap_ca/config.rb', line 19

def self.load(base_dir, *configs)
  configs.each do |file_path|
    file_path = find_file(base_dir, file_path)
    next unless file_path
    puts " * Loading configuration #{file_path}"
    yml = YAML.load(File.read(file_path))
    if yml
      yml.each do |key, value|
        begin
          if value.is_a? Hash
            value = symbolize_keys(value)
          end
          self.send("#{key}=", value)
        rescue NoMethodError => exc
          STDERR.puts "ERROR in file #{file}, '#{key}' is not a valid option"
          exit(1)
        end
      end
    end
  end
  [:ca_key_path, :ca_cert_path].each do |attr|
    path = self.send(attr) || ""
    if path =~ /^\./
      path = File.expand_path(path, base_dir)
      self.send("#{attr}=", path)
    end
    unless File.exists?(path)
      STDERR.puts "ERROR: The config option '#{attr}' is set to '#{path}', but the file does not exist!"
      exit(1)
    end
  end
end