lib/hash_delegator.rb in markdown_exec-2.0.8.2 vs lib/hash_delegator.rb in markdown_exec-2.0.8.3
- old
+ new
@@ -1480,10 +1480,11 @@
#
# @param opts [Hash] Options hash containing configuration settings.
# @param mdoc [YourMDocClass] An instance of the MDoc class.
#
def execute_shell_type(selected:, mdoc:, block_source:, link_state: LinkState.new)
+# binding.irb
if selected.fetch(:shell, '') == BlockType::LINK
debounce_reset
push_link_history_and_trigger_load(link_block_body: selected.fetch(:body, ''),
mdoc: mdoc,
selected: selected,
@@ -1693,11 +1694,10 @@
}
end
def inpseq_execute_block(block_name)
@dml_block_state = block_state_for_name_from_cli(block_name)
-
dump_and_warn_block_state(selected: @dml_block_state.block)
@dml_link_state, @dml_menu_default_dname = \
exec_bash_next_state(
selected: @dml_block_state.block,
mdoc: @dml_mdoc,
@@ -1759,11 +1759,14 @@
file.write(all_code.join("\n"))
file.rewind
if link_block_data.fetch(LinkKeys::EXEC, false)
@run_state.files = Hash.new([])
- execute_command_with_streams([cmd])
+ execute_command_with_streams([cmd]) do |_stdin, stdout, stderr, _thread|
+ line = stdout || stderr
+ output_lines.push(line) if line
+ end
## select output_lines that look like assignment or match other specs
#
output_lines = process_string_array(
output_lines,
@@ -2119,11 +2122,11 @@
format_sym: :output_execution_label_format
), level: level
end
def pop_add_current_code_to_head_and_trigger_load(link_state, block_names, code_lines,
- dependencies, selected)
+ dependencies, selected, next_block_name: nil)
pop = @link_history.pop # updatable
if pop.document_filename
next_state = LinkState.new(
block_name: pop.block_name,
document_filename: pop.document_filename,
@@ -2144,11 +2147,11 @@
curr_block_name: selected.pub_name,
curr_document_filename: @delegate_object[:filename],
inherited_block_names: ((link_state&.inherited_block_names || []) + block_names).sort.uniq,
inherited_dependencies: (link_state&.inherited_dependencies || {}).merge(dependencies || {}), ### merge, not replace, key data
inherited_lines: HashDelegator.code_merge(link_state&.inherited_lines, code_lines),
- next_block_name: '', # not link_block_data[LinkKeys::BLOCK] || ''
+ next_block_name: next_block_name,
next_document_filename: @delegate_object[:filename], # not next_document_filename
next_load_file: LoadFile::REUSE # not next_document_filename == @delegate_object[:filename] ? LoadFile::REUSE : LoadFile::LOAD
)
# LoadFileLinkState.new(LoadFile::REUSE, link_state)
end
@@ -2422,11 +2425,11 @@
ENV[key] = value.to_s
code_lines.push(assign_key_value_in_bash(key, value))
end
end
- ## append blocks loaded, apply LinkKeys::EVAL
+ ## append blocks loaded
#
if (load_expr = link_block_data.fetch(LinkKeys::LOAD, '')).present?
load_filespec = load_filespec_from_expression(load_expr)
code_lines += File.readlines(load_filespec, chomp: true) if load_filespec
end
@@ -2437,23 +2440,23 @@
false) || link_block_data.fetch(LinkKeys::EXEC, false)
code_lines = link_block_data_eval(link_state, code_lines, selected, link_block_data, block_source: block_source)
end
next_document_filename = write_inherited_lines_to_file(link_state, link_block_data)
+ next_block_name = link_block_data.fetch(LinkKeys::NEXT_BLOCK, nil) || link_block_data.fetch(LinkKeys::BLOCK, nil) || ''
if link_block_data[LinkKeys::RETURN]
pop_add_current_code_to_head_and_trigger_load(link_state, block_names, code_lines,
- dependencies, selected)
+ dependencies, selected, next_block_name: next_block_name)
else
link_history_push_and_next(
curr_block_name: selected.pub_name,
curr_document_filename: @delegate_object[:filename],
inherited_block_names: ((link_state&.inherited_block_names || []) + block_names).sort.uniq,
inherited_dependencies: (link_state&.inherited_dependencies || {}).merge(dependencies || {}), ### merge, not replace, key data
inherited_lines: HashDelegator.code_merge(link_state&.inherited_lines, code_lines),
- next_block_name: link_block_data.fetch(LinkKeys::NEXT_BLOCK,
- nil) || link_block_data[LinkKeys::BLOCK] || '',
+ next_block_name: next_block_name,
next_document_filename: next_document_filename,
next_load_file: next_document_filename == @delegate_object[:filename] ? LoadFile::REUSE : LoadFile::LOAD
)
end
end