class Cipherpipe::Configuration
Constants
- FILENAME
- UnknownFormatterError
Attributes
external_sources[R]
file[R]
filename[R]
format[R]
Public Class Methods
new(filename = FILENAME)
click to toggle source
# File lib/cipherpipe/configuration.rb, line 10 def initialize(filename = FILENAME) @filename = filename parse! end
Public Instance Methods
variables()
click to toggle source
# File lib/cipherpipe/configuration.rb, line 16 def variables formatter.read File.read(file) end
variables=(hash)
click to toggle source
# File lib/cipherpipe/configuration.rb, line 20 def variables=(hash) File.write file, formatter.write(hash) if file end
Private Instance Methods
environment()
click to toggle source
# File lib/cipherpipe/configuration.rb, line 28 def environment ENV["CIPHERPIPE_ENV"] || ENV["RAILS_ENV"] || "development" end
formatter()
click to toggle source
# File lib/cipherpipe/configuration.rb, line 32 def formatter case format when "json" Cipherpipe::Formatters::JSON when "hcl" Cipherpipe::Formatters::HCL when "env" Cipherpipe::Formatters::Env else raise UnknownFormatterError, "unknown format #{format}" end end
parse!()
click to toggle source
# File lib/cipherpipe/configuration.rb, line 45 def parse! @external_sources = yaml["sources"].collect { |source| parse_source source } @format = yaml["format"] @file = yaml["file"].gsub("ENVIRONMENT", environment) end
parse_source(hash)
click to toggle source
# File lib/cipherpipe/configuration.rb, line 51 def parse_source(hash) hash.each do |key, value| hash[key] = value.gsub("ENVIRONMENT", environment) if value.is_a?(String) end Cipherpipe::ExternalSource.new hash end
yaml()
click to toggle source
# File lib/cipherpipe/configuration.rb, line 59 def yaml @yaml ||= YAML.load File.read(filename) end