gloo 7.1.2 → 7.2
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/Rakefile +23 -0
- data/docs/application.md +47 -2
- data/docs/development.md +10 -0
- data/docs/iterators.md +22 -5
- data/docs/language_objects.md +20 -15
- data/docs/language_scripting.md +6 -2
- data/docs/plugins.md +1 -1
- data/docs/testing.md +4 -7
- data/docs/verbs.md +23 -3
- data/lib/VERSION +1 -1
- data/lib/VERSION_NOTES +13 -0
- data/lib/dependencies.rb +4 -1
- data/lib/gloo/app/engine.rb +18 -6
- data/lib/gloo/core/obj.rb +0 -23
- data/lib/gloo/exec/script.rb +12 -2
- data/lib/gloo/objs/basic/script.rb +5 -28
- data/lib/gloo/objs/ctrl/each.rb +4 -3
- data/lib/gloo/objs/ctrl/repeat.rb +4 -3
- data/lib/gloo/persist/declaration_ledger.rb +9 -9
- data/lib/gloo/persist/declaration_writer.rb +208 -0
- data/lib/gloo/persist/disc_mech.rb +70 -39
- data/lib/gloo/persist/file_loader.rb +125 -66
- data/lib/gloo/persist/file_saver.rb +130 -198
- data/lib/gloo/persist/file_storage.rb +15 -4
- data/lib/gloo/persist/file_style.rb +89 -0
- data/lib/gloo/persist/line_splitter.rb +16 -1
- data/lib/gloo/persist/persist_man.rb +112 -30
- data/lib/gloo/persist/save_index.rb +211 -0
- data/lib/gloo/persist/script_body_collector.rb +16 -21
- data/lib/gloo/persist/source/blank_node.rb +10 -3
- data/lib/gloo/persist/source/comment_node.rb +10 -2
- data/lib/gloo/persist/source/directive_node.rb +10 -2
- data/lib/gloo/persist/source/obj_node.rb +174 -9
- data/lib/gloo/persist/source/source_doc.rb +54 -0
- data/lib/gloo/persist/subtree_extractor.rb +9 -37
- data/lib/gloo/persist/trivia_buffer.rb +7 -7
- data/lib/gloo/verbs/break.rb +99 -10
- data/lib/gloo/verbs/load.rb +27 -21
- data/lib/gloo/verbs/move.rb +42 -3
- data/lib/gloo/verbs/save.rb +26 -4
- data/test.gloo/app/exit_status.test.gloo +34 -0
- data/test.gloo/app/fixtures/exit_after_error.gloo +9 -0
- data/test.gloo/lang/declaration.test.gloo +36 -0
- data/test.gloo/lang/fixtures/mixed_indent.gloo +5 -0
- data/test.gloo/lang/naming.test.gloo +44 -6
- data/test.gloo/verbs/break.test.gloo +104 -11
- data/test.gloo/verbs/fixtures/load_beside.gloo +6 -0
- data/test.gloo/verbs/fixtures/lossless_text.gloo +7 -0
- data/test.gloo/verbs/fixtures/lossless_text_saved.gloo +9 -0
- data/test.gloo/verbs/load.test.gloo +18 -0
- data/test.gloo/verbs/move.test.gloo +39 -0
- data/test.gloo/verbs/save.test.gloo +239 -0
- metadata +10 -1
|
@@ -222,3 +222,242 @@ END
|
|
|
222
222
|
assert "reload should restore the on-disk value"
|
|
223
223
|
tell demo to unload
|
|
224
224
|
tell ^^.f to delete
|
|
225
|
+
|
|
226
|
+
# -------------------------------------------------------------------
|
|
227
|
+
# Lossless save (7.2): an untouched declaration is written back
|
|
228
|
+
# exactly; a changed one changes only its own line.
|
|
229
|
+
# -------------------------------------------------------------------
|
|
230
|
+
|
|
231
|
+
body_fixture [text] : BEGIN
|
|
232
|
+
lossless_body [can] :
|
|
233
|
+
n [int] : 0
|
|
234
|
+
s [script] :
|
|
235
|
+
put 1 into ^.n
|
|
236
|
+
|
|
237
|
+
# a comment inside the body
|
|
238
|
+
put ^.n + 1 into ^.n # an inline comment
|
|
239
|
+
put ^.n + \
|
|
240
|
+
2 into ^.n
|
|
241
|
+
after [string] : after
|
|
242
|
+
END
|
|
243
|
+
|
|
244
|
+
directive_fixture [text] : BEGIN
|
|
245
|
+
#
|
|
246
|
+
# A comment block above the directive.
|
|
247
|
+
#
|
|
248
|
+
load lib yaml
|
|
249
|
+
|
|
250
|
+
lossless_lib [can] :
|
|
251
|
+
cfg [yaml] :
|
|
252
|
+
END
|
|
253
|
+
|
|
254
|
+
untyped_fixture [text] : BEGIN
|
|
255
|
+
lossless_untyped [can] :
|
|
256
|
+
plain : no type given
|
|
257
|
+
END
|
|
258
|
+
|
|
259
|
+
untyped_changed [text] : BEGIN
|
|
260
|
+
lossless_untyped [can] :
|
|
261
|
+
plain : changed
|
|
262
|
+
END
|
|
263
|
+
|
|
264
|
+
same_name_fixture [text] : BEGIN
|
|
265
|
+
lossless_same [can] :
|
|
266
|
+
a [string] : First A
|
|
267
|
+
a [string] : Second A
|
|
268
|
+
END
|
|
269
|
+
|
|
270
|
+
same_name_changed [text] : BEGIN
|
|
271
|
+
lossless_same [can] :
|
|
272
|
+
a [string] : Changed
|
|
273
|
+
a [string] : Second A
|
|
274
|
+
END
|
|
275
|
+
|
|
276
|
+
shorthand_fixture [text] : BEGIN
|
|
277
|
+
lossless_short [can] :
|
|
278
|
+
x [int] : 1
|
|
279
|
+
|
|
280
|
+
lossless_short.b [can] :
|
|
281
|
+
y [int] : 2
|
|
282
|
+
END
|
|
283
|
+
|
|
284
|
+
style_fixture [text] : BEGIN
|
|
285
|
+
lossless_style [can] :
|
|
286
|
+
n [int] : 1
|
|
287
|
+
END
|
|
288
|
+
|
|
289
|
+
style_changed [text] : BEGIN
|
|
290
|
+
lossless_style [can] :
|
|
291
|
+
n [int] : 1
|
|
292
|
+
k [int] : 5
|
|
293
|
+
END
|
|
294
|
+
|
|
295
|
+
# A text value's fixture has its own BEGIN/END blocks, so it can't be
|
|
296
|
+
# a text block here: it's a file beside this one.
|
|
297
|
+
text_fixture [file] :
|
|
298
|
+
text_saved [file] :
|
|
299
|
+
text_src [string] :
|
|
300
|
+
text_want [string] :
|
|
301
|
+
where [string] :
|
|
302
|
+
|
|
303
|
+
utf8_fixture [text] : BEGIN
|
|
304
|
+
# Café — ünïcödé 🎉
|
|
305
|
+
lossless_utf8 [can] :
|
|
306
|
+
greeting [string] : héllo wörld 👋
|
|
307
|
+
END
|
|
308
|
+
|
|
309
|
+
untouched_script_body_round_trips [test] :
|
|
310
|
+
description [string] : blank lines, comments and a continuation in a script body survive a save.
|
|
311
|
+
on_test [script] :
|
|
312
|
+
tell ^^.f to write ( ^^.body_fixture )
|
|
313
|
+
load ( ^^.f )
|
|
314
|
+
tell lossless_body.s to run
|
|
315
|
+
eval lossless_body.n = 4
|
|
316
|
+
assert "sanity: the body ran, continuation and all"
|
|
317
|
+
put 0 into lossless_body.n
|
|
318
|
+
save lossless_body
|
|
319
|
+
tell ^^.f to read ( ^^.out )
|
|
320
|
+
eval ^^.out = ^^.body_fixture
|
|
321
|
+
assert "expected the body exactly as written"
|
|
322
|
+
tell lossless_body to unload
|
|
323
|
+
tell ^^.f to delete
|
|
324
|
+
|
|
325
|
+
directive_stays_below_its_comments [test] :
|
|
326
|
+
description [string] : a load lib directive stays where it was written.
|
|
327
|
+
on_test [script] :
|
|
328
|
+
tell ^^.f to write ( ^^.directive_fixture )
|
|
329
|
+
load ( ^^.f )
|
|
330
|
+
save lossless_lib
|
|
331
|
+
tell ^^.f to read ( ^^.out )
|
|
332
|
+
eval ^^.out = ^^.directive_fixture
|
|
333
|
+
assert "expected the directive below the comment block"
|
|
334
|
+
tell lossless_lib to unload
|
|
335
|
+
tell ^^.f to delete
|
|
336
|
+
|
|
337
|
+
untyped_stays_untyped [test] :
|
|
338
|
+
description [string] : an untyped declaration is saved without a type, changed or not.
|
|
339
|
+
on_test [script] :
|
|
340
|
+
tell ^^.f to write ( ^^.untyped_fixture )
|
|
341
|
+
load ( ^^.f )
|
|
342
|
+
save lossless_untyped
|
|
343
|
+
tell ^^.f to read ( ^^.out )
|
|
344
|
+
eval ^^.out = ^^.untyped_fixture
|
|
345
|
+
assert "expected the untouched declaration exactly as written"
|
|
346
|
+
put 'changed' into lossless_untyped.plain
|
|
347
|
+
save lossless_untyped
|
|
348
|
+
tell ^^.f to read ( ^^.out )
|
|
349
|
+
eval ^^.out = ^^.untyped_changed
|
|
350
|
+
assert "expected only the value to change"
|
|
351
|
+
tell lossless_untyped to unload
|
|
352
|
+
tell ^^.f to delete
|
|
353
|
+
|
|
354
|
+
an_edit_changes_only_the_first_same_name_line [test] :
|
|
355
|
+
description [string] : the first declaration holds the value; a later same-name line is kept as written.
|
|
356
|
+
expect_errors [bool] : true
|
|
357
|
+
on_test [script] :
|
|
358
|
+
tell ^^.f to write ( ^^.same_name_fixture )
|
|
359
|
+
load ( ^^.f )
|
|
360
|
+
put 'Changed' into lossless_same.a
|
|
361
|
+
save lossless_same
|
|
362
|
+
tell ^^.f to read ( ^^.out )
|
|
363
|
+
eval ^^.out = ^^.same_name_changed
|
|
364
|
+
assert "expected Second A to stay"
|
|
365
|
+
tell lossless_same to unload
|
|
366
|
+
tell ^^.f to delete
|
|
367
|
+
|
|
368
|
+
a_shorthand_child_is_written_once [test] :
|
|
369
|
+
description [string] : a container plus shorthand into it saves exactly as written.
|
|
370
|
+
on_test [script] :
|
|
371
|
+
tell ^^.f to write ( ^^.shorthand_fixture )
|
|
372
|
+
load ( ^^.f )
|
|
373
|
+
save lossless_short
|
|
374
|
+
tell ^^.f to read ( ^^.out )
|
|
375
|
+
eval ^^.out = ^^.shorthand_fixture
|
|
376
|
+
assert "expected the shorthand child not to be written again"
|
|
377
|
+
tell lossless_short to unload
|
|
378
|
+
tell ^^.f to delete
|
|
379
|
+
|
|
380
|
+
a_new_child_follows_the_files_style [test] :
|
|
381
|
+
description [string] : a new object is written with the file's indentation and type spelling.
|
|
382
|
+
on_test [script] :
|
|
383
|
+
tell ^^.f to write ( ^^.style_fixture )
|
|
384
|
+
load ( ^^.f )
|
|
385
|
+
create lossless_style.k as integer : 5
|
|
386
|
+
save lossless_style
|
|
387
|
+
tell ^^.f to read ( ^^.out )
|
|
388
|
+
eval ^^.out = ^^.style_changed
|
|
389
|
+
assert "expected two spaces and [int]"
|
|
390
|
+
tell lossless_style to unload
|
|
391
|
+
tell ^^.f to delete
|
|
392
|
+
|
|
393
|
+
appending_to_text_does_not_indent_it [test] :
|
|
394
|
+
description [string] : a changed text value is written exactly, so saving it twice adds nothing.
|
|
395
|
+
on_test [script] :
|
|
396
|
+
check ^^ for source_dir
|
|
397
|
+
put it into ^^.where
|
|
398
|
+
put ^^.where '/fixtures/lossless_text.gloo' into ^^.text_fixture
|
|
399
|
+
put ^^.where '/fixtures/lossless_text_saved.gloo' into ^^.text_saved
|
|
400
|
+
tell ^^.text_fixture to read ( ^^.text_src )
|
|
401
|
+
tell ^^.text_saved to read ( ^^.text_want )
|
|
402
|
+
tell ^^.f to write ( ^^.text_src )
|
|
403
|
+
load ( ^^.f )
|
|
404
|
+
put lossless_text.log + lossless_text.entry into lossless_text.log
|
|
405
|
+
save lossless_text
|
|
406
|
+
put lossless_text.log + lossless_text.entry into lossless_text.log
|
|
407
|
+
save lossless_text
|
|
408
|
+
tell ^^.f to read ( ^^.out )
|
|
409
|
+
eval ^^.out = ^^.text_want
|
|
410
|
+
assert "expected the lines with no added indentation"
|
|
411
|
+
tell lossless_text to unload
|
|
412
|
+
tell ^^.f to delete
|
|
413
|
+
|
|
414
|
+
utf8_round_trips [test] :
|
|
415
|
+
description [string] : non-ASCII text loads and saves exactly.
|
|
416
|
+
on_test [script] :
|
|
417
|
+
tell ^^.f to write ( ^^.utf8_fixture )
|
|
418
|
+
load ( ^^.f )
|
|
419
|
+
eval lossless_utf8.greeting = 'héllo wörld 👋'
|
|
420
|
+
assert "expected the value as written"
|
|
421
|
+
save lossless_utf8
|
|
422
|
+
tell ^^.f to read ( ^^.out )
|
|
423
|
+
eval ^^.out = ^^.utf8_fixture
|
|
424
|
+
assert "expected the file exactly as written"
|
|
425
|
+
tell lossless_utf8 to unload
|
|
426
|
+
tell ^^.f to delete
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
# -------------------------------------------------------------------
|
|
430
|
+
# Where a new file saved with a relative name goes (7.2): next to
|
|
431
|
+
# the saving script's file. These scripts are declared in this
|
|
432
|
+
# file, so that's the folder this file is in.
|
|
433
|
+
# -------------------------------------------------------------------
|
|
434
|
+
|
|
435
|
+
beside_target [file] :
|
|
436
|
+
|
|
437
|
+
save_to_a_relative_name_beside_this_file [test] :
|
|
438
|
+
description [string] : save {obj} to {relative name} writes the file next to the file the script came from.
|
|
439
|
+
on_test [script] :
|
|
440
|
+
check ^^ for source_dir
|
|
441
|
+
put it '/fixtures/save_beside.gloo' into ^^.beside_target
|
|
442
|
+
create save_beside_demo as can
|
|
443
|
+
create save_beside_demo.s as string : beside
|
|
444
|
+
save save_beside_demo to fixtures/save_beside
|
|
445
|
+
check ^^.beside_target for exists?
|
|
446
|
+
assert "expected fixtures/save_beside.gloo beside this file"
|
|
447
|
+
tell ^^.beside_target to read ( ^^.out )
|
|
448
|
+
check ^^.out for substring? ( "s [string] : beside" )
|
|
449
|
+
assert "expected the saved object in the file"
|
|
450
|
+
tell save_beside_demo to unload
|
|
451
|
+
tell ^^.beside_target to delete
|
|
452
|
+
|
|
453
|
+
save_a_new_root_beside_this_file [test] :
|
|
454
|
+
description [string] : save of a top-level object with no file yet writes it next to the file the script came from.
|
|
455
|
+
on_test [script] :
|
|
456
|
+
check ^^ for source_dir
|
|
457
|
+
put it '/save_beside_root.gloo' into ^^.beside_target
|
|
458
|
+
create save_beside_root as can
|
|
459
|
+
save save_beside_root
|
|
460
|
+
check ^^.beside_target for exists?
|
|
461
|
+
assert "expected save_beside_root.gloo beside this file"
|
|
462
|
+
tell save_beside_root to unload
|
|
463
|
+
tell ^^.beside_target to delete
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gloo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 7.
|
|
4
|
+
version: '7.2'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Eric Crane
|
|
@@ -389,13 +389,16 @@ files:
|
|
|
389
389
|
- lib/gloo/objs/web/json.rb
|
|
390
390
|
- lib/gloo/objs/web/uri.rb
|
|
391
391
|
- lib/gloo/persist/declaration_ledger.rb
|
|
392
|
+
- lib/gloo/persist/declaration_writer.rb
|
|
392
393
|
- lib/gloo/persist/disc_mech.rb
|
|
393
394
|
- lib/gloo/persist/file_loader.rb
|
|
394
395
|
- lib/gloo/persist/file_saver.rb
|
|
395
396
|
- lib/gloo/persist/file_storage.rb
|
|
397
|
+
- lib/gloo/persist/file_style.rb
|
|
396
398
|
- lib/gloo/persist/indent_stack.rb
|
|
397
399
|
- lib/gloo/persist/line_splitter.rb
|
|
398
400
|
- lib/gloo/persist/persist_man.rb
|
|
401
|
+
- lib/gloo/persist/save_index.rb
|
|
399
402
|
- lib/gloo/persist/script_body_collector.rb
|
|
400
403
|
- lib/gloo/persist/shorthand_expander.rb
|
|
401
404
|
- lib/gloo/persist/source/blank_node.rb
|
|
@@ -443,7 +446,9 @@ files:
|
|
|
443
446
|
- lib/gloo/verbs/wait.rb
|
|
444
447
|
- lib/run.rb
|
|
445
448
|
- test.gloo/app/embed.test.gloo
|
|
449
|
+
- test.gloo/app/exit_status.test.gloo
|
|
446
450
|
- test.gloo/app/fixtures/embed_harness.rb
|
|
451
|
+
- test.gloo/app/fixtures/exit_after_error.gloo
|
|
447
452
|
- test.gloo/basic.test.gloo
|
|
448
453
|
- test.gloo/ctrl/each.test.gloo
|
|
449
454
|
- test.gloo/dt/date.test.gloo
|
|
@@ -455,6 +460,7 @@ files:
|
|
|
455
460
|
- test.gloo/lang/dt_comparisons.test.gloo
|
|
456
461
|
- test.gloo/lang/exceptions.test.gloo
|
|
457
462
|
- test.gloo/lang/failures.test.gloo
|
|
463
|
+
- test.gloo/lang/fixtures/mixed_indent.gloo
|
|
458
464
|
- test.gloo/lang/gloo_sys.test.gloo
|
|
459
465
|
- test.gloo/lang/here.test.gloo
|
|
460
466
|
- test.gloo/lang/it.test.gloo
|
|
@@ -495,6 +501,9 @@ files:
|
|
|
495
501
|
- test.gloo/verbs/create.test.gloo
|
|
496
502
|
- test.gloo/verbs/eval.test.gloo
|
|
497
503
|
- test.gloo/verbs/exists.test.gloo
|
|
504
|
+
- test.gloo/verbs/fixtures/load_beside.gloo
|
|
505
|
+
- test.gloo/verbs/fixtures/lossless_text.gloo
|
|
506
|
+
- test.gloo/verbs/fixtures/lossless_text_saved.gloo
|
|
498
507
|
- test.gloo/verbs/if.test.gloo
|
|
499
508
|
- test.gloo/verbs/invoke.test.gloo
|
|
500
509
|
- test.gloo/verbs/list.test.gloo
|