tina4ruby 3.11.10 → 3.11.12

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: b34971f90bd1f889e9f8449670704a31f49d09e5e2707e9ba3238d532b4de190
4
- data.tar.gz: b9a55d76f87b11e1dc38ea54f145ef0f5bc2b63e73783a9009d86987e3680e91
3
+ metadata.gz: 1ffc1ea931cf8203378e774e1efb4b3dbec399dd4309757200f8cd7967732b8b
4
+ data.tar.gz: 5141bdc93061f5eafa53e40098732d5342f645a69cd6978f3380bd7e2c3f1606
5
5
  SHA512:
6
- metadata.gz: ae188f9e3379dd807fdd21d20703ad13741cff59f7da1825b251c4cc292bfa80c330cf1b52e983841c969a9368244e265e8d50f08ede36a00e09776f49fbf4b0
7
- data.tar.gz: 44562a4fd4ac7c065b93cb6bbbdc3ea9b1581f772c64a326daf0a4997ff80249a947afc6bc4c151b0e8e0fbfbae9015b02535c9ad5901dffb7ae60efcb47e166
6
+ metadata.gz: 10b0c0e20c2389c088b494a6db800b3ea95aae3317d826491ebc4f610d6dd11e6ce13d3cc79eba23e4bde0adba2ff9fe76a4d9bbe91b10bdb47ead3ac333933a
7
+ data.tar.gz: a748a5ce83aa37858b99a7a1ed204385ce09f2c43886fe6742dffe2332fb5ffba56849f0f3c81e046b31d6bed17f7d1a4d5f1ba7c61365398c0863dce0c6cf7f
@@ -14,7 +14,7 @@ module Tina4
14
14
 
15
15
  def connect(connection_string)
16
16
  require "sqlite3"
17
- @db_path = connection_string.to_s.sub(/^sqlite3?:\/\//, "").sub(/^sqlite3?:/, "")
17
+ @db_path = self.class.resolve_path(connection_string)
18
18
  @connection = SQLite3::Database.new(@db_path)
19
19
  @connection.results_as_hash = true
20
20
  @connection.execute("PRAGMA journal_mode=WAL")
@@ -22,6 +22,32 @@ module Tina4
22
22
  self
23
23
  end
24
24
 
25
+ # Resolve a SQLite URL / path against the project root (cwd).
26
+ # Convention matches Tina4::Drivers::SqliteDriver.resolve_path —
27
+ # three slashes = relative, four = absolute, drive letter = Windows abs.
28
+ def self.resolve_path(connection_string)
29
+ return ":memory:" if connection_string == "sqlite::memory:" || connection_string == "sqlite:///:memory:"
30
+
31
+ raw = connection_string.to_s
32
+ .sub(/^sqlite3?:\/\/\//, "")
33
+ .sub(/^sqlite3?:\/\//, "")
34
+ .sub(/^sqlite3?:/, "")
35
+ return ":memory:" if raw == ":memory:"
36
+
37
+ is_windows_abs = raw.match?(/^[A-Za-z]:[\/\\]/)
38
+ is_unix_abs = raw.start_with?("/")
39
+
40
+ if is_windows_abs || is_unix_abs
41
+ raw
42
+ else
43
+ resolved = File.join(Dir.pwd, raw)
44
+ parent = File.dirname(resolved)
45
+ require "fileutils"
46
+ FileUtils.mkdir_p(parent) unless File.directory?(parent)
47
+ resolved
48
+ end
49
+ end
50
+
25
51
  def close
26
52
  @connection.close if @connection
27
53
  @connection = nil
@@ -7,10 +7,7 @@ module Tina4
7
7
 
8
8
  def connect(connection_string, username: nil, password: nil)
9
9
  require "sqlite3"
10
- db_path = connection_string.sub(/^sqlite:\/\//, "").sub(/^sqlite:/, "")
11
- # Windows: sqlite:///C:/Users/app.db → /C:/Users/app.db after stripping scheme.
12
- # The leading / before the drive letter must be removed.
13
- db_path = db_path[1..] if db_path.match?(/^\/[A-Za-z]:/)
10
+ db_path = self.class.resolve_path(connection_string)
14
11
 
15
12
  @connection = SQLite3::Database.new(db_path)
16
13
  @connection.results_as_hash = true
@@ -18,6 +15,42 @@ module Tina4
18
15
  @connection.execute("PRAGMA foreign_keys=ON")
19
16
  end
20
17
 
18
+ # Resolve a SQLite URL / path against the project root (cwd).
19
+ #
20
+ # Convention (matches tina4-python, tina4-php, tina4-nodejs):
21
+ # sqlite::memory: → :memory:
22
+ # sqlite:///:memory: → :memory:
23
+ # sqlite:///app.db → {cwd}/app.db (relative)
24
+ # sqlite:///data/app.db → {cwd}/data/app.db (relative; auto-mkdir under cwd)
25
+ # sqlite:////var/data/app.db → /var/data/app.db (absolute; no auto-mkdir)
26
+ # sqlite:///C:/Users/app.db → C:/Users/app.db (Windows absolute)
27
+ #
28
+ # Never mkdir outside cwd — that was the root cause of the
29
+ # "Read-only file system: '/data'" crash on macOS.
30
+ def self.resolve_path(connection_string)
31
+ return ":memory:" if connection_string == "sqlite::memory:" || connection_string == "sqlite:///:memory:"
32
+
33
+ # Strip the scheme + up to three slashes, preserving a potential fourth
34
+ # slash (absolute) or drive letter.
35
+ raw = connection_string.sub(/^sqlite:\/\/\//, "").sub(/^sqlite:\/\//, "").sub(/^sqlite:/, "")
36
+ return ":memory:" if raw == ":memory:"
37
+
38
+ is_windows_abs = raw.match?(/^[A-Za-z]:[\/\\]/)
39
+ is_unix_abs = raw.start_with?("/")
40
+
41
+ if is_windows_abs || is_unix_abs
42
+ # Absolute — trust the user; don't auto-mkdir outside cwd.
43
+ raw
44
+ else
45
+ # Relative — resolve under cwd; auto-mkdir parent dir.
46
+ resolved = File.join(Dir.pwd, raw)
47
+ parent = File.dirname(resolved)
48
+ require "fileutils"
49
+ FileUtils.mkdir_p(parent) unless File.directory?(parent)
50
+ resolved
51
+ end
52
+ end
53
+
21
54
  def close
22
55
  @connection&.close
23
56
  end
data/lib/tina4/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tina4
4
- VERSION = "3.11.10"
4
+ VERSION = "3.11.12"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tina4ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.10
4
+ version: 3.11.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tina4 Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-04-15 00:00:00.000000000 Z
11
+ date: 2026-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack