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.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/lib/VERSION +1 -1
  3. data/lib/VERSION_NOTES +10 -0
  4. data/lib/gloo/app/engine.rb +57 -13
  5. data/lib/gloo/app/engine_context.rb +1 -1
  6. data/lib/gloo/app/info.rb +0 -1
  7. data/lib/gloo/app/log.rb +1 -1
  8. data/lib/gloo/app/platform.rb +2 -2
  9. data/lib/gloo/app/prompt.rb +1 -0
  10. data/lib/gloo/app/settings.rb +0 -5
  11. data/lib/gloo/app/table.rb +1 -1
  12. data/lib/gloo/convert/nilclass_to_datetime.rb +1 -1
  13. data/lib/gloo/convert/nilclass_to_integer.rb +1 -3
  14. data/lib/gloo/convert/nilclass_to_string.rb +0 -2
  15. data/lib/gloo/convert/nilclass_to_time.rb +1 -1
  16. data/lib/gloo/convert/string_to_decimal.rb +1 -1
  17. data/lib/gloo/core/dictionary.rb +16 -22
  18. data/lib/gloo/core/event_manager.rb +19 -0
  19. data/lib/gloo/core/here.rb +2 -1
  20. data/lib/gloo/core/literal.rb +1 -1
  21. data/lib/gloo/core/obj.rb +5 -1
  22. data/lib/gloo/core/obj_finder.rb +0 -1
  23. data/lib/gloo/core/pn.rb +4 -2
  24. data/lib/gloo/exec/exec_env.rb +0 -2
  25. data/lib/gloo/exec/runner.rb +7 -2
  26. data/lib/gloo/expr/l_decimal.rb +1 -1
  27. data/lib/gloo/expr/l_string.rb +1 -1
  28. data/lib/gloo/expr/op_eq.rb +3 -1
  29. data/lib/gloo/expr/op_gt.rb +3 -0
  30. data/lib/gloo/expr/op_gteq.rb +3 -0
  31. data/lib/gloo/expr/op_ineq.rb +3 -0
  32. data/lib/gloo/expr/op_lt.rb +3 -0
  33. data/lib/gloo/expr/op_lteq.rb +3 -0
  34. data/lib/gloo/objs/basic/alias.rb +1 -1
  35. data/lib/gloo/objs/basic/boolean.rb +1 -1
  36. data/lib/gloo/objs/basic/decimal.rb +22 -1
  37. data/lib/gloo/objs/basic/integer.rb +19 -1
  38. data/lib/gloo/objs/basic/string_generator.rb +4 -7
  39. data/lib/gloo/objs/basic/untyped.rb +1 -1
  40. data/lib/gloo/objs/ctrl/each_child.rb +0 -2
  41. data/lib/gloo/objs/ctrl/function.rb +2 -5
  42. data/lib/gloo/objs/ctrl/repeat.rb +1 -2
  43. data/lib/gloo/objs/dt/datetime.rb +19 -8
  44. data/lib/gloo/objs/dt/dt_tools.rb +101 -21
  45. data/lib/gloo/objs/dt/time.rb +17 -1
  46. data/lib/gloo/objs/str_utils/cipher.rb +8 -11
  47. data/lib/gloo/objs/str_utils/outline.rb +0 -2
  48. data/lib/gloo/objs/system/erb.rb +5 -6
  49. data/lib/gloo/objs/system/file_handle.rb +0 -1
  50. data/lib/gloo/objs/system/system.rb +5 -11
  51. data/lib/gloo/objs/web/http_get.rb +6 -12
  52. data/lib/gloo/objs/web/http_post.rb +5 -31
  53. data/lib/gloo/objs/web/json.rb +1 -1
  54. data/lib/gloo/objs/web/uri.rb +2 -2
  55. data/lib/gloo/persist/disc_mech.rb +2 -2
  56. data/lib/gloo/persist/file_loader.rb +1 -1
  57. data/lib/gloo/persist/file_saver.rb +2 -2
  58. data/lib/gloo/persist/persist_man.rb +12 -8
  59. data/lib/gloo/plugin/callback.rb +1 -1
  60. data/lib/gloo/plugin/ext_manager.rb +1 -1
  61. data/lib/gloo/plugin/lib_manager.rb +1 -1
  62. data/lib/gloo/verbs/execute.rb +0 -6
  63. data/lib/gloo/verbs/files.rb +0 -1
  64. data/lib/gloo/verbs/help.rb +0 -16
  65. data/lib/gloo/verbs/list.rb +1 -1
  66. data/lib/gloo/verbs/load.rb +1 -1
  67. data/lib/gloo/verbs/show.rb +1 -1
  68. data/lib/gloo/verbs/throw.rb +55 -0
  69. data/test.gloo/ctrl/each.test.gloo +39 -0
  70. data/test.gloo/dt/date.test.gloo +1 -1
  71. data/test.gloo/dt/datetime.test.gloo +61 -0
  72. data/test.gloo/dt/time.test.gloo +14 -1
  73. data/test.gloo/lang/dt_comparisons.test.gloo +124 -0
  74. data/test.gloo/lang/exceptions.test.gloo +63 -0
  75. data/test.gloo/objs/alias.test.gloo +24 -0
  76. data/test.gloo/objs/decimal.test.gloo +38 -0
  77. data/test.gloo/objs/erb.test.gloo +35 -0
  78. data/test.gloo/objs/int.test.gloo +14 -0
  79. data/test.gloo/objs/string.test.gloo +44 -0
  80. data/test.gloo/verbs/create.test.gloo +14 -0
  81. data/test.gloo/verbs/invoke.test.gloo +20 -0
  82. data/test.gloo/verbs/unless.test.gloo +22 -0
  83. metadata +14 -4
  84. data/lib/gloo/utils/format.rb +0 -21
  85. data/lib/gloo/utils/words.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5353f95b95c44382afa5fbd36d3f14681314dcee7a284bb60c51806f6b9be5a
