gloo 3.4.0 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34119d3b6c3fc676b45d7172a6300e1bef50e7bfd480ecaaeab9ad39be040cc4
4
- data.tar.gz: b812253883e7589dea4b6588b85661a1cf6e849a61e2c36a658be8279a0a6411
3
+ metadata.gz: b527dd8c4837506689358a05681e7e81ba5804aeb617815db80e014a6f0f381b
4
+ data.tar.gz: 9d0d089ff54f1c669ee3b1009411e8a0310ed01792b008946f3fee8feff89313
5
5
  SHA512:
6
- metadata.gz: 33d90fe0f4135042d0d5d6cfa4323438183e43e034ce525542bff0aa34bd16baf703ed7819de51c5ad19b38dd51fec8423a4999179e08e41e0dbc89ad0f3d20c
7
- data.tar.gz: 017e592805017fc75f776a9a1673eb50aba32ef227260c573f382e8dc83d067ac2429b1f18d722df22672b8f7c57cd941769180d517398db74cde98aeb56a64d
6
+ metadata.gz: f0632bc38a33051cbe970e0f29e01fac34d29ad9988df31773518c5cdc4d501a9462ff9a3c17fd54fa5db8b5c5326fa890eb8a1d395d7dedef057b5e41da16fc
7
+ data.tar.gz: 6370739e3e635f6659ed5f28c62fd7d858cd8cb7b02e2115c29119434b8459e5cdb78dc9d1f3a547424425e41242d000216b9f89899734aa7d1e9206b4282662
data/lib/VERSION CHANGED
@@ -1 +1 @@
1
- 3.4.0
1
+ 3.5.0
data/lib/VERSION_NOTES CHANGED
@@ -1,3 +1,16 @@
1
+ 3.5.0 - 2024.10.18
2
+ - check obj for message alternate to tell
3
+ - new base object messages
4
+ - fixes issue with single row returned from query
5
+ - adds on_error event
6
+ - use aliases in pwd obj
7
+
8
+
9
+ 3.4.1 - 2024.09.23
10
+ - Removes old, unused sound objects
11
+ - Adds support for lib folder in gloo rather than in the project folder
12
+
13
+
1
14
  3.4.0 - 2024.09.22
2
15
  - Refactor for old TTY lib
3
16
  - Additional web server functionality
data/lib/gloo/app/args.rb CHANGED
@@ -51,12 +51,12 @@ module Gloo
51
51
  return true unless app?
52
52
 
53
53
  if @app_path.nil?
54
- @engine.log.error "App Path required to run in App mode."
54
+ @engine.err "App Path required to run in App mode."
55
55
  return false
56
56
  end
57
57
 
58
58
  unless File.directory? @app_path
59
- @engine.log.error "'#{@app_path}' is not a valid directory."
59
+ @engine.err "'#{@app_path}' is not a valid directory."
60
60
  return false
61
61
  end
62
62
 
@@ -201,7 +201,7 @@ module Gloo
201
201
  begin
202
202
  @parser.run @last_cmd
203
203
  rescue => e
204
- err e.message
204
+ log_exception e
205
205
  end
206
206
  end
207
207
 
@@ -282,11 +282,30 @@ module Gloo
282
282
  # Report an error.
283
283
  # Write it to the log and set the heap error value.
284
284
  #
285
- def err( msg )
285
+ def err( msg, backtrace=nil )
286
286
  @log.error msg
287
287
  @heap.error.set_to msg
288
+
289
+ @event_manager.on_error( msg, backtrace)
288
290
  end
289
291
 
292
+ #
293
+ # Log an exception.
294
+ # This function does not log the full backtrace, but
295
+ # does write part of it to the log.
296
+ #
297
+ def log_exception ex
298
+ # Get the stack trace, and if needed truncate to fit.
299
+ msg_lines = ex.backtrace
300
+ if msg_lines.count > 27
301
+ msg_lines = msg_lines[0..13] + [ '... truncated ...' ] + msg_lines[-13..-1]
302
+ end
303
+ backtrace = msg_lines.join( "\n" )
304
+ @log.error backtrace
305
+
306
+ err( ex.message, backtrace)
307
+ end
308
+
290
309
  end
291
310
  end
292
311
  end
@@ -30,8 +30,7 @@ module Gloo
30
30
  o = clazz.new
31
31
  return o.convert( value )
32
32
  rescue => e
