Sha256: 554c160180fb2d52ae54b30ef5c08663164819fa6049586a8fafeb768b8326ba
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
require "easy-settings/coercion" class EasySettings::CertificateManagerSource < EasySettings::PathSource 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 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 def valid_folder?(path) # ensure the folder contains all the files we expect (filenames.keys - Dir["#{path}/*"].map{ |path| File.basename(path) }).none? end def filenames {"ca.crt" => "ca", "tls.crt" => "crt", "tls.key" => "key"} end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
easy-settings-2.0.0 | lib/easy-settings/certificate_manager_source.rb |