gloo 6.0.1 → 6.2.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 (96) hide show
  1. checksums.yaml +4 -4
  2. data/CLAUDE.md +9 -3
  3. data/README.md +39 -7
  4. data/docs/application.md +184 -0
  5. data/docs/getting_started.md +110 -0
  6. data/docs/iterators.md +294 -0
  7. data/docs/language_objects.md +190 -0
  8. data/docs/language_scripting.md +62 -0
  9. data/docs/language_syntax.md +334 -0
  10. data/docs/objects.md +77 -0
  11. data/docs/operators.md +62 -0
  12. data/docs/plugins.md +376 -0
  13. data/docs/verbs.md +64 -0
  14. data/docs/web_app.md +211 -0
  15. data/gloo.gemspec +3 -1
  16. data/lib/VERSION +1 -1
  17. data/lib/VERSION_NOTES +16 -0
  18. data/lib/gloo/app/engine.rb +17 -2
  19. data/lib/gloo/app/log.rb +5 -4
  20. data/lib/gloo/app/platform.rb +34 -2
  21. data/lib/gloo/app/prompt.rb +2 -1
  22. data/lib/gloo/app/settings.rb +25 -15
  23. data/lib/gloo/app/table.rb +7 -3
  24. data/lib/gloo/app/theme.rb +144 -0
  25. data/lib/gloo/core/gloo_system.rb +52 -1
  26. data/lib/gloo/core/invoker.rb +102 -0
  27. data/lib/gloo/core/parser.rb +48 -7
  28. data/lib/gloo/core/tokens.rb +81 -1
  29. data/lib/gloo/docs/doc_data.rb +160 -0
  30. data/lib/gloo/docs/help_shell.rb +332 -0
  31. data/lib/gloo/docs/markdown_renderer.rb +39 -0
  32. data/lib/gloo/expr/call.rb +54 -0
  33. data/lib/gloo/expr/expression.rb +3 -0
  34. data/lib/gloo/objs/basic/alias.rb +53 -0
  35. data/lib/gloo/objs/basic/boolean.rb +30 -0
  36. data/lib/gloo/objs/basic/container.rb +38 -0
  37. data/lib/gloo/objs/basic/decimal.rb +30 -0
  38. data/lib/gloo/objs/basic/integer.rb +58 -0
  39. data/lib/gloo/objs/basic/script.rb +31 -0
  40. data/lib/gloo/objs/basic/string.rb +31 -4
  41. data/lib/gloo/objs/basic/string_msgs.rb +212 -2
  42. data/lib/gloo/objs/basic/text.rb +30 -4
  43. data/lib/gloo/objs/basic/untyped.rb +21 -0
  44. data/lib/gloo/objs/ctrl/each.rb +63 -1
  45. data/lib/gloo/objs/ctrl/function.rb +86 -4
  46. data/lib/gloo/objs/ctrl/repeat.rb +41 -0
  47. data/lib/gloo/objs/dt/date.rb +43 -0
  48. data/lib/gloo/objs/dt/datetime.rb +50 -0
  49. data/lib/gloo/objs/dt/time.rb +43 -0
  50. data/lib/gloo/objs/str_utils/cipher.rb +59 -0
  51. data/lib/gloo/objs/str_utils/outline.rb +65 -1
  52. data/lib/gloo/objs/str_utils/password.rb +56 -0
  53. data/lib/gloo/objs/system/erb.rb +39 -0
  54. data/lib/gloo/objs/system/file_handle.rb +56 -0
  55. data/lib/gloo/objs/system/system.rb +29 -0
  56. data/lib/gloo/objs/web/http_get.rb +35 -0
  57. data/lib/gloo/objs/web/http_post.rb +33 -0
  58. data/lib/gloo/objs/web/json.rb +40 -0
  59. data/lib/gloo/objs/web/uri.rb +40 -0
  60. data/lib/gloo/shell/command_node.rb +39 -0
  61. data/lib/gloo/shell/context.rb +93 -0
  62. data/lib/gloo/shell/runner.rb +315 -0
  63. data/lib/gloo/verbs/break.rb +32 -0
  64. data/lib/gloo/verbs/check.rb +49 -0
  65. data/lib/gloo/verbs/cls.rb +18 -0
  66. data/lib/gloo/verbs/context.rb +47 -0
  67. data/lib/gloo/verbs/create.rb +42 -0
  68. data/lib/gloo/verbs/eval.rb +27 -0
  69. data/lib/gloo/verbs/execute.rb +27 -0
  70. data/lib/gloo/verbs/exists.rb +54 -2
  71. data/lib/gloo/verbs/files.rb +22 -0
  72. data/lib/gloo/verbs/help.rb +46 -178
  73. data/lib/gloo/verbs/if.rb +52 -0
  74. data/lib/gloo/verbs/invoke.rb +88 -33
  75. data/lib/gloo/verbs/list.rb +37 -4
  76. data/lib/gloo/verbs/load.rb +55 -2
  77. data/lib/gloo/verbs/log.rb +44 -0
  78. data/lib/gloo/verbs/move.rb +36 -1
  79. data/lib/gloo/verbs/put.rb +35 -0
  80. data/lib/gloo/verbs/quit.rb +19 -0
  81. data/lib/gloo/verbs/redirect.rb +52 -2
  82. data/lib/gloo/verbs/reload.rb +27 -0
  83. data/lib/gloo/verbs/run.rb +39 -0
  84. data/lib/gloo/verbs/save.rb +26 -0
  85. data/lib/gloo/verbs/show.rb +54 -0
  86. data/lib/gloo/verbs/tell.rb +32 -0
  87. data/lib/gloo/verbs/throw.rb +29 -0
  88. data/lib/gloo/verbs/unless.rb +50 -0
  89. data/lib/gloo/verbs/unload.rb +23 -0
  90. data/lib/gloo/verbs/version.rb +37 -3
  91. data/lib/gloo/verbs/wait.rb +26 -0
  92. data/test.gloo/objs/string.test.gloo +54 -0
  93. data/test.gloo/verbs/invoke.test.gloo +73 -0
  94. metadata +26 -10
  95. data/.DS_Store +0 -0
  96. data/.travis.yml +0 -5