33
- @engine.log.error e.message
34
- @engine.heap.error.set_to e.message
33
+ @engine.log_exception e
35
34
  end
36
35
 
37
36
  return default
@@ -190,7 +190,7 @@ module Gloo
190
190
  #
191
191
  def add_key( keyword )
192
192
  if @keywords.include?( keyword )
193
- # @engine.log.error "duplicate keyword '#{keyword}'"
193
+ # @engine.err "duplicate keyword '#{keyword}'"
194
194
  return
195
195
  end
196
196
 
@@ -72,6 +72,25 @@ module Gloo
72
72
  arr.each { |o| Gloo::Exec::Dispatch.message( @engine, 'run', o ) }
73
73
  end
74
74
 
75
+ #
76
+ # Run the on_error scripts in any open objects.
77
+ # For each on_error script found, look for the error_data container
78
+ # and set the error message and backtrace.
79
+ #
80
+ def on_error msg, backtrace
81
+ @engine.log.debug 'on_error event'
82
+ arr = Gloo::Core::ObjFinder.by_name( @engine, 'on_error' )
83
+ arr.each do |o|
84
+ data = o.parent.find_child 'error_data'
85
+ if data
86
+ data.find_child( 'message' ).set_value msg
87
+ data.find_child( 'backtrace' ).set_value backtrace
88
+ end
89
+
90
+ Gloo::Exec::Dispatch.message( @engine, 'run', o )
91
+ end
92
+ end
93
+
75
94
  end
76
95
  end
77
96
  end
@@ -164,7 +164,7 @@ module Gloo
164
164
  #
165
165
  def create_new( name, value, type, parent )
166
166
  unless parent
167
- @engine.log.error "Could not create object. Bad path: #{name}"
167
+ @engine.err "Could not create object. Bad path: #{name}"
168
168
  return nil
169
169
  end
170
170
 
@@ -202,7 +202,7 @@ module Gloo
202
202
  end
203
203
 
204
204
  unless t.can_create?
205
- @engine.log.error "'#{type_name}' cannot be created."
205
+ @engine.err "'#{type_name}' cannot be created."
206
206
  return nil
207
207
  end
208
208
 
@@ -138,7 +138,7 @@ module Gloo
138
138
  o = "msg_#{msg}"
139
139
  return self.public_send( o ) if self.respond_to? o
140
140
 
141
- @engine.log.error "Message #{msg} not implemented"
141
+ @engine.err "Message #{msg} not implemented"
142
142
  return false
143
143
  end
144
144
 
data/lib/gloo/core/obj.rb CHANGED
@@ -216,6 +216,30 @@ module Gloo
216
216
  return nil
217
217
  end
218
218
 
219
+ #
220
+ # Find a child, resolve any alias references.
221
+ # This returns the object, not the value.
222
+ #
223
+ def find_child_resolve_alias( name )
224
+ o = find_child name
225
+ return nil unless o
226
+
227
+ o = Gloo::Objs::Alias.resolve_alias( @engine, o )
228
+ return o
229
+ end
230
+
231
+ #
232
+ # Find a child, resolve any alias references,
233
+ # and return the object's value.
234
+ #
235
+ def find_child_value( name )
236
+ o = find_child name
237
+ return nil unless o
238
+
239
+ o = Gloo::Objs::Alias.resolve_alias( @engine, o )
240
+ return o&.value
241
+ end
242
+
219
243
  #
220
244
  # Get the index of the child with the given name.
221
245
  #
@@ -264,7 +288,7 @@ module Gloo
264
288
  # Get a list of message names that this object receives.
265
289
  #
266
290
  def self.messages
267
- return %w[reload unload]
291
+ return %w[reload unload blank? contains?]
268
292
  end
269
293
 
270
294
  #
@@ -282,7 +306,7 @@ module Gloo
282
306
  @params = params
283
307
  return self.dispatch msg if self.can_receive_message? msg
284
308
 
285
- @engine.log.error "Object #{self.name} cannot receive message #{msg}"
309
+ @engine.err "Object #{self.name} cannot receive message #{msg}"
286
310
  return false
287
311
  end
288
312
 
@@ -295,7 +319,7 @@ module Gloo
295
319
  self.public_send( o )
296
320
  return true
297
321
  else
298
- @engine.log.error "Message #{msg} not implemented"
322
+ @engine.err "Message #{msg} not implemented"
299
323
  return false
300
324
  end
301
325
  end
