Class: MarkdownExec::HashDelegator

Inherits:
HashDelegatorParent show all
Includes:
ErrorReporting
Defined in:
lib/hash_delegator.rb

Instance Attribute Summary

Attributes inherited from HashDelegatorParent

#p_all_arguments, #p_options_parsed, #p_params, #p_rest, #pass_args, #run_state

Class Method Summary collapse

Methods included from ErrorReporting

included, #report_and_reraise

Methods inherited from HashDelegatorParent

#absolute_path, #add_back_option, #add_exit_option, #add_inherited_lines, #add_menu_chrome_blocks!, #annotate_required_lines, #append_chrome_block, #append_divider, #append_inherited_lines, #apply_block_type_color_option, #apply_tree_decorations, #assign_key_value_in_bash, #block_is_back, #block_is_edit, #block_is_exit, #block_is_history, #block_is_load, #block_is_save, #block_is_shell, #block_is_view, #blocks_as_menu_items, #blocks_from_nested_files, #build_menu_options, #build_replacement_dictionary, #calc_logged_stdout_filename, #cfile, #check_file_existence, #code_from_auto_vars_blocks, #code_from_ux_block_to_set_environment_variables, #code_from_vars_block_to_set_environment_variables, #code_line_to_assign_a_variable, #collect_line_decor_patterns, #command_execute, #command_execute_in_own_window, #command_execute_in_own_window_format_arguments, #command_execute_in_process, #compile_execute_and_trigger_reuse, #contains_glob?, #copy_to_clipboard, #count_blocks_in_filename, #count_named_group_occurrences, #count_named_group_occurrences_block_body_fix_indent, #create_and_add_chrome_block, #create_and_add_chrome_blocks, #create_divider, #debounce_allows, #debounce_reset, #determine_block_state, #display_required_code, #divider_formatting_present?, #dml_menu_append_chrome_item, #do_save_execution_output, #document_name_in_glob_as_file_name, #dump_and_warn_block_state, #dump_delobj, #edit_text, #env_set, #execute_block_by_type_for_lfls, #execute_block_for_state_and_name, #execute_block_in_state, #execute_block_type_history_ux, #execute_block_type_link_with_state, #execute_block_type_load_code_lines, #execute_block_type_port_code_lines, #execute_block_type_save, #execute_command_with_streams, #execute_history_select, #execute_inherited_save, #execute_navigate_back, #execute_required_lines, #expand_blocks_with_replacements, #expand_references!, #expand_variable_references!, #export_environment_variable, #fetch_color, #file_info, #find_block_by_name, #find_block_state_by_name, #find_option_by_name, #format_and_execute_command, #format_echo_command, #format_expression, #format_references_send_color, #formatted_block_name, #formatted_expression, #fout_execution_report, #generate_echo_commands, #generate_temp_filename, #handle_back_or_continue, #handle_consecutive_inactive_items!, #handle_selection, #handle_stream, #history_files, #inherited_lines_from_auto_blocks, #initial_state, #initialize, #interactive_menu_with_display_modes, #iter_blocks_from_nested_files, #iter_source_blocks, #join_array_of_arrays, #link_block_data_eval, #link_history_push_and_next, #link_load_format_data, #list_blocks, #load_auto_opts_block, #load_cli_or_user_selected_block, #load_filespec_from_expression, #load_filespec_wildcard_expansion, #manage_cli_selection_state, #mdoc_and_blocks_from_nested_files, #mdoc_menu_and_blocks_from_nested_files, #menu_add_disabled_option, #menu_chrome_colored_option, #menu_chrome_formatted_option, #menu_from_list_with_back, #menu_toggle_collapsible_block, #method_missing, #next_item, #next_state_append_code, #next_state_set_code, #options_command_substitution_regexp, #options_import_paths, #options_variable_expansion_regexp, #output_color_formatted, #output_execution_summary, #output_labeled_value, #pause_user_exit, #persist_fcb, #pop_add_current_code_to_head_and_trigger_load, #pop_link_history_new_state, #post_execution_process, #print_formatted_option, #process_command_result_lines, #process_string_array, #prompt_approve_repeat, #prompt_for_command, #prompt_for_filespec_with_wildcard, #prompt_for_user_approval, #prompt_margin_left_text, #prompt_margin_left_width, #prompt_margin_right_width, #prompt_select_continue, #prompt_select_from_list, #prompt_user_exit, #publish_for_external_automation, #read_saved_assets_for_history_table, #read_show_options_and_trigger_reuse, #register_console_attributes, #replace_keys_in_lines, #report_error, #respond_to?, #respond_to_missing?, #runtime_exception, #safe_yaml_load, #save_filespec_from_expression, #save_filespec_wildcard_expansion, #save_to_file, #saved_asset_filename, #saved_asset_for_history, #screen_width, #screen_width_for_table, #screen_width_for_wrapping, #select_automatic_ux_blocks, #select_blocks, #select_document_if_multiple, #select_option_with_metadata, #selected_id_name, #selected_shell, #shell, #shell=, #shell_escape_asset_format, #should_add_back_option?, #simple_menu_options, #start_fenced_block, #string_send_color, #transform_export_value, #update_line_and_block_state, #update_menu_base, #ux_block_eval_for_export, #ux_block_export_activated, #ux_block_export_automatic, #variable_is_exportable, #vux_await_user_selection, #vux_clear_menu_state, #vux_edit_inherited, #vux_execute_and_prompt, #vux_execute_block_per_type, #vux_formatted_names_for_state_chrome_blocks, #vux_history_files_table_rows, #vux_init, #vux_input_and_execute_shell_commands, #vux_load_code_files_into_state, #vux_load_inherited, #vux_main_loop, #vux_menu_append_history_files, #vux_navigate_back_for_ls, #vux_parse_document, #vux_publish_block_name_for_external_automation, #vux_publish_document_file_name_for_external_automation, #vux_user_selected_block_name, #vux_view_inherited, #wait_for_stream_processing, #wait_for_user_selected_block, #wait_for_user_selection, #warning_failure, #warning_required_empty, #write_command_file, #write_file_with_directory_creation, #write_inherited_lines_to_file

