class SecretHub::Config
Attributes
data[R]
Public Class Methods
load(config_file)
click to toggle source
# File lib/secret_hub/config.rb, line 7 def self.load(config_file) raise ConfigurationError, "Config file not found #{config_file}" unless File.exist? config_file new YAML.load_file config_file end
new(data)
click to toggle source
# File lib/secret_hub/config.rb, line 12 def initialize(data) @data = data end
Public Instance Methods
each(&block)
click to toggle source
# File lib/secret_hub/config.rb, line 20 def each(&block) to_h.each &block end
each_repo(&block)
click to toggle source
# File lib/secret_hub/config.rb, line 24 def each_repo(&block) to_h.keys.each &block end
to_h()
click to toggle source
# File lib/secret_hub/config.rb, line 16 def to_h @to_h ||= to_h! end
Private Instance Methods
resolve_secrets(secrets)
click to toggle source
# File lib/secret_hub/config.rb, line 39 def resolve_secrets(secrets) secrets = [] unless secrets if secrets.is_a? Hash secrets.map { |key, value| [key, value || ENV[key]] }.to_h elsif secrets.is_a? Array secrets.map { |key| [key, ENV[key]] }.to_h end end
to_h!()
click to toggle source
# File lib/secret_hub/config.rb, line 30 def to_h! result = {} data.each do |repo, secrets| next unless repo.include? '/' result[repo] = resolve_secrets secrets end result end