@@ -104,11 +104,73 @@ module Gloo
104
104
  EachDir.new( @engine, self ).run
105
105
  # elsif EachRepo.use_for?( self )
106
106
  # EachRepo.new( @engine, self ).run
107
- else
107
+ else
108
108
  @engine.err "Not set up to run each for that target."
109
109
  end
110
110
  end
111
111
 
112
+ # ---------------------------------------------------------------------
113
+ # Object Documentation
114
+ # ---------------------------------------------------------------------
115
+
116
+ #
117
+ # Get the object's documentation data.
118
+ #
119
+ def self.doc_data
120
+ {
121
+ :name => KEYWORD,
122
+ :shortcut => KEYWORD_SHORT,
123
+ :description => 'Perform an action for each item in a ' \
124
+ 'collection. There are several variations on this object ' \
125
+ 'type, determined by which named child is present: each ' \
126
+ 'child object in a container, each word in a string, each ' \
127
+ 'line in a block of text, each file in a folder, or each ' \
128
+ 'directory in a folder.',
129
+ :children => [
130
+ 'in — The collection or source to iterate over (a container, string, or folder path, depending on variation).',
131
+ 'do (script) — The action to perform for each item in the loop.',
132
+ 'One of the following, whose presence determines which kind of loop this is:',
133
+ 'child (alias) — iterate a container\'s children.',
134
+ 'word (string) — iterate the words in a string.',
135
+ 'line (string) — iterate the lines in a block of text.',
136
+ 'file (file) — iterate the files in a folder; an optional ext (string) child limits to files of that extension.',
137
+ 'dir (file) — iterate the directories in a folder.'
138
+ ],
139
+ :messages => [
140
+ 'run — Run the loop for each item in the collection.'
141
+ ],
142
+ :notes => 'When iterating a container\'s children, an ' \
143
+ 'optional group_by feature is available: add a group_by ' \
144
+ '(string) child naming a property of each child, plus ' \
145
+ 'on_group_start / on_group_end (script) children — those ' \
146
+ 'scripts run whenever the group_by value changes, letting ' \
147
+ 'you aggregate results in groups.',
148
+ :examples => <<~EXAMPLES.strip
149
+ #
150
+ # Show each child in a container.
151
+ #
152
+ each_child [can] :
153
+
154
+ # Iterator on children of a container.
155
+ for [each] :
156
+ child [alias] :
157
+ in [alias] : each_child.objs
158
+ do [script] : show ^.child
159
+
160
+ # Data
161
+ objs [can] :
162
+ 1 [string] : one
163
+ 2 [string] : two
164
+ 3 [string] : three
165
+
166
+ # Run the iterator.
167
+ on_load [script] :
168
+ show 'showing children in container' (white)
169
+ tell each_child.for to run
170
+ EXAMPLES
171
+ }
172
+ end
173
+
112
174
  end
