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’] } rubocop:enable Layout/LineLength :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
- #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.
251 252 253 254 255 256 |
# File 'lib/markdown_exec.rb', line 251 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.
246 247 248 |
# File 'lib/markdown_exec.rb', line 246 def @options end |
#prompt ⇒ Object (readonly)
Returns the value of attribute prompt.
246 247 248 |
# File 'lib/markdown_exec.rb', line 246 def prompt @prompt end |
#run_state ⇒ Object (readonly)
Returns the value of attribute run_state.
246 247 248 |
# File 'lib/markdown_exec.rb', line 246 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
318 319 320 321 322 323 324 325 326 327 328 329 330 |
# File 'lib/markdown_exec.rb', line 318 def determine_filename(specified_filename: nil, specified_folder: nil, default_filename: nil, default_folder: nil, filetree: nil) if specified_filename&.present? return specified_filename if specified_filename.start_with?('/') File.join(specified_folder || default_folder, specified_filename) elsif specified_folder&.present? File.join(specified_folder, filetree ? @options[:md_filename_match] : @options[:md_filename_glob]) else File.join(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
605 606 607 608 609 610 611 |
# File 'lib/markdown_exec.rb', line 605 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
613 614 615 616 |
# File 'lib/markdown_exec.rb', line 613 def list_markdown_files_in_path Dir.glob(File.join(@options[:path], @options[:md_filename_glob])) end |
#run ⇒ Object
695 696 697 698 699 700 701 702 |
# File 'lib/markdown_exec.rb', line 695 def run execute_block_with_error_handling rescue StandardError error_handler('run') ensure yield if block_given? end |
#tab_completions(data = menu_for_optparse) ⇒ Object
784 785 786 787 788 |
# File 'lib/markdown_exec.rb', line 784 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
792 793 794 795 796 797 798 799 |
# File 'lib/markdown_exec.rb', line 792 def (opts = {}, over: true) if over @options = @options.merge opts else @options.merge! opts end @options end |