ask-ruby-harness 0.3.1 → 0.3.2
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/CHANGELOG.md +13 -0
- data/lib/ask/ruby/harness/version.rb +1 -1
- data/lib/ask/ruby/harness.rb +27 -4
- 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: bc926a8ba86f90bbc682d1361f4b436decfb071f543303a4f1055b7d8e986b59
|
|
4
|
+
data.tar.gz: b49641a4b3d21015363f0744ea28a5a146dd42eec21859120faee3977adfcba1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fe9cef5ac7bab9ae6742e988b0e46359d95809aedc91995918dd49d1481e770819d1e08388b90e60a3d1db0b4344dd32309ff317808283bf9ef4031104cd1713
|
|
7
|
+
data.tar.gz: b29401a3227880eb954e684b14fe4b197da492da840d1ab068f594f10007e6309deeeae95ca6bc5afcd6108fbadb1e119589bba5c478eb4ff959d9dbefba809e
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## [0.3.2] — 2026-08-12
|
|
2
|
+
|
|
3
|
+
### Fixed
|
|
4
|
+
|
|
5
|
+
- **ERB-safe `config/database.yml` parsing** — `database_yaml` now renders
|
|
6
|
+
ERB (Rails-style) before YAML loading. Raw `YAML.safe_load` choked on the
|
|
7
|
+
ERB most real database.yml files embed (ENV/credentials), so the named
|
|
8
|
+
database fallback reported "not found" for those apps.
|
|
9
|
+
- **Env-name lookup for named databases** — `database: "production"` from a
|
|
10
|
+
development-booted server now resolves that environment's own section in
|
|
11
|
+
`config/database.yml`: its flat single-DB config, or its `primary` pool
|
|
12
|
+
for multi-DB apps.
|
|
13
|
+
|
|
1
14
|
## [0.3.0] — 2026-08-10
|
|
2
15
|
|
|
3
16
|
### Added
|
data/lib/ask/ruby/harness.rb
CHANGED
|
@@ -97,7 +97,11 @@ module Ask
|
|
|
97
97
|
# Config for a NAMED database. Resolution order:
|
|
98
98
|
# 1. the host app's own configurations registry (Rails multi-DB —
|
|
99
99
|
# resolves credentials/ENV for us),
|
|
100
|
-
# 2. config/database.yml, the environment section's key
|
|
100
|
+
# 2. config/database.yml, the current environment section's key,
|
|
101
|
+
# 3. config/database.yml, the named environment section itself —
|
|
102
|
+
# "database: production" from a development-booted server
|
|
103
|
+
# resolves production's config (its "primary" pool for
|
|
104
|
+
# multi-DB apps).
|
|
101
105
|
def database_config_for(name)
|
|
102
106
|
name = name.to_s
|
|
103
107
|
if ActiveRecord::Base.respond_to?(:configurations)
|
|
@@ -107,6 +111,15 @@ module Ask
|
|
|
107
111
|
|
|
108
112
|
section = database_yaml_section
|
|
109
113
|
config = section[name] if section.is_a?(Hash) && section[name].is_a?(Hash)
|
|
114
|
+
return sanitize_database_config(config) if config
|
|
115
|
+
|
|
116
|
+
yaml = database_yaml
|
|
117
|
+
env_section = yaml[name] if yaml.is_a?(Hash)
|
|
118
|
+
return nil unless env_section.is_a?(Hash)
|
|
119
|
+
|
|
120
|
+
# Multi-DB apps nest pools under the env key; single-DB apps keep
|
|
121
|
+
# the connection config flat under it.
|
|
122
|
+
config = env_section["primary"].is_a?(Hash) ? env_section["primary"] : env_section
|
|
110
123
|
sanitize_database_config(config)
|
|
111
124
|
end
|
|
112
125
|
|
|
@@ -205,12 +218,22 @@ module Ask
|
|
|
205
218
|
private
|
|
206
219
|
|
|
207
220
|
def database_yaml_section
|
|
221
|
+
yaml = database_yaml || {}
|
|
222
|
+
yaml[env] || yaml["development"] || {}
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# Parses config/database.yml with ERB preprocessing (Rails-style) —
|
|
226
|
+
# most real database.yml files embed ENV/credentials ERB, which raw
|
|
227
|
+
# YAML.safe_load cannot parse. Returns nil when unreadable; the
|
|
228
|
+
# callers fall back to the Rails configurations registry.
|
|
229
|
+
def database_yaml
|
|
208
230
|
path = app_root.join("config", "database.yml")
|
|
209
231
|
return nil unless path.exist?
|
|
210
232
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
233
|
+
require "erb"
|
|
234
|
+
rendered = ERB.new(path.read).result
|
|
235
|
+
YAML.safe_load(rendered, aliases: true) || {}
|
|
236
|
+
rescue Psych::Exception, NameError, SyntaxError
|
|
214
237
|
nil
|
|
215
238
|
end
|
|
216
239
|
|