113
175
  end
114
176
  end
@@ -161,23 +161,36 @@ module Gloo
161
161
  # Messages
162
162
  # ---------------------------------------------------------------------
163
163
 
164
- #
164
+ #
165
165
  # Invoke the function, run the script and return the result.
166
- #
166
+ #
167
+ # If on_invoke itself hits an error, it is left alone rather
168
+ # than being clobbered with an unreliable result - callers can
169
+ # tell this happened because the engine is left in an error
170
+ # state (@engine.heap.error), same as any other failed verb.
171
+ #
167
172
  def invoke args
168
173
  @engine.log.debug "Invoking function: #{name}"
169
174
 
170
175
  set_params args if args
176
+
177
+ @engine.heap.error.start_tracking
171
178
  run_on_invoke
179
+ failed = @engine.heap.error.error_count.positive?
180
+
181
+ if failed
182
+ run_after_invoke
183
+ return nil
184
+ end
172
185
 
173
- if @engine.running_app&.obj&.embedded_renderer
186
+ if @engine.running_app&.obj&.embedded_renderer
174
187
  return_value = @engine.running_app.obj.embedded_renderer.render result, params_hash
175
188
  else
176
189
  return_value = result
177
190
  end
178
191
  @engine.heap.it.set_to return_value
179
192
  run_after_invoke
180
-
193
+
181
194
  return return_value
182
195
  end
183
196
 
@@ -194,6 +207,75 @@ module Gloo
194
207
  end
195
208
  end
196
209
 
210
+ # ---------------------------------------------------------------------
211
+ # Object Documentation
212
+ # ---------------------------------------------------------------------
213
+
214
+ #
215
+ # Get the object's documentation data.
216
+ #
217
+ def self.doc_data
218
+ {
219
+ :name => KEYWORD,
220
+ :shortcut => KEYWORD_SHORT,
221
+ :description => 'Define a function that will be performed ' \
222
+ 'somewhere else. When the function is invoked, the ' \
223
+ 'parameter values are set, the on_invoke script is run, the ' \
224
+ 'result is determined, the after_invoke script is run, and ' \
225
+ 'the result is returned.',
226
+ :children => [
227
+ 'on_invoke (script) — Script to run when the function is invoked.',
228
+ 'after_invoke (optional script) — Script to run after the function has been invoked and before the value is returned. Can be used to clean up and reset the object state.',
229
+ 'params (container) — The collection of parameters to the function. Parameter values are used as defaults if no value is passed in during invocation.',
230
+ 'result (string) — The result of the function to return to the caller.'
231
+ ],
232
+ :messages => [
233
+ 'invoke — Invoke the function, set it and return the result. The function result is put into it as well as being returned to the caller.'
234
+ ],
235
+ :examples => <<~EXAMPLES.strip
236
+ #
237
+ # Function examples
238
+ #
239
+
240
+ functions [can] :
241
+
242
+ name [string] : Jasper
243
+
244
+ on_load [script] :
245
+ show 'running function examples' (white)
246
+
247
+ invoke functions.greet ^.name
248
+ show it
249
+
250
+ invoke functions.add 3 4
251
+ show it
252
+
253
+ show 'done' (white)
254
+
255
+ #
256
+ # Say hi to person (name)
257
+ #
258
+ greet [ƒ] :
259
+ on_invoke [script] :
260
+ put 'Hi, ' + ^.params.name into ^.result
261
+ params [container] :
262
+ name [string] : none
263
+ result [string] :
264
+
265
+ #
266
+ # Add 2 numbers
267
+ #
268
+ add [ƒ] :
269
+ on_invoke [script] :
270
+ put ^.params.x and ^.params.y into ^.result
271
+ params [container] :
272
+ x [int] :
273
+ y [int] :
274
+ result [string] :
275
+ EXAMPLES
276
+ }
277
+ end
278
+
197
279
  end