@@ -305,7 +329,7 @@ module Gloo
305
329
  #
306
330
  def msg_unload
307
331
  if self.root?
308
- @engine.log.error 'Cannot unload the root object.'
332
+ @engine.err 'Cannot unload the root object.'
309
333
  return
310
334
  end
311
335
 
@@ -318,13 +342,31 @@ module Gloo
318
342
  #
319
343
  def msg_reload
320
344
  if self.root?
321
- @engine.log.error 'Cannot reload the root object.'
345
+ @engine.err 'Cannot reload the root object.'
322
346
  return
323
347
  end
324
348
 
325
349
  @engine.persist_man.reload self
326
350
  end
327
351
 
352
+ #
353
+ # Check to see if the value is blank.
354
+ #
355
+ def msg_blank?
356
+ val_blank = value.blank?
357
+ @engine.heap.it.set_to val_blank
358
+ return val_blank
359
+ end
360
+
361
+ #
362
+ # Check to see if there are children.
363
+ #
364
+ def msg_contains?
365
+ has_children = child_count.positive?
366
+ @engine.heap.it.set_to has_children
367
+ return has_children
368
+ end
369
+
328
370
 
329
371
  # ---------------------------------------------------------------------
330
372
  # Render
@@ -31,7 +31,7 @@ module Gloo
31
31
  verb = dic.find_verb( tokens.verb )
32
32
  return verb.new( @engine, tokens, params ) if verb
33
33
 
34
- @engine.log.error "Verb '#{tokens.verb}' was not found."
34
+ @engine.err "Verb '#{tokens.verb}' was not found."
35
35
  return nil
36
36
  end
37
37
 
data/lib/gloo/core/pn.rb CHANGED
@@ -150,7 +150,7 @@ module Gloo
150
150
  @elements[ 0..-2 ].each do |e|
151
151
  o = o.find_child( e )
152
152
  if o.nil?
153
- @engine.log.error "Object '#{e}' was not found."
153
+ @engine.err "Object '#{e}' was not found."
154
154
  return nil
155
155
  end
156
156
  end
@@ -12,6 +12,23 @@ module Gloo
12
12
  module Exec
13
13
  class Dispatch
14
14
 
15
+ OBJ_NOT_FOUND_ERR = 'Object was not found: '.freeze
16
+
17
+ #
18
+ # Send a message to an object of a given name (and path).
19
+ # Once the object is found, the message is dispatched.
20
+ #
21
+ def self.send_message( engine, msg, to_obj_pn, params = nil )
22
+ pn = Gloo::Core::Pn.new( engine, to_obj_pn )
23
+ target_obj = pn.resolve
24
+
25
+ unless target_obj
26
+ engine.err "#{OBJ_NOT_FOUND_ERR} #{to_obj_pn}"
27
+ return
28
+ end
29
+ Gloo::Exec::Dispatch.message( engine, msg, target_obj, params )
30
+ end
31
+
15
32
  #
16
33
  # Dispatch the given message to the given object.
17
34
  #
@@ -36,7 +36,7 @@ module Gloo
36
36
  if o
37
37
  o.send_message 'run'
38
38
  else
39
- engine.log.error "Could not send message to object. Bad path: #{path_name}"
39
+ engine.err "Could not send message to object. Bad path: #{path_name}"
40
40
  end
41
41
  end
42
42
 
@@ -160,7 +160,7 @@ module Gloo
160
160
 
161
161
  heads = rs.fields if rs
162
162
  rescue => e
163
- @engine.err e.message
163
+ @engine.log_exception e
164
164
  end
165
165
 
166
166
  return [ heads, data ]
@@ -242,7 +242,7 @@ module Gloo
242
242
  }
243
243
  Mysql2::Client.new( h )
244
244
  rescue => e
245
- @engine.err e.message
245
+ @engine.log_exception e
246
246
  @engine.heap.it.set_to false
247
247
  return false
248
248
  end
@@ -189,7 +189,7 @@ module Gloo
189
189
  begin
190
190
  result = pg_conn.exec( "SELECT NOW()" )
191
191
  rescue => e
192
- @engine.err e.message
192
+ @engine.log_exception e
193
193
  @engine.heap.it.set_to false
194
194
  return false
195
195
  end
@@ -81,7 +81,7 @@ module Gloo
81
81
  result = db.query( sql_value, param_array )
82
82
  process_result( result, db )
83
83
  rescue => e
