markdown_exec 1.6 → 1.8
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 +5 -2
- data/Gemfile.lock +1 -1
- data/Rakefile +2 -0
- data/bin/tab_completion.sh +19 -3
- data/examples/colors.md +48 -0
- data/examples/import0.md +41 -5
- data/examples/import1.md +9 -8
- data/examples/include.md +11 -4
- data/examples/linked1.md +8 -4
- data/examples/opts.md +7 -0
- data/lib/ansi_formatter.rb +161 -0
- 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/directory_searcher.rb +239 -0
- 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 +2796 -0
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/markdown_exec.rb +190 -1474
- data/lib/mdoc.rb +148 -36
- data/lib/menu.src.yml +224 -37
- data/lib/menu.yml +209 -33
- data/lib/method_sorter.rb +19 -17
- data/lib/object_present.rb +1 -1
- data/lib/pty1.rb +16 -16
- data/lib/regexp.rb +2 -4
- data/lib/shared.rb +0 -5
- data/lib/string_util.rb +22 -0
- metadata +13 -3
- data/lib/environment_opt_parse.rb +0 -209
data/lib/menu.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# MDE - Markdown Executor (1.
|
1
|
+
# MDE - Markdown Executor (1.8)
|
2
2
|
---
|
3
3
|
- :description: Show current configuration values
|
4
4
|
:procname: show_config
|
@@ -77,6 +77,46 @@
|
|
77
77
|
:env_var: MDE_DOCUMENT_LOAD_OPTS_BLOCK_NAME
|
78
78
|
:opt_name: document_load_opts_block_name
|
79
79
|
:procname: val_as_str
|
80
|
+
- :arg_name: BOOL
|
81
|
+
:default: false
|
82
|
+
:description: Dump BlocksInFile (stage 1)
|
83
|
+
:env_var: MDE_DUMP_BLOCKS_IN_FILE
|
84
|
+
:opt_name: dump_blocks_in_file
|
85
|
+
:procname: val_as_bool
|
86
|
+
- :arg_name: BOOL
|
87
|
+
:default: false
|
88
|
+
:description: Dump MenuBlocks (stage 2)
|
89
|
+
:env_var: MDE_DUMP_MENU_BLOCKS
|
90
|
+
:opt_name: dump_menu_blocks
|
91
|
+
:procname: val_as_bool
|
92
|
+
- :arg_name: BOOL
|
93
|
+
:default: false
|
94
|
+
:description: Dump selected block
|
95
|
+
:env_var: MDE_DUMP_SELECTED_BLOCK
|
96
|
+
:opt_name: dump_selected_block
|
97
|
+
:procname: val_as_bool
|
98
|
+
- :default: fg_rgbh_E0_E0_20
|
99
|
+
:description: Color of exception detail
|
100
|
+
:env_var: MDE_EXCEPTION_COLOR_DETAIL
|
101
|
+
:opt_name: exception_color_detail
|
102
|
+
:procname: val_as_str
|
103
|
+
- :default: " - %{detail}\n"
|
104
|
+
:description: Format for exception detail
|
105
|
+
:env_var: MDE_EXCEPTION_FORMAT_DETAIL
|
106
|
+
:opt_name: exception_format_detail
|
107
|
+
:procname: val_as_str
|
108
|
+
- :default: fg_rgbh_E0_20_20
|
109
|
+
:description: Color of exception name
|
110
|
+
:env_var: MDE_EXCEPTION_COLOR_NAME
|
111
|
+
:opt_name: exception_color_name
|
112
|
+
:procname: val_as_str
|
113
|
+
- :default: |2-
|
114
|
+
|
115
|
+
%{name}
|
116
|
+
:description: Format for exception name
|
117
|
+
:env_var: MDE_EXCEPTION_FORMAT_NAME
|
118
|
+
:opt_name: exception_format_name
|
119
|
+
:procname: val_as_str
|
80
120
|
- :arg_name: REGEX
|
81
121
|
:default:
|
82
122
|
:description: Exclude blocks with name matching
|
@@ -95,6 +135,23 @@
|
|
95
135
|
:env_var: MDE_EXCLUDE_EXPECT_BLOCKS
|
96
136
|
:opt_name: exclude_expect_blocks
|
97
137
|
:procname: val_as_bool
|
138
|
+
- :default: fg_rgbh_20_80_80
|
139
|
+
:description: execution_report_preview_frame_color
|
140
|
+
:env_var: MDE_EXECUTION_REPORT_PREVIEW_FRAME_COLOR
|
141
|
+
:opt_name: execution_report_preview_frame_color
|
142
|
+
:procname: val_as_str
|
143
|
+
- :default: |2-
|
144
|
+
|
145
|
+
-^-
|
146
|
+
:description: execution_report_preview_head
|
147
|
+
:env_var: MDE_EXECUTION_REPORT_PREVIEW_HEAD
|
148
|
+
:opt_name: execution_report_preview_head
|
149
|
+
:procname: val_as_str
|
150
|
+
- :default: " -v-"
|
151
|
+
:description: execution_report_preview_tail
|
152
|
+
:env_var: MDE_EXECUTION_REPORT_PREVIEW_TAIL
|
153
|
+
:opt_name: execution_report_preview_tail
|
154
|
+
:procname: val_as_str
|
98
155
|
- :description: Exit app
|
99
156
|
:long_name: exit
|
100
157
|
:procname: exit
|
@@ -116,6 +173,12 @@
|
|
116
173
|
:opt_name: filename
|
117
174
|
:procname: val_as_str
|
118
175
|
:short_name: f
|
176
|
+
- :arg_name: FIND
|
177
|
+
:default: ''
|
178
|
+
:description: Find in documents
|
179
|
+
:long_name: find
|
180
|
+
:procname: find
|
181
|
+
:short_name: "?"
|
119
182
|
- :default: "^# *(?<name>[^#]*?) *$"
|
120
183
|
:env_var: MDE_HEADING1_MATCH
|
121
184
|
:opt_name: heading1_match
|
@@ -148,7 +211,13 @@
|
|
148
211
|
:env_var: MDE_HISTORY_PROPERTY_SEPARATOR
|
149
212
|
:opt_name: history_property_separator
|
150
213
|
:procname: val_as_str
|
151
|
-
- :
|
214
|
+
- :arg_name: HOW
|
215
|
+
:default: ''
|
216
|
+
:description: Find in YAML configuration options
|
217
|
+
:long_name: how
|
218
|
+
:procname: how
|
219
|
+
:short_name: "?"
|
220
|
+
- :default: "^ *@import +(?<name>.+?) *$"
|
152
221
|
:env_var: MDE_IMPORT_PATTERN
|
153
222
|
:opt_name: import_pattern
|
154
223
|
:procname: val_as_str
|
@@ -201,7 +270,7 @@
|
|
201
270
|
:env_var: MDE_MENU_BACK_AT_TOP
|
202
271
|
:opt_name: menu_back_at_top
|
203
272
|
:procname: val_as_bool
|
204
|
-
- :default:
|
273
|
+
- :default: fg_rgbh_40_c0_f0
|
205
274
|
:description: Color of menu bash
|
206
275
|
:env_var: MDE_MENU_BASH_COLOR
|
207
276
|
:opt_name: menu_bash_color
|
@@ -218,7 +287,7 @@
|
|
218
287
|
:env_var: MDE_MENU_BLOCKS_WITH_HEADINGS
|
219
288
|
:opt_name: menu_blocks_with_headings
|
220
289
|
:procname: val_as_bool
|
221
|
-
- :default:
|
290
|
+
- :default: fg_rgbh_80_80_20
|
222
291
|
:description: Color of menu chrome
|
223
292
|
:env_var: MDE_MENU_CHROME_COLOR
|
224
293
|
:opt_name: menu_chrome_color
|
@@ -228,7 +297,7 @@
|
|
228
297
|
:env_var: MDE_MENU_CHROME_FORMAT
|
229
298
|
:opt_name: menu_chrome_format
|
230
299
|
:procname: val_as_str
|
231
|
-
- :default:
|
300
|
+
- :default: fg_rgbh_20_98_80
|
232
301
|
:description: Color of menu divider
|
233
302
|
:env_var: MDE_MENU_DIVIDER_COLOR
|
234
303
|
:opt_name: menu_divider_color
|
@@ -260,13 +329,30 @@
|
|
260
329
|
:env_var: MDE_MENU_FINAL_DIVIDER
|
261
330
|
:opt_name: menu_final_divider
|
262
331
|
:procname: val_as_str
|
332
|
+
- :default: '0'
|
333
|
+
:description: Import levels for blocks to appear in menu. Empty is all.
|
334
|
+
:env_var: MDE_MENU_IMPORT_LEVEL_MATCH
|
335
|
+
:opt_name: menu_import_level_match
|
336
|
+
:procname: val_as_str
|
337
|
+
- :arg_name: BOOL
|
338
|
+
:default: true
|
339
|
+
:description: Include imported blocks in menu
|
340
|
+
:env_var: MDE_MENU_INCLUDE_IMPORTED_BLOCKS
|
341
|
+
:opt_name: menu_include_imported_blocks
|
342
|
+
:procname: val_as_bool
|
343
|
+
- :arg_name: BOOL
|
344
|
+
:default: false
|
345
|
+
:description: Include imported notes in menu
|
346
|
+
:env_var: MDE_MENU_INCLUDE_IMPORTED_NOTES
|
347
|
+
:opt_name: menu_include_imported_notes
|
348
|
+
:procname: val_as_bool
|
263
349
|
- :default:
|
264
350
|
:line: ''
|
265
351
|
:description: opening demarcation for menu
|
266
352
|
:env_var: MDE_MENU_INITIAL_DIVIDER
|
267
353
|
:opt_name: menu_initial_divider
|
268
354
|
:procname: val_as_str
|
269
|
-
- :default:
|
355
|
+
- :default: fg_rgbh_20_E0_20
|
270
356
|
:description: Color of menu link
|
271
357
|
:env_var: MDE_MENU_LINK_COLOR
|
272
358
|
:opt_name: menu_link_color
|
@@ -276,7 +362,7 @@
|
|
276
362
|
:env_var: MDE_MENU_LINK_FORMAT
|
277
363
|
:opt_name: menu_link_format
|
278
364
|
:procname: val_as_str
|
279
|
-
- :default:
|
365
|
+
- :default: fg_rgbh_40_a0_a0
|
280
366
|
:description: Color of menu note
|
281
367
|
:env_var: MDE_MENU_NOTE_COLOR
|
282
368
|
:opt_name: menu_note_color
|
@@ -303,12 +389,12 @@
|
|
303
389
|
:env_var: MDE_MENU_OPTION_EXIT_NAME
|
304
390
|
:opt_name: menu_option_exit_name
|
305
391
|
:procname: val_as_str
|
306
|
-
- :default:
|
392
|
+
- :default: fg_rgbh_E0_60_E0
|
307
393
|
:description: Color of menu opts
|
308
394
|
:env_var: MDE_MENU_OPTS_COLOR
|
309
395
|
:opt_name: menu_opts_color
|
310
396
|
:procname: val_as_str
|
311
|
-
- :default:
|
397
|
+
- :default: fg_rgbh_E0_20_20
|
312
398
|
:description: Color of menu opts
|
313
399
|
:env_var: MDE_MENU_OPTS_SET_COLOR
|
314
400
|
:opt_name: menu_opts_set_color
|
@@ -318,7 +404,7 @@
|
|
318
404
|
:env_var: MDE_MENU_OPTS_SET_FORMAT
|
319
405
|
:opt_name: menu_opts_set_format
|
320
406
|
:procname: val_as_str
|
321
|
-
- :default:
|
407
|
+
- :default: fg_rgbh_A0_20_D0
|
322
408
|
:description: Color of menu task
|
323
409
|
:env_var: MDE_MENU_TASK_COLOR
|
324
410
|
:opt_name: menu_task_color
|
@@ -338,12 +424,12 @@
|
|
338
424
|
:env_var: MDE_MENU_TASK_SYMBOL
|
339
425
|
:opt_name: menu_task_symbol
|
340
426
|
:procname: val_as_str
|
341
|
-
- :default:
|
427
|
+
- :default: fg_rgbh_E0_80_20
|
342
428
|
:description: Color of menu vars
|
343
429
|
:env_var: MDE_MENU_VARS_COLOR
|
344
430
|
:opt_name: menu_vars_color
|
345
431
|
:procname: val_as_str
|
346
|
-
- :default:
|
432
|
+
- :default: fg_rgbh_E0_80_20
|
347
433
|
:description: Color of menu vars
|
348
434
|
:env_var: MDE_MENU_VARS_SET_COLOR
|
349
435
|
:opt_name: menu_vars_set_color
|
@@ -371,16 +457,6 @@
|
|
371
457
|
:env_var: MDE_NO_CHROME
|
372
458
|
:opt_name: no_chrome
|
373
459
|
: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
460
|
- :arg_name: BOOL
|
385
461
|
:default: false
|
386
462
|
:description: Display summary for execution
|
@@ -388,6 +464,21 @@
|
|
388
464
|
:long_name: output-execution-summary
|
389
465
|
:opt_name: output_execution_summary
|
390
466
|
:procname: val_as_bool
|
467
|
+
- :default: "%{name}: %{value}"
|
468
|
+
:description: format for menu dividers and demarcations
|
469
|
+
:env_var: MDE_OUTPUT_EXECUTION_LABEL_FORMAT
|
470
|
+
:opt_name: output_execution_label_format
|
471
|
+
:procname: val_as_str
|
472
|
+
- :default: fg_rgbh_20_D8_80
|
473
|
+
:description: Color of output_execution_label_name
|
474
|
+
:env_var: MDE_OUTPUT_EXECUTION_LABEL_NAME_COLOR
|
475
|
+
:opt_name: output_execution_label_name_color
|
476
|
+
:procname: val_as_str
|
477
|
+
- :default: fg_rgbh_20_E0_80
|
478
|
+
:description: Color of output_execution_label_value
|
479
|
+
:env_var: MDE_OUTPUT_EXECUTION_LABEL_VALUE_COLOR
|
480
|
+
:opt_name: output_execution_label_value_color
|
481
|
+
:procname: val_as_str
|
391
482
|
- :arg_name: BOOL
|
392
483
|
:default: false
|
393
484
|
:description: Output saved script filename at end of execution
|
@@ -423,19 +514,28 @@
|
|
423
514
|
- :arg_name: BOOL
|
424
515
|
:default: true
|
425
516
|
:description: Pause afte executing a BASH block
|
426
|
-
:env_var:
|
427
|
-
:opt_name:
|
517
|
+
:env_var: MDE_PAUSE_after_script_execution
|
518
|
+
:opt_name: pause_after_script_execution
|
428
519
|
:procname: val_as_bool
|
429
|
-
- :default:
|
430
|
-
|
431
|
-
|
432
|
-
:
|
433
|
-
:
|
434
|
-
|
520
|
+
- :default: |2-
|
521
|
+
|
522
|
+
Continue?
|
523
|
+
:description: Prompt after script execution
|
524
|
+
:env_var: MDE_PROMPT_after_script_execution
|
525
|
+
:opt_name: prompt_after_script_execution
|
526
|
+
:procname: val_as_str
|
527
|
+
- :default: |2-
|
528
|
+
|
529
|
+
Process?
|
435
530
|
:description: Prompt to approve a block
|
436
531
|
:env_var: MDE_PROMPT_APPROVE_BLOCK
|
437
532
|
:opt_name: prompt_approve_block
|
438
533
|
:procname: val_as_str
|
534
|
+
- :default: fg_rgbh_20_E8_80
|
535
|
+
:description: Color of prompt after script execution
|
536
|
+
:env_var: MDE_PROMPT_COLOR_AFTER_SCRIPT_EXECUTION
|
537
|
+
:opt_name: prompt_color_after_script_execution
|
538
|
+
:procname: val_as_str
|
439
539
|
- :default: Exit
|
440
540
|
:description: Prompt to exit app
|
441
541
|
:env_var: MDE_PROMPT_EXIT
|
@@ -456,17 +556,23 @@
|
|
456
556
|
:env_var: MDE_PROMPT_SCRIPT_TO_CLIPBOARD
|
457
557
|
:opt_name: prompt_script_to_clipboard
|
458
558
|
:procname: val_as_str
|
459
|
-
- :default:
|
559
|
+
- :default: |2-
|
560
|
+
|
561
|
+
Choose a block:
|
460
562
|
:description: Prompt to select a block
|
461
563
|
:env_var: MDE_PROMPT_SELECT_BLOCK
|
462
564
|
:opt_name: prompt_select_block
|
463
565
|
:procname: val_as_str
|
464
|
-
- :default:
|
566
|
+
- :default: |2-
|
567
|
+
|
568
|
+
Choose a file:
|
465
569
|
:description: Prompt to select a markdown document
|
466
570
|
:env_var: MDE_PROMPT_SELECT_MD
|
467
571
|
:opt_name: prompt_select_md
|
468
572
|
:procname: val_as_str
|
469
|
-
- :default:
|
573
|
+
- :default: |2-
|
574
|
+
|
575
|
+
Choose a file:
|
470
576
|
:description: Prompt to select a saved file
|
471
577
|
:env_var: MDE_PROMPT_SELECT_OUTPUT
|
472
578
|
:opt_name: prompt_select_output
|
@@ -484,6 +590,12 @@
|
|
484
590
|
:long_name: run-last-script
|
485
591
|
:opt_name: run_last_script
|
486
592
|
:procname: val_as_bool
|
593
|
+
- :default: 1
|
594
|
+
:description: Runtime exception error level (warn if < 0, ignore if 0, abort if
|
595
|
+
> 0)
|
596
|
+
:env_var: MDE_RUNTIME_EXCEPTION_ERROR_LEVEL
|
597
|
+
:opt_name: runtime_exception_error_level
|
598
|
+
:procname: val_as_int
|
487
599
|
- :arg_name: BOOL
|
488
600
|
:default: false
|
489
601
|
:description: Save executed script
|
@@ -498,6 +610,16 @@
|
|
498
610
|
:long_name: save-execution-output
|
499
611
|
:opt_name: save_execution_output
|
500
612
|
:procname: val_as_bool
|
613
|
+
- :default: "/"
|
614
|
+
:description: Pattern to replace in file names
|
615
|
+
:env_var: MDE_SAVED_FILENAME_PATTERN
|
616
|
+
:opt_name: saved_filename_pattern
|
617
|
+
:procname: val_as_str
|
618
|
+
- :default: ",~"
|
619
|
+
:description: Replacement for pattern in file names
|
620
|
+
:env_var: MDE_SAVED_FILENAME_REPLACEMENT
|
621
|
+
:opt_name: saved_filename_replacement
|
622
|
+
:procname: val_as_str
|
501
623
|
- :arg_name: INT
|
502
624
|
:default: 493
|
503
625
|
:description: chmod for saved scripts
|
@@ -536,6 +658,40 @@
|
|
536
658
|
:env_var: MDE_SAVED_STDOUT_GLOB
|
537
659
|
:opt_name: saved_stdout_glob
|
538
660
|
:procname: val_as_str
|
661
|
+
- :default: fg_rgbh_20_80_80
|
662
|
+
:description: script_execution_frame_color
|
663
|
+
:env_var: MDE_SCRIPT_EXECUTION_FRAME_COLOR
|
664
|
+
:opt_name: script_execution_frame_color
|
665
|
+
:procname: val_as_str
|
666
|
+
- :default: |2-
|
667
|
+
|
668
|
+
-^-
|
669
|
+
:description: script_execution_head
|
670
|
+
:env_var: MDE_SCRIPT_EXECUTION_HEAD
|
671
|
+
:opt_name: script_execution_head
|
672
|
+
:procname: val_as_str
|
673
|
+
- :default: " -v-\n"
|
674
|
+
:description: script_execution_tail
|
675
|
+
:env_var: MDE_SCRIPT_EXECUTION_TAIL
|
676
|
+
:opt_name: script_execution_tail
|
677
|
+
:procname: val_as_str
|
678
|
+
- :default: fg_rgbh_20_80_80
|
679
|
+
:description: Color of output divider
|
680
|
+
:env_var: MDE_OUTPUT_DIVIDER_COLOR
|
681
|
+
:opt_name: script_preview_frame_color
|
682
|
+
:procname: val_as_str
|
683
|
+
- :default: |2-
|
684
|
+
|
685
|
+
-^-
|
686
|
+
:description: script_preview_head
|
687
|
+
:env_var: MDE_SCRIPT_PREVIEW_HEAD
|
688
|
+
:opt_name: script_preview_head
|
689
|
+
:procname: val_as_str
|
690
|
+
- :default: " -v-\n"
|
691
|
+
:description: script_preview_tail
|
692
|
+
:env_var: MDE_SCRIPT_PREVIEW_TAIL
|
693
|
+
:opt_name: script_preview_tail
|
694
|
+
:procname: val_as_str
|
539
695
|
- :arg_name: REGEX
|
540
696
|
:default:
|
541
697
|
:description: Select blocks with name matching
|
@@ -571,6 +727,16 @@
|
|
571
727
|
:env_var: MDE_SHELL
|
572
728
|
:opt_name: shell
|
573
729
|
:procname: val_as_str
|
730
|
+
- :default: "# -^- +%{name} -^-"
|
731
|
+
:description: shell_code_label_format_above
|
732
|
+
:env_var: MDE_SHELL_CODE_LABEL_FORMAT_ABOVE
|
733
|
+
:opt_name: shell_code_label_format_above
|
734
|
+
:procname: val_as_str
|
735
|
+
- :default: "# -v- +%{name} -v-"
|
736
|
+
:description: shell_code_label_format_below
|
737
|
+
:env_var: MDE_SHELL_CODE_LABEL_FORMAT_BELOW
|
738
|
+
:opt_name: shell_code_label_format_below
|
739
|
+
:procname: val_as_str
|
574
740
|
- :description: List tab completions
|
575
741
|
:long_name: tab-completions
|
576
742
|
:opt_name: tab_completions
|
@@ -587,6 +753,16 @@
|
|
587
753
|
:long_name: version
|
588
754
|
:procname: version
|
589
755
|
:short_name: v
|
756
|
+
- :default: fg_rgbh_E0_E0_20
|
757
|
+
:description: Color of warning message
|
758
|
+
:env_var: MDE_WARNING_COLOR
|
759
|
+
:opt_name: warning_color
|
760
|
+
:procname: val_as_str
|
761
|
+
- :default: 'Error: %{error}'
|
762
|
+
:description: Format of warning message
|
763
|
+
:env_var: MDE_WARNING_FORMAT
|
764
|
+
:opt_name: warning_format
|
765
|
+
:procname: val_as_str
|
590
766
|
- :arg_name: INT.0-3
|
591
767
|
:default: 1
|
592
768
|
: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/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
|
data/lib/shared.rb
CHANGED
@@ -16,11 +16,6 @@ DISPLAY_LEVEL_DUMP = 3
|
|
16
16
|
DISPLAY_LEVEL_DEFAULT = DISPLAY_LEVEL_ADMIN
|
17
17
|
DISPLAY_LEVEL_MAX = DISPLAY_LEVEL_DUMP
|
18
18
|
|
19
|
-
# @execute_files[ind] = @execute_files[ind] + [block]
|
20
|
-
EF_STDOUT = 0
|
21
|
-
EF_STDERR = 1
|
22
|
-
EF_STDIN = 2
|
23
|
-
|
24
19
|
LOCAL_YML = 'menu.yml'
|
25
20
|
MENU_YML = "lib/#{LOCAL_YML}"
|
26
21
|
|
data/lib/string_util.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# encoding=utf-8
|
5
|
+
|
6
|
+
module StringUtil
|
7
|
+
# Splits the given string on the first occurrence of the specified character.
|
8
|
+
# Returns an array containing the portion of the string before the character and the rest of the string.
|
9
|
+
#
|
10
|
+
# @param input_str [String] The string to be split.
|
11
|
+
# @param split_char [String] The character on which to split the string.
|
12
|
+
# @return [Array<String>] An array containing two elements: the part of the string before split_char, and the rest of the string.
|
13
|
+
def self.partition_at_first(input_str, split_char)
|
14
|
+
split_index = input_str.index(split_char)
|
15
|
+
|
16
|
+
if split_index.nil?
|
17
|
+
[input_str, '']
|
18
|
+
else
|
19
|
+
[input_str[0...split_index], input_str[(split_index + 1)..-1]]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markdown_exec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.8'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fareed Stevenson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11
|
11
|
+
date: 2023-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clipboard
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- bin/setup
|
114
114
|
- bin/tab_completion.sh
|
115
115
|
- bin/tab_completion.sh.erb
|
116
|
+
- examples/colors.md
|
116
117
|
- examples/duplicate_block.md
|
117
118
|
- examples/import0.md
|
118
119
|
- examples/import1.md
|
@@ -127,15 +128,23 @@ files:
|
|
127
128
|
- examples/port.md
|
128
129
|
- examples/vars.md
|
129
130
|
- examples/wrap.md
|
131
|
+
- lib/ansi_formatter.rb
|
132
|
+
- lib/array.rb
|
133
|
+
- lib/array_util.rb
|
130
134
|
- lib/block_label.rb
|
131
135
|
- lib/block_types.rb
|
132
136
|
- lib/cached_nested_file_reader.rb
|
133
137
|
- lib/cli.rb
|
134
138
|
- lib/colorize.rb
|
139
|
+
- lib/constants.rb
|
140
|
+
- lib/directory_searcher.rb
|
135
141
|
- lib/env.rb
|
136
|
-
- lib/
|
142
|
+
- lib/exceptions.rb
|
137
143
|
- lib/fcb.rb
|
138
144
|
- lib/filter.rb
|
145
|
+
- lib/fout.rb
|
146
|
+
- lib/hash.rb
|
147
|
+
- lib/hash_delegator.rb
|
139
148
|
- lib/markdown_exec.rb
|
140
149
|
- lib/markdown_exec/version.rb
|
141
150
|
- lib/mdoc.rb
|
@@ -151,6 +160,7 @@ files:
|
|
151
160
|
- lib/saved_files_matcher.rb
|
152
161
|
- lib/shared.rb
|
153
162
|
- lib/sort_yaml_gpt4.rb
|
163
|
+
- lib/string_util.rb
|
154
164
|
- lib/tap.rb
|
155
165
|
homepage: https://rubygems.org/gems/markdown_exec
|
156
166
|
licenses:
|