198
280
  end
199
281
  end
@@ -102,6 +102,47 @@ module Gloo
102
102
  end
103
103
  end
104
104
 
105
+ # ---------------------------------------------------------------------
106
+ # Object Documentation
107
+ # ---------------------------------------------------------------------
108
+
109
+ #
110
+ # Get the object's documentation data.
111
+ #
112
+ def self.doc_data
113
+ {
114
+ :name => KEYWORD,
115
+ :shortcut => KEYWORD_SHORT,
116
+ :description => 'Run a script a given number of times.',
117
+ :children => [
118
+ 'times (integer) — Default: 0. The number of times to run the script.',
119
+ 'index (integer) — Default: 0. The current iteration when the repeat loop is running.',
120
+ 'do (script) — The action to perform for each iteration of the loop.'
121
+ ],
122
+ :messages => [
123
+ 'run — Run the script for the given number of times.'
124
+ ],
125
+ :examples => <<~EXAMPLES.strip
126
+ repeat [can] :
127
+ s [string] :
128
+ on_load [script] :
129
+ put $.screen_cols / 2 into repeat.x.times
130
+ tell repeat.x to run
131
+ show repeat.s
132
+ tell repeat.y to run
133
+ show repeat.s
134
+ x [repeat] :
135
+ times [integer] : 30
136
+ index [integer] : 0
137
+ do [script] : put repeat.s + '-' into repeat.s
138
+ y [repeat] :
139
+ times [integer] : 10
140
+ index [integer] : 0
141
+ do [script] : show repeat.y.index
142
+ EXAMPLES
143
+ }
144
+ end
145
+
105
146
  end
106
147
  end
107
148
  end
@@ -149,6 +149,49 @@ module Gloo
149
149
  dt = Chronic.parse( self.value )
150
150
  @engine.heap.it.set_to dt.strftime( format )
151
151
  end
152
+
153
+ # ---------------------------------------------------------------------
154
+ # Object Documentation
155
+ # ---------------------------------------------------------------------
156
+
157
+ #
158
+ # Get the object's documentation data.
159
+ #
160
+ def self.doc_data
161
+ {
162
+ :name => KEYWORD,
163
+ :shortcut => KEYWORD_SHORT,
164
+ :description => 'A reference to a date, but without time. The ' \
165
+ "default format is: #{DEFAULT_FORMAT}. Note that you can " \
166
+ 'put a date into a datetime object. You can also put a ' \
167
+ 'Chronic phrase into the date.',
168
+ :messages => [
169
+ 'now — Set to the current system date.',
170
+ 'add ({amount}) — Add the amount to the date. The amount will be in the form of "1 day" or "3 months".',
171
+ 'sub ({amount}) — Subtract the amount from the date. The amount will be in the form of "1 day" or "2 weeks".',
172
+ 'dd — Get the day portion of the date. Put the day number into it.',
173
+ 'mm — Get the month portion of the date. Put the month number into it.',
174
+ 'yy — Get the 2 digit year portion of the date. Put the 2 digit year into it.',
175
+ 'yyyy — Get the 4 digit year portion of the date. Put the 4 digit year into it.',
176
+ 'format ({fmt}) — Format the date using a strftime-style format string. Default if none given: %Y-%m-%d. It will have the formatted string.'
177
+ ],
178
+ :examples => <<~EXAMPLES.strip
179
+ #
180
+ # Show the current date.
181
+ #
182
+
183
+ date [can] :
184
+ d [date] :
185
+ on_load [script] :
186
+ tell date.d to now
187
+ show date.d
188
+ next [script] :
189
+ put 'tomorrow' into date.d
190
+ show date.d
191
+ EXAMPLES
192
+ }
193
+ end
194
+
152
195
  end
153
196
  end
154
197
  end
@@ -249,6 +249,56 @@ module Gloo
249
249
  @engine.heap.it.set_to dt.strftime( format )
250
250
  end
251
251
 
