ask-ruby-harness 0.2.0 → 0.2.1
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 +11 -0
- data/lib/ask/ruby/harness/tools/query_database.rb +2 -2
- data/lib/ask/ruby/harness/version.rb +1 -1
- data/lib/ask/ruby/harness.rb +20 -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: 411e139b4a5cfe5e017a748753c36a1f811a45f719e2245c7789267d4fe9f476
|
|
4
|
+
data.tar.gz: bd78de0520de347c8ffb675c7c704187c98fc7971b3b4a30770c227479adf7f3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4010a7f88a99c289dc68a1bbb40e7b8b829ac794b2a9daf609558128dad5b809f1a6900fae0d8d4c46d795ab69aa5802aa4cfde361256601c913d893f2551000
|
|
7
|
+
data.tar.gz: 6c0362992da2df7e54e0191fbc494c35c90641d538c9f2f7ea63e58b8a33a5d4a9248f32ee58def32d5db09547c83887dd598f7dbe524fc98b19a29c04a6f4bb
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## [0.2.1] — 2026-08-10
|
|
2
|
+
|
|
3
|
+
### Fixed
|
|
4
|
+
|
|
5
|
+
- **Standalone DB connection guard** — `QueryDatabase` now checks whether a
|
|
6
|
+
connection spec is *defined* (pool presence) instead of `connected?`
|
|
7
|
+
(which stays false until the first checkout), so `establish_connection`
|
|
8
|
+
from `ASK_DATABASE_URL`/`database.yml` is actually honored.
|
|
9
|
+
- **Relative sqlite paths in `database.yml`** — resolved against the app
|
|
10
|
+
root (like Rails does) instead of the harness's cwd.
|
|
11
|
+
|
|
1
12
|
## [0.2.0] — 2026-08-10
|
|
2
13
|
|
|
3
14
|
### Added
|
|
@@ -30,10 +30,10 @@ module Ask
|
|
|
30
30
|
)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
unless Ask::Ruby::Harness.
|
|
33
|
+
unless Ask::Ruby::Harness.database_configured?
|
|
34
34
|
Ask::Ruby::Harness.connect_database!
|
|
35
35
|
end
|
|
36
|
-
unless Ask::Ruby::Harness.
|
|
36
|
+
unless Ask::Ruby::Harness.database_configured?
|
|
37
37
|
return Ask::Result.failure(
|
|
38
38
|
"Database not connected. Set ASK_DATABASE_URL or provide a config/database.yml."
|
|
39
39
|
)
|
data/lib/ask/ruby/harness.rb
CHANGED
|
@@ -72,7 +72,7 @@ module Ask
|
|
|
72
72
|
#
|
|
73
73
|
# Connection sources, in order: ASK_DATABASE_URL, config/database.yml.
|
|
74
74
|
def connect_database!
|
|
75
|
-
return if
|
|
75
|
+
return if database_configured?
|
|
76
76
|
|
|
77
77
|
config = ENV["ASK_DATABASE_URL"] || database_config_from_yaml
|
|
78
78
|
ActiveRecord::Base.establish_connection(config) if config
|
|
@@ -80,8 +80,17 @@ module Ask
|
|
|
80
80
|
warn "[ask-ruby-harness] database connect failed: #{e.message}"
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
# Whether a connection spec is defined. Uses the pool presence, not
|
|
84
|
+
# `connected?` — ActiveRecord's connected? stays false until a
|
|
85
|
+
# connection is actually checked out, while pool.with_connection
|
|
86
|
+
# establishes lazily on first use.
|
|
87
|
+
def database_configured?
|
|
88
|
+
defined?(ActiveRecord::Base) &&
|
|
89
|
+
ActiveRecord::Base.connection_handler.retrieve_connection_pool(
|
|
90
|
+
ActiveRecord::Base.connection_specification_name
|
|
91
|
+
)
|
|
92
|
+
rescue StandardError
|
|
93
|
+
false
|
|
85
94
|
end
|
|
86
95
|
|
|
87
96
|
private
|
|
@@ -178,7 +187,14 @@ module Ask
|
|
|
178
187
|
section = section["primary"] if section.is_a?(Hash) && section["primary"].is_a?(Hash)
|
|
179
188
|
return nil unless section.is_a?(Hash)
|
|
180
189
|
|
|
181
|
-
section.slice(*Configuration::DATABASE_CONFIG_KEYS)
|
|
190
|
+
config = section.slice(*Configuration::DATABASE_CONFIG_KEYS)
|
|
191
|
+
# Resolve relative sqlite paths against app_root, like Rails does —
|
|
192
|
+
# the harness may run with a different cwd than the project root.
|
|
193
|
+
if config["adapter"].to_s.include?("sqlite") &&
|
|
194
|
+
config["database"] && !config["database"].start_with?("/", ":")
|
|
195
|
+
config["database"] = app_root.join(config["database"]).to_s
|
|
196
|
+
end
|
|
197
|
+
config.presence
|
|
182
198
|
rescue Psych::Exception
|
|
183
199
|
nil
|
|
184
200
|
end
|