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
|
@@ -56,7 +56,7 @@ module Gloo
|
|
|
56
56
|
# Get a list of message names that this object receives.
|
|
57
57
|
#
|
|
58
58
|
def self.messages
|
|
59
|
-
return super + %w[inc dec randomize]
|
|
59
|
+
return super + %w[inc dec randomize format]
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
#
|
|
@@ -100,6 +100,24 @@ module Gloo
|
|
|
100
100
|
return rand_value
|
|
101
101
|
end
|
|
102
102
|
|
|
103
|
+
#
|
|
104
|
+
# Format the integer.
|
|
105
|
+
# With no parameter, adds comma separators (Ex: 1000 -> 1,000).
|
|
106
|
+
# With a parameter, uses it as a sprintf-style format string (Ex: '%05d').
|
|
107
|
+
#
|
|
108
|
+
# @param format [String] The sprintf-style format to use.
|
|
109
|
+
#
|
|
110
|
+
def msg_format
|
|
111
|
+
if @params&.token_count&.positive?
|
|
112
|
+
expr = Gloo::Expr::Expression.new( @engine, @params.tokens )
|
|
113
|
+
fmt = expr.evaluate
|
|
114
|
+
formatted = format( fmt, value )
|
|
115
|
+
else
|
|
116
|
+
formatted = value.to_s.reverse.scan( /.{1,3}/ ).join( ',' ).reverse
|
|
117
|
+
end
|
|
118
|
+
@engine.heap.it.set_to formatted
|
|
119
|
+
end
|
|
120
|
+
|
|
103
121
|
end
|
|
104
122
|
end
|
|
105
123
|
end
|
|
@@ -9,9 +9,6 @@ module Gloo
|
|
|
9
9
|
module Objs
|
|
10
10
|
class StringGenerator
|
|
11
11
|
|
|
12
|
-
# TO DO: Consider adding in Faker generators as well.
|
|
13
|
-
|
|
14
|
-
|
|
15
12
|
# ---------------------------------------------------------------------
|
|
16
13
|
# Generators
|
|
17
14
|
# ---------------------------------------------------------------------
|
|
@@ -26,21 +23,21 @@ module Gloo
|
|
|
26
23
|
#
|
|
27
24
|
# Generate a random alphanumeric string.
|
|
28
25
|
#
|
|
29
|
-
def self.alphanumeric len=10
|
|
26
|
+
def self.alphanumeric( len = 10 )
|
|
30
27
|
return SecureRandom.alphanumeric( len )
|
|
31
28
|
end
|
|
32
29
|
|
|
33
30
|
#
|
|
34
31
|
# Generate a random hex string.
|
|
35
32
|
#
|
|
36
|
-
def self.hex len=10
|
|
37
|
-
|
|
33
|
+
def self.hex( len = 10 )
|
|
34
|
+
return SecureRandom.hex( len )
|
|
38
35
|
end
|
|
39
36
|
|
|
40
37
|
#
|
|
41
38
|
# Generate a random base64 string.
|
|
42
39
|
#
|
|
43
|
-
def self.base64 len=12
|
|
40
|
+
def self.base64( len = 12 )
|
|
44
41
|
return SecureRandom.base64( len )
|
|
45
42
|
end
|
|
46
43
|
|
|
@@ -118,10 +118,8 @@ module Gloo
|
|
|
118
118
|
o.children.each do |child|
|
|
119
119
|
if group_mode
|
|
120
120
|
group_value = group_by_value( child )
|
|
121
|
-
# puts "last group = #{last_group}, group_value = #{group_value}"
|
|
122
121
|
if last_group != group_value
|
|
123
122
|
last_group = group_value
|
|
124
|
-
# puts "New group: #{group_value}"
|
|
125
123
|
if first_time
|
|
126
124
|
first_time = false
|
|
127
125
|
else
|
|
@@ -63,12 +63,9 @@ module Gloo
|
|
|
63
63
|
# Get the result, the return value or container of objects.
|
|
64
64
|
#
|
|
65
65
|
def result
|
|
66
|
-
return_any = find_child RESULT
|
|
67
|
-
|
|
68
66
|
# TODO: what does it look like to return objects?
|
|
69
67
|
# if return_any is a container with children, return the container
|
|
70
|
-
|
|
71
|
-
return return_any ? return_any.value : nil
|
|
68
|
+
return find_child_value RESULT
|
|
72
69
|
end
|
|
73
70
|
|
|
74
71
|
#
|
|
@@ -128,7 +125,7 @@ module Gloo
|
|
|
128
125
|
|
|
129
126
|
#
|
|
130
127
|
# Send the object the invoke message.
|
|
131
|
-
# Invoke the
|
|
128
|
+
# Invoke the function and return the result.
|
|
132
129
|
#
|
|
133
130
|
def msg_invoke
|
|
134
131
|
return invoke( nil )
|
|
@@ -59,10 +59,10 @@ module Gloo
|
|
|
59
59
|
# Get a list of message names that this object receives.
|
|
60
60
|
#
|
|
61
61
|
def self.messages
|
|
62
|
-
return super + %w[now add sub is_today is_future
|
|
62
|
+
return super + %w[now add sub is_today is_future
|
|
63
63
|
is_past is_yesterday is_tomorrow is_this_week
|
|
64
64
|
begin_day end_day begin_week end_week
|
|
65
|
-
begin_month end_month begin_year end_year]
|
|
65
|
+
begin_month end_month begin_year end_year format]
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
#
|
|
@@ -102,20 +102,15 @@ module Gloo
|
|
|
102
102
|
# Set the value to the beginning of the month.
|
|
103
103
|
#
|
|
104
104
|
def msg_begin_month
|
|
105
|
-
# dt = DtTools.beginning_of_month( self.value.to_time )
|
|
106
105
|
dt = self.value.to_time.beginning_of_month
|
|
107
106
|
self.set_value dt
|
|
108
107
|
@engine.heap.it.set_to dt
|
|
109
|
-
|
|
110
|
-
self.set_value dt
|
|
111
|
-
@engine.heap.it.set_to dt
|
|
112
108
|
end
|
|
113
109
|
|
|
114
110
|
#
|
|
115
111
|
# Set the value to the end of the month.
|
|
116
112
|
#
|
|
117
113
|
def msg_end_month
|
|
118
|
-
# dt = DtTools.end_of_month( self.value.to_time )
|
|
119
114
|
dt = self.value.to_time.end_of_month
|
|
120
115
|
self.set_value dt
|
|
121
116
|
@engine.heap.it.set_to dt
|
|
@@ -237,7 +232,23 @@ module Gloo
|
|
|
237
232
|
self.set_value( DateTime.now )
|
|
238
233
|
@engine.heap.it.set_to self.value
|
|
239
234
|
end
|
|
240
|
-
|
|
235
|
+
|
|
236
|
+
#
|
|
237
|
+
# Format the date and time.
|
|
238
|
+
#
|
|
239
|
+
# @param format [String] The format to use.
|
|
240
|
+
#
|
|
241
|
+
def msg_format
|
|
242
|
+
format = "%Y-%m-%d %H:%M:%S"
|
|
243
|
+
if @params&.token_count&.positive?
|
|
244
|
+
expr = Gloo::Expr::Expression.new( @engine, @params.tokens )
|
|
245
|
+
data = expr.evaluate
|
|
246
|
+
format = data
|
|
247
|
+
end
|
|
248
|
+
dt = Chronic.parse( self.value )
|
|
249
|
+
@engine.heap.it.set_to dt.strftime( format )
|
|
250
|
+
end
|
|
251
|
+
|
|
241
252
|
end
|
|
242
253
|
end
|
|
243
254
|
end
|
|
@@ -76,14 +76,14 @@ class DtTools
|
|
|
76
76
|
# Is the date in the past?
|
|
77
77
|
#
|
|
78
78
|
def self.is_past?( dt )
|
|
79
|
-
|
|
79
|
+
dt < Time.now.beginning_of_day
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
-
#
|
|
82
|
+
#
|
|
83
83
|
# Is the date in the future?
|
|
84
|
-
#
|
|
84
|
+
#
|
|
85
85
|
def self.is_future?( dt )
|
|
86
|
-
|
|
86
|
+
dt > Time.now.end_of_day
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
#
|
|
@@ -132,28 +132,108 @@ class DtTools
|
|
|
132
132
|
|
|
133
133
|
|
|
134
134
|
# ---------------------------------------------------------------------
|
|
135
|
-
#
|
|
135
|
+
# Comparison
|
|
136
136
|
# ---------------------------------------------------------------------
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
# Kind pairings that can never be compared, even though both sides
|
|
139
|
+
# look like date/time values (eg. a time can't be compared to a date).
|
|
140
|
+
INCOMPATIBLE_DT_KINDS = [
|
|
141
|
+
[ :date, :time ], [ :time, :date ],
|
|
142
|
+
[ :time, :datetime ], [ :datetime, :time ]
|
|
143
|
+
].freeze
|
|
144
|
+
|
|
145
|
+
#
|
|
146
|
+
# What kind of date/time value does this string look like?
|
|
147
|
+
# Returns :date, :time, :datetime, or nil if it doesn't match
|
|
148
|
+
# the exact format that gloo date/time/datetime objects use.
|
|
149
|
+
#
|
|
150
|
+
def self.dt_kind( value )
|
|
151
|
+
return nil unless value.is_a? String
|
|
152
|
+
return :datetime if value =~ /\A\d{4}\.\d{2}\.\d{2}\s\d{2}:\d{2}:\d{2}\s(am|pm)\z/i
|
|
153
|
+
return :date if value =~ /\A\d{4}\.\d{2}\.\d{2}\z/
|
|
154
|
+
return :time if value =~ /\A\d{2}:\d{2}:\d{2}\s(am|pm)\z/i
|
|
155
|
+
|
|
156
|
+
return nil
|
|
141
157
|
end
|
|
142
|
-
|
|
143
|
-
#
|
|
144
|
-
#
|
|
145
|
-
#
|
|
146
|
-
def self.
|
|
147
|
-
|
|
148
|
-
|
|
158
|
+
|
|
159
|
+
#
|
|
160
|
+
# Strictly parse a string using the exact format for the given kind.
|
|
161
|
+
#
|
|
162
|
+
def self.strict_dt_parse( kind, str )
|
|
163
|
+
format = { date: Gloo::Objs::Date::DEFAULT_FORMAT,
|
|
164
|
+
time: Gloo::Objs::Time::DEFAULT_FORMAT,
|
|
165
|
+
datetime: Gloo::Objs::Datetime::DEFAULT_FORMAT }[ kind ]
|
|
166
|
+
return ::DateTime.strptime( str, format )
|
|
167
|
+
rescue StandardError
|
|
168
|
+
return nil
|
|
149
169
|
end
|
|
150
170
|
|
|
151
|
-
#
|
|
152
|
-
#
|
|
153
|
-
#
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
171
|
+
#
|
|
172
|
+
# Reduce a parsed value down to the granularity of the given kind,
|
|
173
|
+
# so a strictly-parsed value and a loosely-parsed value can be compared.
|
|
174
|
+
#
|
|
175
|
+
def self.normalize_dt( kind, dt )
|
|
176
|
+
return dt.to_date if kind == :date
|
|
177
|
+
return [ dt.hour, dt.min, dt.sec ] if kind == :time
|
|
178
|
+
|
|
179
|
+
return dt
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
#
|
|
183
|
+
# Loosely parse an arbitrary string (eg. "3 days from now") and reduce
|
|
184
|
+
# it to the granularity of the given kind for comparison.
|
|
185
|
+
#
|
|
186
|
+
# Bare numbers (eg. "11", "2026") are rejected even though Chronic can
|
|
187
|
+
# parse them - it treats them as an hour or day-of-month relative to
|
|
188
|
+
# today, which is misleading rather than a genuine date/time value.
|
|
189
|
+
#
|
|
190
|
+
def self.loose_dt_parse( kind, str )
|
|
191
|
+
return nil if str =~ /\A\s*\d+\s*\z/
|
|
192
|
+
|
|
193
|
+
dt = Chronic.parse( str )
|
|
194
|
+
return nil if dt.nil?
|
|
195
|
+
|
|
196
|
+
return normalize_dt( kind, dt.to_datetime )
|
|
197
|
+
rescue StandardError
|
|
198
|
+
return nil
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
#
|
|
202
|
+
# Compare two raw values with date/time/datetime semantics.
|
|
203
|
+
# Returns :not_dt if neither value looks like a date, time, or datetime,
|
|
204
|
+
# so the caller can fall back to its normal comparison logic.
|
|
205
|
+
# Otherwise returns -1, 0, or 1 (as with <=>), or nil if the two
|
|
206
|
+
# values can't be meaningfully compared.
|
|
207
|
+
#
|
|
208
|
+
def self.compare_dt( left, right )
|
|
209
|
+
l_kind = dt_kind( left )
|
|
210
|
+
r_kind = dt_kind( right )
|
|
211
|
+
return :not_dt if l_kind.nil? && r_kind.nil?
|
|
212
|
+
|
|
213
|
+
if l_kind && r_kind
|
|
214
|
+
return nil if INCOMPATIBLE_DT_KINDS.include?( [ l_kind, r_kind ] )
|
|
215
|
+
|
|
216
|
+
l = strict_dt_parse( l_kind, left )
|
|
217
|
+
r = strict_dt_parse( r_kind, right )
|
|
218
|
+
return nil if l.nil? || r.nil?
|
|
219
|
+
|
|
220
|
+
return l <=> r
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# Only one side looks like a date/time/datetime value. Try to parse
|
|
224
|
+
# the other side as that same kind (eg. a date compared to a string).
|
|
225
|
+
kind = l_kind || r_kind
|
|
226
|
+
known, other = l_kind ? [ left, right ] : [ right, left ]
|
|
227
|
+
return nil unless other.is_a? String
|
|
228
|
+
|
|
229
|
+
k = strict_dt_parse( kind, known )
|
|
230
|
+
return nil if k.nil?
|
|
231
|
+
|
|
232
|
+
o = loose_dt_parse( kind, other )
|
|
233
|
+
return nil if o.nil?
|
|
234
|
+
|
|
235
|
+
result = normalize_dt( kind, k ) <=> o
|
|
236
|
+
return l_kind ? result : -result
|
|
157
237
|
end
|
|
158
238
|
|
|
159
239
|
end
|
data/lib/gloo/objs/dt/time.rb
CHANGED
|
@@ -58,7 +58,7 @@ module Gloo
|
|
|
58
58
|
# Get a list of message names that this object receives.
|
|
59
59
|
#
|
|
60
60
|
def self.messages
|
|
61
|
-
return super + %w[now add sub hh mm ss am]
|
|
61
|
+
return super + %w[now add sub hh mm ss am format]
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
#
|
|
@@ -133,6 +133,22 @@ module Gloo
|
|
|
133
133
|
dt = Chronic.parse( self.value )
|
|
134
134
|
@engine.heap.it.set_to dt.strftime( '%p' )
|
|
135
135
|
end
|
|
136
|
+
|
|
137
|
+
#
|
|
138
|
+
# Format the time.
|
|
139
|
+
#
|
|
140
|
+
# @param format [String] The format to use.
|
|
141
|
+
#
|
|
142
|
+
def msg_format
|
|
143
|
+
format = "%H:%M:%S"
|
|
144
|
+
if @params&.token_count&.positive?
|
|
145
|
+
expr = Gloo::Expr::Expression.new( @engine, @params.tokens )
|
|
146
|
+
data = expr.evaluate
|
|
147
|
+
format = data
|
|
148
|
+
end
|
|
149
|
+
dt = Chronic.parse( self.value )
|
|
150
|
+
@engine.heap.it.set_to dt.strftime( format )
|
|
151
|
+
end
|
|
136
152
|
end
|
|
137
153
|
end
|
|
138
154
|
end
|
|
@@ -37,8 +37,7 @@ module Gloo
|
|
|
37
37
|
# Returns nil if there is none.
|
|
38
38
|
#
|
|
39
39
|
def key
|
|
40
|
-
|
|
41
|
-
return o&.value
|
|
40
|
+
return find_child_value KEY
|
|
42
41
|
end
|
|
43
42
|
|
|
44
43
|
#
|
|
@@ -46,25 +45,23 @@ module Gloo
|
|
|
46
45
|
# Returns nil if there is none.
|
|
47
46
|
#
|
|
48
47
|
def init_vector
|
|
49
|
-
|
|
50
|
-
return o&.value
|
|
48
|
+
return find_child_value INIT_VECTOR
|
|
51
49
|
end
|
|
52
50
|
|
|
53
51
|
#
|
|
54
52
|
# Get the data value of the object.
|
|
55
|
-
# This might be encrypted or decrypted based on
|
|
53
|
+
# This might be encrypted or decrypted based on
|
|
56
54
|
# what action was last taken.
|
|
57
55
|
#
|
|
58
56
|
def data
|
|
59
|
-
|
|
60
|
-
return o&.value
|
|
57
|
+
return find_child_value DATA
|
|
61
58
|
end
|
|
62
59
|
|
|
63
60
|
#
|
|
64
61
|
# Update the key value.
|
|
65
62
|
#
|
|
66
63
|
def update_key( new_val )
|
|
67
|
-
o =
|
|
64
|
+
o = find_child_resolve_alias KEY
|
|
68
65
|
return unless o
|
|
69
66
|
|
|
70
67
|
o.set_value new_val
|
|
@@ -74,7 +71,7 @@ module Gloo
|
|
|
74
71
|
# Update the initialization vector value.
|
|
75
72
|
#
|
|
76
73
|
def update_init_vector( new_val )
|
|
77
|
-
o =
|
|
74
|
+
o = find_child_resolve_alias INIT_VECTOR
|
|
78
75
|
return unless o
|
|
79
76
|
|
|
80
77
|
o.set_value new_val
|
|
@@ -84,7 +81,7 @@ module Gloo
|
|
|
84
81
|
# Update the data value of the object.
|
|
85
82
|
#
|
|
86
83
|
def update_data( new_val )
|
|
87
|
-
o =
|
|
84
|
+
o = find_child_resolve_alias DATA
|
|
88
85
|
return unless o
|
|
89
86
|
|
|
90
87
|
o.set_value new_val
|
|
@@ -137,7 +134,7 @@ module Gloo
|
|
|
137
134
|
key = Base64.encode64 key
|
|
138
135
|
update_key key
|
|
139
136
|
|
|
140
|
-
iv =
|
|
137
|
+
iv = cipher.random_iv
|
|
141
138
|
iv = Base64.encode64 iv
|
|
142
139
|
update_init_vector iv
|
|
143
140
|
end
|
data/lib/gloo/objs/system/erb.rb
CHANGED
|
@@ -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 that
|
|
4
|
+
# An object that evaluates an ERB template.
|
|
5
5
|
#
|
|
6
6
|
require 'erb'
|
|
7
7
|
|
|
@@ -34,17 +34,16 @@ module Gloo
|
|
|
34
34
|
#
|
|
35
35
|
def template_value
|
|
36
36
|
tmpl = find_child TEMPLATE
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return tmpl.value
|
|
37
|
+
tmpl = Gloo::Objs::Alias.resolve_alias( @engine, tmpl )
|
|
38
|
+
return tmpl&.value
|
|
40
39
|
end
|
|
41
40
|
|
|
42
41
|
#
|
|
43
42
|
# Set the result of the ERB template conversion.
|
|
44
43
|
#
|
|
45
44
|
def set_result( data )
|
|
46
|
-
r =
|
|
47
|
-
return
|
|
45
|
+
r = find_child_resolve_alias RESULT
|
|
46
|
+
return unless r
|
|
48
47
|
|
|
49
48
|
r.set_value data
|
|
50
49
|
end
|
|
@@ -30,22 +30,19 @@ module Gloo
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
#
|
|
33
|
-
# Get the
|
|
33
|
+
# Get the command from the child object.
|
|
34
34
|
# Returns nil if there is none.
|
|
35
35
|
#
|
|
36
36
|
def cmd_value
|
|
37
|
-
|
|
38
|
-
return nil unless cmd
|
|
39
|
-
|
|
40
|
-
return cmd.value
|
|
37
|
+
return find_child_value CMD
|
|
41
38
|
end
|
|
42
39
|
|
|
43
40
|
#
|
|
44
41
|
# Set the result of the system call.
|
|
45
42
|
#
|
|
46
43
|
def set_result( data )
|
|
47
|
-
r =
|
|
48
|
-
return
|
|
44
|
+
r = find_child_resolve_alias RESULT
|
|
45
|
+
return unless r
|
|
49
46
|
|
|
50
47
|
r.set_value data
|
|
51
48
|
end
|
|
@@ -56,10 +53,7 @@ module Gloo
|
|
|
56
53
|
# otherwise it will just get the result of the call.
|
|
57
54
|
#
|
|
58
55
|
def output?
|
|
59
|
-
|
|
60
|
-
return false unless o
|
|
61
|
-
|
|
62
|
-
return o.value
|
|
56
|
+
return find_child_value GET_OUTPUT
|
|
63
57
|
end
|
|
64
58
|
|
|
65
59
|
# ---------------------------------------------------------------------
|
|
@@ -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 that can
|
|
4
|
+
# An object that can make an HTTP GET request.
|
|
5
5
|
#
|
|
6
6
|
require 'net/http'
|
|
7
7
|
require 'uri'
|
|
@@ -111,28 +111,22 @@ module Gloo
|
|
|
111
111
|
# Returns nil if there is none.
|
|
112
112
|
#
|
|
113
113
|
def uri_value
|
|
114
|
-
|
|
115
|
-
return nil unless uri
|
|
116
|
-
|
|
117
|
-
return uri.value
|
|
114
|
+
return find_child_value URL
|
|
118
115
|
end
|
|
119
116
|
|
|
120
117
|
#
|
|
121
118
|
# Should we skip SSL verification during the request?
|
|
122
119
|
#
|
|
123
120
|
def skip_ssl_verify?
|
|
124
|
-
|
|
125
|
-
return false unless skip
|
|
126
|
-
|
|
127
|
-
return skip.value
|
|
121
|
+
return find_child_value( SKIP_SSL_VERIFY ) || false
|
|
128
122
|
end
|
|
129
123
|
|
|
130
124
|
#
|
|
131
125
|
# Set the result of the API call.
|
|
132
126
|
#
|
|
133
127
|
def update_result( data )
|
|
134
|
-
r =
|
|
135
|
-
return
|
|
128
|
+
r = find_child_resolve_alias RESULT
|
|
129
|
+
return unless r
|
|
136
130
|
|
|
137
131
|
r.set_value data
|
|
138
132
|
end
|
|
@@ -142,7 +136,7 @@ module Gloo
|
|
|
142
136
|
#
|
|
143
137
|
def full_url_value
|
|
144
138
|
p = ''
|
|
145
|
-
params =
|
|
139
|
+
params = find_child_resolve_alias PARAMS
|
|
146
140
|
params.children.each do |child|
|
|
147
141
|
p << ( p.empty? ? '?' : '&' )
|
|
148
142
|
|
|
@@ -37,10 +37,7 @@ module Gloo
|
|
|
37
37
|
# Returns nil if there is none.
|
|
38
38
|
#
|
|
39
39
|
def uri_value
|
|
40
|
-
|
|
41
|
-
return nil unless uri
|
|
42
|
-
|
|
43
|
-
return uri.value
|
|
40
|
+
return find_child_value URL
|
|
44
41
|
end
|
|
45
42
|
|
|
46
43
|
#
|
|
@@ -50,7 +47,7 @@ module Gloo
|
|
|
50
47
|
def body_as_json
|
|
51
48
|
h = {}
|
|
52
49
|
|
|
53
|
-
body =
|
|
50
|
+
body = find_child_resolve_alias BODY
|
|
54
51
|
body.children.each do |child|
|
|
55
52
|
child_val = Gloo::Objs::Alias.resolve_alias( @engine, child )
|
|
56
53
|
h[ child.name ] = child_val.value
|
|
@@ -63,8 +60,8 @@ module Gloo
|
|
|
63
60
|
# Set the result of the API call.
|
|
64
61
|
#
|
|
65
62
|
def update_result( data )
|
|
66
|
-
r =
|
|
67
|
-
return
|
|
63
|
+
r = find_child_resolve_alias RESULT
|
|
64
|
+
return unless r
|
|
68
65
|
|
|
69
66
|
r.set_value data
|
|
70
67
|
end
|
|
@@ -142,26 +139,6 @@ module Gloo
|
|
|
142
139
|
end
|
|
143
140
|
end
|
|
144
141
|
|
|
145
|
-
# #
|
|
146
|
-
# # Post the content to the endpoint.
|
|
147
|
-
# #
|
|
148
|
-
# def self.post_json_1( url, body, use_ssl = true )
|
|
149
|
-
# # Structure the request
|
|
150
|
-
# uri = URI.parse( url )
|
|
151
|
-
#
|
|
152
|
-
# request = Net::HTTP::Post.new( uri.path )
|
|
153
|
-
# request.content_type = 'application/json'
|
|
154
|
-
# request.body = body
|
|
155
|
-
# n = Net::HTTP.new( uri.host, uri.port )
|
|
156
|
-
# n.use_ssl = use_ssl
|
|
157
|
-
#
|
|
158
|
-
# # Send the payload to the endpoint.
|
|
159
|
-
# result = n.start { |http| http.request( request ) }
|
|
160
|
-
# @engine.log.debug result.code
|
|
161
|
-
# @engine.log.debug result.message
|
|
162
|
-
# return result.body
|
|
163
|
-
# end
|
|
164
|
-
|
|
165
142
|
# ---------------------------------------------------------------------
|
|
166
143
|
# Private functions
|
|
167
144
|
# ---------------------------------------------------------------------
|
|
@@ -172,10 +149,7 @@ module Gloo
|
|
|
172
149
|
# Should we skip SSL verification during the request?
|
|
173
150
|
#
|
|
174
151
|
def skip_ssl_verify?
|
|
175
|
-
|
|
176
|
-
return false unless skip
|
|
177
|
-
|
|
178
|
-
return skip.value
|
|
152
|
+
return find_child_value( SKIP_SSL_VERIFY ) || false
|
|
179
153
|
end
|
|
180
154
|
|
|
181
155
|
end
|
data/lib/gloo/objs/web/json.rb
CHANGED
data/lib/gloo/objs/web/uri.rb
CHANGED
|
@@ -62,7 +62,7 @@ module Gloo
|
|
|
62
62
|
#
|
|
63
63
|
def msg_get_cert_expires
|
|
64
64
|
return unless value
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
uri = URI( value )
|
|
67
67
|
response = Net::HTTP.start( uri.host, uri.port, :use_ssl => true )
|
|
68
68
|
cert = response.peer_cert
|
|
@@ -143,7 +143,7 @@ module Gloo
|
|
|
143
143
|
|
|
144
144
|
|
|
145
145
|
# ---------------------------------------------------------------------
|
|
146
|
-
# Helper
|
|
146
|
+
# Helper function to open a URL
|
|
147
147
|
# ---------------------------------------------------------------------
|
|
148
148
|
|
|
149
149
|
#
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
# Copyright:: Copyright (c) 2022 Eric Crane. All rights reserved.
|
|
3
3
|
#
|
|
4
4
|
# Disc based mechanism for files.
|
|
5
|
-
# Provides interaction between the
|
|
5
|
+
# Provides interaction between the persistence classes and the OS
|
|
6
6
|
# file and folder system.
|
|
7
|
-
# This class might be
|
|
7
|
+
# This class might be overridden elsewhere to provide other mechanism.
|
|
8
8
|
# For example, in gloo-web, there will be a db based mechanism.
|
|
9
9
|
#
|
|
10
10
|
|