84
- @engine.err e.message
84
+ @engine.log_exception e
85
85
  return
86
86
  end
87
87
  end
@@ -105,7 +105,7 @@ module Gloo
105
105
  app.add_db_time elapsed if app
106
106
  return result
107
107
  rescue => e
108
- @engine.err e.message
108
+ @engine.log_exception e
109
109
  return
110
110
  end
111
111
  end
@@ -33,8 +33,13 @@ module Gloo
33
33
 
34
34
  #
35
35
  # Does the data contain a single row?
36
+ # OR, if the result is empty, return false.
36
37
  #
37
38
  def single_row_result?
39
+ if @result_can && ( @result_can.child_count == 0 )
40
+ return false
41
+ end
42
+
38
43
  return @data.count == 1
39
44
  end
40
45
 
@@ -108,7 +113,7 @@ module Gloo
108
113
  def update_single_row
109
114
  row = @data[0]
110
115
  @heads.each_with_index do |h, i|
111
- child = @result_can.find_child h
116
+ child = @result_can.find_child h
112
117
  child.set_value row[i] if child
113
118
  end
114
119
  end
@@ -162,7 +162,7 @@ module Gloo
162
162
  sql = "SELECT COUNT(name) FROM sqlite_master WHERE type='table'"
163
163
  db.get_first_value sql
164
164
  rescue => e
165
- @engine.err e.message
165
+ @engine.log_exception e
166
166
  @engine.heap.it.set_to false
167
167
  return false
168
168
  end
@@ -67,7 +67,7 @@ module Gloo
67
67
  result = o.run_query
68
68
  return result
69
69
  rescue => e
70
- @engine.err e.message
70
+ @engine.log_exception e
71
71
  return nil
72
72
  end
73
73
  else
@@ -196,7 +196,7 @@ module Gloo
196
196
  helper = Gloo::WebSvr::TableRenderer.new( @engine )
197
197
  return helper.data_to_table params
198
198
  rescue => e
199
- @engine.err e.message
199
+ @engine.log_exception e
200
200
  return nil
201
201
  end
202
202
  end
@@ -98,7 +98,7 @@ module Gloo
98
98
  set_result result
99
99
  @engine.heap.it.set_to result
100
100
  rescue => e
101
- @engine.err e.message
101
+ @engine.log_exception e
102
102
  end
103
103
  end
104
104
 
@@ -39,8 +39,7 @@ module Gloo
39
39
  # Returns nil if there is none.
40
40
  #
41
41
  def salt
42
- o = find_child SALT
43
- return o&.value
42
+ return find_child_value SALT
44
43
  end
45
44
 
46
45
  #
@@ -48,15 +47,14 @@ module Gloo
48
47
  # Returns nil if there is none.
49
48
  #
50
49
  def password
51
- o = find_child PASSWORD
52
- return o&.value
50
+ return find_child_value PASSWORD
53
51
  end
54
52
 
55
53
  #
56
54
  # Update the password value.
57
55
  #
58
56
  def update_password( new_pwd )
59
- o = find_child PASSWORD
57
+ o = find_child_resolve_alias PASSWORD
60
58
  return unless o
61
59
 
62
60
  o.set_value new_pwd
@@ -74,15 +72,14 @@ module Gloo
74
72
  # Returns nil if there is none.
75
73
  #
76
74
  def hash
77
- o = find_child HASH
78
- return o&.value
75
+ return find_child_value HASH
79
76
  end
80
77
 
81
78
  #
82
79
  # Update the hashed password value.
83
80
  #
84
81
  def update_hash( new_hash )
85
- o = find_child HASH
82
+ o = find_child_resolve_alias HASH
86
83
  return unless o
87
84
 
88
85
  o.set_value new_hash
@@ -242,7 +242,7 @@ module Gloo
242
242
  begin
243
243
  return e.render( render_ƒ )
244
244
  rescue => e
245
- engine.err e.message
245
+ engine.log_exception e
246
246
  return ''
247
247
  end
248
248
  end
@@ -354,7 +354,7 @@ module Gloo
354
354
  elsif is_text?
355
355
  contents = render_text params
356
356
  else
357
- @engine.log.error "Unknown content type: #{content_type}"
357
+ @engine.err "Unknown content type: #{content_type}"
358
358
  return nil
359
359
  end
360
360
 
@@ -50,6 +50,7 @@ module Gloo
50
50
  CODE = 'code'.freeze
