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.
118 119 120 121 122 123 |
# File 'lib/markdown_exec.rb', line 118 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.
113 114 115 |
# File 'lib/markdown_exec.rb', line 113 def @options end |
#prompt ⇒ Object (readonly)
Returns the value of attribute prompt.
113 114 115 |
# File 'lib/markdown_exec.rb', line 113 def prompt @prompt end |
#run_state ⇒ Object (readonly)
Returns the value of attribute run_state.
113 114 115 |
# File 'lib/markdown_exec.rb', line 113 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
185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/markdown_exec.rb', line 185 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
442 443 444 445 446 447 448 |
# File 'lib/markdown_exec.rb', line 442 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
450 451 452 453 |
# File 'lib/markdown_exec.rb', line 450 def list_markdown_files_in_path Dir.glob(File.join(@options[:path], @options[:md_filename_glob])) end |
#run ⇒ Object
532 533 534 535 536 537 538 539 |
# File 'lib/markdown_exec.rb', line 532 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
622 623 624 625 626 |
# File 'lib/markdown_exec.rb', line 622 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
630 631 632 633 634 635 636 637 |
# File 'lib/markdown_exec.rb', line 630 def (opts = {}, over: true) if over @options = @options.merge opts else @options.merge! opts end @options end |