252
+ # ---------------------------------------------------------------------
253
+ # Object Documentation
254
+ # ---------------------------------------------------------------------
255
+
256
+ #
257
+ # Get the object's documentation data.
258
+ #
259
+ def self.doc_data
260
+ {
261
+ :name => KEYWORD,
262
+ :shortcut => KEYWORD_SHORT,
263
+ :description => 'A reference to a date and time. The default ' \
264
+ "format is: #{DEFAULT_FORMAT}. Note that you can put a " \
265
+ 'datetime into a date or time object. You can also put a ' \
266
+ 'Chronic phrase into the datetime.',
267
+ :messages => [
268
+ 'now — Set to the current system date and time.',
269
+ 'add ({amount}) — Add the amount to the date. The amount will be in the form of "1 day" or "3 hours".',
270
+ 'sub ({amount}) — Subtract the amount from the date. The amount will be in the form of "1 day" or "2 weeks".',
271
+ 'is_today — Is the datetime today? It will be true or false.',
272
+ 'is_past — Is the datetime in the past? It will be true or false.',
273
+ 'is_future — Is the datetime in the future? It will be true or false.',
274
+ 'is_yesterday — Is the datetime yesterday? It will be true or false.',
275
+ 'is_tomorrow — Is the datetime tomorrow? It will be true or false.',
276
+ 'is_this_week — Is the datetime during this week? It will be true or false.',
277
+ 'begin_day — Set the datetime to the start of the day.',
278
+ 'end_day — Set the datetime to the end of the day.',
279
+ 'begin_week — Set the datetime to the start of the week.',
280
+ 'end_week — Set the datetime to the end of the week.',
281
+ 'begin_month — Set the datetime to the start of the month.',
282
+ 'end_month — Set the datetime to the end of the month.',
283
+ 'begin_year — Set the datetime to the start of the year.',
284
+ 'end_year — Set the datetime to the end of the year.',
285
+ 'format ({fmt}) — Format the date and time using a strftime-style format string. Default if none given: %Y-%m-%d %H:%M:%S. It will have the formatted string.'
286
+ ],
287
+ :examples => <<~EXAMPLES.strip
288
+ #
289
+ # Show the current date and time.
290
+ #
291
+
292
+ dt [can] :
293
+ d [datetime] :
294
+ on_load [script] :
295
+ tell dt.d to now
296
+ show dt.d
297
+ next [script] : put '1 week from now' into dt.d
298
+ EXAMPLES
299
+ }
300
+ end
301
+
252
302
  end
253
303
  end
254
304
  end
@@ -149,6 +149,49 @@ module Gloo
149
149
  dt = Chronic.parse( self.value )
150
150
  @engine.heap.it.set_to dt.strftime( format )
151
151
  end
152
+
153
+ # ---------------------------------------------------------------------
154
+ # Object Documentation
155
+ # ---------------------------------------------------------------------
156
+
157
+ #
158
+ # Get the object's documentation data.
159
+ #
160
+ def self.doc_data
161
+ {
162
+ :name => KEYWORD,
163
+ :shortcut => KEYWORD_SHORT,
164
+ :description => 'A reference to a time, but without a date. ' \
165
+ "The default format is: #{DEFAULT_FORMAT}. Note that you " \
166
+ 'can put a time into a datetime object. You can also put a ' \
167
+ 'Chronic phrase into the time.',
168
+ :messages => [
169
+ 'now — Set to the current system time.',
170
+ 'add ({amount}) — Add the amount to the date. The amount will be in the form of "1 day" or "3 months".',
171
+ 'sub ({amount}) — Subtract the amount from the date. The amount will be in the form of "1 day" or "2 weeks".',
172
+ 'hh — Get the hour portion of the time. Put the hour into it.',
173
+ 'mm — Get the minute portion of the time. Put the minute into it.',
174
+ 'ss — Get the second portion of the time. Put the second into it.',
175
+ 'am — Get the am/pm portion of the time. Put "am" or "pm" into it.',
176
+ 'format ({fmt}) — Format the time using a strftime-style format string. Default if none given: %H:%M:%S. It will have the formatted string.'
177
+ ],
178
+ :examples => <<~EXAMPLES.strip
179
+ #
180
+ # Show the current time.
181
+ #
182
+
183
+ time [can] :
184
+ t [time] :
185
+ on_load [script] :
186
+ tell time.t to now
187
+ show time.t
188
+ next [script] :
189
+ put '1 hour from now' into time.t
190
+ show time.t
191
+ EXAMPLES
192
+ }
193
+ end
194
+
152
195
  end
