Class: EasySettings::CertificateManagerSource
- Inherits:
-
PathSource
- Object
- PathSource
- EasySettings::CertificateManagerSource
show all
- Defined in:
- lib/easy-settings/certificate_manager_source.rb
Instance Attribute Summary
Attributes inherited from PathSource
#base_path, #converter, #parse_values, #separator, #settings_root
Instance Method Summary
collapse
Methods inherited from PathSource
#assign_value
Constructor Details
#initialize(base_path, settings_root: ["certificates"], separator: "__", converter: :downcase) ⇒ CertificateManagerSource
Returns a new instance of CertificateManagerSource.
4
5
6
|
# File 'lib/easy-settings/certificate_manager_source.rb', line 4
def initialize(base_path, settings_root: ["certificates"], separator: "__", converter: :downcase)
super(base_path, settings_root: settings_root, separator: separator, converter: converter, parse_values: false)
end
|
Instance Method Details
#filenames ⇒ Object
30
31
32
|
# File 'lib/easy-settings/certificate_manager_source.rb', line 30
def filenames
{"ca.crt" => "ca", "tls.crt" => "crt", "tls.key" => "key"}
end
|
#load ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/easy-settings/certificate_manager_source.rb', line 8
def load
{}.tap do |data|
Dir["#{base_path}/*"].each do |path|
next unless File.directory?(path)
next unless valid_folder?(path)
variable = path.gsub("#{base_path}/", "")
keys = settings_root + variable.to_s.split(separator)
filenames.each do |filename, key|
value = File.binread("#{path}/#{filename}").strip
assign_value(data, keys + [key], value)
end
end
end
end
|
#valid_folder?(path) ⇒ Boolean
25
26
27
28
|
# File 'lib/easy-settings/certificate_manager_source.rb', line 25
def valid_folder?(path)
(filenames.keys - Dir["#{path}/*"].map{ |path| File.basename(path) }).none?
end
|