gloo 3.8.0 → 3.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c8d357cda5602195adcfddc50c58705d34670b6ac01848eb8a1d66243571356
4
- data.tar.gz: 86687c8e18f4843dc9bca97111e140c26750479fce8619341a902284dde5a573
3
+ metadata.gz: afc950a2a2470041f3a3d990480cf26bee1005e6f4e00bcc95feb4e38d8de394
4
+ data.tar.gz: fe2cf5549734e2779ed1ed1f90bc5974fcae7c0b8245b22626a9828d2f54c54e
5
5
  SHA512:
6
- metadata.gz: baa186fd096e79a6152b7c287e23048a4b2fa67af5aa5db1c4e860918f42477b75e52fabbae8309506adfa32a77f5616bc2c4f4b22b6972142cb3977c9c965c9
7
- data.tar.gz: 8467cf3db96cd931cad4dc06910a4933c65284b25675a3f884e17d5639cb8b3d9b50ff8bd1c171d329f318317390e715a9a5af62dceed681509fe336d28c3439
6
+ metadata.gz: 7eed261a94581ca0a1e7f5c9a61657bd8e39f1455d55f4754bc4530641fe33ef359d7055f191dd204c505b31e501291803f5ef5822672640a280845c5c27b0d1
7
+ data.tar.gz: 643bd6cc65823bf8d1a8d1666e0b5b51abf5c44d0a8f2b25b51c901a1f18c3efda08264c5e686fe34efb0063a7e9e56b7040c50befa353e17369f0c04f32b186
data/lib/VERSION CHANGED
@@ -1 +1 @@
1
- 3.8.0
1
+ 3.9.0
data/lib/VERSION_NOTES CHANGED
@@ -1,3 +1,12 @@
1
+ 3.9.0 - 2025.02.21
2
+ - Fixes alias in page parameters
3
+ - Adds comparison operators
4
+ - Renames some verb shortcuts for compatibility
5
+ - Adds Group-By option in for each child loop
6
+ - Adds starts_with?, ends_with?, contains?, and format_for_html messages to string
7
+
8
+
9
+
1
10
  3.8.0 - 2025.01.23
2
11
  - Fixes issue with sessions
3
12
  - Adds authenticity token tag and supporting session id and validation
data/lib/gloo/app/log.rb CHANGED
@@ -169,7 +169,7 @@ module Gloo
169
169
  # Also write to the console unless quiet.
170
170
  #
171
171
  def error( msg, ex = nil, engine = nil )
172
- engine&.heap&.error&.set_to msg
172
+ engine&.heap&.error&.set_to( msg ) if engine
173
173
  @logger.error msg
174
174
  @error.error msg
175
175
  if ex
data/lib/gloo/core/op.rb CHANGED
@@ -13,19 +13,39 @@ module Gloo
13
13
  # Is the token an operator?
14
14
  #
15
15
  def self.op?( token )
16
- return [ '+', '-', '*', '/' ].include?( token.strip )
16
+ return [
17
+ Gloo::Expr::OpPlus::SYMBOL,
18
+ Gloo::Expr::OpMinus::SYMBOL,
19
+ Gloo::Expr::OpMult::SYMBOL,
20
+ Gloo::Expr::OpDiv::SYMBOL,
21
+ Gloo::Expr::OpEq::SYMBOL,
22
+ Gloo::Expr::OpEq::ALT_SYMBOL,
23
+ Gloo::Expr::OpIneq::SYMBOL,
24
+ Gloo::Expr::OpGt::SYMBOL,
25
+ Gloo::Expr::OpLt::SYMBOL,
26
+ Gloo::Expr::OpGteq::SYMBOL,
27
+ Gloo::Expr::OpLteq::SYMBOL
28
+ ].include?( token.strip )
17
29
  end
18
30
 
19
31
  #
20
32
  # Create the operator for the given token.
21
33
  #
22
34
  def self.create_op( token )