4
- data.tar.gz: cabbfad7080488c79b911a12d9c070885505b0926f414f821d4d3cc2222c01bd
3
+ metadata.gz: 8d1310b5690bb9901d7c5513d577e50455cc4320cb268ba55f8195e120ff7255
4
+ data.tar.gz: ee36ab64879e30780e3efcc6df46c78024576d0646c93567a847af13bcec48ff
5
5
  SHA512:
6
- metadata.gz: d86a2a5c5476dab64505e1180fb43b6c24d9cb4bec414a9dc9703afb8748a85070eb33ba5db10ed2146ac1244380f8cf3fb7bc81773e892474d441615711c955
7
- data.tar.gz: 8d41fd6c9ee3f5839e423721f8d23c2024f777caaddf60785209f2ad2d867360974c75697cb46fe62a45c81994fe41ff337794fe24118fe2bb5ca93cf2f22d6e
6
+ metadata.gz: fe42ac15476405b90663cf0949e1c8f60c002fb8fa3d7a4afd4076861c43968c658cb0ef6cb52cf2706809e2605a5efce2c3ef7932a0fc9ac66e2b3d27160e4b
7
+ data.tar.gz: 88172ca6ad464958c442c2cffee54105592b6462242dad1d297cf9e8a82e237b178dd110db9014fe47872806f4065599a44e8319c7a196ded59b2cfdd703faf9
data/lib/VERSION CHANGED
@@ -1 +1 @@
1
- 5.3.9
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
 
@@ -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
- log_exception ex
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
- log_exception e
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
- @event_manager.on_error( msg, backtrace)
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
- # Get the stack trace, and if needed truncate to fit.
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
- backtrace = msg_lines.join( "\n" )
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
@@ -48,7 +48,6 @@ module Gloo
48
48
  #
49
49
  def self.full_version
50
50
  return "#{display_title}\n#{ruby_info}"
51
- return str
52
51
  end
53
52
 
54
53
  #
data/lib/gloo/app/log.rb CHANGED
@@ -36,7 +36,7 @@ module Gloo
36
36
  #
37
37
  def initialize( engine, quiet = true )
38
38
  @engine = engine
39
- @quite = quiet
39
+ @quiet = quiet
40
40
  @debug = engine.settings.debug
41
41
 
42
42
  create_loggers
@@ -41,7 +41,7 @@ module Gloo
41
41
  #
42
42
  # Get the file mechanism for this platform.
43
43
  #
44
- def getFileMech( engine )
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 getColorizedString( str, color )
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
@@ -16,6 +16,7 @@ module Gloo
16
16
  #
17
17
  # Set up Prompt.
18
18
  #
19
+ # Set up Prompt with the given platform.
19
20
  def initialize platform
20
21
  @platform = platform
21
22
  end
@@ -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
@@ -20,7 +20,7 @@ module Gloo
20
20
  #
21
21
  # Put a box around the given string.
22
22
  def box( str_value )
23
- puts str_value
23
+ # puts str_value
24
24
  box = Terminal::Table.new( :headings => [], :rows => [ [ str_value ] ] )
25
25
  return box.to_s
26
26
  end
@@ -10,7 +10,7 @@ module Gloo
10
10
  class NilClassToDateTime
11
11
 
12
12
  #
13
- # Convert a nil to a date.
13
+ # Convert a nil to a datetime.
14
14
  #
15
15
  def convert( value )
16
16
  return Chronic.parse( '' )
@@ -3,14 +3,12 @@
3
3
  #
4
4
  # Conversion tool: Nil to Integer.
5
5
  #
