prick 0.39.6 → 0.39.8

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: 75169887ecaae27780bfc25f2aeb21c4f83362c698f855033eacfb02768b1fbd
4
- data.tar.gz: 23fa69d844aab5f9c1d9198d9ca5c016d96729e5fd6ad884438364b653384e10
3
+ metadata.gz: d0d60cf8855c1cd7dcc4b0183a4dffbd308157cd7e15601ed5976a336ce8ceff
4
+ data.tar.gz: 62e2c45a335d45430f27c33a2a078ea45555dc41b722635ee33ce3a598b409d3
5
5
  SHA512:
6
- metadata.gz: da581962a6423ee34d43cc879c718350d1b02bc963efba126037d98f598664f9570c1bff8dccd38372c0e0b162bf3bb8a0e6fe7cd2e1a2fbe32d955a4a6a1695
7
- data.tar.gz: 3c135facadbffa2c1c4b8a5f348d4b78584d01657d6c543d5c5453a3fc4f6b4cfc6f29de259df279ec4c4b16bf4f84681db055fdb13b63339d17e5460871e491
6
+ metadata.gz: cc493ec4c4f87ac990c545da92be73817669fe71418fd3aa20c1604369a4860d7c03218a727546172b5f6f67761b338f1f1db1c5f1f08d351fda5ebdb88f59fb
7
+ data.tar.gz: 767d9ea5b0911f70603b4414fee3d29e259a5489c18a7d8edb6d1699d2915d3a7b096dcae7a0882e8d547e0ad6a3e5c73d560628b109214b71fe010cb792281f
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Fmt
3
3
  # Print table
4
- def self.puts_table(headers, table)
4
+ def self.puts_table(headers, table, bold: nil)
5
5
  widths = headers.map(&:size)
6
6
  signs = []
7
7
  types = []
@@ -58,8 +58,10 @@ module Fmt
58
58
  }
59
59
  puts
60
60
 
61
- for row in table
61
+ table.each.with_index { |row, rownum|
62
62
  # for index, sign, width, type, value in signs.zip(indexes, signs, widths, types, row) # FIXME doesn't work?
63
+ print "\033[1m" if rownum == bold
64
+
63
65
  for i in (0...headers.size)
64
66
  index, sign, width, type, value = indexes[i], signs[i], widths[i], types[i], row[i]
65
67
 
@@ -92,8 +94,8 @@ module Fmt
92
94
  printf "%#{sign}#{width}#{type} ", "#{value}"
93
95
  end
94
96
  end
95
- puts
96
- end
97
+ puts (rownum == bold ? "\033[0m" : "")
98
+ }
97
99
  end
98
100
  end
99
101
 
data/lib/prick/state.rb CHANGED
@@ -357,12 +357,12 @@ module Prick
357
357
 
358
358
  def insert_record(table, attrs = {})
359
359
  sql_fields = attrs.keys.join(", ")
360
- sql_values = attrs.values.map { conn.quote_literal(_1) }.join(", ")
360
+ sql_values = attrs.values.map { conn.quote_value(_1) }.join(", ")
361
361
  conn.value "insert into #{table} (#{sql_fields}) values (#{sql_values}) returning id"
362
362
  end
363
363
 
364
364
  def update_record(table, id, attrs = {})
365
- sql_assign = attrs.map { |k,v| "#{conn.quote_identifier(k)} = #{conn.quote_literal(v)}" }.join(", ")
365
+ sql_assign = attrs.map { |k,v| "#{conn.quote_identifier(k)} = #{conn.quote_value(v)}" }.join(", ")
366
366
  sql_id_cond = (id.nil? ? "true" : "id = #{id}")
367
367
  conn.exec "update #{table} set #{sql_assign} where #{sql_id_cond}"
368
368
  end
@@ -50,8 +50,8 @@ module Prick::SubCommand
50
50
  pool = builder.pool
51
51
  schemas = pool.refresh_schemas
52
52
  end
53
- schema_list = conn.quote_literal_list(schemas)
54
- schema_expr = schemas ? "true = true" : "schema_name in #{schema_list}"
53
+ schema_list = conn.quote_values(schemas)
54
+ schema_expr = schemas ? "true = true" : "schema_name in (#{schema_list})"
55
55
  tables = conn.tuples %(
56
56
  select schema_name, table_name, max_id
57
57
  from prick.snapshots
@@ -50,6 +50,7 @@ module Prick::SubCommand
50
50
  git_rev = Git.id[0...8]
51
51
 
52
52
  rows = []
53
+ current_database_row = nil
53
54
  Prick.databases { |database, conn|
54
55
  row = conn.record(%(
55
56
  select
@@ -58,6 +59,12 @@ module Prick::SubCommand
58
59
  from prick.versions
59
60
  ))
60
61
 
62
+ # Detect is this is the current database
63
+ if Prick.state.database == database
64
+ is_current_database = true
65
+ current_database_row = rows.size
66
+ end
67
+
61
68
  if row[:success]
62
69
  clean = row[:clean]
63
70
  same_revision = row[:branch] == git_branch && row[:rev] == git_rev
@@ -84,12 +91,13 @@ module Prick::SubCommand
84
91
  row[:built_at] = row[:built_at]&.strftime("%Y-%m-%d %H:%M")
85
92
 
86
93
  # Add current database marker
87
- last_column = (Prick.state.database == database ? "*" : "")
94
+ last_column = (is_current_database ? "*" : "")
95
+
88
96
  rows << row.values + [last_column]
89
97
  }
90
98
 
91
99
  headers = %w(database project version branch rev clean environment built success state) + [" "]
92
- Fmt.puts_table(headers, rows)
100
+ Fmt.puts_table(headers, rows, bold: current_database_row)
93
101
  end
94
102
  end
95
103
 
data/lib/prick/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prick
4
- VERSION = "0.39.6"
4
+ VERSION = "0.39.8"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.39.6
4
+ version: 0.39.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-19 00:00:00.000000000 Z
11
+ date: 2024-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semantic