23
- return Gloo::Expr::OpMinus.new if token == '-'
24
- return Gloo::Expr::OpMult.new if token == '*'
25
- return Gloo::Expr::OpDiv.new if token == '/'
26
- return Gloo::Expr::OpPlus.new if token == '+'
27
-
28
- return default_op
35
+ case token
36
+ when Gloo::Expr::OpPlus::SYMBOL then Gloo::Expr::OpPlus.new
37
+ when Gloo::Expr::OpMinus::SYMBOL then Gloo::Expr::OpMinus.new
38
+ when Gloo::Expr::OpMult::SYMBOL then Gloo::Expr::OpMult.new
39
+ when Gloo::Expr::OpDiv::SYMBOL then Gloo::Expr::OpDiv.new
40
+ when Gloo::Expr::OpEq::SYMBOL then return Gloo::Expr::OpEq.new
41
+ when Gloo::Expr::OpEq::ALT_SYMBOL then return Gloo::Expr::OpEq.new
42
+ when Gloo::Expr::OpIneq::SYMBOL then return Gloo::Expr::OpIneq.new
43
+ when Gloo::Expr::OpGt::SYMBOL then return Gloo::Expr::OpGt.new
44
+ when Gloo::Expr::OpLt::SYMBOL then return Gloo::Expr::OpLt.new
45
+ when Gloo::Expr::OpGteq::SYMBOL then return Gloo::Expr::OpGteq.new
46
+ when Gloo::Expr::OpLteq::SYMBOL then return Gloo::Expr::OpLteq.new
47
+ else return default_op
48
+ end
29
49
  end
30
50
 
31
51
  #
@@ -8,6 +8,8 @@ module Gloo
8
8
  module Expr
9
9
  class OpDiv < Gloo::Core::Op
10
10
 
11
+ SYMBOL = '/'.freeze
12
+
11
13
  #
12
14
  # Perform the operation and return the result.
13
15
  #
@@ -0,0 +1,29 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2025 Eric Crane. All rights reserved.
3
+ #
4
+ # Equality operator.
5
+ #
6
+
7
+ module Gloo
8
+ module Expr
9
+ class OpEq < Gloo::Core::Op
10
+
11
+ SYMBOL = '='.freeze
12
+ ALT_SYMBOL = '=='.freeze
13
+
14
+ #
15
+ # Perform the operation and return the result.
16
+ #
17
+ def perform( left, right )
18
+ return left == right.to_s if left.is_a? String
19
+
20
+ return left == right.to_i if left.is_a? Integer
21
+
22
+ return left == right.to_f if left.is_a? Numeric
23
+
24
+ return false
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,26 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2025 Eric Crane. All rights reserved.
3
+ #
4
+ # Greater than operator.
5
+ #
6
+
7
+ module Gloo
8
+ module Expr
9
+ class OpGt < Gloo::Core::Op
10
+
11
+ SYMBOL = '>'.freeze
12
+
13
+ #
14
+ # Perform the operation and return the result.
15
+ #
16
+ def perform( left, right )
17
+ return left > right.to_i if left.is_a? Integer
18
+
19
+ return left > right.to_f if left.is_a? Numeric
20
+
21
+ return false
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2025 Eric Crane. All rights reserved.
3
+ #
4
+ # Greater than or equal operator.
5
+ #
6
+
7
+ module Gloo
8
+ module Expr
9
+ class OpGteq < Gloo::Core::Op
10
+
11
+ SYMBOL = '>='.freeze
12
+
13
+ #
14
+ # Perform the operation and return the result.
15
+ #
16
+ def perform( left, right )
17
+ return left >= right.to_i if left.is_a? Integer
18
+
19
+ return left >= right.to_f if left.is_a? Numeric
20
+
21
+ return false
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,28 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2025 Eric Crane. All rights reserved.
3
+ #
4
+ # Inequality operator.
5
+ #
6
+
7
+ module Gloo
8
+ module Expr
9
+ class OpIneq < Gloo::Core::Op
10
+
11
+ SYMBOL = '!='.freeze
12
+
13
+ #
14
+ # Perform the operation and return the result.
15
+ #
16
+ def perform( left, right )
17
+ return left != right.to_s if left.is_a? String
18
+
19
+ return left != right.to_i if left.is_a? Integer
20
+
21
+ return left != right.to_f if left.is_a? Numeric
22
+
23
+ return false
24
+ end
25
+
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,26 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2025 Eric Crane. All rights reserved.
3
+ #
4
+ # Less than operator.
5
+ #
6
+
7
+ module Gloo
8
+ module Expr
9
+ class OpLt < Gloo::Core::Op
10
+
11
+ SYMBOL = '<'.freeze
12
+
13
+ #
14
+ # Perform the operation and return the result.
15
+ #
16
+ def perform( left, right )
17
+ return left < right.to_i if left.is_a? Integer
18
+
19
+ return left < right.to_f if left.is_a? Numeric
20
+
21
+ return false
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2025 Eric Crane. All rights reserved.
3
+ #
4
+ # Less than or equal operator.
5
+ #
6
+
7
+ module Gloo
8
+ module Expr
9
+ class OpLteq < Gloo::Core::Op
10
+
11
+ SYMBOL = '<='.freeze
12
+
13
+ #
14
+ # Perform the operation and return the result.
15
+ #
16
+ def perform( left, right )
17
+ return left <= right.to_i if left.is_a? Integer
18
+
19
+ return left <= right.to_f if left.is_a? Numeric
20
+
21
+ return false
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -8,6 +8,8 @@ module Gloo
8
8
  module Expr