51
51
  ELAPSED = 'elapsed'.freeze
52
52
  DB = 'db'.freeze
53
+ PAGE = 'page'.freeze
53
54
 
54
55
  # Container with pages in the web app.
55
56
  PAGES = 'pages'.freeze
@@ -426,7 +427,7 @@ module Gloo
426
427
  @engine.stop_running_app
427
428
  # The running app will call the stop function (below)
428
429
  else
429
- @engine.log.error SERVER_NOT_RUNNING
430
+ @engine.err SERVER_NOT_RUNNING
430
431
  end
431
432
  end
432
433
 
@@ -437,7 +438,7 @@ module Gloo
437
438
  if @router
438
439
  @router.show_routes
439
440
  else
440
- @engine.log.error SERVER_NOT_RUNNING
441
+ @engine.err SERVER_NOT_RUNNING
441
442
  end
442
443
  end
443
444
 
@@ -558,7 +559,7 @@ module Gloo
558
559
  # This is done after the page is rendered and before
559
560
  # the on_response event is fired.
560
561
  #
561
- def set_response_data( request, response )
562
+ def set_response_data( request, response, page_obj=nil )
562
563
  data = find_child RESPONSE_DATA
563
564
  return unless data
564
565
  data = Gloo::Objs::Alias.resolve_alias( @engine, data )
@@ -567,6 +568,10 @@ module Gloo
567
568
  data.find_child( DB )&.set_value( request.db )
568
569
  data.find_child( TYPE )&.set_value( response.type )
569
570
  data.find_child( CODE )&.set_value( response.code )
571
+
572
+ if page_obj
573
+ data.find_child( PAGE )&.set_value( page_obj.pn )
574
+ end
570
575
  end
571
576
 
572
577
 
@@ -17,6 +17,7 @@ module Gloo
17
17
  #
18
18
  def initialize( engine )
19
19
  @engine = engine
20
+ @log = @engine.log
20
21
  end
21
22
 
22
23
  #
@@ -32,6 +33,13 @@ module Gloo
32
33
  def get_all_files_in( folder )
33
34
  pns = []
34
35
  dir = File.join( @engine.settings.project_path, folder )
36
+
37
+ unless Dir.exist?( dir )
38
+ @log.debug "Folder does not exist in project: #{folder}"
39
+ dir = File.join( @engine.settings.user_root, folder )
40
+ @log.debug "Looking in gloo home? found == #{Dir.exist?( dir )}"
41
+ end
42
+
35
43
  Dir.glob( "#{dir}*.gloo" ).each do |f|
36
44
  pns << f
37
45
  end
@@ -35,7 +35,7 @@ module Gloo
35
35
  #
36
36
  def load
37
37
  unless @mech.exist?( @pn )
38
- @engine.log.error "File '#{@pn}' does not exist."
38
+ @engine.err "File '#{@pn}' does not exist."
39
39
  return
40
40
  end
41
41
 
@@ -37,7 +37,7 @@ module Gloo
37
37
  if @obj
38
38
  @engine.log.debug "Loaded object: #{@obj.name}"
39
39
  else
40
- @engine.log.error "Error loading file at #{@pn}"
40
+ @engine.err "Error loading file at #{@pn}"
41
41
  end
42
42
  end
43
43
 
@@ -0,0 +1,54 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2024 Eric Crane. All rights reserved.
3
+ #
4
+ # Alternate version of the Tell verb.
5
+ # Reads better to check object conditions.
6
+ #
7
+
8
+ module Gloo
9
+ module Verbs
10
+ class Check < Gloo::Core::Verb
11
+
12
+ KEYWORD = 'check'.freeze
13
+ KEYWORD_SHORT = '<-'.freeze
14
+ FOR = 'for'.freeze
15
+ UNKNOWN_MSG_ERR = 'Missing message!'.freeze
16
+
17
+ #
18
+ # Run the verb.
19
+ #
20
+ def run
21
+ msg = @tokens.after_token( FOR )
22
+
23
+ unless msg
24
+ @engine.err( UNKNOWN_MSG_ERR )
25
+ return
26
+ end
27
+
28
+ Gloo::Exec::Dispatch.send_message(
29
+ @engine, msg, @tokens.second, @params )
30
+ end
31
+
32
+ #
33
+ # Get the Verb's keyword.
34
+ #
35
+ def self.keyword
36
+ return KEYWORD
37
+ end
38
+
39
+ #
40
+ # Get the Verb's keyword shortcut.
41
+ #
42
+ def self.keyword_shortcut
43
+ return KEYWORD_SHORT
44
+ end
45
+
46
+ # ---------------------------------------------------------------------
47
+ # Private functions
48
+ # ---------------------------------------------------------------------
49
+
50
+ private
51
+
52
+ end
53
+ end
54
+ end
@@ -83,6 +83,7 @@ module Gloo
83
83
  #
