lib/markdown_exec.rb in markdown_exec-1.3.1 vs lib/markdown_exec.rb in markdown_exec-1.3.2

- old
+ new

@@ -4,19 +4,19 @@ # encoding=utf-8 require 'English' require 'clipboard' require 'open3' -# require 'optparse' +require 'optparse' require 'shellwords' require 'tty-prompt' require 'yaml' require_relative 'cli' require_relative 'colorize' require_relative 'env' -require_relative 'environment_opt_parse' +# require_relative 'environment_opt_parse' require_relative 'object_present' require_relative 'shared' require_relative 'tap' require_relative 'markdown_exec/version' @@ -476,11 +476,11 @@ stdin.puts(line = $stdin.gets) @execute_files[EF_STDIN] = @execute_files[EF_STDIN] + [line] yield line, nil, nil, exec_thr if block_given? end #d 'exec_thr now dead' - rescue + rescue StandardError #d 'stdin error, thread killed, do nothing' end #d 'join exec_thr' exec_thr.join @@ -786,15 +786,13 @@ def list_named_blocks_in_file(call_options = {}, &options_block) opts = optsmerge call_options, options_block blocks_in_file = list_blocks_in_file(opts.merge(struct: true)) mdoc = MDoc.new(blocks_in_file) - list_blocks_in_file(opts).map do |block| - next if mdoc.hide_menu_block_per_options(opts, block) - - block - end.compact.tap_inspect + list_blocks_in_file(opts).reject do |block| + mdoc.hide_menu_block_per_options(opts, block) + end.tap_inspect end def list_recent_output(saved_stdout_folder, saved_stdout_glob, list_count) Sfiles.new(saved_stdout_folder, saved_stdout_glob).most_recent_list(list_count) end @@ -1000,25 +998,10 @@ .transform_keys(&:to_sym)) end # :reek:NestedIterators def run - # eop = EnvironmentOptParse.new( - # menu: File.join(File.expand_path(__dir__), 'menu.yml'), - # options: { - # menu_exit_at_top: true, - # menu_with_exit: true - # } - # ).tap_yaml '** eop' - # # eop = EnvironmentOptParse.new(menu: 'lib/menu.yml', options: ".#{MarkdownExec::APP_NAME.downcase}.yml", version: MarkdownExec::VERSION).tap_yaml '** eop' - # eop.options.tap_inspect 'eop.options' - # eop.remainder.tap_inspect 'eop.remainder' - - # exec_block eop.options, eop.options[:block_name] - - # return - ## default configuration # @options = base_options ## read local configuration file @@ -1079,11 +1062,11 @@ time: Time.now.utc).stdout_name @options[:logged_stdout_filespec] = File.join @options[:saved_stdout_folder], @options[:logged_stdout_filename] @logged_stdout_filespec = @options[:logged_stdout_filespec] (dirname = File.dirname(@options[:logged_stdout_filespec])).tap_inspect name: :dirname - Dir.mkdir dirname unless File.exist?(dirname) + Dir.mkdir_p dirname ol = ["-STDOUT-\n"] ol += @execute_files&.fetch(EF_STDOUT, []) ol += ["\n-STDERR-\n"] ol += @execute_files&.fetch(EF_STDERR, []) @@ -1216,10 +1199,10 @@ @execute_script_filespec = @options[:saved_filespec] = File.join opts[:saved_script_folder], opts[:saved_script_filename] dirname = File.dirname(@options[:saved_filespec]) - Dir.mkdir dirname unless File.exist?(dirname) + Dir.mkdir_p dirname (shebang = if @options[:shebang]&.present? "#{@options[:shebang]} #{@options[:shell]}\n" else '' end