6
- require 'chronic'
7
-
8
6
  module Gloo
9
7
  module Convert
10
8
  class NilClassToInteger
11
9
 
12
10
  #
13
- # Convert a nil to a string.
11
+ # Convert a nil to an integer.
14
12
  #
15
13
  def convert( value )
16
14
  return 0
@@ -3,8 +3,6 @@
3
3
  #
4
4
  # Conversion tool: Nil to String.
5
5
  #
6
- require 'chronic'
7
-
8
6
  module Gloo
9
7
  module Convert
10
8
  class NilClassToString
@@ -10,7 +10,7 @@ module Gloo
10
10
  class NilClassToTime
11
11
 
12
12
  #
13
- # Convert a nil to a date.
13
+ # Convert a nil to a time.
14
14
  #
15
15
  def convert( value )
16
16
  return Chronic.parse( '' )
@@ -9,7 +9,7 @@ module Gloo
9
9
  class StringToDecimal
10
10
 
11
11
  #
12
- # Convert the given string value to an integer.
12
+ # Convert the given string value to a decimal.
13
13
  #
14
14
  def convert( value )
15
15
  return value.to_f
@@ -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 o
221
+ def add_object( obj )
226
222
  # Make sure it hasn't already been registered
227
- if ( @objs.key?(o.typename) || @objs.key?(o.short_typename) )
228
- @engine.err "duplicate object type '#{o.typename}' or '#{o.short_typename}'"
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[ o.typename ] = o
233
- @objs[ o.short_typename ] = o
234
- add_key o.typename
235
- add_key o.short_typename if o.typename != o.short_typename
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 v
236
+ #
237
+ def add_verb( verb )
242
238
  # Make sure it hasn't already been registered
243
- if ( verb?( v.keyword ) || verb?( v.keyword_shortcut ))
244
- puts "duplicate verb keyword '#{v.keyword}' or '#{v.keyword_shortcut}'"
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[ v.keyword ] = v
250
- @verbs[ v.keyword_shortcut ] = v
251
- # v.send( :new ).run
252
- add_key v.keyword
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
@@ -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.set_to "#{target.pn}.#{remainder}"
31
+ full_path = target.pn.empty? ? remainder : "#{target.pn}.#{remainder}"
32
+ pn.set_to full_path
32
33
  end
33
34
 
34
35
  end
@@ -12,7 +12,7 @@ module Gloo
12
12
  attr_reader :value
13
13
 
14
14
  #
15
- # Create the expression from a list of tokens.
15
+ # Create the literal with the given value.
16
16
  #
17
17
  def initialize( value )
18
18
  set_value( value )
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.downcase == 'root'
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?
@@ -38,7 +38,6 @@ module Gloo
38
38
  arr = []
39
39
 
40
40
  container.children.each do |o|
41
- # puts "#{o.class.typename} == #{type}"
42
41
  arr << o if o.class.typename == type
43
42
  arr += by_type( engine, type, o ) if o.child_count.positive?
44
43
  end
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
- colors = %w[red blue green white black yellow]
181
- return true if colors.include?( @src.downcase )
181
+ return true if NAMED_COLORS.include?( @src.downcase )
182
+
183
+ return false
182
184
  end
183
185
 
184
186
  #
@@ -63,7 +63,6 @@ module Gloo
63
63
  #
64
64
  def push_action( action )
65
65
  @actions.push action
66
- # @here.push action.to
67
66
  end
68
67
 
69
68
  #
@@ -71,7 +70,6 @@ module Gloo
71
70
  #
72
71
  def pop_action
73
72
  @actions.pop
74
- # @here.pop
75
73
  end
76
74
 
77
75
  end
@@ -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
- verb&.run
23
- engine.exec_env.verbs.pop
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
 
@@ -19,7 +19,7 @@ module Gloo
19
19
  end
20
20
 
21
21
  #
22
- # Set the value, converting to an integer.
22
+ # Set the value, converting to a decimal.
23
23
  #
24
24
  def set_value( value )
25
25
  value = value.to_s if value.is_a? Numeric
@@ -9,7 +9,7 @@ module Gloo
9
9
  class LString < Gloo::Core::Literal
10
10
 
11
11
  #
12
- # Set the value, triming opening and closing
12
+ # Set the value, trimming opening and closing
13
13
  # quotations if necessary.
14
14
  #
15
15
  def set_value( value )
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -1,7 +1,7 @@
1
1
  # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
2
  # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
3
  #
4
- # A String.
4
+ # An Alias.
5
5
  #
6
6
 
7
7
  module Gloo
@@ -1,7 +1,7 @@
1
1
  # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
2
  # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
3
  #
4
- # An object with an boolean value.
4
+ # An object with a boolean value.
5
5
  #
6
6
 
7
7
  module Gloo
@@ -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