gloo-lang 1.2.2 → 1.2.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: f902743811fec6c55772cbf3db6a20dc6d41702334f4089e1c35a05d780ffadc
4
- data.tar.gz: 529e7168fcf0e59d2a90b3bee49c70776763a5019016fa7dec3a77b291360660
3
+ metadata.gz: 58d680f352b7415cdb3136da8cc6144d44cc3bb26dcfd4f9313fe70bcdcc2e9e
4
+ data.tar.gz: 9f3d7d0b2f3766156e02675834fc2449485a1203732f006e27f9946e5d073c75
5
5
  SHA512:
6
- metadata.gz: cee004bc20d2fdfd6dafed5bdbd75f17da5883db081236604c9fc64be63d215adad0fd69c5fce71cf387bca5953774ede38bcb2e5f9fd7a92d9bc02a80510921
7
- data.tar.gz: a874636b58d09345512247e2b9d7caf505720b264715122f4e4ec8b1752571eefebe16aebb29df623da77707b0c054031d5aebe19017d5a44e63871f4123868b
6
+ metadata.gz: d79ec414dff160a370d2ad13fde171f945549a5555111ad538afacecf677a194b17326dbd7b7adb2928e563c6490031d993b7fd80ed22cf8f73fa2c2902ec99a
7
+ data.tar.gz: 60debf4197aab940342ed07ce665c2d7f42a505dab66a36689d95b3f0a793b7114eadbcef34f64bd149770c595c9f95108866d8ed2b603ece61427d13673ede5
data/lib/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.2
1
+ 1.2.4
@@ -83,6 +83,54 @@ module GlooLang
83
83
  process_result result
84
84
  end
85
85
 
86
+ # ---------------------------------------------------------------------
87
+ # Show Results
88
+ # ---------------------------------------------------------------------
89
+
90
+ #
91
+ # The first row will be a header row,
92
+ # so if there are exactly 2 rows, then we have only
93
+ # a single row of data.
94
+ #
95
+ def single_row_result?( data )
96
+ return data.count == 1
97
+ end
98
+
99
+ #
100
+ # Show a single row in a vertical, form style view.
101
+ #
102
+ def show_single_row( heads, data )
103
+ row = data[0]
104
+ heads.each_with_index do |h, i|
105
+ puts "#{h}: \t #{row[i]}"
106
+ end
107
+ end
108
+
109
+ #
110
+ # Show multiple rows in a table view.
111
+ #
112
+ def show_rows( heads, data )
113
+ puts heads.map { |o| o }.join( " \t " ).white
114
+
115
+ data.each do |row|
116
+ # Show the row data
117
+ puts row.map { |v| v }.join( " \t " )
118
+ end
119
+ end
120
+
121
+ #
122
+ # Show multiple rows in a table view.
123
+ #
124
+ def show_rows2( data )
125
+ data.each_with_index do |row, i|
126
+ # Show header for the first row
127
+ puts row.map { |k, _| k }.join( " \t " ).white if i.zero?
128
+
129
+ # Show the row data
130
+ puts row.map { |_, v| v }.join( " \t " )
131
+ end
132
+ end
133
+
86
134
  # ---------------------------------------------------------------------
87
135
  # Private functions
88
136
  # ---------------------------------------------------------------------
@@ -144,15 +192,15 @@ module GlooLang
144
192
  #
145
193
  # Show the result of the query in the console.
146
194
  #
147
- def show_result( data )
148
- return if data.nil?
195
+ def show_result( result )
196
+ return if result.nil?
149
197
 
150
- data.each_with_index do |row, i|
151
- # Show header for the first row
152
- puts row.map { |k, _| k }.join( " \t " ).white if i.zero?
153
-
154
- # Show the row data
155
- puts row.map { |_, v| v }.join( " \t " )
198
+ heads = result[0]
199
+ data = result[1]
200
+ if single_row_result?( data )
201
+ show_single_row( heads, data )
202
+ else
203
+ show_rows( heads, data )
156
204
  end
157
205
  end
158
206
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gloo-lang
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Crane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-24 00:00:00.000000000 Z
11
+ date: 2022-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler