tina4ruby 3.12.1 → 3.12.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/lib/tina4/drivers/firebird_driver.rb +77 -2
- data/lib/tina4/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a97e5249b5ffd22de2dac45ce08f27e217c9c1253192d41b036b0ef90e14dc11
|
|
4
|
+
data.tar.gz: d2a67f3f7a4e11dab682f2333e4aed920ada9ba553737c5c77899ed3b7bf8cd2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: beb243e57f2aa6df523fe64e63c2057a46058d711acda139342ca06144fd207949e24a3a35d25787d1f110bf7bead2cd85178c1cefb0c8158e46be89e7f31004
|
|
7
|
+
data.tar.gz: dd2169f5c8837fe90185e9c81eb5bd6e5fa49819230cf6ec79207f32aa6288a6eaec80236d565d7a0b561d08a95f7c0949456d21abd8ac887425c54ac7fe1997
|
|
@@ -19,20 +19,95 @@ module Tina4
|
|
|
19
19
|
"broken pipe"
|
|
20
20
|
].freeze
|
|
21
21
|
|
|
22
|
+
# Detects a Windows drive-letter prefix like "C:/" or "C:\". The leading-slash
|
|
23
|
+
# variant ("/C:/...") shows up after URI.parse strips one slash off
|
|
24
|
+
# "firebird://host:port/C:/...".
|
|
25
|
+
WIN_DRIVE_RE = %r{\A/?[A-Za-z]:[/\\]}.freeze
|
|
26
|
+
|
|
27
|
+
# Turn the URL path component into a Firebird database identifier.
|
|
28
|
+
#
|
|
29
|
+
# Firebird is the awkward one — it needs either an absolute file path
|
|
30
|
+
# on the server, a Windows drive-letter path, or an alias name. The
|
|
31
|
+
# classic URI form uses a double-slash to keep the leading "/" of an
|
|
32
|
+
# absolute path through URI.parse:
|
|
33
|
+
#
|
|
34
|
+
# firebird://host:port//firebird/data/app.fdb → /firebird/data/app.fdb
|
|
35
|
+
#
|
|
36
|
+
# But that double slash is unintuitive to anyone used to the way
|
|
37
|
+
# postgres / mysql / mssql encode the database name. We accept five
|
|
38
|
+
# equivalent forms and normalise all of them:
|
|
39
|
+
#
|
|
40
|
+
# * "//abs/path/db.fdb" → "/abs/path/db.fdb" (classic double-slash)
|
|
41
|
+
# * "/abs/path/db.fdb" → "/abs/path/db.fdb" (single-slash, what most people type)
|
|
42
|
+
# * "/C:/Data/db.fdb" → "C:/Data/db.fdb" (Windows, leading URL slash dropped)
|
|
43
|
+
# * "/C%3A/Data/db.fdb" → "C:/Data/db.fdb" (Windows with URL-encoded colon)
|
|
44
|
+
# * "/employee" → "employee" (alias — single token)
|
|
45
|
+
#
|
|
46
|
+
# Aliases are detected as the leftover case: a single token with no
|
|
47
|
+
# slashes. Anything path-like is kept as a path.
|
|
48
|
+
def self.normalize_db_identifier(raw_path)
|
|
49
|
+
require "uri"
|
|
50
|
+
return "" if raw_path.nil? || raw_path.empty?
|
|
51
|
+
|
|
52
|
+
decoded = URI.decode_www_form_component(raw_path)
|
|
53
|
+
|
|
54
|
+
# Classic double-slash form: //abs/path → /abs/path
|
|
55
|
+
decoded = decoded[1..] if decoded.start_with?("//")
|
|
56
|
+
|
|
57
|
+
# Windows drive-letter — drop the URL-introduced leading slash.
|
|
58
|
+
# /C:/Data/db.fdb → C:/Data/db.fdb
|
|
59
|
+
if WIN_DRIVE_RE.match?(decoded)
|
|
60
|
+
decoded = decoded[1..] if decoded.start_with?("/")
|
|
61
|
+
return decoded
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Look at the content after stripping the leading slash. If it's a
|
|
65
|
+
# single token with no separators, it's a Firebird alias — return
|
|
66
|
+
# WITHOUT the leading slash (the alias name itself is the identifier).
|
|
67
|
+
body = decoded.start_with?("/") ? decoded[1..] : decoded
|
|
68
|
+
if !body.empty? && !body.include?("/") && !body.include?("\\")
|
|
69
|
+
return body
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Otherwise it's a file path. If it already has a leading slash,
|
|
73
|
+
# keep it. If it's a relative-looking path (slash-separated but no
|
|
74
|
+
# leading "/") promote it to absolute — Firebird needs absolute paths
|
|
75
|
+
# and we don't know the server's CWD anyway.
|
|
76
|
+
decoded.start_with?("/") ? decoded : "/#{decoded}"
|
|
77
|
+
end
|
|
78
|
+
|
|
22
79
|
def connect(connection_string, username: nil, password: nil)
|
|
23
80
|
require "fb"
|
|
24
81
|
require "uri"
|
|
25
82
|
uri = URI.parse(connection_string)
|
|
26
83
|
host = uri.host
|
|
27
84
|
port = uri.port || 3050
|
|
28
|
-
db_path = uri.path&.sub(/^\//, "")
|
|
29
85
|
db_user = username || uri.user
|
|
30
86
|
db_pass = password || uri.password
|
|
31
87
|
|
|
88
|
+
# Firebird database identifier resolution — two layers:
|
|
89
|
+
#
|
|
90
|
+
# 1. TINA4_DATABASE_FIREBIRD_PATH env override wins if set.
|
|
91
|
+
# Useful for Windows users with raw backslash paths (no URL
|
|
92
|
+
# encoding required) and for ops setups that keep server URL
|
|
93
|
+
# and DB location in separate config layers.
|
|
94
|
+
# 2. Otherwise normalise the URL path component — accepts every
|
|
95
|
+
# sensible variant (single/double slash, drive letter, alias).
|
|
96
|
+
env_override = ENV["TINA4_DATABASE_FIREBIRD_PATH"].to_s
|
|
97
|
+
db_path = if !env_override.empty?
|
|
98
|
+
env_override
|
|
99
|
+
else
|
|
100
|
+
self.class.normalize_db_identifier(uri.path.to_s)
|
|
101
|
+
end
|
|
102
|
+
|
|
32
103
|
database = if host
|
|
33
104
|
"#{host}/#{port}:#{db_path}"
|
|
34
105
|
else
|
|
35
|
-
|
|
106
|
+
# No host → fall back to the raw identifier (or, for
|
|
107
|
+
# totally non-URL inputs, strip the scheme prefix).
|
|
108
|
+
return_path = db_path
|
|
109
|
+
return_path = connection_string.sub(/^firebird:\/\//, "") if return_path.empty?
|
|
110
|
+
return_path
|
|
36
111
|
end
|
|
37
112
|
|
|
38
113
|
# Cache for transparent reconnect — never logged, lives only in
|
data/lib/tina4/version.rb
CHANGED
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.12.
|
|
4
|
+
version: 3.12.2
|
|
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-05-
|
|
11
|
+
date: 2026-05-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rack
|