gorynich 1.3.2.231715 → 1.3.3.231946
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gorynich/config.rb +7 -3
- data/lib/gorynich/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c580367795e9f7b4337327a151bb380c0beb210126b4c3382f9cd9179b517b6f
|
|
4
|
+
data.tar.gz: 072e6a4cdf3f7948c7861ca53d5c94075d451302ad837acbfdea90dcbc6d4a26
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b5a314c932a44623e787e77858e247127e7f437bd77f1d0888767579c63c6908467f7baafcafc03c8d82476ea0131ecd59713207e71920b6a6a2522af8ae2878
|
|
7
|
+
data.tar.gz: 42332bba266151eda388aa3dea13904806721d29b9d9e3f4a1e295ec23f5b62e16def75dacf5151fafbf78eb95c7d2ab779a61ae089b0b7dac2eb2e903de1303
|
data/lib/gorynich/config.rb
CHANGED
|
@@ -126,13 +126,17 @@ module Gorynich
|
|
|
126
126
|
|
|
127
127
|
#
|
|
128
128
|
# Database config for database.yml
|
|
129
|
+
# If used <%= Gorynich.instance.database_config(your_enviroment) %> without gorynich config it will raise an error.
|
|
130
|
+
# You can use <%= Gorynich.instance.database_config(your_enviroment, fail_ignore: true) %> if there is no configuration for the environment
|
|
131
|
+
# and dummy_value depending on whether you have a configuration in the database.yml under this environment (dummy_value: nil when there is and dummy_value: {} if there is not. Default dummy_value is nil)
|
|
129
132
|
#
|
|
130
133
|
# @param [String] env enviroment
|
|
131
|
-
# @param [Boolean]
|
|
134
|
+
# @param [Boolean] fail_ignore ignore if there is no configuration for the environment
|
|
135
|
+
# @param [nil or Hash] dummy_value value for YAML if there is no config.
|
|
132
136
|
#
|
|
133
137
|
# @return [String] yaml result
|
|
134
138
|
#
|
|
135
|
-
def database_config(env = nil, fail_ignore: false)
|
|
139
|
+
def database_config(env = nil, fail_ignore: false, dummy_value: nil)
|
|
136
140
|
envs = Dir.glob(Rails.root.join('config/environments/*.rb').to_s).map { |f| File.basename(f, '.rb') }
|
|
137
141
|
cfg = fetcher.fetch.extract!(*envs)
|
|
138
142
|
|
|
@@ -146,7 +150,7 @@ module Gorynich
|
|
|
146
150
|
end
|
|
147
151
|
else
|
|
148
152
|
if fail_ignore && cfg[env].nil?
|
|
149
|
-
{ env =>
|
|
153
|
+
{ env => dummy_value }
|
|
150
154
|
else
|
|
151
155
|
{
|
|
152
156
|
env => configs_sort(cfg.fetch(env)).to_h { |t, c| [t, c.fetch('db_config')] }
|
data/lib/gorynich/version.rb
CHANGED