Methods included from HashDelegatorSelf

#apply_color_from_hash, #block_find, #block_match, #block_select, #chrome_block_criteria, #count_matches_in_lines, #create_directory_for_file, #create_file_and_write_string_with_permissions, #default_block_title_from_body, #delete_consecutive_blank_lines!, #error_handler, #execute_bash_script_lines, #flatten_and_compact_arrays, #indent_all_lines, #initialize_fcb_names, #join_code_lines, #next_link_state, #parse_yaml_data_from_body, #persist_fcb_self, #read_required_blocks_from_temp_file, #remove_file_without_standard_errors, #safeval, #set_file_permissions, #tables_into_columns!, #tty_prompt_without_disabled_symbol, #update_menu_attrib_yield_selected, #yield_line_if_selected

Methods included from TextAnalyzer

analyze_hierarchy, highlight_segments, yield_matches_and_non_matches

Methods included from CompactionHelpers

#compact_and_convert_array_to_hash, #compact_and_index_hash, #compact_hash

Constructor Details

This class inherits a constructor from MarkdownExec::HashDelegatorParent

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class MarkdownExec::HashDelegatorParent

Class Method Details

.clean_hash_recursively(obj) ⇒ Object

Recursively cleans the given hash or struct from unwanted values.



6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
# File 'lib/hash_delegator.rb', line 6219

def self.clean_hash_recursively(obj)
  obj.each do |key, value|
    cleaned_value = clean_value(value) # Clean and possibly convert value
    obj[key] = cleaned_value if value.is_a?(Hash) || value.is_a?(Struct)
  end

  if obj.is_a?(Hash)
    obj.reject! do |_key, value|
      [nil, '', [], {}, nil].include?(value)
    end
  end

  obj
end

.clean_value(value) ⇒ Object

Cleans a value, handling both Hash and Struct types. For Structs, the cleaned version is converted to a hash.



6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
# File 'lib/hash_delegator.rb', line 6204

def self.clean_value(value)
  case value
  when Hash
    clean_hash_recursively(value)
  when Struct
    struct_hash = value.to_h # Convert the Struct to a hash
    clean_hash_recursively(struct_hash) # Clean the hash
    # Return the cleaned hash instead of updating the Struct

  else
    value
  end
end


6234
6235
6236
# File 'lib/hash_delegator.rb', line 6234

def self.next_link_state(*args, **kwargs, &block)
  super
end

.options_for_tty_menu(options) ⇒ Object



6238
6239
6240
# File 'lib/hash_delegator.rb', line 6238

def self.options_for_tty_menu(options)
  options.slice(:menu_active_color_pastel_messages, :select_page_height)
end