pg_conn 0.31.0 → 0.32.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 122b4fc4ba631ecac00021695532624fd13a578183812a98617a9f05b5a9104f
4
- data.tar.gz: 02e3a823f17d4c6012a51186a2da124b0dfacf5ece0e4f8f5a6a6c31d97675d1
3
+ metadata.gz: e4afbef1cc74d235f8434c2c92a6537ec24b37cd36e85bb9f07eb6153e6c7938
4
+ data.tar.gz: cd5af7434cb01ae1f873a7cb18a4cc350e425976c695b93252f2e36cefca2273
5
5
  SHA512:
6
- metadata.gz: c2c84bb43ba856724e246d4fe264e739abe01d8abee3e8f39678893e671124b31a9e57748fe4347b5f3b1192e547c5bd76e8f84558f8a5035a12604e2635c0dd
7
- data.tar.gz: dae9131834552ad7a23c16e36ead22ba1ef6b9f0e16e5747ab7cb9c29341120dddbd3cc2dd25969375898659ec3a93924f80c554afe382a659e9bf04ebab4208
6
+ metadata.gz: c94d25247ae2167f022a704bdf5b03691f87691dfe88c5187a5cbf2fb117c5ac252c3f649b5b0a20578cfe325b08cfff7f09e41da1d8f6c0bbf81c11cab501bf
7
+ data.tar.gz: 689be40d28cb3a7ea0c84ab0109b7dc7749b16c47a8240b694ae746ff8602ebed6e5fa4394dc628d1df699a6c7c091db7f345c1ffb81cfc93e81e98d48c60ea0
@@ -1,3 +1,3 @@
1
1
  module PgConn
2
- VERSION = "0.31.0"
2
+ VERSION = "0.32.0"
3
3
  end
data/lib/pg_conn.rb CHANGED
@@ -958,6 +958,40 @@ module PgConn
958
958
  end
959
959
  end
960
960
 
961
+ def dump(*query)
962
+ records = self.records(*query)
963
+
964
+ if records.empty?
965
+ puts "No records found"
966
+ else
967
+ headers = records.first.keys
968
+ column_widths = headers.map(&:size)
969
+ column_signs = [nil] * headers.size
970
+
971
+ records.each { |r|
972
+ r.values.each.with_index { |v, i|
973
+ value_width = v.to_s.size
974
+ column_widths[i] = [column_widths[i], value_width].max
975
+
976
+ column_signs[i] ||=
977
+ case v
978
+ when nil; nil
979
+ when Integer; ""
980
+ else
981
+ "-"
982
+ end
983
+ }
984
+ }
985
+
986
+ header_format = column_widths.map { |w,t| "%-#{w}s" }.join(" ")
987
+ body_format = column_widths.zip(column_signs).map { |w,s| "%#{s}#{w}s" }.join(" ")
988
+
989
+ printf "#{header_format}\n", *headers
990
+ printf "#{header_format}\n", *column_widths.map { |w| "-" * w }
991
+ records.each { |r| printf "#{body_format}\n", *r.values }
992
+ end
993
+ end
994
+
961
995
  private
962
996
  # Wrapper around PG::Connection.new that switches to the postgres user
963
997
  # before connecting if the current user is the root user
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_conn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.31.0
4
+ version: 0.32.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-14 00:00:00.000000000 Z
11
+ date: 2025-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg