simple-sql 0.5.19 → 0.5.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pg/deprecated_constants.rb +1 -1
- data/lib/simple/sql.rb +6 -0
- data/lib/simple/sql/connection.rb +0 -2
- data/lib/simple/sql/connection/base.rb +1 -1
- data/lib/simple/sql/helpers.rb +0 -1
- data/lib/simple/sql/{helpers/printer.rb → table_print.rb} +6 -2
- data/lib/simple/sql/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35d1b619f4df0cf9527247e4148c10c035bc6ce3fc3d8302d9d59f68aba13efe
|
4
|
+
data.tar.gz: 945a6e98dc8057b9bbf222a149f6cda25105144d0e9815965c05e6b35423627a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a132b274a9ab9c10bebba9948d9611d9eba759ba3e492e40b94da391e136970039e3e88b495073e8da358d029c492a75b42128a8921894acd523362719b6d2d
|
7
|
+
data.tar.gz: 938f7f09cd06b1f743434edd3f257b30142fc82b067badef3e7e79aea92da430e0074cb41df9364eb49c13c3d8e32fcbd87932ee4e621c0159bd969a1a74c772
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# pg 0.21 requires a file "pg/deprecated_constants" to warn about constant
|
2
2
|
# deprecations of PGconn, PGresult, and PGError. Since this is the latest
|
3
|
-
# version supported by Rails 4.2 Since this is also the latest version
|
3
|
+
# version supported by Rails 4.2 Since this is also the latest version
|
4
4
|
# supported by ActiveRecord 4.2.* this means that with such a old version
|
5
5
|
# you would be stuck with this rather senseless warning.
|
6
6
|
|
data/lib/simple/sql.rb
CHANGED
@@ -11,6 +11,7 @@ require_relative "sql/result"
|
|
11
11
|
require_relative "sql/config"
|
12
12
|
require_relative "sql/logging"
|
13
13
|
require_relative "sql/connection"
|
14
|
+
require_relative "sql/table_print"
|
14
15
|
|
15
16
|
module Simple
|
16
17
|
# The Simple::SQL module
|
@@ -34,6 +35,11 @@ module Simple
|
|
34
35
|
"'#{PG::Connection.escape_string(s)}'"
|
35
36
|
end
|
36
37
|
|
38
|
+
def table_print(records, io: STDOUT, width: :auto)
|
39
|
+
::Simple::SQL::TablePrint.table_print(records, width: width, io: io)
|
40
|
+
records
|
41
|
+
end
|
42
|
+
|
37
43
|
# connects to the database specified via the url parameter. If called
|
38
44
|
# without argument it tries to determine a DATABASE_URL from either the
|
39
45
|
# environment setting (DATABASE_URL) or from a config/database.yml file,
|
data/lib/simple/sql/helpers.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
2
2
|
|
3
3
|
# private
|
4
|
-
module Simple::SQL::
|
4
|
+
module Simple::SQL::TablePrint
|
5
5
|
extend self
|
6
6
|
|
7
7
|
ROW_SEPARATOR = " | "
|
8
8
|
|
9
|
-
def
|
9
|
+
def table_print(records, io: STDOUT, width: :auto)
|
10
10
|
# check args
|
11
11
|
|
12
12
|
return if records.empty?
|
@@ -23,6 +23,7 @@ module Simple::SQL::Helpers::Printer
|
|
23
23
|
|
24
24
|
rows = materialize_rows(records)
|
25
25
|
column_widths = column_max_lengths(rows)
|
26
|
+
|
26
27
|
if width
|
27
28
|
column_widths = distribute_column_widths(column_widths, width, column_count, rows.first)
|
28
29
|
end
|
@@ -68,6 +69,9 @@ module Simple::SQL::Helpers::Printer
|
|
68
69
|
|
69
70
|
return column_widths if available_chars <= 0
|
70
71
|
|
72
|
+
required_chars = column_widths.sum
|
73
|
+
return column_widths if required_chars < total_chars
|
74
|
+
|
71
75
|
# [TODO] The algorithm below produces ok-ish results - but usually misses a few characters
|
72
76
|
# that could still be assigned a column. To do this we shuld emply D'Hondt or something
|
73
77
|
# similar.
|
data/lib/simple/sql/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-sql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- radiospiel
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-07-
|
12
|
+
date: 2019-07-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pg_array_parser
|
@@ -210,13 +210,13 @@ files:
|
|
210
210
|
- lib/simple/sql/helpers/decoder.rb
|
211
211
|
- lib/simple/sql/helpers/encoder.rb
|
212
212
|
- lib/simple/sql/helpers/immutable.rb
|
213
|
-
- lib/simple/sql/helpers/printer.rb
|
214
213
|
- lib/simple/sql/helpers/row_converter.rb
|
215
214
|
- lib/simple/sql/logging.rb
|
216
215
|
- lib/simple/sql/result.rb
|
217
216
|
- lib/simple/sql/result/association_loader.rb
|
218
217
|
- lib/simple/sql/result/records.rb
|
219
218
|
- lib/simple/sql/scope/count.rb
|
219
|
+
- lib/simple/sql/table_print.rb
|
220
220
|
- lib/simple/sql/version.rb
|
221
221
|
- log/.gitkeep
|
222
222
|
- scripts/stats
|
@@ -269,7 +269,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
269
269
|
- !ruby/object:Gem::Version
|
270
270
|
version: '0'
|
271
271
|
requirements: []
|
272
|
-
rubygems_version: 3.0.
|
272
|
+
rubygems_version: 3.0.2
|
273
273
|
signing_key:
|
274
274
|
specification_version: 4
|
275
275
|
summary: SQL with a simple interface
|