9
9
  class OpMinus < Gloo::Core::Op
10
10
 
11
+ SYMBOL = '-'.freeze
12
+
11
13
  #
12
14
  # Perform the operation and return the result.
13
15
  #
@@ -8,6 +8,8 @@ module Gloo
8
8
  module Expr
9
9
  class OpMult < Gloo::Core::Op
10
10
 
11
+ SYMBOL = '*'.freeze
12
+
11
13
  #
12
14
  # Perform the operation and return the result.
13
15
  #
@@ -8,6 +8,8 @@ module Gloo
8
8
  module Expr
9
9
  class OpPlus < Gloo::Core::Op
10
10
 
11
+ SYMBOL = '+'.freeze
12
+
11
13
  #
12
14
  # Perform the operation and return the result.
13
15
  #
@@ -12,6 +12,7 @@ module Gloo
12
12
 
13
13
  KEYWORD = 'string'.freeze
14
14
  KEYWORD_SHORT = 'str'.freeze
15
+ MISSING_PARAM_MSG = 'Missing parameter!'.freeze
15
16
 
16
17
  #
17
18
  # The name of the object type.
@@ -42,10 +43,95 @@ module Gloo
42
43
  # Get a list of message names that this object receives.
43
44
  #
44
45
  def self.messages
45
- return super + %w[up down size encode64 decode64 escape unescape
46
+ return super + %w[up down size starts_with? ends_with? contains?
47
+ format_for_html encode64 decode64 escape unescape
46
48
  gen_alphanumeric gen_uuid gen_hex gen_base64]
47
49
  end
48
50
 
51
+ #
52
+ # Convert whitespace to HTML friendly spaces.
53
+ #
54
+ def msg_format_for_html
55
+ text = self.value
56
+ out = ""
57
+ return out unless text
58
+
59
+ # indentation
60
+ text.each_line do |line|
61
+ i = 0
62
+ while line[i] == ' '
63
+ i += 1
64
+ out << "&nbsp;"
65
+ end
66
+
67
+ i = 0
68
+ while line[i] == "\t"
69
+ i += 1
70
+ out << "&nbsp;&nbsp;&nbsp;&nbsp;"
71
+ end
72
+ out << line
73
+ end
74
+
75
+ self.value = out.gsub( "\n", "<br/>" )
76
+ end
77
+
78
+ #
79
+ # Does the string start with the given string?
80
+ #
81
+ def msg_starts_with?
82
+ if @params&.token_count&.positive?
83
+ expr = Gloo::Expr::Expression.new( @engine, @params.tokens )
84
+ data = expr.evaluate
85
+
86
+ result = self.value.start_with?( data )
87
+ @engine.heap.it.set_to result
88
+ return result
89
+ else
90
+ # Error
91
+ @engine.log.error MISSING_PARAM_MSG
92
+ @engine.heap.it.set_to false
93
+ return false
94
+ end
95
+ end
96
+
97
+ #
98
+ # Does the string end with the given string?
99
+ #
100
+ def msg_ends_with?
101
+ if @params&.token_count&.positive?
102
+ expr = Gloo::Expr::Expression.new( @engine, @params.tokens )
103
+ data = expr.evaluate
104
+
105
+ result = value.end_with?( data )
106
+ @engine.heap.it.set_to result
107
+ return result
108
+ else
109
+ # Error
110
+ @engine.log.error MISSING_PARAM_MSG
111
+ @engine.heap.it.set_to false
112
+ return false
113
+ end
114
+ end
115
+
116
+ #
117
+ # Does the string contain the given string?
118
+ #
119
+ def msg_contains?
120
+ if @params&.token_count&.positive?
121
+ expr = Gloo::Expr::Expression.new( @engine, @params.tokens )
122
+ data = expr.evaluate
123
+
124
+ result = value.include?( data )
125
+ @engine.heap.it.set_to result
126
+ return result
127
+ else
128
+ # Error
129
+ @engine.log.error MISSING_PARAM_MSG
130
+ @engine.heap.it.set_to false
131
+ return false
132
+ end
133
+ end
134
+
49
135
  #
50
136
  # Get the size of the string.
51
137
  #
@@ -10,6 +10,11 @@ module Gloo
10
10
 
11
11
  CHILD = 'child'.freeze
12
12
  IN = 'IN'.freeze
13
+
14
+ GROUP_BY = 'group_by'.freeze
15
+ ON_GROUP_START = 'on_group_start'.freeze
16
+ ON_GROUP_END = 'on_group_end'.freeze
17
+
13
18
 
14
19
  # ---------------------------------------------------------------------
15
20
  # Create Iterator
@@ -34,6 +39,61 @@ module Gloo
34
39
  return false
35
40
  end
36
41
 
42
+
43
+ # ---------------------------------------------------------------------
44
+ # Group By
45
+ # ---------------------------------------------------------------------
46
+
47
+ #
48
+ # If the iterator has a group by,
49
+ # then we need to group by that value.
50
+ # Otherwise, we just loop for each child.
51
+ #
52
+ def has_group_by?
53
+ child = @iterator_obj.find_child GROUP_BY
54
+ return false unless child
55
+
56
+ return true
57
+ end
58
+
59
+ #
60
+ # Get the child that is the group by.
61
+ # Return nil if there is no group by.
62
+ #
63
+ def group_by_value obj_can
64
+ return nil unless obj_can
65
+
66
+ child = @iterator_obj.find_child GROUP_BY
67
+ return nil unless child
68
+
69
+ group_by_child_name = child.value
70
+
71
+ obj = obj_can.find_child( group_by_child_name )
72
+ return nil unless obj
73
+
74
+ return obj.value
75
+ end
76
+
77
+ #
78
+ # Run the on group start script.
79
+ #
80
+ def run_on_group_start
81
+ o = @iterator_obj.find_child ON_GROUP_START
82
+ return unless o
83
+
84
+ Gloo::Exec::Dispatch.message( @engine, 'run', o )
85
+ end
86
+
87
+ #
88
+ # Run the on group end script.
89
+ #
90
+ def run_on_group_end
91
+ o = @iterator_obj.find_child ON_GROUP_END
92
+ return unless o
93
+
94
+ Gloo::Exec::Dispatch.message( @engine, 'run', o )
95
+ end
96
+
37
97
 
38
98
  # ---------------------------------------------------------------------
39
99
  # Iterate
@@ -46,11 +106,38 @@ module Gloo
46
106
  o = @iterator_obj.find_child IN
47
107
  return unless o
48
108
 
109
+ # Set up for optional groups.
110
+ group_mode = false
111
+ if has_group_by?
112
+ group_mode = true
113
+ last_group = nil
114
+ first_time = true
115
+ end
116
+
49
117
  o = Gloo::Objs::Alias.resolve_alias( @engine, o )
50
118
  o.children.each do |child|
119
+ if group_mode
120
+ group_value = group_by_value( child )
121
+ # puts "last group = #{last_group}, group_value = #{group_value}"
122
+ if last_group != group_value
123
+ last_group = group_value
124
+ # puts "New group: #{group_value}"
125
+ if first_time
126
+ first_time = false
127
+ else
128
+ run_on_group_end
129
+ end
130
+ run_on_group_start
131
+ end
132
+ end
133
+
51
134
  set_child child
52
135
  @iterator_obj.run_do
53
136
  end
137
+
138
+ if group_mode && !first_time
139
+ run_on_group_end
140
+ end
54
141
  end
55
142
 
56
143
  #
@@ -137,6 +137,8 @@ module Gloo
137
137
 
138
138
  h = {}
139
139
  params_can.children.each do |o|
140
+ # resolve aliases
141
+ o = Gloo::Objs::Alias.resolve_alias( @engine, o )
140
142
  h[ o.name ] = o.value
141
143
  end
142
144
 
@@ -9,7 +9,7 @@ module Gloo
9
9
  class Load < Gloo::Core::Verb
10
10
 
11
11
  KEYWORD = 'load'.freeze
12
- KEYWORD_SHORT = '<'.freeze
12
+ KEYWORD_SHORT = 'ld'.freeze
13
13
  MISSING_EXPR_ERR = 'Missing Expression!'.freeze
14
14
 
15
15
  #
@@ -9,7 +9,7 @@ module Gloo
9
9
  class Save < Gloo::Core::Verb
10
10
 
11
11
  KEYWORD = 'save'.freeze
12
- KEYWORD_SHORT = '>'.freeze
12
+ KEYWORD_SHORT = 'sv'.freeze
13
13
 
14
14
  #
15
15
  # Run the verb.
@@ -9,7 +9,7 @@ module Gloo
9
9
  class Show < Gloo::Core::Verb
10
10
 
11
11
  KEYWORD = 'show'.freeze
12
- KEYWORD_SHORT = '='.freeze
12
+ KEYWORD_SHORT = 'print'.freeze
13
13
 
14
14
  #
15
15
  # Run the verb.
@@ -73,8 +73,8 @@ module Gloo
73
73
  end
74
74
 
75
75
  str += "<tr class='#{styles[ ROW ]}'>"
76
- str += "<th style='#{styles[ HEAD_CELL ]}'>#{head[ :title ]}</th>"
77
- str += "<td style='#{styles[ CELL ]}'>#{cell_value}</td>"
76
+ str += "<th class='#{styles[ HEAD_CELL ]}'>#{head[ :title ]}</th>"
77
+ str += "<td class='#{styles[ CELL ]}'>#{cell_value}</td>"
78
78
  str += "</tr>"
79
79
  end
80
80
 
@@ -113,7 +113,7 @@ module Gloo
113
113
  else
114
114
  cell_value = cell
115
115
  end
116
- str += "<td style='#{styles[ CELL ]}'>#{cell_value}</td>"
116
+ str += "<td class='#{styles[ CELL ]}'>#{cell_value}</td>"
117
117
  end
118
118
  str += "</tr>"
119
119
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gloo
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.8.0
4
+ version: 3.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Crane
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-23 00:00:00.000000000 Z
11
+ date: 2025-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -419,6 +419,12 @@ files:
419
419
  - lib/gloo/expr/l_integer.rb
420
420
  - lib/gloo/expr/l_string.rb
421
421
  - lib/gloo/expr/op_div.rb
422
+ - lib/gloo/expr/op_eq.rb
423
+ - lib/gloo/expr/op_gt.rb
424
+ - lib/gloo/expr/op_gteq.rb
425
+ - lib/gloo/expr/op_ineq.rb
426
+ - lib/gloo/expr/op_lt.rb
427
+ - lib/gloo/expr/op_lteq.rb
422
428
  - lib/gloo/expr/op_minus.rb
423
429
  - lib/gloo/expr/op_mult.rb
424
430
  - lib/gloo/expr/op_plus.rb