lib/muchkeys/rails.rb in muchkeys-0.5.0 vs lib/muchkeys/rails.rb in muchkeys-0.7.0
- old
+ new
@@ -1,19 +1,18 @@
-class MuchKeys::Rails < Rails::Railtie
- config.before_configuration do
- MuchKeys.configure do |config|
- config.application_name = Rails.application.class.parent_name.underscore
- end
+module Muchkeys
+ class Rails < Rails::Railtie
+ config.before_configuration do
+ app_config = YAML.load(File.read(::Rails.root.join("config", "muchkeys.yml")))
+ Muchkeys.configure do |config|
+ config.application_name ||= app_config[:application_name] || ::Rails.application.class.parent_name.underscore
+ config.consul_url ||= app_config[:consul_url] || "http://localhost:8500"
+ config.keys_dir ||= app_config[:keys_dir]
+ config.private_key ||= app_config[:private_key]
+ config.public_key ||= app_config[:public_key]
+ config.search_paths ||= app_config[:search_paths]
+ config.secrets_hint ||= app_config[:secrets_hint]
+ end
- MuchKeys.populate_environment!(*env_keys)
- end
-
-
- def env_keys
- # parse all environments found in .env and populate them from consul
- unless File.exists?(Rails.root.join(".env"))
- raise IOError, ".env files are required for Muchkeys ENV injection to work"
+ Muchkeys.populate_environment!(*Muchkeys.env_keys)
end
-
- File.read(Rails.root.join(".env")).each_line.map { |x| x.split("=")[0] }
end
end