blackstack-db 1.0.4 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/blackstack-db/crdb.rb +6 -4
- data/lib/blackstack-db/postgresql.rb +3 -0
- data/lib/blackstack-db.rb +11 -0
- 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: 25578f16a2bc64d70e9070f80d4db0670defdf81d6676c04692f6037a3c0f45a
|
4
|
+
data.tar.gz: 98ec2ee0b7e35cddb34785b45d1d08dde7ced218ee3ebb1088ad53ed2473cca7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94048636735c829dddb4c80875f069b4f356c6a1752d3ad1e487f9f8bf3efe3dfb6c43516ed1ca07439a93ffa984bca9d06ffedb256574e0772facbaf7134f28
|
7
|
+
data.tar.gz: 051eb7d1f310bce9fb52f44ed9e25f0e308cd762ed7daa60eb4af1edb1485a6c422cc6c62b5ad3e3ce6fba9436d4eaaca854b0f23e05ec181230b19f087b5b9a
|
data/lib/blackstack-db/crdb.rb
CHANGED
@@ -93,6 +93,9 @@ module BlackStack
|
|
93
93
|
# validate: the :db_password key must be a string
|
94
94
|
raise 'The key :db_password must be a string' unless h[:db_password].is_a?(String)
|
95
95
|
|
96
|
+
# set type
|
97
|
+
BlackStack::set_db_type(BlackStack::TYPE_CRDB)
|
98
|
+
|
96
99
|
# map values
|
97
100
|
@@db_url = h[:db_url]
|
98
101
|
@@db_port = h[:db_port].to_i
|
@@ -140,14 +143,13 @@ module BlackStack
|
|
140
143
|
# This validation checks the connection to the correct database.
|
141
144
|
begin
|
142
145
|
l.logs "Verify database name... "
|
143
|
-
s = @db["SHOW DATABASES"].
|
144
|
-
raise 'Wrong database name' if s !~
|
146
|
+
s = @db["SHOW DATABASES"].all.map { |x| x[:database_name] }.join("\n")
|
147
|
+
raise 'Wrong database name'.red if s !~ /#{Regexp.escape(BlackStack::CRDB::db_name)}/i
|
145
148
|
l.logf "success".green
|
146
149
|
rescue => e
|
147
150
|
l.logf "failed".red
|
148
151
|
l.log e.message
|
149
152
|
end
|
150
|
-
end
|
151
|
-
|
153
|
+
end # test
|
152
154
|
end # module CRDB
|
153
155
|
end # module BlackStack
|
@@ -66,6 +66,9 @@ module BlackStack
|
|
66
66
|
# validate: the :db_password key must be a string
|
67
67
|
raise 'The key :db_password must be a string' unless h[:db_password].is_a?(String)
|
68
68
|
|
69
|
+
# set type
|
70
|
+
BlackStack::set_db_type(BlackStack::TYPE_POSTGRESQL)
|
71
|
+
|
69
72
|
# map values
|
70
73
|
@@db_url = h[:db_url]
|
71
74
|
@@db_port = h[:db_port].to_i
|
data/lib/blackstack-db.rb
CHANGED
@@ -16,6 +16,17 @@ module BlackStack
|
|
16
16
|
def self.db_type
|
17
17
|
@@db_type
|
18
18
|
end # db_type
|
19
|
+
|
20
|
+
def self.db_connect
|
21
|
+
if @@db_type == TYPE_POSTGRESQL
|
22
|
+
return BlackStack::PostgreSQL.connect
|
23
|
+
elsif @@db_type == TYPE_CRDB
|
24
|
+
return BlackStack::CRDB.connect
|
25
|
+
else
|
26
|
+
raise "Unknown database type"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
19
30
|
end # BlackStack
|
20
31
|
|
21
32
|
# return a postgresql uuid
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blackstack-db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Daniel Sardi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|