Skip to content

Commit

Permalink
feat(config): support for loading a postal.local.yml config file from…
Browse files Browse the repository at this point in the history
… the config root if it exists
  • Loading branch information
adamcooke committed Jul 29, 2021
1 parent 189dfa5 commit 8e3294b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ config/fast_server.cert
config/fast_server.key
config/postal/**/*

spec/config/postal.local.yml

public/assets
vendor/bundle
Expand Down
11 changes: 10 additions & 1 deletion lib/postal/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def self.config
@config ||= begin
require 'hashie/mash'
config = Hashie::Mash.new(self.defaults)
config.deep_merge(self.yaml_config)
config = config.deep_merge(self.yaml_config)
config.deep_merge(self.local_yaml_config)
end
end

Expand Down Expand Up @@ -64,6 +65,14 @@ def self.yaml_config
@yaml_config ||= File.exist?(config_file_path) ? YAML.load_file(config_file_path) : {}
end

def self.local_config_file_path
@local_config_file_path ||= File.join(config_root, 'postal.local.yml')
end

def self.local_yaml_config
@local_yaml_config ||= File.exist?(local_config_file_path) ? YAML.load_file(local_config_file_path) : {}
end

def self.defaults_file_path
@defaults_file_path ||= app_root.join('config', 'postal.defaults.yml')
end
Expand Down

0 comments on commit 8e3294b

Please sign in to comment.