blackstack-db 1.0.1 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0071d134f56134425dfa5667077f9ca8ee1d57fc4c23783be3ad6fb05afca2a9
4
- data.tar.gz: 694fe13b831760553ad8736a120d56615650f437f4fa3987711bb5534d1783b2
3
+ metadata.gz: d09e6d2f5af17a813d5c536f864de997551a9194448902d6c461f4c534b89cea
4
+ data.tar.gz: 5516cc43d2b141c373f80fcd1140fd32771edb7ddc2592698ed70719bede0ff1
5
5
  SHA512:
6
- metadata.gz: adc65af017b86399f60d1015f474fdf18565fffa4ee25c420bc1ac51f9257cbca87407dca6e7b436faf706e4f2828b1445a90ef9e76c32ba4b2454f439107c31
7
- data.tar.gz: 9c16d76967f2eb07a74e32c12fc984e925e844e934ca3079ef8d52a6f5f8b8adc38a331466e51ec098500683b174879dd3c8a476024f8c3245141d59117ab82f
6
+ metadata.gz: 2834217481c0801578b04fe9d0b85517cbb4e38f1a8a148ab7e91650700a0b9d6fb4de9ce4b4de73c308b6c0288fe03903b1b7011c174d38152f8f05283d59af
7
+ data.tar.gz: b55847daa76635ac4df18db153343a286b4dd8ad9858986c70479a01442beeff46cb4f4ba829ea1300fa189a93c0c87b2daaee007538fcff629283d14e48663a
@@ -115,7 +115,7 @@ module BlackStack
115
115
  tz = 'America/Argentina/Buenos_Aires' #DB["SELECT current_setting('TIMEZONE') AS tz"].first[:tz]
116
116
  DB["SELECT current_timestamp() at TIME ZONE '#{tz}' AS now"].first[:now]
117
117
  end
118
- =begin
118
+
119
119
  # test the connection to the database.
120
120
  # raise an exception if the connection fails, or if any incongruence is found.
121
121
  def self.test(l=nil)
@@ -128,11 +128,11 @@ module BlackStack
128
128
  l.logs "Testing connection... "
129
129
  begin
130
130
  @db = BlackStack::Deployer::DB::connect(
131
- BlackStack::TYPE_CRDB::connection_string # use the connection parameters setting in ./config.rb
131
+ BlackStack::CRDB::connection_string # use the connection parameters setting in ./config.rb
132
132
  )
133
- l.logf "success"
133
+ l.logf "success".green
134
134
  rescue => e
135
- l.logf "failed"
135
+ l.logf "failed".red
136
136
  l.log e.message
137
137
  end
138
138
 
@@ -140,14 +140,13 @@ module BlackStack
140
140
  # This validation checks the connection to the correct database.
141
141
  begin
142
142
  l.logs "Verify database name... "
143
- s = @db["SHOW DATABASES"].first.to_s
144
- raise 'Wrong database name' if s !~ /:database_name=>\"#{Regexp.escape(BlackStack::TYPE_CRDB::db_name)}\"/i
145
- l.logf "success"
143
+ s = @db["SHOW DATABASES"].all.map { |x| x[:database_name] }.join("\n")
144
+ raise 'Wrong database name'.red if s !~ /#{Regexp.escape(BlackStack::CRDB::db_name)}/i
145
+ l.logf "success".green
146
146
  rescue => e
147
- l.logf "failed"
147
+ l.logf "failed".red
148
148
  l.log e.message
149
149
  end
150
- end
151
- =end
150
+ end # test
152
151
  end # module CRDB
153
152
  end # module BlackStack
@@ -97,7 +97,7 @@ module BlackStack
97
97
  tz = 'America/Argentina/Buenos_Aires' #DB["SELECT current_setting('TIMEZONE') AS tz"].first[:tz]
98
98
  DB["SELECT (current_timestamp - interval '#{n} seconds') at TIME ZONE '#{tz}' AS now"].first[:now]
99
99
  end
100
- =begin
100
+
101
101
  # test the connection to the database.
102
102
  # raise an exception if the connection fails, or if any incongruence is found.
103
103
  def self.test(l=nil)
@@ -112,9 +112,9 @@ module BlackStack
112
112
  @db = BlackStack::Deployer::DB::connect(
113
113
  BlackStack::PostgreSQL::connection_string # use the connection parameters setting in ./config.rb
114
114
  )
115
- l.logf "success"
115
+ l.logf "success".green
116
116
  rescue => e
117
- l.logf "failed"
117
+ l.logf "failed".red
118
118
  l.log e.message
119
119
  end
120
120
 
@@ -122,14 +122,14 @@ module BlackStack
122
122
  # This validation checks the connection to the correct database.
123
123
  begin
124
124
  l.logs "Verify database name... "
125
- s = @db["SHOW DATABASES"].first.to_s
125
+ s = @db["SELECT datname FROM pg_database"].first.to_s
126
126
  raise 'Wrong database name' if s !~ /:database_name=>\"#{Regexp.escape(BlackStack::PostgreSQL::db_name)}\"/i
127
- l.logf "success"
127
+ l.logf "success".green
128
128
  rescue => e
129
- l.logf "failed"
129
+ l.logf "failed".red
130
130
  l.log e.message
131
131
  end
132
132
  end
133
- =end
133
+
134
134
  end # module PostgreSQL
135
135
  end
data/lib/blackstack-db.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'colorize'
2
+ require 'simple_cloud_logging'
1
3
  require 'sequel'
2
4
  require_relative './blackstack-db/postgresql.rb'
3
5
  require_relative './blackstack-db/crdb.rb'
metadata CHANGED
@@ -1,15 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blackstack-db
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.5
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: 2023-10-06 00:00:00.000000000 Z
11
+ date: 2023-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colorize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.8.1
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.8.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 0.8.1
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.8.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: simple_cloud_logging
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 1.2.2
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 1.2.2
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: 1.2.2
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 1.2.2
13
53
  - !ruby/object:Gem::Dependency
14
54
  name: sequel
15
55
  requirement: !ruby/object:Gem::Requirement