class Secrets
Public Class Methods
config_path_for(env)
click to toggle source
# File lib/secrets.rb, line 16 def config_path_for(env) File.exist?(ejson_path_for(env)) ? ejson_path_for(env) : json_path_for(env) end
default_filename()
click to toggle source
# File lib/secrets.rb, line 12 def default_filename config_path_for(Environment.environment) end
new(filename = "")
click to toggle source
# File lib/secrets.rb, line 35 def initialize(filename = "") @filename = filename.empty? ? Secrets.default_filename : actual_filename_for(filename) end
Private Class Methods
app_config_path()
click to toggle source
# File lib/secrets.rb, line 30 def app_config_path expand_path(Options.get("secrets.path")) end
ejson_path_for(env)
click to toggle source
# File lib/secrets.rb, line 22 def ejson_path_for(env) "config/#{env}/secrets.ejson" end
json_path_for(env)
click to toggle source
# File lib/secrets.rb, line 26 def json_path_for(env) "config/#{env}/secrets.json" end
Private Instance Methods
actual_filename_for(filename)
click to toggle source
# File lib/secrets.rb, line 41 def actual_filename_for(filename) File.exist?(filename) ? filename : filename.sub(".ejson", ".json") end
ejson_contents()
click to toggle source
# File lib/secrets.rb, line 51 def ejson_contents @ejson_contents ||= begin out, err, _status = Open3.capture3("ejson decrypt #{@filename}") # TODO: err is only nil in testing, but I can't figure out why the stubbing isn't working raise ParsingError, "#{@filename}: #{err}" unless err.nil? || err.empty? out end end
file_contents()
click to toggle source
Calls superclass method
AppConfig#file_contents
# File lib/secrets.rb, line 45 def file_contents @file_contents ||= begin @filename.match(/\.ejson$/) ? ejson_contents : super end end