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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb7b07e97747d9737683a53429df81442e810b0ff9825724a02e64c49bb49c0b
4
- data.tar.gz: 27b471f9c55911b41636bd3e81d0ea68fc4d168322fffdfaea387211fc58c13d
3
+ metadata.gz: 411e139b4a5cfe5e017a748753c36a1f811a45f719e2245c7789267d4fe9f476
4
+ data.tar.gz: bd78de0520de347c8ffb675c7c704187c98fc7971b3b4a30770c227479adf7f3
5
5
  SHA512:
6
- metadata.gz: 943ae9fcc4698ff7a6c79feba5d93f30b31975417c6355a38394e146308545ecef270ad70a0675addd2929361c8043fbe8bc6f24b6e439f416fa689e4b5b0861
7
- data.tar.gz: ae876247273fa9e6936d0f817ac42f6b57c250abdc4fd7671403a7c289f9da0b03d20b7fb48b6685d7f168db854017a5790f2130430e20f6240b22ae79d477ff
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.database_connected?
33
+ unless Ask::Ruby::Harness.database_configured?
34
34
  Ask::Ruby::Harness.connect_database!
35
35
  end
36
- unless Ask::Ruby::Harness.database_connected?
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
  )
@@ -3,7 +3,7 @@
3
3
  module Ask
4
4
  module Ruby
5
5
  module Harness
6
- VERSION = "0.2.0"
6
+ VERSION = "0.2.1"
7
7
  end
8
8
  end
9
9
  end
@@ -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 database_connected?
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
- def database_connected?
84
- defined?(ActiveRecord::Base) && ActiveRecord::Base.connected?
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).presence
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ask-ruby-harness
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaka Ruto