84
84
  def redirect_to_page
85
85
  if @engine.app_running?
86
+ @engine.exec_env.running_script.break_out
86
87
  @engine.running_app.obj.redirect = @target_obj
87
88
  else
88
89
  @engine.err APP_NOT_RUNING_ERR
@@ -1,7 +1,9 @@
1
1
  # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
2
  # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
3
  #
4
- # Create an object, optionally of a type.
4
+ # Send a message to an object.
5
+ # Tell the object to do some known action.
6
+ # Also see the Check verb.
5
7
  #
6
8
 
7
9
  module Gloo
@@ -11,18 +13,21 @@ module Gloo
11
13
  KEYWORD = 'tell'.freeze
12
14
  KEYWORD_SHORT = '->'.freeze
13
15
  TO = 'to'.freeze
14
- OBJ_NOT_FOUND_ERR = 'Object was not found: '.freeze
15
16
  UNKNOWN_MSG_ERR = 'Missing message!'.freeze
16
17
 
17
18
  #
18
19
  # Run the verb.
19
20
  #
20
21
  def run
21
- setup_msg
22
- return unless @msg
22
+ msg = @tokens.after_token( TO )
23
23
 
24
- setup_target
25
- dispatch_msg
24
+ unless msg
25
+ @engine.err( UNKNOWN_MSG_ERR )
26
+ return
27
+ end
28
+
29
+ Gloo::Exec::Dispatch.send_message(
30
+ @engine, msg, @tokens.second, @params )
26
31
  end
27
32
 
28
33
  #
@@ -45,36 +50,6 @@ module Gloo
45
50
 
46
51
  private
47
52
 
48
- #
49
- # Lookup the message to send.
50
- #
51
- def setup_msg
52
- @msg = @tokens.after_token( TO )
53
-
54
- @engine.err( UNKNOWN_MSG_ERR ) unless @msg
55
- end
56
-
57
- #
58
- # Setup the target of the message.
59
- #
60
- def setup_target
61
- @obj_name = @tokens.second
62
- pn = Gloo::Core::Pn.new( @engine, @obj_name )
63
- @target_obj = pn.resolve
64
- end
65
-
66
- #
67
- # Dispatch the message to the target object.
68
- #
69
- def dispatch_msg
70
- if @target_obj
71
- Gloo::Exec::Dispatch.message(
72
- @engine, @msg, @target_obj, @params )
73
- else
74
- @engine.err "#{OBJ_NOT_FOUND_ERR} #{@obj_name}"
75
- end
76
- end
77
-
78
53
  end
79
54
  end
80
55
  end
@@ -35,6 +35,7 @@ module Gloo
35
35
  #
36
36
  def handle request
37
37
  @request = request
38
+ page_obj = nil
38
39
 
39
40
  page, id = @server_obj.router.page_for_route( @request.path, @request.method )
40
41
  @engine.log.debug "Found Page: #{page&.name}" if page
@@ -44,12 +45,13 @@ module Gloo
44
45
  result = handle_file page
45
46
  else
46
47
  result = handle_page page
48
+ page_obj = page
47
49
  end
48
50
  else
49
51
  result = server_error_result
50
52
  end
51
53
 
52
- return result
54
+ return result, page_obj
53
55
  end
54
56
 
55
57
  #
@@ -60,11 +60,11 @@ module Gloo
60
60
  @handler.server_obj.set_request_data self
61
61
  @handler.server_obj.run_on_request
62
62
 
63
- result = @handler.handle self
63
+ result, page_obj = @handler.handle self
64
64
  finish_timer
65
65
 
66
66
  # Run the on_response script if there is one.
67
- @handler.server_obj.set_response_data self, result
67
+ @handler.server_obj.set_response_data( self, result, page_obj )
68
68
  @handler.server_obj.run_on_response
69
69
 
70
70
  return result
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.4.0
4
+ version: 3.5.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: 2024-09-22 00:00:00.000000000 Z
11
+ date: 2024-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -458,8 +458,6 @@ files:
458
458
  - lib/gloo/objs/ror/eval.rb
