gloo-lang 1.2.4 → 1.2.6

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: 58d680f352b7415cdb3136da8cc6144d44cc3bb26dcfd4f9313fe70bcdcc2e9e
4
- data.tar.gz: 9f3d7d0b2f3766156e02675834fc2449485a1203732f006e27f9946e5d073c75
3
+ metadata.gz: 9335e0a7a17938ea90557c3dfd56ac8362e5d038f8f9cc9a1508c06c94e28a2c
4
+ data.tar.gz: f7c9c2f81fb9a70bd84f5afaba25c82879b4043abf9ffb5e64da70d805a06061
5
5
  SHA512:
6
- metadata.gz: d79ec414dff160a370d2ad13fde171f945549a5555111ad538afacecf677a194b17326dbd7b7adb2928e563c6490031d993b7fd80ed22cf8f73fa2c2902ec99a
7
- data.tar.gz: 60debf4197aab940342ed07ce665c2d7f42a505dab66a36689d95b3f0a793b7114eadbcef34f64bd149770c595c9f95108866d8ed2b603ece61427d13673ede5
6
+ metadata.gz: 97ab8e4b87348a19377d295d78451bf99985f237dbc3c59abfdfef06c5ef8f79461208ae0cd19b828da6b9e8c3733339cc6895cf5558971a9d2a7c92b5633641
7
+ data.tar.gz: 2102270c7e198bc1497baf07a396412b5f015ad9448a5da00b5af1225c6925cec01d127762518e5294cdfa2b4d771e4252f366d0ba052a7821c9dd343b05ff49
data/lib/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.4
1
+ 1.2.6
@@ -120,10 +120,17 @@ module GlooLang
120
120
  # Then quit.
121
121
  #
122
122
  def run_files
123
- @args.files.each { |f| @persist_man.load( f ) }
123
+ load_files
124
124
  quit
125
125
  end
126
126
 
127
+ #
128
+ # Load all file specified in the CLI.
129
+ #
130
+ def load_files
131
+ @args.files.each { |f| @persist_man.load( f ) }
132
+ end
133
+
127
134
  #
128
135
  # Run in interactive mode.
129
136
  #
@@ -131,7 +138,8 @@ module GlooLang
131
138
  # Open default file(s)
132
139
  self.open_start_file
133
140
 
134
- # TODO: open any files specifed in args
141
+ # Open any files specifed in args
142
+ load_files
135
143
 
136
144
  unless @mode == Mode::SCRIPT || @args.quiet?
137
145
  self.loop
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.4
4
+ version: 1.2.6
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-09-14 00:00:00.000000000 Z
11
+ date: 2022-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -261,7 +261,6 @@ files:
261
261
  - lib/gloo_lang/objs/ctrl/each.rb
262
262
  - lib/gloo_lang/objs/ctrl/repeat.rb
263
263
  - lib/gloo_lang/objs/data/markdown.rb
264
- - lib/gloo_lang/objs/data/query.rb
265
264
  - lib/gloo_lang/objs/data/table.rb
266
265
  - lib/gloo_lang/objs/dt/date.rb
267
266
  - lib/gloo_lang/objs/dt/datetime.rb
@@ -1,224 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
- #
4
- # A SQL database query.
5
- # Relies on a database connection object.
6
- #
7
-
8
- module GlooLang
9
- module Objs
10
- class Query < GlooLang::Core::Obj
11
-
12
- KEYWORD = 'query'.freeze
13
- KEYWORD_SHORT = 'sql'.freeze
14
-
15
- DB = 'database'.freeze
16
- SQL = 'sql'.freeze
17
- RESULT = 'result'.freeze
18
- PARAMS = 'params'.freeze
19
-
20
- DB_MISSING_ERR = 'The database connection is missing!'.freeze
21
-
22
- #
23
- # The name of the object type.
24
- #
25
- def self.typename
26
- return KEYWORD
27
- end
28
-
29
- #
30
- # The short name of the object type.
31
- #
32
- def self.short_typename
33
- return KEYWORD_SHORT
34
- end
35
-
36
- # ---------------------------------------------------------------------
37
- # Children
38
- # ---------------------------------------------------------------------
39
-
40
- #
41
- # Does this object have children to add when an object
42
- # is created in interactive mode?
43
- # This does not apply during obj load, etc.
44
- #
45
- def add_children_on_create?
46
- return true
47
- end
48
-
49
- #
50
- # Add children to this object.
51
- # This is used by containers to add children needed
52
- # for default configurations.
53
- #
54
- def add_default_children
55
- fac = @engine.factory
56
- fac.create_alias DB, nil, self
57
- fac.create_string SQL, nil, self
58
- fac.create_can RESULT, self
59
- end
60
-
61
- # ---------------------------------------------------------------------
62
- # Messages
63
- # ---------------------------------------------------------------------
64
-
65
- #
66
- # Get a list of message names that this object receives.
67
- #
68
- def self.messages
69
- return super + [ 'run' ]
70
- end
71
-
72
- #
73
- # SSH to the host and execute the command, then update result.
74
- #
75
- def msg_run
76
- db = db_obj
77
- unless db
78
- @engine.err DB_MISSING_ERR
79
- return
80
- end
81
-
82
- result = db.query( sql_value, param_array )
83
- process_result result
84
- end
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
-
134
- # ---------------------------------------------------------------------
135
- # Private functions
136
- # ---------------------------------------------------------------------
137
-
138
- private
139
-
140
- #
141
- # Get the database connection.
142
- #
143
- def db_obj
144
- o = find_child DB
145
- return GlooLang::Objs::Alias.resolve_alias( @engine, o )
146
- end
147
-
148
- #
149
- # Get the SQL from the child object.
150
- # Returns nil if there is none.
151
- #
152
- def sql_value
153
- o = find_child SQL
154
- return nil unless o
155
-
156
- return o.value
157
- end
158
-
159
- #
160
- # Do something with the result of the SQL Query call.
161
- # If there's a result container, we'll create objects in it.
162
- # If not, we'll just show the output in the console.
163
- #
164
- def process_result( data )
165
- r = find_child RESULT
166
- if r
167
- update_result_contaier data
168
- else
169
- show_result data
170
- end
171
- end
172
-
173
- #
174
- # Get the arrya of parameters.
175
- # If there is no PARAM container of if it is empty,
176
- # we'll return a nil value.
177
- #
178
- def param_array
179
- o = find_child PARAMS
180
- return nil unless o
181
-
182
- return nil if o.child_count.zero?
183
-
184
- params = []
185
- o.children.each do |p|
186
- params << p.value
187
- end
188
-
189
- return params
190
- end
191
-
192
- #
193
- # Show the result of the query in the console.
194
- #
195
- def show_result( result )
196
- return if result.nil?
197
-
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 )
204
- end
205
- end
206
-
207
- #
208
- # Update the result container with the data from the query.
209
- #
210
- def update_result_contaier( data )
211
- r = find_child RESULT
212
- r = GlooLang::Objs::Alias.resolve_alias( @engine, r )
213
- data.each_with_index do |row, i|
214
- can = r.find_add_child( i.to_s, 'can' )
215
- row.each do |k, v|
216
- o = can.find_add_child( k, 'untyped' )
217
- o.set_value v
218
- end
219
- end
220
- end
221
-
222
- end
223
- end
224
- end