blackstack-db 1.0.1 → 1.0.4

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: cf0c5cdf7acfb91f583f4b1c2acd296e8575a65fa26baafc5c91845ac1b84341
4
+ data.tar.gz: 26407def1ad08b2c2ac84cf6d50d71e44f4db60acb48a56ef935cdb967055960
5
5
  SHA512:
6
- metadata.gz: adc65af017b86399f60d1015f474fdf18565fffa4ee25c420bc1ac51f9257cbca87407dca6e7b436faf706e4f2828b1445a90ef9e76c32ba4b2454f439107c31
7
- data.tar.gz: 9c16d76967f2eb07a74e32c12fc984e925e844e934ca3079ef8d52a6f5f8b8adc38a331466e51ec098500683b174879dd3c8a476024f8c3245141d59117ab82f
6
+ metadata.gz: 4665dfbbe3ebde9c392ce305ab052e3ab60fc4024fd095782fed2c8bc059b99d6a1022df48de52cf092cc18caed475d0d0a486dbd4471d8a4de5fc2ea383a3ed
7
+ data.tar.gz: da754c75b967522e65839c06376ec56da75eae72b6f7afcef694b456dbf0c466fda401b4d41be549e308bf81c99dd339cdc08182e1b765f6c55cd89b052a23cc
@@ -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
 
@@ -141,13 +141,13 @@ module BlackStack
141
141
  begin
142
142
  l.logs "Verify database name... "
143
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"
144
+ raise 'Wrong database name' if s !~ /:database_name=>\"#{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
150
  end
151
- =end
151
+
152
152
  end # module CRDB
153
153
  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.4
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