459
459
  - lib/gloo/objs/security/cipher.rb
460
460
  - lib/gloo/objs/security/password.rb
461
- - lib/gloo/objs/snd/play.rb
462
- - lib/gloo/objs/snd/say.rb
463
461
  - lib/gloo/objs/system/file_handle.rb
464
462
  - lib/gloo/objs/system/ssh_exec.rb
465
463
  - lib/gloo/objs/system/system.rb
@@ -485,6 +483,7 @@ files:
485
483
  - lib/gloo/verbs/alert.rb
486
484
  - lib/gloo/verbs/beep.rb
487
485
  - lib/gloo/verbs/break.rb
486
+ - lib/gloo/verbs/check.rb
488
487
  - lib/gloo/verbs/cls.rb
489
488
  - lib/gloo/verbs/context.rb
490
489
  - lib/gloo/verbs/create.rb
@@ -1,48 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
- #
4
- # Play an audio file (MP3).
5
- #
6
-
7
- module Gloo
8
- module Objs
9
- class Play < Gloo::Core::Obj
10
-
11
- KEYWORD = 'play'.freeze
12
- KEYWORD_SHORT = 'play'.freeze
13
-
14
- #
15
- # The name of the object type.
16
- #
17
- def self.typename
18
- return KEYWORD
19
- end
20
-
21
- #
22
- # The short name of the object type.
23
- #
24
- def self.short_typename
25
- return KEYWORD_SHORT
26
- end
27
-
28
- # ---------------------------------------------------------------------
29
- # Messages
30
- # ---------------------------------------------------------------------
31
-
32
- #
33
- # Get a list of message names that this object receives.
34
- #
35
- def self.messages
36
- return super + [ 'run' ]
37
- end
38
-
39
- #
40
- # Play the audio file.
41
- #
42
- def msg_run
43
- system "afplay #{value}"
44
- end
45
-
46
- end
47
- end
48
- end
@@ -1,98 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
- #
4
- # Wrapper for the 'say something' function on the Mac.
5
- #
6
- require 'erb'
7
-
8
- module Gloo
9
- module Objs
10
- class Say < Gloo::Core::Obj
11
-
12
- KEYWORD = 'say'.freeze
13
- KEYWORD_SHORT = 'say'.freeze
14
- VOICE = 'voice'.freeze
15
- MSG = 'message'.freeze
16
- DEFAULT_MSG = 'talk to me'.freeze
17
-
18
- #
19
- # The name of the object type.
20
- #
21
- def self.typename
22
- return KEYWORD
23
- end
24
-
25
- #
26
- # The short name of the object type.
27
- #
28
- def self.short_typename
29
- return KEYWORD_SHORT
30
- end
31
-
32
- #
33
- # Get the voice to use.
34
- #
35
- def voice_value
36
- v = find_child VOICE
37
- return nil unless v
38
-
39
- return v.value
40
- end
41
-
42
- #
43
- # Get the message to speak.
44
- #
45
- def msg_value
46
- o = find_child MSG
47
- return nil unless o
48
-
49
- return o.value
50
- end
51
-
52
- # ---------------------------------------------------------------------
53
- # Children
54
- # ---------------------------------------------------------------------
55
-
56
- #
57
- # Does this object have children to add when an object
58
- # is created in interactive mode?
59
- # This does not apply during obj load, etc.
60
- #
61
- def add_children_on_create?
62
- return true
63
- end
64
-
65
- #
66
- # Add children to this object.
67
- # This is used by containers to add children needed
68
- # for default configurations.
69
- #
70
- def add_default_children
71
- fac = @engine.factory
72
- fac.create_string VOICE, '', self
73
- fac.create_string MSG, DEFAULT_MSG, self
74
- end
75
-
76
- # ---------------------------------------------------------------------
77
- # Messages
78
- # ---------------------------------------------------------------------
79
-
80
- #
81
- # Get a list of message names that this object receives.
82
- #
83
- def self.messages
84
- return super + [ 'run' ]
85
- end
86
-
87
- #
88
- # Have the computer 'speak' the message.
89
- #
90
- def msg_run
91
- v = voice_value.empty? ? '' : "-v '#{voice_value}'"
92
- cmd = "say #{v} '#{msg_value}'"
93
- system cmd
94
- end
95
-
96
- end
97
- end
98
- end