153
196
  end
154
197
  end
@@ -185,6 +185,65 @@ module Gloo
185
185
  return cipher.update( data ) + cipher.final
186
186
  end
187
187
 
188
+ # ---------------------------------------------------------------------
189
+ # Object Documentation
190
+ # ---------------------------------------------------------------------
191
+
192
+ #
193
+ # Get the object's documentation data.
194
+ #
195
+ def self.doc_data
196
+ {
197
+ :name => KEYWORD,
198
+ :shortcut => KEYWORD_SHORT,
199
+ :description => 'Tool to encrypt and decrypt data.',
200
+ :children => [
201
+ 'key (string) — The encryption key. Base64 encoded.',
202
+ 'init_vector (string) — The initialization vector. Base64 encoded.',
203
+ 'data (string) — The encrypted or decrypted data.'
204
+ ],
205
+ :messages => [
206
+ 'generate_keys — Generate an encryption key and initialization vector. The keys are base64 encoded.',
207
+ 'encrypt — Encrypt the data.',
208
+ 'decrypt — Decrypt the data.'
209
+ ],
210
+ :examples => <<~EXAMPLES.strip
211
+ #
212
+ # Encrypt and Decrypt a string.
213
+ #
214
+
215
+ encrypt [can] :
216
+
217
+ str [string] : Encrypt your data for better security!
218
+
219
+ cipher [cipher] :
220
+ key [string] :
221
+ init_vector [string] :
222
+ data [string] :
223
+
224
+ on_load [script] :
225
+ show
226
+ show 'Original string' (white)
227
+ show ^.str
228
+ show
229
+ show 'Generating Key' (white)
230
+ tell ^.cipher to generate_keys
231
+ show ^.cipher.key
232
+ show ^.cipher.init_vector
233
+ show
234
+ show 'Encrpting the string' (white)
235
+ put ^.str into ^.cipher.data
236
+ tell ^.cipher to encrypt
237
+ show ^.cipher.data
238
+ show
239
+ show 'Decrypting the string' (white)
240
+ tell ^.cipher to decrypt
241
+ show ^.cipher.data
242
+ show
243
+ EXAMPLES
244
+ }
245
+ end
246
+
188
247
  end
189
248
  end
190
249
  end
@@ -249,7 +249,71 @@ module Gloo
249
249
  end
250
250
  end
251
251
  end
252
-
252
+
253
+ # ---------------------------------------------------------------------
254
+ # Object Documentation
255
+ # ---------------------------------------------------------------------
256
+
257
+ #
258
+ # Get the object's documentation data.
259
+ #
260
+ def self.doc_data
261
+ {
262
+ :name => KEYWORD,
263
+ :shortcut => KEYWORD_SHORT,
264
+ :description => 'Convert strings with a path to a hierarchical outline.',
265
+ :children => [
266
+ 'object_source (alias) — Points to the data source. Should be a container with objects, each of which has a name and optionally an id.',
267
+ 'entity_path (string) — The path to the entity, used to generate links to entities that have IDs.',
268
+ "separator_char (string) — Optional. If not specified, the '/' character is used. The character used to separate the path elements.",
269
+ 'data (string) — The generated outline: a hierarchical outline of OL and LI elements. For children with IDs, links to entities are included.'
270
+ ],
271
+ :messages => [
272
+ 'generate — Generate the outline from the list of strings.'
273
+ ],
274
+ :examples => <<~EXAMPLES.strip
275
+ #
276
+ # Convert flat elements to hierarchal outline.
277
+ #
278
+
279
+ outline [container] :
280
+
281
+ on_load [script] :
282
+ tell outline.util to generate
283
+ show outline.util.data
284
+
285
+ src_data [container] :
286
+ 1 [container] :
287
+ id [int] : 1
288
+ name [string] : a/b/c
289
+ 2 [container] :
290
+ id [int] : 2
291
+ name [string] : a/b/d
292
+ 3 [container] :
293
+ id [int] : 3
294
+ name [string] : a/b/e
295
+ 4 [container] :
296
+ id [int] : 4
297
+ name [string] : x
298
+ 5 [container] :
299
+ id [int] : 5
300
+ name [string] : x/y
301
+ 6 [container] :
302
+ id [int] : 6
303
+ name [string] : x/y/z
304
+ 7 [container] :
305
+ id [int] : 7
306
+ name [string] : last
307
+
308
+ util [outline] :
309
+ object_source [alias] : outline.src_data
310
+ entity_path [string] : /entity/
311
+ separator_char [string] : /
312
+ data [string] :
313
+ EXAMPLES
314
+ }
315
+ end
316
+
253
317
  end
