Module: Doing::Util

Extended by:
Util
Included in:
CSVExport, CalendarImport, DayoneExport, DoingImport, HTMLExport, JSONExport, JSONImport, MarkdownExport, TaskPaperExport, TemplateExport, TimingImport, Util, Backup
Defined in:
lib/doing/util.rb,
lib/doing/util_backup.rb

Overview

Utilities

Defined Under Namespace

Modules: Backup

Instance Method Summary collapse

Instance Method Details

#args_for_editor(editor) ⇒ Object

#deep_merge_hashes(master_hash, other_hash) ⇒ Object

Non-destructive version of deep_merge_hashes!

Parameters:

  • master_hash (Hash)

    The master hash

  • other_hash (Hash)

    The other hash

Returns:

  • the merged hashes.

See Also:

  • {deep_merge_hashes!}

#deep_merge_hashes!(target, overwrite) ⇒ Hash

Merges a master hash with another hash, recursively.

This code was lovingly stolen from some random gem: http://gemjack.com/gems/tartan-0.1.1/classes/Hash.html

Thanks to whoever made it.

Parameters:

  • target (Hash)

    the "parent" hash whose values will be overridden

  • overwrite (Hash)

    the other hash whose values will be persisted after the merge

Returns:

  • (Hash)

    merged hashes

#default_editorObject

#duplicable?(obj) ⇒ Boolean

Returns:

  • (Boolean)

#duplicate_frozen_values(target) ⇒ Object

#editor_with_argsObject

#exec_available(cli) ⇒ Object

Test if command line tool is available

Parameters:

  • cli (String)

    The name or path of the cli

#find_default_editor(editor_for = 'default') ⇒ Object

#first_available_exec(*commands) ⇒ Object

Return the first valid executable from a list of commands

Examples:

Doing::Util.first_available_exec('bat', 'less -Xr', 'more -r', 'cat')

#mergable?(value) ⇒ Boolean

Returns:

  • (Boolean)

#merge_default_proc(target, overwrite) ⇒ Object

#merge_values(target, overwrite) ⇒ Object

#safe_load_file(filename) ⇒ Object

#user_homeObject

#write_to_file(file, content, backup: true) ⇒ Object

Write content to a file

Parameters:

  • file (String)

    The path to the file to (over)write

  • content (String)

    The content to write to the file

  • backup (Boolean) (defaults to: true)

    create a ~ backup