markdown_exec 1.6 → 1.7
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/.rubocop.yml +1 -1
- data/Gemfile.lock +1 -1
- data/Rakefile +1 -0
- data/bin/tab_completion.sh +2 -2
- data/examples/import0.md +41 -5
- data/examples/import1.md +9 -8
- data/examples/linked1.md +8 -4
- data/lib/array.rb +27 -0
- data/lib/array_util.rb +21 -0
- data/lib/cached_nested_file_reader.rb +51 -31
- data/lib/constants.rb +46 -0
- data/lib/env.rb +2 -1
- data/lib/exceptions.rb +34 -0
- data/lib/fcb.rb +41 -1
- data/lib/filter.rb +32 -17
- data/lib/fout.rb +52 -0
- data/lib/hash.rb +21 -0
- data/lib/hash_delegator.rb +2709 -0
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/markdown_exec.rb +137 -1458
- data/lib/mdoc.rb +0 -3
- data/lib/menu.src.yml +137 -27
- data/lib/menu.yml +131 -23
- data/lib/method_sorter.rb +19 -17
- data/lib/object_present.rb +1 -1
- data/lib/option_value.rb +4 -2
- data/lib/pty1.rb +16 -16
- data/lib/regexp.rb +4 -5
- data/lib/saved_assets.rb +4 -2
- data/lib/saved_files_matcher.rb +7 -3
- data/lib/shared.rb +0 -5
- data/lib/string_util.rb +22 -0
- data/lib/tap.rb +5 -2
- metadata +10 -3
- data/lib/environment_opt_parse.rb +0 -209
data/lib/mdoc.rb
CHANGED
@@ -209,9 +209,6 @@ module MarkdownExec
|
|
209
209
|
end
|
210
210
|
end
|
211
211
|
|
212
|
-
# def load_auto_blocks(opts)
|
213
|
-
# end
|
214
|
-
|
215
212
|
# Recursively fetches required code blocks for a given list of requirements.
|
216
213
|
#
|
217
214
|
# @param reqs [Array<String>] An array of requirements to start the recursion from.
|
data/lib/menu.src.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
- :description: Show current configuration values
|
3
3
|
:procname: show_config
|
4
|
-
:short_name:
|
4
|
+
:short_name: "0"
|
5
5
|
|
6
6
|
- :arg_name: BOOL
|
7
7
|
:default: false
|
@@ -113,6 +113,24 @@
|
|
113
113
|
:opt_name: exclude_expect_blocks
|
114
114
|
:procname: val_as_bool
|
115
115
|
|
116
|
+
- :default: magenta
|
117
|
+
:description: execution_report_preview_frame_color
|
118
|
+
:env_var: MDE_EXECUTION_REPORT_PREVIEW_FRAME_COLOR
|
119
|
+
:opt_name: execution_report_preview_frame_color
|
120
|
+
:procname: val_as_str
|
121
|
+
|
122
|
+
- :default: "\n -^-"
|
123
|
+
:description: execution_report_preview_head
|
124
|
+
:env_var: MDE_EXECUTION_REPORT_PREVIEW_HEAD
|
125
|
+
:opt_name: execution_report_preview_head
|
126
|
+
:procname: val_as_str
|
127
|
+
|
128
|
+
- :default: " -v-"
|
129
|
+
:description: execution_report_preview_tail
|
130
|
+
:env_var: MDE_EXECUTION_REPORT_PREVIEW_TAIL
|
131
|
+
:opt_name: execution_report_preview_tail
|
132
|
+
:procname: val_as_str
|
133
|
+
|
116
134
|
- :description: Exit app
|
117
135
|
:long_name: exit
|
118
136
|
:procname: exit
|
@@ -178,7 +196,7 @@
|
|
178
196
|
:opt_name: history_property_separator
|
179
197
|
:procname: val_as_str
|
180
198
|
|
181
|
-
- :default: "^ *@import (
|
199
|
+
- :default: "^ *@import +(?<name>.+?) *$"
|
182
200
|
:env_var: MDE_IMPORT_PATTERN
|
183
201
|
:opt_name: import_pattern
|
184
202
|
:procname: val_as_str
|
@@ -313,6 +331,26 @@
|
|
313
331
|
:opt_name: menu_final_divider
|
314
332
|
:procname: val_as_str
|
315
333
|
|
334
|
+
- :default: "0"
|
335
|
+
:description: Import levels for blocks to appear in menu. Empty is all.
|
336
|
+
:env_var: MDE_MENU_IMPORT_LEVEL_MATCH
|
337
|
+
:opt_name: menu_import_level_match
|
338
|
+
:procname: val_as_str
|
339
|
+
|
340
|
+
- :arg_name: BOOL
|
341
|
+
:default: true
|
342
|
+
:description: Include imported blocks in menu
|
343
|
+
:env_var: MDE_MENU_INCLUDE_IMPORTED_BLOCKS
|
344
|
+
:opt_name: menu_include_imported_blocks
|
345
|
+
:procname: val_as_bool
|
346
|
+
|
347
|
+
- :arg_name: BOOL
|
348
|
+
:default: false
|
349
|
+
:description: Include imported notes in menu
|
350
|
+
:env_var: MDE_MENU_INCLUDE_IMPORTED_NOTES
|
351
|
+
:opt_name: menu_include_imported_notes
|
352
|
+
:procname: val_as_bool
|
353
|
+
|
316
354
|
- :default:
|
317
355
|
:line: ""
|
318
356
|
:description: opening demarcation for menu
|
@@ -447,18 +485,6 @@
|
|
447
485
|
:opt_name: no_chrome
|
448
486
|
:procname: val_as_bool
|
449
487
|
|
450
|
-
- :default: " #=#=#"
|
451
|
-
:description: Output divider
|
452
|
-
:env_var: MDE_OUTPUT_DIVIDER
|
453
|
-
:opt_name: output_divider
|
454
|
-
:procname: val_as_str
|
455
|
-
|
456
|
-
- :default: yellow
|
457
|
-
:description: Color of output divider
|
458
|
-
:env_var: MDE_OUTPUT_DIVIDER_COLOR
|
459
|
-
:opt_name: output_divider_color
|
460
|
-
:procname: val_as_str
|
461
|
-
|
462
488
|
- :arg_name: BOOL
|
463
489
|
:default: false
|
464
490
|
:description: Display summary for execution
|
@@ -467,6 +493,24 @@
|
|
467
493
|
:opt_name: output_execution_summary
|
468
494
|
:procname: val_as_bool
|
469
495
|
|
496
|
+
- :default: "%{name}: %{value}"
|
497
|
+
:description: format for menu dividers and demarcations
|
498
|
+
:env_var: MDE_OUTPUT_EXECUTION_LABEL_FORMAT
|
499
|
+
:opt_name: output_execution_label_format
|
500
|
+
:procname: val_as_str
|
501
|
+
|
502
|
+
- :default: yellow
|
503
|
+
:description: Color of output_execution_label_name
|
504
|
+
:env_var: MDE_OUTPUT_EXECUTION_LABEL_NAME_COLOR
|
505
|
+
:opt_name: output_execution_label_name_color
|
506
|
+
:procname: val_as_str
|
507
|
+
|
508
|
+
- :default: plain
|
509
|
+
:description: Color of output_execution_label_value
|
510
|
+
:env_var: MDE_OUTPUT_EXECUTION_LABEL_VALUE_COLOR
|
511
|
+
:opt_name: output_execution_label_value_color
|
512
|
+
:procname: val_as_str
|
513
|
+
|
470
514
|
- :arg_name: BOOL
|
471
515
|
:default: false
|
472
516
|
:description: Output saved script filename at end of execution
|
@@ -507,29 +551,35 @@
|
|
507
551
|
- :arg_name: BOOL
|
508
552
|
:default: true
|
509
553
|
:description: Pause afte executing a BASH block
|
510
|
-
:env_var:
|
511
|
-
:opt_name:
|
554
|
+
:env_var: MDE_PAUSE_after_script_execution
|
555
|
+
:opt_name: pause_after_script_execution
|
512
556
|
:procname: val_as_bool
|
513
557
|
|
514
|
-
- :default:
|
515
|
-
:description: Prompt
|
516
|
-
:env_var:
|
517
|
-
:opt_name:
|
558
|
+
- :default: "\nContinue?"
|
559
|
+
:description: Prompt after script execution
|
560
|
+
:env_var: MDE_PROMPT_after_script_execution
|
561
|
+
:opt_name: prompt_after_script_execution
|
518
562
|
:procname: val_as_str
|
519
563
|
|
520
|
-
- :default:
|
564
|
+
- :default: "\nProcess?"
|
521
565
|
:description: Prompt to approve a block
|
522
566
|
:env_var: MDE_PROMPT_APPROVE_BLOCK
|
523
567
|
:opt_name: prompt_approve_block
|
524
568
|
:procname: val_as_str
|
525
569
|
|
570
|
+
- :default: cyan
|
571
|
+
:description: Color of prompt after script execution
|
572
|
+
:env_var: MDE_PROMPT_COLOR_AFTER_SCRIPT_EXECUTION
|
573
|
+
:opt_name: prompt_color_after_script_execution
|
574
|
+
:procname: val_as_str
|
575
|
+
|
526
576
|
- :default: Exit
|
527
577
|
:description: Prompt to exit app
|
528
578
|
:env_var: MDE_PROMPT_EXIT
|
529
579
|
:opt_name: prompt_exit
|
530
580
|
:procname: val_as_str
|
531
581
|
|
532
|
-
- :default:
|
582
|
+
- :default: "No"
|
533
583
|
:description: Prompt for no
|
534
584
|
:env_var: MDE_PROMPT_NO
|
535
585
|
:opt_name: prompt_no
|
@@ -547,25 +597,25 @@
|
|
547
597
|
:opt_name: prompt_script_to_clipboard
|
548
598
|
:procname: val_as_str
|
549
599
|
|
550
|
-
- :default:
|
600
|
+
- :default: "\nChoose a block:"
|
551
601
|
:description: Prompt to select a block
|
552
602
|
:env_var: MDE_PROMPT_SELECT_BLOCK
|
553
603
|
:opt_name: prompt_select_block
|
554
604
|
:procname: val_as_str
|
555
605
|
|
556
|
-
- :default:
|
606
|
+
- :default: "\nChoose a file:"
|
557
607
|
:description: Prompt to select a markdown document
|
558
608
|
:env_var: MDE_PROMPT_SELECT_MD
|
559
609
|
:opt_name: prompt_select_md
|
560
610
|
:procname: val_as_str
|
561
611
|
|
562
|
-
- :default:
|
612
|
+
- :default: "\nChoose a file:"
|
563
613
|
:description: Prompt to select a saved file
|
564
614
|
:env_var: MDE_PROMPT_SELECT_OUTPUT
|
565
615
|
:opt_name: prompt_select_output
|
566
616
|
:procname: val_as_str
|
567
617
|
|
568
|
-
- :default:
|
618
|
+
- :default: "Yes"
|
569
619
|
:description: Prompt for yes
|
570
620
|
:env_var: MDE_PROMPT_YES
|
571
621
|
:opt_name: prompt_yes
|
@@ -597,6 +647,18 @@
|
|
597
647
|
:opt_name: save_execution_output
|
598
648
|
:procname: val_as_bool
|
599
649
|
|
650
|
+
- :default: "/"
|
651
|
+
:description: Pattern to replace in file names
|
652
|
+
:env_var: MDE_SAVED_FILENAME_PATTERN
|
653
|
+
:opt_name: saved_filename_pattern
|
654
|
+
:procname: val_as_str
|
655
|
+
|
656
|
+
- :default: ",~"
|
657
|
+
:description: Replacement for pattern in file names
|
658
|
+
:env_var: MDE_SAVED_FILENAME_REPLACEMENT
|
659
|
+
:opt_name: saved_filename_replacement
|
660
|
+
:procname: val_as_str
|
661
|
+
|
600
662
|
- :arg_name: INT
|
601
663
|
:default: 493
|
602
664
|
:description: chmod for saved scripts
|
@@ -641,6 +703,42 @@
|
|
641
703
|
:opt_name: saved_stdout_glob
|
642
704
|
:procname: val_as_str
|
643
705
|
|
706
|
+
- :default: green
|
707
|
+
:description: script_execution_frame_color
|
708
|
+
:env_var: MDE_SCRIPT_EXECUTION_FRAME_COLOR
|
709
|
+
:opt_name: script_execution_frame_color
|
710
|
+
:procname: val_as_str
|
711
|
+
|
712
|
+
- :default: "\n -^-"
|
713
|
+
:description: script_execution_head
|
714
|
+
:env_var: MDE_SCRIPT_EXECUTION_HEAD
|
715
|
+
:opt_name: script_execution_head
|
716
|
+
:procname: val_as_str
|
717
|
+
|
718
|
+
- :default: " -v-\n"
|
719
|
+
:description: script_execution_tail
|
720
|
+
:env_var: MDE_SCRIPT_EXECUTION_TAIL
|
721
|
+
:opt_name: script_execution_tail
|
722
|
+
:procname: val_as_str
|
723
|
+
|
724
|
+
- :default: yellow
|
725
|
+
:description: Color of output divider
|
726
|
+
:env_var: MDE_OUTPUT_DIVIDER_COLOR
|
727
|
+
:opt_name: script_preview_frame_color
|
728
|
+
:procname: val_as_str
|
729
|
+
|
730
|
+
- :default: "\n -^-"
|
731
|
+
:description: script_preview_head
|
732
|
+
:env_var: MDE_SCRIPT_PREVIEW_HEAD
|
733
|
+
:opt_name: script_preview_head
|
734
|
+
:procname: val_as_str
|
735
|
+
|
736
|
+
- :default: " -v-\n"
|
737
|
+
:description: script_preview_tail
|
738
|
+
:env_var: MDE_SCRIPT_PREVIEW_TAIL
|
739
|
+
:opt_name: script_preview_tail
|
740
|
+
:procname: val_as_str
|
741
|
+
|
644
742
|
- :arg_name: REGEX
|
645
743
|
:default:
|
646
744
|
:description: Select blocks with name matching
|
@@ -656,7 +754,7 @@
|
|
656
754
|
:procname: val_as_str
|
657
755
|
|
658
756
|
- :default: 36
|
659
|
-
:description:
|
757
|
+
:description: "Maximum # of rows in select list"
|
660
758
|
:env_var: MDE_SELECT_PAGE_HEIGHT
|
661
759
|
:opt_name: select_page_height
|
662
760
|
:procname: val_as_int
|
@@ -701,3 +799,15 @@
|
|
701
799
|
:long_name: version
|
702
800
|
:procname: version
|
703
801
|
:short_name: v
|
802
|
+
|
803
|
+
- :default: red
|
804
|
+
:description: Color of warning message
|
805
|
+
:env_var: MDE_WARNING_COLOR
|
806
|
+
:opt_name: warning_color
|
807
|
+
:procname: val_as_str
|
808
|
+
|
809
|
+
- :default: "Error: %{error}"
|
810
|
+
:description: Format of warning message
|
811
|
+
:env_var: MDE_WARNING_FORMAT
|
812
|
+
:opt_name: warning_format
|
813
|
+
:procname: val_as_str
|
data/lib/menu.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# MDE - Markdown Executor (1.
|
1
|
+
# MDE - Markdown Executor (1.7)
|
2
2
|
---
|
3
3
|
- :description: Show current configuration values
|
4
4
|
:procname: show_config
|
@@ -95,6 +95,23 @@
|
|
95
95
|
:env_var: MDE_EXCLUDE_EXPECT_BLOCKS
|
96
96
|
:opt_name: exclude_expect_blocks
|
97
97
|
:procname: val_as_bool
|
98
|
+
- :default: magenta
|
99
|
+
:description: execution_report_preview_frame_color
|
100
|
+
:env_var: MDE_EXECUTION_REPORT_PREVIEW_FRAME_COLOR
|
101
|
+
:opt_name: execution_report_preview_frame_color
|
102
|
+
:procname: val_as_str
|
103
|
+
- :default: |2-
|
104
|
+
|
105
|
+
-^-
|
106
|
+
:description: execution_report_preview_head
|
107
|
+
:env_var: MDE_EXECUTION_REPORT_PREVIEW_HEAD
|
108
|
+
:opt_name: execution_report_preview_head
|
109
|
+
:procname: val_as_str
|
110
|
+
- :default: " -v-"
|
111
|
+
:description: execution_report_preview_tail
|
112
|
+
:env_var: MDE_EXECUTION_REPORT_PREVIEW_TAIL
|
113
|
+
:opt_name: execution_report_preview_tail
|
114
|
+
:procname: val_as_str
|
98
115
|
- :description: Exit app
|
99
116
|
:long_name: exit
|
100
117
|
:procname: exit
|
@@ -148,7 +165,7 @@
|
|
148
165
|
:env_var: MDE_HISTORY_PROPERTY_SEPARATOR
|
149
166
|
:opt_name: history_property_separator
|
150
167
|
:procname: val_as_str
|
151
|
-
- :default: "^ *@import (
|
168
|
+
- :default: "^ *@import +(?<name>.+?) *$"
|
152
169
|
:env_var: MDE_IMPORT_PATTERN
|
153
170
|
:opt_name: import_pattern
|
154
171
|
:procname: val_as_str
|
@@ -260,6 +277,23 @@
|
|
260
277
|
:env_var: MDE_MENU_FINAL_DIVIDER
|
261
278
|
:opt_name: menu_final_divider
|
262
279
|
:procname: val_as_str
|
280
|
+
- :default: '0'
|
281
|
+
:description: Import levels for blocks to appear in menu. Empty is all.
|
282
|
+
:env_var: MDE_MENU_IMPORT_LEVEL_MATCH
|
283
|
+
:opt_name: menu_import_level_match
|
284
|
+
:procname: val_as_str
|
285
|
+
- :arg_name: BOOL
|
286
|
+
:default: true
|
287
|
+
:description: Include imported blocks in menu
|
288
|
+
:env_var: MDE_MENU_INCLUDE_IMPORTED_BLOCKS
|
289
|
+
:opt_name: menu_include_imported_blocks
|
290
|
+
:procname: val_as_bool
|
291
|
+
- :arg_name: BOOL
|
292
|
+
:default: false
|
293
|
+
:description: Include imported notes in menu
|
294
|
+
:env_var: MDE_MENU_INCLUDE_IMPORTED_NOTES
|
295
|
+
:opt_name: menu_include_imported_notes
|
296
|
+
:procname: val_as_bool
|
263
297
|
- :default:
|
264
298
|
:line: ''
|
265
299
|
:description: opening demarcation for menu
|
@@ -371,16 +405,6 @@
|
|
371
405
|
:env_var: MDE_NO_CHROME
|
372
406
|
:opt_name: no_chrome
|
373
407
|
:procname: val_as_bool
|
374
|
-
- :default: " #=#=#"
|
375
|
-
:description: Output divider
|
376
|
-
:env_var: MDE_OUTPUT_DIVIDER
|
377
|
-
:opt_name: output_divider
|
378
|
-
:procname: val_as_str
|
379
|
-
- :default: yellow
|
380
|
-
:description: Color of output divider
|
381
|
-
:env_var: MDE_OUTPUT_DIVIDER_COLOR
|
382
|
-
:opt_name: output_divider_color
|
383
|
-
:procname: val_as_str
|
384
408
|
- :arg_name: BOOL
|
385
409
|
:default: false
|
386
410
|
:description: Display summary for execution
|
@@ -388,6 +412,21 @@
|
|
388
412
|
:long_name: output-execution-summary
|
389
413
|
:opt_name: output_execution_summary
|
390
414
|
:procname: val_as_bool
|
415
|
+
- :default: "%{name}: %{value}"
|
416
|
+
:description: format for menu dividers and demarcations
|
417
|
+
:env_var: MDE_OUTPUT_EXECUTION_LABEL_FORMAT
|
418
|
+
:opt_name: output_execution_label_format
|
419
|
+
:procname: val_as_str
|
420
|
+
- :default: yellow
|
421
|
+
:description: Color of output_execution_label_name
|
422
|
+
:env_var: MDE_OUTPUT_EXECUTION_LABEL_NAME_COLOR
|
423
|
+
:opt_name: output_execution_label_name_color
|
424
|
+
:procname: val_as_str
|
425
|
+
- :default: plain
|
426
|
+
:description: Color of output_execution_label_value
|
427
|
+
:env_var: MDE_OUTPUT_EXECUTION_LABEL_VALUE_COLOR
|
428
|
+
:opt_name: output_execution_label_value_color
|
429
|
+
:procname: val_as_str
|
391
430
|
- :arg_name: BOOL
|
392
431
|
:default: false
|
393
432
|
:description: Output saved script filename at end of execution
|
@@ -423,19 +462,28 @@
|
|
423
462
|
- :arg_name: BOOL
|
424
463
|
:default: true
|
425
464
|
:description: Pause afte executing a BASH block
|
426
|
-
:env_var:
|
427
|
-
:opt_name:
|
465
|
+
:env_var: MDE_PAUSE_after_script_execution
|
466
|
+
:opt_name: pause_after_script_execution
|
428
467
|
:procname: val_as_bool
|
429
|
-
- :default:
|
430
|
-
|
431
|
-
|
432
|
-
:
|
433
|
-
:
|
434
|
-
|
468
|
+
- :default: |2-
|
469
|
+
|
470
|
+
Continue?
|
471
|
+
:description: Prompt after script execution
|
472
|
+
:env_var: MDE_PROMPT_after_script_execution
|
473
|
+
:opt_name: prompt_after_script_execution
|
474
|
+
:procname: val_as_str
|
475
|
+
- :default: |2-
|
476
|
+
|
477
|
+
Process?
|
435
478
|
:description: Prompt to approve a block
|
436
479
|
:env_var: MDE_PROMPT_APPROVE_BLOCK
|
437
480
|
:opt_name: prompt_approve_block
|
438
481
|
:procname: val_as_str
|
482
|
+
- :default: cyan
|
483
|
+
:description: Color of prompt after script execution
|
484
|
+
:env_var: MDE_PROMPT_COLOR_AFTER_SCRIPT_EXECUTION
|
485
|
+
:opt_name: prompt_color_after_script_execution
|
486
|
+
:procname: val_as_str
|
439
487
|
- :default: Exit
|
440
488
|
:description: Prompt to exit app
|
441
489
|
:env_var: MDE_PROMPT_EXIT
|
@@ -456,17 +504,23 @@
|
|
456
504
|
:env_var: MDE_PROMPT_SCRIPT_TO_CLIPBOARD
|
457
505
|
:opt_name: prompt_script_to_clipboard
|
458
506
|
:procname: val_as_str
|
459
|
-
- :default:
|
507
|
+
- :default: |2-
|
508
|
+
|
509
|
+
Choose a block:
|
460
510
|
:description: Prompt to select a block
|
461
511
|
:env_var: MDE_PROMPT_SELECT_BLOCK
|
462
512
|
:opt_name: prompt_select_block
|
463
513
|
:procname: val_as_str
|
464
|
-
- :default:
|
514
|
+
- :default: |2-
|
515
|
+
|
516
|
+
Choose a file:
|
465
517
|
:description: Prompt to select a markdown document
|
466
518
|
:env_var: MDE_PROMPT_SELECT_MD
|
467
519
|
:opt_name: prompt_select_md
|
468
520
|
:procname: val_as_str
|
469
|
-
- :default:
|
521
|
+
- :default: |2-
|
522
|
+
|
523
|
+
Choose a file:
|
470
524
|
:description: Prompt to select a saved file
|
471
525
|
:env_var: MDE_PROMPT_SELECT_OUTPUT
|
472
526
|
:opt_name: prompt_select_output
|
@@ -498,6 +552,16 @@
|
|
498
552
|
:long_name: save-execution-output
|
499
553
|
:opt_name: save_execution_output
|
500
554
|
:procname: val_as_bool
|
555
|
+
- :default: "/"
|
556
|
+
:description: Pattern to replace in file names
|
557
|
+
:env_var: MDE_SAVED_FILENAME_PATTERN
|
558
|
+
:opt_name: saved_filename_pattern
|
559
|
+
:procname: val_as_str
|
560
|
+
- :default: ",~"
|
561
|
+
:description: Replacement for pattern in file names
|
562
|
+
:env_var: MDE_SAVED_FILENAME_REPLACEMENT
|
563
|
+
:opt_name: saved_filename_replacement
|
564
|
+
:procname: val_as_str
|
501
565
|
- :arg_name: INT
|
502
566
|
:default: 493
|
503
567
|
:description: chmod for saved scripts
|
@@ -536,6 +600,40 @@
|
|
536
600
|
:env_var: MDE_SAVED_STDOUT_GLOB
|
537
601
|
:opt_name: saved_stdout_glob
|
538
602
|
:procname: val_as_str
|
603
|
+
- :default: green
|
604
|
+
:description: script_execution_frame_color
|
605
|
+
:env_var: MDE_SCRIPT_EXECUTION_FRAME_COLOR
|
606
|
+
:opt_name: script_execution_frame_color
|
607
|
+
:procname: val_as_str
|
608
|
+
- :default: |2-
|
609
|
+
|
610
|
+
-^-
|
611
|
+
:description: script_execution_head
|
612
|
+
:env_var: MDE_SCRIPT_EXECUTION_HEAD
|
613
|
+
:opt_name: script_execution_head
|
614
|
+
:procname: val_as_str
|
615
|
+
- :default: " -v-\n"
|
616
|
+
:description: script_execution_tail
|
617
|
+
:env_var: MDE_SCRIPT_EXECUTION_TAIL
|
618
|
+
:opt_name: script_execution_tail
|
619
|
+
:procname: val_as_str
|
620
|
+
- :default: yellow
|
621
|
+
:description: Color of output divider
|
622
|
+
:env_var: MDE_OUTPUT_DIVIDER_COLOR
|
623
|
+
:opt_name: script_preview_frame_color
|
624
|
+
:procname: val_as_str
|
625
|
+
- :default: |2-
|
626
|
+
|
627
|
+
-^-
|
628
|
+
:description: script_preview_head
|
629
|
+
:env_var: MDE_SCRIPT_PREVIEW_HEAD
|
630
|
+
:opt_name: script_preview_head
|
631
|
+
:procname: val_as_str
|
632
|
+
- :default: " -v-\n"
|
633
|
+
:description: script_preview_tail
|
634
|
+
:env_var: MDE_SCRIPT_PREVIEW_TAIL
|
635
|
+
:opt_name: script_preview_tail
|
636
|
+
:procname: val_as_str
|
539
637
|
- :arg_name: REGEX
|
540
638
|
:default:
|
541
639
|
:description: Select blocks with name matching
|
@@ -587,6 +685,16 @@
|
|
587
685
|
:long_name: version
|
588
686
|
:procname: version
|
589
687
|
:short_name: v
|
688
|
+
- :default: red
|
689
|
+
:description: Color of warning message
|
690
|
+
:env_var: MDE_WARNING_COLOR
|
691
|
+
:opt_name: warning_color
|
692
|
+
:procname: val_as_str
|
693
|
+
- :default: 'Error: %{error}'
|
694
|
+
:description: Format of warning message
|
695
|
+
:env_var: MDE_WARNING_FORMAT
|
696
|
+
:opt_name: warning_format
|
697
|
+
:procname: val_as_str
|
590
698
|
- :arg_name: INT.0-3
|
591
699
|
:default: 1
|
592
700
|
:description: Output display level (0 to 3 [data, +context, +info])
|
data/lib/method_sorter.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'ripper'
|
2
4
|
require 'parser/current'
|
3
5
|
|
@@ -16,10 +18,10 @@ class MethodSorter
|
|
16
18
|
|
17
19
|
method_nodes = []
|
18
20
|
|
19
|
-
# Look for method def nodes within each child node
|
21
|
+
# Look for method def nodes within each child node
|
20
22
|
class_node.children.compact.each do |child|
|
21
23
|
if child.type == :begin
|
22
|
-
method_nodes += child.children.select {|n| n.type == :def}
|
24
|
+
method_nodes += child.children.select { |n| n.type == :def }
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
@@ -30,44 +32,44 @@ class MethodSorter
|
|
30
32
|
# return
|
31
33
|
# end
|
32
34
|
|
33
|
-
# method_nodes = class_node.children.compact.select { |node|
|
35
|
+
# method_nodes = class_node.children.compact.select { |node|
|
34
36
|
# node.type == :def
|
35
|
-
# }
|
37
|
+
# }
|
36
38
|
|
37
|
-
sorted_methods = method_nodes.sort_by{ |n| n.children[0].to_s }
|
39
|
+
sorted_methods = method_nodes.sort_by { |n| n.children[0].to_s }
|
38
40
|
ripper = Ripper.sexp(file_contents)
|
39
|
-
lines = ripper.each_with_index.map{|sexp, index| [sexp, index] }
|
40
|
-
|
41
|
+
lines = ripper.each_with_index.map { |sexp, index| [sexp, index] }
|
42
|
+
|
41
43
|
method_ranges = get_method_ranges(lines, method_nodes)
|
42
|
-
|
44
|
+
|
43
45
|
result = replace_method_ranges(lines, method_ranges, sorted_methods)
|
44
|
-
|
45
|
-
puts result.compact.select{|v|v.is_a? String}.join("\n")
|
46
|
+
|
47
|
+
puts result.compact.select { |v| v.is_a? String }.join("\n")
|
46
48
|
# File.write(@file_path, result.join)
|
47
49
|
end
|
48
50
|
|
49
51
|
private
|
50
|
-
|
52
|
+
|
51
53
|
def get_method_ranges(lines, method_nodes)
|
52
54
|
method_nodes.map do |method_node|
|
53
55
|
start_line = method_node.loc.line - 1
|
54
56
|
end_line = start_line
|
55
|
-
|
57
|
+
|
56
58
|
while end_line < lines.size && lines[end_line][0] !~ /^end/
|
57
59
|
end_line += 1
|
58
60
|
end
|
59
|
-
|
61
|
+
|
60
62
|
(start_line..end_line)
|
61
63
|
end
|
62
64
|
end
|
63
|
-
|
65
|
+
|
64
66
|
def replace_method_ranges(lines, ranges, sorted_methods)
|
65
67
|
result = lines.dup
|
66
|
-
|
68
|
+
|
67
69
|
ranges.each_with_index do |range, index|
|
68
|
-
result[range] = sorted_methods[index].loc.expression.source.split("\n")
|
70
|
+
result[range] = sorted_methods[index].loc.expression.source.split("\n")
|
69
71
|
end
|
70
|
-
|
72
|
+
|
71
73
|
result
|
72
74
|
end
|
73
75
|
end
|
data/lib/object_present.rb
CHANGED
data/lib/option_value.rb
CHANGED
@@ -65,7 +65,8 @@ if $PROGRAM_NAME == __FILE__
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def test_for_hash_with_empty_value
|
68
|
-
assert_equal 'default',
|
68
|
+
assert_equal 'default',
|
69
|
+
MarkdownExec::OptionValue.for_hash([], 'default')
|
69
70
|
end
|
70
71
|
|
71
72
|
def test_for_yaml_with_string
|
@@ -82,7 +83,8 @@ if $PROGRAM_NAME == __FILE__
|
|
82
83
|
end
|
83
84
|
|
84
85
|
def test_for_yaml_with_empty_value
|
85
|
-
assert_equal 'default',
|
86
|
+
assert_equal 'default',
|
87
|
+
MarkdownExec::OptionValue.for_yaml([], 'default')
|
86
88
|
end
|
87
89
|
end
|
88
90
|
end
|
data/lib/pty1.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'pty'
|
2
4
|
|
3
5
|
def launch_and_interact_with_terminal
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
stdin.puts "echo 'Hello from Ruby!'"
|
6
|
+
PTY.spawn('bash') do |stdout, stdin, _pid|
|
7
|
+
# Send a command to the terminal
|
8
|
+
stdin.puts "echo 'Hello from Ruby!'"
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
# Read the output of the command
|
11
|
+
stdout.each do |line|
|
12
|
+
puts line
|
13
|
+
break if line.include?('Hello from Ruby!')
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
# You can continue to interact with the terminal here
|
17
|
+
# ...
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
rescue PTY::ChildExited => e
|
22
|
-
puts "The child process exited!"
|
19
|
+
# Ensure to exit the spawned shell
|
20
|
+
stdin.puts 'exit'
|
23
21
|
end
|
22
|
+
rescue PTY::ChildExited
|
23
|
+
puts 'The child process exited!'
|
24
24
|
end
|
25
25
|
|
26
26
|
launch_and_interact_with_terminal
|
data/lib/regexp.rb
CHANGED
@@ -25,15 +25,13 @@
|
|
25
25
|
# captures_hash[:file_name] = $~.pre_match.split("\n").last
|
26
26
|
# captures_hash[:line_number] = $~.pre_match.count("\n") + 1
|
27
27
|
# captures_hash[:line] = $&
|
28
|
-
|
29
|
-
require 'English'
|
30
28
|
class Regexp
|
31
29
|
def gsub_format(input_str, format_str, context: {})
|
32
30
|
input_str.gsub(self) do
|
33
31
|
format(
|
34
32
|
format_str,
|
35
|
-
context.merge(
|
36
|
-
hash[name.to_sym] =
|
33
|
+
context.merge($~.names.each_with_object({}) do |name, hash|
|
34
|
+
hash[name.to_sym] = $~[name]
|
37
35
|
end)
|
38
36
|
)
|
39
37
|
end
|
@@ -92,7 +90,8 @@ if $PROGRAM_NAME == __FILE__
|
|
92
90
|
re = /^(?<name>\w+) is (?<age>\d+).*$/
|
93
91
|
fmt = "%<name>s's age is %<age>d and she lives in %<city>s"
|
94
92
|
|
95
|
-
result = re.gsub_format(input_str, re, fmt,
|
93
|
+
result = re.gsub_format(input_str, re, fmt,
|
94
|
+
context: { city: 'New York' })
|
96
95
|
|
97
96
|
assert_equal "Jane's age is 25 and she lives in New York", result
|
98
97
|
end
|