254
318
  end
255
319
  end
@@ -159,6 +159,62 @@ module Gloo
159
159
  @engine.heap.it.set_to result
160
160
  end
161
161
 
162
+ # ---------------------------------------------------------------------
163
+ # Object Documentation
164
+ # ---------------------------------------------------------------------
165
+
166
+ #
167
+ # Get the object's documentation data.
168
+ #
169
+ def self.doc_data
170
+ {
171
+ :name => KEYWORD,
172
+ :shortcut => KEYWORD_SHORT,
173
+ :description => 'A password object that can be generated, hashed, and compared.',
174
+ :children => [
175
+ 'salt (string) — Optional salt to use when hashing and checking passwords.',
176
+ 'password (string) — The password. generate puts a new random password here. Used in the hash and check messages.',
177
+ 'hash (string) — The hashed value of the password. Created when the hash message is called, and compared when the check message is called.'
178
+ ],
179
+ :messages => [
180
+ 'generate ({len}) — Generate a new password, put in the password child object. The {len} parameter is optional; the length is 7 if not specified.',
181
+ 'hash — Hash the password in the child object. Put it in the hash child object.',
182
+ 'check — Check the password in the child object. Is it the same as the hash?'
183
+ ],
184
+ :examples => <<~EXAMPLES.strip
185
+ #
186
+ # Password Hashing and checking.
187
+ #
188
+ password [can] :
189
+
190
+ pwd [password] :
191
+ salt [string] : MySalt
192
+ password [string] :
193
+ hash [string] :
194
+
195
+ on_load [script] :
196
+ show
197
+ show 'Generating a new password' (white)
198
+ tell ^.pwd to generate
199
+ show 'Password: ' + ^.pwd.password
200
+ show
201
+ show 'hashing the password' (white)
202
+ tell ^.pwd to hash
203
+ show ^.pwd.hash (red)
204
+ show
205
+ show 'checking with the correct password' (white)
206
+ tell ^.pwd to check
207
+ show 'Result of check: ' + it (green)
208
+ show
209
+ show 'checking with the wrong password' (white)
210
+ tell ^.pwd to generate(23)
211
+ tell ^.pwd to check
212
+ show 'Result of check: ' + it (red)
213
+ show
214
+ EXAMPLES
215
+ }
216
+ end
217
+
162
218
  end
163
219
  end
164
220
  end
@@ -110,6 +110,45 @@ module Gloo
110
110
  set_result render.result_with_hash( param_hash )
111
111
  end
112
112
 
113
+ # ---------------------------------------------------------------------
114
+ # Object Documentation
115
+ # ---------------------------------------------------------------------
116
+
117
+ #
118
+ # Get the object's documentation data.
119
+ #
120
+ def self.doc_data
121
+ {
122
+ :name => KEYWORD,
123
+ :shortcut => KEYWORD_SHORT,
124
+ :description => 'Use the ERB templating system to generate ' \
125
+ 'content. For example, you can use the ERB object for ' \
126
+ 'string interpolation.',
127
+ :children => [
128
+ 'template (text) — The template that will be used when the ERB object is run.',
129
+ 'params (container) — The collection of children values used when the template is rendered.',
130
+ 'result (text) — The result of the template rendering.'
131
+ ],
132
+ :messages => [
133
+ 'run — Render the result based on the template and the parameter values.'
134
+ ],
135
+ :examples => <<~EXAMPLES.strip
136
+ e [can] :
137
+ erb [erb] :
138
+ template [text] : BEGIN
139
+ Hello <%= first %> <%= last %>!
140
+ END
141
+ params [container] :
142
+ first [string] : Eric
143
+ last [string] : Crane
144
+ result [text] :
145
+ on_load [script] :
146
+ run e.erb
147
+ show e.erb.result
148
+ EXAMPLES
149
+ }
150
+ end
151
+
113
152
  end
114
153
  end
115
154
  end