gloo 5.3.9 → 6.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 +4 -4
- data/lib/VERSION +1 -1
- data/lib/VERSION_NOTES +10 -0
- data/lib/gloo/app/engine.rb +57 -13
- data/lib/gloo/app/engine_context.rb +1 -1
- data/lib/gloo/app/info.rb +0 -1
- data/lib/gloo/app/log.rb +1 -1
- data/lib/gloo/app/platform.rb +2 -2
- data/lib/gloo/app/prompt.rb +1 -0
- data/lib/gloo/app/settings.rb +0 -5
- data/lib/gloo/app/table.rb +1 -1
- data/lib/gloo/convert/nilclass_to_datetime.rb +1 -1
- data/lib/gloo/convert/nilclass_to_integer.rb +1 -3
- data/lib/gloo/convert/nilclass_to_string.rb +0 -2
- data/lib/gloo/convert/nilclass_to_time.rb +1 -1
- data/lib/gloo/convert/string_to_decimal.rb +1 -1
- data/lib/gloo/core/dictionary.rb +16 -22
- data/lib/gloo/core/event_manager.rb +19 -0
- data/lib/gloo/core/here.rb +2 -1
- data/lib/gloo/core/literal.rb +1 -1
- data/lib/gloo/core/obj.rb +5 -1
- data/lib/gloo/core/obj_finder.rb +0 -1
- data/lib/gloo/core/pn.rb +4 -2
- data/lib/gloo/exec/exec_env.rb +0 -2
- data/lib/gloo/exec/runner.rb +7 -2
- data/lib/gloo/expr/l_decimal.rb +1 -1
- data/lib/gloo/expr/l_string.rb +1 -1
- data/lib/gloo/expr/op_eq.rb +3 -1
- data/lib/gloo/expr/op_gt.rb +3 -0
- data/lib/gloo/expr/op_gteq.rb +3 -0
- data/lib/gloo/expr/op_ineq.rb +3 -0
- data/lib/gloo/expr/op_lt.rb +3 -0
- data/lib/gloo/expr/op_lteq.rb +3 -0
- data/lib/gloo/objs/basic/alias.rb +1 -1
- data/lib/gloo/objs/basic/boolean.rb +1 -1
- data/lib/gloo/objs/basic/decimal.rb +22 -1
- data/lib/gloo/objs/basic/integer.rb +19 -1
- data/lib/gloo/objs/basic/string_generator.rb +4 -7
- data/lib/gloo/objs/basic/untyped.rb +1 -1
- data/lib/gloo/objs/ctrl/each_child.rb +0 -2
- data/lib/gloo/objs/ctrl/function.rb +2 -5
- data/lib/gloo/objs/ctrl/repeat.rb +1 -2
- data/lib/gloo/objs/dt/datetime.rb +19 -8
- data/lib/gloo/objs/dt/dt_tools.rb +101 -21
- data/lib/gloo/objs/dt/time.rb +17 -1
- data/lib/gloo/objs/str_utils/cipher.rb +8 -11
- data/lib/gloo/objs/str_utils/outline.rb +0 -2
- data/lib/gloo/objs/system/erb.rb +5 -6
- data/lib/gloo/objs/system/file_handle.rb +0 -1
- data/lib/gloo/objs/system/system.rb +5 -11
- data/lib/gloo/objs/web/http_get.rb +6 -12
- data/lib/gloo/objs/web/http_post.rb +5 -31
- data/lib/gloo/objs/web/json.rb +1 -1
- data/lib/gloo/objs/web/uri.rb +2 -2
- data/lib/gloo/persist/disc_mech.rb +2 -2
- data/lib/gloo/persist/file_loader.rb +1 -1
- data/lib/gloo/persist/file_saver.rb +2 -2
- data/lib/gloo/persist/persist_man.rb +12 -8
- data/lib/gloo/plugin/callback.rb +1 -1
- data/lib/gloo/plugin/ext_manager.rb +1 -1
- data/lib/gloo/plugin/lib_manager.rb +1 -1
- data/lib/gloo/verbs/execute.rb +0 -6
- data/lib/gloo/verbs/files.rb +0 -1
- data/lib/gloo/verbs/help.rb +0 -16
- data/lib/gloo/verbs/list.rb +1 -1
- data/lib/gloo/verbs/load.rb +1 -1
- data/lib/gloo/verbs/show.rb +1 -1
- data/lib/gloo/verbs/throw.rb +55 -0
- data/test.gloo/ctrl/each.test.gloo +39 -0
- data/test.gloo/dt/date.test.gloo +1 -1
- data/test.gloo/dt/datetime.test.gloo +61 -0
- data/test.gloo/dt/time.test.gloo +14 -1
- data/test.gloo/lang/dt_comparisons.test.gloo +124 -0
- data/test.gloo/lang/exceptions.test.gloo +63 -0
- data/test.gloo/objs/alias.test.gloo +24 -0
- data/test.gloo/objs/decimal.test.gloo +38 -0
- data/test.gloo/objs/erb.test.gloo +35 -0
- data/test.gloo/objs/int.test.gloo +14 -0
- data/test.gloo/objs/string.test.gloo +44 -0
- data/test.gloo/verbs/create.test.gloo +14 -0
- data/test.gloo/verbs/invoke.test.gloo +20 -0
- data/test.gloo/verbs/unless.test.gloo +22 -0
- metadata +14 -4
- data/lib/gloo/utils/format.rb +0 -21
- data/lib/gloo/utils/words.rb +0 -19
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8d1310b5690bb9901d7c5513d577e50455cc4320cb268ba55f8195e120ff7255
|
|
4
|
+
data.tar.gz: ee36ab64879e30780e3efcc6df46c78024576d0646c93567a847af13bcec48ff
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fe42ac15476405b90663cf0949e1c8f60c002fb8fa3d7a4afd4076861c43968c658cb0ef6cb52cf2706809e2605a5efce2c3ef7932a0fc9ac66e2b3d27160e4b
|
|
7
|
+
data.tar.gz: 88172ca6ad464958c442c2cffee54105592b6462242dad1d297cf9e8a82e237b178dd110db9014fe47872806f4065599a44e8319c7a196ded59b2cfdd703faf9
|
data/lib/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
6.0
|
data/lib/VERSION_NOTES
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
6.0 - 2026.07.12
|
|
2
|
+
- General code cleanup, additional tests added.
|
|
3
|
+
- ERB object's template can now be an alias.
|
|
4
|
+
- Clean up the unused Utils directory.
|
|
5
|
+
- Adds format message to integer and decimal objects.
|
|
6
|
+
- Adds format message for time and datetime objects.
|
|
7
|
+
- Adds comparison operators for dates and times.
|
|
8
|
+
- Adds throw verb and exception error handling with on_exception.
|
|
9
|
+
|
|
10
|
+
|
|
1
11
|
5.3.9 - 2026.06.11
|
|
2
12
|
- Adds append message to file object
|
|
3
13
|
|
data/lib/gloo/app/engine.rb
CHANGED
|
@@ -37,6 +37,8 @@ module Gloo
|
|
|
37
37
|
@platform = context.platform
|
|
38
38
|
@log.debug "platform (class: #{@platform.class.name}) in use ..."
|
|
39
39
|
|
|
40
|
+
@handling_exception = false
|
|
41
|
+
@handling_error = false
|
|
40
42
|
@log.debug 'engine intialized...'
|
|
41
43
|
end
|
|
42
44
|
|
|
@@ -141,7 +143,7 @@ module Gloo
|
|
|
141
143
|
@lib_manager.load_lib TEST_LIB_NAME
|
|
142
144
|
TestRunner.new( self, @args.files ).run
|
|
143
145
|
rescue => ex
|
|
144
|
-
|
|
146
|
+
handle_exception ex
|
|
145
147
|
end
|
|
146
148
|
|
|
147
149
|
@log.debug 'Tests complete.'
|
|
@@ -215,7 +217,7 @@ module Gloo
|
|
|
215
217
|
begin
|
|
216
218
|
@parser.run @last_cmd
|
|
217
219
|
rescue => e
|
|
218
|
-
|
|
220
|
+
handle_exception e
|
|
219
221
|
end
|
|
220
222
|
end
|
|
221
223
|
|
|
@@ -296,32 +298,74 @@ module Gloo
|
|
|
296
298
|
|
|
297
299
|
#
|
|
298
300
|
# Report an error.
|
|
299
|
-
# Write it to the log and set the heap error value.
|
|
301
|
+
# Write it to the log and set the heap error value. Always logged;
|
|
302
|
+
# runs the on_error script (if any) unless we're already inside
|
|
303
|
+
# one, so a broken handler can't loop.
|
|
300
304
|
#
|
|
301
305
|
def err( msg, backtrace=nil )
|
|
302
306
|
@log.error msg
|
|
303
307
|
@heap.error.set_to msg
|
|
304
308
|
|
|
305
|
-
|
|
309
|
+
return if @handling_error
|
|
310
|
+
|
|
311
|
+
@handling_error = true
|
|
312
|
+
begin
|
|
313
|
+
@event_manager.on_error( msg, backtrace )
|
|
314
|
+
ensure
|
|
315
|
+
@handling_error = false
|
|
316
|
+
end
|
|
306
317
|
end
|
|
307
318
|
|
|
308
|
-
#
|
|
319
|
+
#
|
|
309
320
|
# Log an exception.
|
|
310
|
-
# This function does not log the full backtrace, but
|
|
321
|
+
# This function does not log the full backtrace, but
|
|
311
322
|
# does write part of it to the log.
|
|
312
|
-
#
|
|
323
|
+
#
|
|
313
324
|
def log_exception ex
|
|
314
|
-
|
|
325
|
+
backtrace = format_backtrace( ex )
|
|
326
|
+
@log.error backtrace
|
|
327
|
+
|
|
328
|
+
err( ex.message, backtrace)
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
#
|
|
332
|
+
# Handle an unanticipated Ruby exception caught at one of the
|
|
333
|
+
# engine's rescue points. Always logged; runs the on_exception
|
|
334
|
+
# script (if any) unless we're already inside one, so a broken
|
|
335
|
+
# handler can't loop.
|
|
336
|
+
#
|
|
337
|
+
def handle_exception ex
|
|
338
|
+
backtrace = format_backtrace( ex )
|
|
339
|
+
@log.error ex.message
|
|
340
|
+
@log.error backtrace
|
|
341
|
+
|
|
342
|
+
return if @handling_exception
|
|
343
|
+
|
|
344
|
+
@handling_exception = true
|
|
345
|
+
begin
|
|
346
|
+
@event_manager.on_exception( ex.message, backtrace )
|
|
347
|
+
ensure
|
|
348
|
+
@handling_exception = false
|
|
349
|
+
end
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
# ---------------------------------------------------------------------
|
|
353
|
+
# Private functions
|
|
354
|
+
# ---------------------------------------------------------------------
|
|
355
|
+
|
|
356
|
+
private
|
|
357
|
+
|
|
358
|
+
#
|
|
359
|
+
# Get the stack trace as a string, truncating the middle if it's long.
|
|
360
|
+
#
|
|
361
|
+
def format_backtrace ex
|
|
315
362
|
msg_lines = ex.backtrace
|
|
316
363
|
if msg_lines.count > 27
|
|
317
364
|
msg_lines = msg_lines[0..13] + [ '... truncated ...' ] + msg_lines[-13..-1]
|
|
318
365
|
end
|
|
319
|
-
|
|
320
|
-
@log.error backtrace
|
|
321
|
-
|
|
322
|
-
err( ex.message, backtrace)
|
|
366
|
+
return msg_lines.join( "\n" )
|
|
323
367
|
end
|
|
324
|
-
|
|
368
|
+
|
|
325
369
|
end
|
|
326
370
|
end
|
|
327
371
|
end
|
|
@@ -13,7 +13,7 @@ module Gloo
|
|
|
13
13
|
#
|
|
14
14
|
# Create the context, supplying defaults where relevant.
|
|
15
15
|
#
|
|
16
|
-
def initialize( params = [], platform=nil, log=nil, user_root=nil )
|
|
16
|
+
def initialize( params = [], platform = nil, log = nil, user_root = nil )
|
|
17
17
|
@params = params
|
|
18
18
|
@platform = platform ? platform : Gloo::App::Platform.new
|
|
19
19
|
@log = log ? log : Gloo::App::Log
|
data/lib/gloo/app/info.rb
CHANGED
data/lib/gloo/app/log.rb
CHANGED
data/lib/gloo/app/platform.rb
CHANGED
|
@@ -41,7 +41,7 @@ module Gloo
|
|
|
41
41
|
#
|
|
42
42
|
# Get the file mechanism for this platform.
|
|
43
43
|
#
|
|
44
|
-
def
|
|
44
|
+
def get_file_mech( engine )
|
|
45
45
|
return Gloo::Persist::DiscMech.new( engine )
|
|
46
46
|
end
|
|
47
47
|
|
|
@@ -53,7 +53,7 @@ module Gloo
|
|
|
53
53
|
#
|
|
54
54
|
# Get colorized string.
|
|
55
55
|
#
|
|
56
|
-
def
|
|
56
|
+
def get_colorized_string( str, color )
|
|
57
57
|
colorized = ColorizedString[ str.to_s ].colorize( color )
|
|
58
58
|
return colorized.to_s
|
|
59
59
|
end
|
data/lib/gloo/app/prompt.rb
CHANGED
data/lib/gloo/app/settings.rb
CHANGED
|
@@ -110,11 +110,6 @@ module Gloo
|
|
|
110
110
|
def init_root root
|
|
111
111
|
if root
|
|
112
112
|
@user_root = root
|
|
113
|
-
# if in_test_mode?
|
|
114
|
-
# path = File.dirname( File.dirname( File.absolute_path( __FILE__ ) ) )
|
|
115
|
-
# path = File.dirname( File.dirname( path ) )
|
|
116
|
-
# path = File.join( path, 'test', 'gloo' )
|
|
117
|
-
# @user_root = path
|
|
118
113
|
else
|
|
119
114
|
@user_root = File.join( Dir.home, 'gloo' )
|
|
120
115
|
end
|
data/lib/gloo/app/table.rb
CHANGED
data/lib/gloo/core/dictionary.rb
CHANGED
|
@@ -52,7 +52,6 @@ module Gloo
|
|
|
52
52
|
# Initialize verbs and objects in the dictionary.
|
|
53
53
|
#
|
|
54
54
|
def init
|
|
55
|
-
# @engine.log.debug 'initializing dictionaries'
|
|
56
55
|
init_verbs
|
|
57
56
|
init_objs
|
|
58
57
|
end
|
|
@@ -192,7 +191,6 @@ module Gloo
|
|
|
192
191
|
#
|
|
193
192
|
def add_key( keyword )
|
|
194
193
|
if @keywords.include?( keyword )
|
|
195
|
-
# @engine.err "duplicate keyword '#{keyword}'"
|
|
196
194
|
return
|
|
197
195
|
end
|
|
198
196
|
|
|
@@ -203,7 +201,6 @@ module Gloo
|
|
|
203
201
|
# Init the list of objects.
|
|
204
202
|
#
|
|
205
203
|
def init_objs
|
|
206
|
-
# @engine.log.debug "initializing #{@obj_references.count} objects"
|
|
207
204
|
@obj_references.each do |o|
|
|
208
205
|
add_object o
|
|
209
206
|
end
|
|
@@ -213,7 +210,6 @@ module Gloo
|
|
|
213
210
|
# Init the list of verbs.
|
|
214
211
|
#
|
|
215
212
|
def init_verbs
|
|
216
|
-
# @engine.log.debug "initializing #{@verb_references.count} verbs"
|
|
217
213
|
@verb_references.each do |v|
|
|
218
214
|
add_verb v
|
|
219
215
|
end
|
|
@@ -222,35 +218,33 @@ module Gloo
|
|
|
222
218
|
#
|
|
223
219
|
# Add an object to the dictionary
|
|
224
220
|
#
|
|
225
|
-
def add_object
|
|
221
|
+
def add_object( obj )
|
|
226
222
|
# Make sure it hasn't already been registered
|
|
227
|
-
if ( @objs.key?(
|
|
228
|
-
@engine.err "duplicate object type '#{
|
|
223
|
+
if ( @objs.key?(obj.typename) || @objs.key?(obj.short_typename) )
|
|
224
|
+
@engine.err "duplicate object type '#{obj.typename}' or '#{obj.short_typename}'"
|
|
229
225
|
return
|
|
230
226
|
end
|
|
231
227
|
|
|
232
|
-
@objs[
|
|
233
|
-
@objs[
|
|
234
|
-
add_key
|
|
235
|
-
add_key
|
|
228
|
+
@objs[ obj.typename ] = obj
|
|
229
|
+
@objs[ obj.short_typename ] = obj
|
|
230
|
+
add_key obj.typename
|
|
231
|
+
add_key obj.short_typename if obj.typename != obj.short_typename
|
|
236
232
|
end
|
|
237
233
|
|
|
238
|
-
#
|
|
234
|
+
#
|
|
239
235
|
# Add a verb to the dictionary
|
|
240
|
-
#
|
|
241
|
-
def add_verb
|
|
236
|
+
#
|
|
237
|
+
def add_verb( verb )
|
|
242
238
|
# Make sure it hasn't already been registered
|
|
243
|
-
if ( verb?(
|
|
244
|
-
|
|
245
|
-
@engine.err "duplicate verb keyword '#{v.keyword}' or '#{v.keyword_shortcut}'"
|
|
239
|
+
if ( verb?( verb.keyword ) || verb?( verb.keyword_shortcut ) )
|
|
240
|
+
@engine.err "duplicate verb keyword '#{verb.keyword}' or '#{verb.keyword_shortcut}'"
|
|
246
241
|
return
|
|
247
242
|
end
|
|
248
243
|
|
|
249
|
-
@verbs[
|
|
250
|
-
@verbs[
|
|
251
|
-
|
|
252
|
-
add_key
|
|
253
|
-
add_key v.keyword_shortcut if v.keyword != v.keyword_shortcut
|
|
244
|
+
@verbs[ verb.keyword ] = verb
|
|
245
|
+
@verbs[ verb.keyword_shortcut ] = verb
|
|
246
|
+
add_key verb.keyword
|
|
247
|
+
add_key verb.keyword_shortcut if verb.keyword != verb.keyword_shortcut
|
|
254
248
|
end
|
|
255
249
|
|
|
256
250
|
end
|
|
@@ -91,6 +91,25 @@ module Gloo
|
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
93
|
|
|
94
|
+
#
|
|
95
|
+
# Run the on_exception scripts in any open objects.
|
|
96
|
+
# For each on_exception script found, look for the exception_data
|
|
97
|
+
# container and set the exception message and backtrace.
|
|
98
|
+
#
|
|
99
|
+
def on_exception msg, backtrace
|
|
100
|
+
@engine.log.debug 'on_exception event'
|
|
101
|
+
arr = Gloo::Core::ObjFinder.by_name( @engine, 'on_exception' )
|
|
102
|
+
arr.each do |o|
|
|
103
|
+
data = o.parent.find_child 'exception_data'
|
|
104
|
+
if data
|
|
105
|
+
data.find_child( 'message' ).set_value msg
|
|
106
|
+
data.find_child( 'backtrace' ).set_value backtrace
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
Gloo::Exec::Dispatch.message( @engine, 'run', o )
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
94
113
|
end
|
|
95
114
|
end
|
|
96
115
|
end
|
data/lib/gloo/core/here.rb
CHANGED
|
@@ -28,7 +28,8 @@ module Gloo
|
|
|
28
28
|
remainder = pn.elements[ 1..-1 ].join( '.' )
|
|
29
29
|
|
|
30
30
|
here.length.times { target = target.parent }
|
|
31
|
-
pn.
|
|
31
|
+
full_path = target.pn.empty? ? remainder : "#{target.pn}.#{remainder}"
|
|
32
|
+
pn.set_to full_path
|
|
32
33
|
end
|
|
33
34
|
|
|
34
35
|
end
|
data/lib/gloo/core/literal.rb
CHANGED
data/lib/gloo/core/obj.rb
CHANGED
|
@@ -55,7 +55,7 @@ module Gloo
|
|
|
55
55
|
#
|
|
56
56
|
def root?
|
|
57
57
|
return false if @parent
|
|
58
|
-
return false unless name
|
|
58
|
+
return false unless name&.downcase == 'root'
|
|
59
59
|
|
|
60
60
|
return true
|
|
61
61
|
end
|
|
@@ -69,8 +69,12 @@ module Gloo
|
|
|
69
69
|
|
|
70
70
|
#
|
|
71
71
|
# Get the path and name to this object.
|
|
72
|
+
# Paths are always relative to root, so root itself has no
|
|
73
|
+
# path/name segment of its own.
|
|
72
74
|
#
|
|
73
75
|
def pn
|
|
76
|
+
return '' if self.root?
|
|
77
|
+
|
|
74
78
|
str = self.name
|
|
75
79
|
p = self.parent
|
|
76
80
|
while p && !p.root?
|
data/lib/gloo/core/obj_finder.rb
CHANGED
data/lib/gloo/core/pn.rb
CHANGED
|
@@ -13,6 +13,7 @@ module Gloo
|
|
|
13
13
|
IT = 'it'.freeze
|
|
14
14
|
ERROR = 'error'.freeze
|
|
15
15
|
CONTEXT = '@'.freeze
|
|
16
|
+
NAMED_COLORS = %w[red blue green white black yellow].freeze
|
|
16
17
|
|
|
17
18
|
attr_reader :src, :elements
|
|
18
19
|
|
|
@@ -177,8 +178,9 @@ module Gloo
|
|
|
177
178
|
# Is the reference to a color?
|
|
178
179
|
#
|
|
179
180
|
def named_color?
|
|
180
|
-
|
|
181
|
-
|
|
181
|
+
return true if NAMED_COLORS.include?( @src.downcase )
|
|
182
|
+
|
|
183
|
+
return false
|
|
182
184
|
end
|
|
183
185
|
|
|
184
186
|
#
|
data/lib/gloo/exec/exec_env.rb
CHANGED
data/lib/gloo/exec/runner.rb
CHANGED
|
@@ -19,8 +19,13 @@ module Gloo
|
|
|
19
19
|
engine.log.debug "running verb #{verb.type_display}"
|
|
20
20
|
engine.heap.error.start_tracking
|
|
21
21
|
engine.exec_env.verbs.push verb
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
begin
|
|
23
|
+
verb&.run
|
|
24
|
+
rescue => ex
|
|
25
|
+
engine.handle_exception( ex )
|
|
26
|
+
ensure
|
|
27
|
+
engine.exec_env.verbs.pop
|
|
28
|
+
end
|
|
24
29
|
engine.heap.error.clear_if_no_errors
|
|
25
30
|
end
|
|
26
31
|
|
data/lib/gloo/expr/l_decimal.rb
CHANGED
data/lib/gloo/expr/l_string.rb
CHANGED
data/lib/gloo/expr/op_eq.rb
CHANGED
|
@@ -15,13 +15,15 @@ module Gloo
|
|
|
15
15
|
# Perform the operation and return the result.
|
|
16
16
|
#
|
|
17
17
|
def perform( left, right )
|
|
18
|
+
cmp = DtTools.compare_dt( left, right )
|
|
19
|
+
return cmp == 0 unless cmp == :not_dt
|
|
20
|
+
|
|
18
21
|
return left == right.to_s if left.is_a? String
|
|
19
22
|
|
|
20
23
|
return left == right.to_i if left.is_a? Integer
|
|
21
24
|
|
|
22
25
|
return left == right.to_f if left.is_a? Numeric
|
|
23
26
|
|
|
24
|
-
# puts "left: #{left}, right: #{right}"
|
|
25
27
|
if Gloo::Objs::Boolean.boolean?( left ) && Gloo::Objs::Boolean.boolean?( right )
|
|
26
28
|
return left == right
|
|
27
29
|
end
|
data/lib/gloo/expr/op_gt.rb
CHANGED
|
@@ -14,6 +14,9 @@ module Gloo
|
|
|
14
14
|
# Perform the operation and return the result.
|
|
15
15
|
#
|
|
16
16
|
def perform( left, right )
|
|
17
|
+
cmp = DtTools.compare_dt( left, right )
|
|
18
|
+
return cmp.is_a?( Integer ) && cmp.positive? unless cmp == :not_dt
|
|
19
|
+
|
|
17
20
|
return left > right.to_i if left.is_a? Integer
|
|
18
21
|
|
|
19
22
|
return left > right.to_f if left.is_a? Numeric
|
data/lib/gloo/expr/op_gteq.rb
CHANGED
|
@@ -14,6 +14,9 @@ module Gloo
|
|
|
14
14
|
# Perform the operation and return the result.
|
|
15
15
|
#
|
|
16
16
|
def perform( left, right )
|
|
17
|
+
cmp = DtTools.compare_dt( left, right )
|
|
18
|
+
return cmp.is_a?( Integer ) && !cmp.negative? unless cmp == :not_dt
|
|
19
|
+
|
|
17
20
|
return left >= right.to_i if left.is_a? Integer
|
|
18
21
|
|
|
19
22
|
return left >= right.to_f if left.is_a? Numeric
|
data/lib/gloo/expr/op_ineq.rb
CHANGED
|
@@ -14,6 +14,9 @@ module Gloo
|
|
|
14
14
|
# Perform the operation and return the result.
|
|
15
15
|
#
|
|
16
16
|
def perform( left, right )
|
|
17
|
+
cmp = DtTools.compare_dt( left, right )
|
|
18
|
+
return cmp.is_a?( Integer ) && cmp != 0 unless cmp == :not_dt
|
|
19
|
+
|
|
17
20
|
return left != right.to_s if left.is_a? String
|
|
18
21
|
|
|
19
22
|
return left != right.to_i if left.is_a? Integer
|
data/lib/gloo/expr/op_lt.rb
CHANGED
|
@@ -14,6 +14,9 @@ module Gloo
|
|
|
14
14
|
# Perform the operation and return the result.
|
|
15
15
|
#
|
|
16
16
|
def perform( left, right )
|
|
17
|
+
cmp = DtTools.compare_dt( left, right )
|
|
18
|
+
return cmp.is_a?( Integer ) && cmp.negative? unless cmp == :not_dt
|
|
19
|
+
|
|
17
20
|
return left < right.to_i if left.is_a? Integer
|
|
18
21
|
|
|
19
22
|
return left < right.to_f if left.is_a? Numeric
|
data/lib/gloo/expr/op_lteq.rb
CHANGED
|
@@ -14,6 +14,9 @@ module Gloo
|
|
|
14
14
|
# Perform the operation and return the result.
|
|
15
15
|
#
|
|
16
16
|
def perform( left, right )
|
|
17
|
+
cmp = DtTools.compare_dt( left, right )
|
|
18
|
+
return cmp.is_a?( Integer ) && !cmp.positive? unless cmp == :not_dt
|
|
19
|
+
|
|
17
20
|
return left <= right.to_i if left.is_a? Integer
|
|
18
21
|
|
|
19
22
|
return left <= right.to_f if left.is_a? Numeric
|
|
@@ -50,7 +50,7 @@ module Gloo
|
|
|
50
50
|
# Get a list of message names that this object receives.
|
|
51
51
|
#
|
|
52
52
|
def self.messages
|
|
53
|
-
return super + %w[round]
|
|
53
|
+
return super + %w[round format]
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
#
|
|
@@ -71,6 +71,27 @@ module Gloo
|
|
|
71
71
|
return i
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
+
#
|
|
75
|
+
# Format the decimal.
|
|
76
|
+
# With no parameter, adds comma separators to the whole part
|
|
77
|
+
# (Ex: 1000.5 -> 1,000.5).
|
|
78
|
+
# With a parameter, uses it as a sprintf-style format string (Ex: '%.2f').
|
|
79
|
+
#
|
|
80
|
+
# @param format [String] The sprintf-style format to use.
|
|
81
|
+
#
|
|
82
|
+
def msg_format
|
|
83
|
+
if @params&.token_count&.positive?
|
|
84
|
+
expr = Gloo::Expr::Expression.new( @engine, @params.tokens )
|
|
85
|
+
fmt = expr.evaluate
|
|
86
|
+
formatted = format( fmt, value )
|
|
87
|
+
else
|
|
88
|
+
whole, frac = value.to_s.split( '.' )
|
|
89
|
+
grouped = whole.reverse.scan( /.{1,3}/ ).join( ',' ).reverse
|
|
90
|
+
formatted = frac ? "#{grouped}.#{frac}" : grouped
|
|
91
|
+
end
|
|
92
|
+
@engine.heap.it.set_to formatted
|
|
93
|
+
end
|
|
94
|
+
|
|
74
95
|
end
|
|
75
96
|
end
|
|
76
97
|
end
|