Class: MarkdownExec::MarkParse
- Includes:
- ArrayUtil, StringUtil
- Defined in:
- lib/markdown_exec.rb
Overview
:reek:DuplicateMethodCall { allow_calls: [‘block’, ‘item’, ‘lm’, ‘opts’, ‘option’, ‘@options’, ‘required_blocks’] } :reek:MissingSafeMethod { exclude: [ read_configuration_file! ] } :reek:TooManyInstanceVariables ### temp :reek:TooManyMethods ### temp
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#prompt ⇒ Object
readonly
Returns the value of attribute prompt.
-
#run_state ⇒ Object
readonly
Returns the value of attribute run_state.
Instance Method Summary collapse
-
#determine_filename(specified_filename: nil, specified_folder: nil, default_filename: nil, default_folder: nil, filetree: nil) ⇒ Object
Determines the correct filename to use for searching files.
-
#initialize(options = {}) ⇒ MarkParse
constructor
A new instance of MarkParse.
-
#list_files_specified(fn, filetree = nil) ⇒ Object
Searches for files based on the specified or default filenames and folders.
- #list_markdown_files_in_path ⇒ Object
-
#list_recent_output(saved_stdout_folder, saved_stdout_glob, list_count) ⇒ Object
:reek:UtilityFunction.
-
#list_recent_scripts(saved_script_folder, saved_script_glob, list_count) ⇒ Object
:reek:UtilityFunction.
-
#mde_vux_main_loop(files) ⇒ Object
Reports and executes block logic.
- #run ⇒ Object
- #tab_completions(data = menu_for_optparse) ⇒ Object
-
#update_options(opts = {}, over: true) ⇒ Object
:reek:BooleanParameter :reek:ControlParameter.
Methods included from StringUtil
Methods included from ArrayUtil
Constructor Details
#initialize(options = {}) ⇒ MarkParse
Returns a new instance of MarkParse.
284 285 286 287 288 289 |
# File 'lib/markdown_exec.rb', line 284 def initialize( = {}) @option_parser = nil @options = HashDelegator.new() @fout = FOut.new(@delegate_object) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
279 280 281 |
# File 'lib/markdown_exec.rb', line 279 def @options end |
#prompt ⇒ Object (readonly)
Returns the value of attribute prompt.
279 280 281 |
# File 'lib/markdown_exec.rb', line 279 def prompt @prompt end |
#run_state ⇒ Object (readonly)
Returns the value of attribute run_state.
279 280 281 |
# File 'lib/markdown_exec.rb', line 279 def run_state @run_state end |
Instance Method Details
#determine_filename(specified_filename: nil, specified_folder: nil, default_filename: nil, default_folder: nil, filetree: nil) ⇒ Object
Determines the correct filename to use for searching files
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 |
# File 'lib/markdown_exec.rb', line 371 def determine_filename( specified_filename: nil, specified_folder: nil, default_filename: nil, default_folder: nil, filetree: nil ) File.join( *(if specified_filename&.present? if specified_filename.start_with?('/') [specified_filename] else [specified_folder || default_folder, specified_filename] end elsif specified_folder&.present? [specified_folder, if filetree @options[:md_filename_match] else @options[:md_filename_glob] end] else [default_folder, default_filename] end) ) end |
#list_files_specified(fn, filetree = nil) ⇒ Object
Searches for files based on the specified or default filenames and folders
790 791 792 793 794 795 796 |
# File 'lib/markdown_exec.rb', line 790 def list_files_specified(fn, filetree = nil) return Dir.glob(fn) unless filetree filetree.select do |filename| filename == fn || filename.match(/^#{fn}$/) || filename.match(%r{^#{fn}/.+$}) end end |
#list_markdown_files_in_path ⇒ Object
798 799 800 801 |
# File 'lib/markdown_exec.rb', line 798 def list_markdown_files_in_path Dir.glob(File.join(@options[:path], @options[:md_filename_glob])) end |
#list_recent_output(saved_stdout_folder, saved_stdout_glob, list_count) ⇒ Object
:reek:UtilityFunction
804 805 806 807 808 |
# File 'lib/markdown_exec.rb', line 804 def list_recent_output(saved_stdout_folder, saved_stdout_glob, list_count) SavedFilesMatcher.most_recent_list(saved_stdout_folder, saved_stdout_glob, list_count) end |
#list_recent_scripts(saved_script_folder, saved_script_glob, list_count) ⇒ Object
:reek:UtilityFunction
811 812 813 814 815 |
# File 'lib/markdown_exec.rb', line 811 def list_recent_scripts(saved_script_folder, saved_script_glob, list_count) SavedFilesMatcher.most_recent_list(saved_script_folder, saved_script_glob, list_count) end |
#mde_vux_main_loop(files) ⇒ Object
Reports and executes block logic
818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 |
# File 'lib/markdown_exec.rb', line 818 def mde_vux_main_loop(files) # !!b @options[:filename] = select_document_if_multiple(files) @options.vux_main_loop do |type, data| case type when :command_names # !!b simple_commands(data).keys when :call_proc # !!b # simple_commands(data[0])[data[1]].call simple_commands(data[0])[data[1]][1].call when :end_of_cli # !!b execute_simple_commands(, stage: 2) else raise end end end |
#run ⇒ Object
968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 |
# File 'lib/markdown_exec.rb', line 968 def run initialize_parse_execute_cli execute_block_with_error_handling rescue BlockMissing warn 'Block missing' exit 1 rescue AppInterrupt, TTY::Reader::InputInterrupt, BlockMissing warn 'Exiting...' if $DEBUG exit 1 rescue StandardError error_handler('run') # rubocop:disable Style/RescueStandardError rescue warn 'Exiting...' if $DEBUG exit 1 # rubocop:enable Style/RescueStandardError end |
#tab_completions(data = menu_for_optparse) ⇒ Object
1064 1065 1066 1067 1068 |
# File 'lib/markdown_exec.rb', line 1064 def tab_completions(data = ) data.map do |item| "--#{item[:long_name]}" if item[:long_name] end.compact end |
#update_options(opts = {}, over: true) ⇒ Object
:reek:BooleanParameter :reek:ControlParameter
1072 1073 1074 1075 1076 1077 1078 1079 |
# File 'lib/markdown_exec.rb', line 1072 def (opts = {}, over: true) if over @options = @options.merge opts else @options.merge! opts end @options end |