Class: Doing::WWID

Inherits:
Object
  • Object
show all
Defined in:
lib/doing/wwid.rb

Overview

Main "What Was I Doing" methods

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWWID

Initializes the object.

Instance Attribute Details

#additional_configsObject (readonly)

Returns the value of attribute additional_configs.

#auto_tagObject

Returns the value of attribute auto_tag.

#configObject

Returns the value of attribute config.

#config_fileObject

Returns the value of attribute config_file.

#contentObject (readonly)

Returns the value of attribute content.

#current_sectionObject (readonly)

Returns the value of attribute current_section.

#default_optionObject

Returns the value of attribute default_option.

#doing_fileObject (readonly)

Returns the value of attribute doing_file.

Instance Method Details

#act_on(items, opt = {}) ⇒ Object

Perform actions on a set of entries. If no valid action is included in the opt hash and the terminal is a TTY, a menu will be presented

Parameters:

  • items

    The items to affect

  • opt (defaults to: {})

    The actions and options. Can include :editor, :delete, :tag, :flag, :finish, :cancel, :archive, :output, :save_to, :again, and :resume

#add_item(title, section = nil, opt = {}) ⇒ Object

Adds an entry

Parameters:

  • title (String)

    The entry title

  • section (String) (defaults to: nil)

    The section to add to

  • opt (Hash) (defaults to: {})

    Additional Options: :date, :note, :back, :timed

#add_section(title) ⇒ Object

Adds a section.

Parameters:

  • title (String)

    The new section title

#all_tags(items, opt: {}) ⇒ Object

#archive(section = @config['current_section'], options = {}) ⇒ Object

Move entries from a section to Archive or other specified section

Parameters:

  • section (String) (defaults to: @config['current_section'])

    The source section

  • options (Hash) (defaults to: {})

    Options

#autotag(text) ⇒ Object

Uses 'autotag' configuration to turn keywords into tags for time tracking. Does not repeat tags in a title, and only converts the first instance of an untagged keyword

Parameters:

  • text (String)

    The text to tag

#choose_from(options, prompt: 'Make a selection: ', multiple: false, sorted: true, fzf_args: []) ⇒ String

Generate a menu of options and allow user selection

Returns:

  • (String)

    The selected option

#choose_from_items(items, opt = {}, include_section: false) ⇒ Object

#choose_sectionString

Generate a menu of sections and allow user selection

Returns:

  • (String)

    The selected section name

#choose_viewString

Generate a menu of views and allow user selection

Returns:

  • (String)

    The selected view name

#chronify(input, future: false, guess: :begin) ⇒ DateTime

Converts input string into a Time object when input takes on the following formats: - interval format e.g. '1d2h30m', '45m' etc. - a semantic phrase e.g. 'yesterday 5:30pm' - a strftime e.g. '2016-03-15 15:32:04 PDT'

Parameters:

  • input (String)

    String to chronify

Returns:

  • (DateTime)

    result

Raises:

  • (InvalidTimeExpression)

#chronify_qty(qty) ⇒ Integer

Converts simple strings into seconds that can be added to a Time object

Parameters:

Returns:

  • (Integer)

    seconds

#create(filename = nil) ⇒ Object

Create a new doing file

#dedup(items, no_overlap = false) ⇒ Object

Remove items from a list that already exist in @content

Parameters:

  • items (Array)

    The items to deduplicate

  • no_overlap (Boolean) (defaults to: false)

    Remove items with overlapping time spans

#delete_item(item, single: false) ⇒ Object

Delete an item from the index

Parameters:

  • item

    The item

#edit_last(section: 'All', options: {}) ⇒ Object

Edit the last entry

Parameters:

  • section (String) (defaults to: 'All')

    The section, default "All"

#filter_items(items = [], opt: {}) ⇒ Object

Filter items based on search criteria

Parameters:

  • items (Array) (defaults to: [])

    The items to filter (if empty, filters all items)

  • opt (Hash) (defaults to: {})

    The filter parameters

Options Hash (opt:):

  • :section (String)
  • :unfinished (Boolean)
  • :tag (Array or String) — default: Array or comma-separated string
  • :tag_bool (Symbol) — default: :and, :or, :not
  • :search (String) — default: string, optional regex with //
  • :date_filter (Array)

    [[Time]start, [Time]end]

  • :only_timed (Boolean)
  • :before (String) — default: Date/Time string, unparsed
  • :after (String) — default: Date/Time string, unparsed
  • :today (Boolean)
  • :yesterday (Boolean)
  • :count (Number) — default: Number to return
  • :age (String) — default: 'old' or 'new'

#fork_editor(input = '') ⇒ Object

Create a process for an editor and wait for the file handle to return

Parameters:

  • input (String) (defaults to: '')

    Text input for editor

Raises:

  • (MissingEditor)

#format_input(input) ⇒ Array

Takes a multi-line string and formats it as an entry

Parameters:

  • input (String)

    The string to parse

Returns:

  • (Array)

    [[String]title, [Note]note]

Raises:

  • (EmptyInput)

#format_time(seconds, human: false) ⇒ Object

Format human readable time from seconds

Parameters:

  • seconds (Integer)

    Seconds

#get_interval(item, formatted: true, record: true) ⇒ Object

Gets the interval between entry's start date and @done date

Parameters:

  • item (Item)

    The entry

  • formatted (Boolean) (defaults to: true)

    Return human readable time (default seconds)

  • record (Boolean) (defaults to: true)

    Add the interval to the total for each tag

Returns:

  • Interval in seconds, or [d, h, m] array if formatted is true. False if no end date or interval is 0

#get_view(title) ⇒ Object

Gets a view from configuration

Parameters:

  • title (String)

    The title of the view to retrieve

#guess_section(frag, guessed: false, suggest: false) ⇒ Object

Attempt to match a string with an existing section

Parameters:

  • frag (String)

    The user-provided string

  • guessed (Boolean) (defaults to: false)

    already guessed and failed

#guess_view(frag, guessed: false, suggest: false) ⇒ Object

Attempt to match a string with an existing view

Parameters:

  • frag (String)

    The user-provided string

  • guessed (Boolean) (defaults to: false)

    already guessed

#import(paths, opt = {}) ⇒ Object

Imports external entries

Parameters:

  • paths (String)

    Path to JSON report file

  • opt (Hash) (defaults to: {})

    Additional Options

#init_doing_file(path = nil) ⇒ Object

Initializes the doing file.

Parameters:

  • path (String) (defaults to: nil)

    Override path to a doing file, optional

#interactive(opt = {}) ⇒ Object

Display an interactive menu of entries

Parameters:

  • opt (Hash) (defaults to: {})

    Additional options

Raises:

  • (NoResults)

#last(times: true, section: nil, options: {}) ⇒ Object

Show the last entry

Parameters:

  • times (Bool) (defaults to: true)

    Show times

  • section (String) (defaults to: nil)

    Section to pull from, default Currently

#last_entry(opt = {}) ⇒ Object

Get the last entry

Parameters:

  • opt (Hash) (defaults to: {})

    Additional Options

#last_note(section = 'All') ⇒ Object

Return the content of the last note for a given section

Parameters:

  • section (String) (defaults to: 'All')

    The section to retrieve from, default All

Raises:

  • (NoEntryError)

#list_date(dates, section, times = nil, output = nil, opt = {}) ⇒ Object

Display entries within a date range

Parameters:

  • dates (Array)

    [start, end]

  • section (String)

    The section

  • times (Bool) (defaults to: nil)

    Show times

  • output (String) (defaults to: nil)

    Output format

  • opt (Hash) (defaults to: {})

    Additional Options

#list_section(opt = {}) ⇒ Object

Display contents of a section based on options

Parameters:

  • opt (Hash) (defaults to: {})

    Additional Options

#loggerObject

Logger

Responds to :debug, :info, :warn, and :error

Each method takes a topic, and a message or block

Example: debug('Hooks', 'Hook 1 triggered')

#move_item(item, section, label: true) ⇒ Item

Move item from current section to destination section

Parameters:

  • item (Item)

    The item to move

  • section (String)

    The destination section

Returns:

  • (Item)

    Updated item

#next_item(item, options = {}) ⇒ Item

Get next item in the index

Parameters:

  • item (Item)

    target item

  • options (Hash) (defaults to: {})

    additional options

Returns:

  • (Item)

    the next chronological item in the index

See Also:

#recent(count = 10, section = nil, opt = {}) ⇒ Object

Show recent entries

Parameters:

  • count (Integer) (defaults to: 10)

    The number to show

  • section (String) (defaults to: nil)

    The section to show from, default Currently

  • opt (Hash) (defaults to: {})

    Additional Options

#repeat_item(item, opt = {}) ⇒ Object

#repeat_last(opt = {}) ⇒ Object

Restart the last entry

Parameters:

  • opt (Hash) (defaults to: {})

    Additional Options

#reset_item(item, resume: false) ⇒ Object

#restore_backup(file) ⇒ Object

Restore a backed up version of a file

Parameters:

  • file (String)

    The filepath to restore

#rotate(opt = {}) ⇒ Object

Rename doing file with date and start fresh one

#sectionsArray

List sections

Returns:

  • (Array)

    section titles

#stop_start(target_tag, opt = {}) ⇒ Object

Accepts one tag and the raw text of a new item if the passed tag is on any item, it's replaced with @done. if new_item is not nil, it's tagged with the passed tag and inserted. This is for use where only one instance of a given tag should exist (@meanwhile)

Parameters:

  • target_tag (String)

    Tag to replace

  • opt (Hash) (defaults to: {})

    Additional Options

#tag_groups(items, opt: {}) ⇒ Object

#tag_item(item, tags, remove: false, date: false, single: false) ⇒ Item

Tag an item from the index

Parameters:

  • item (Item)

    The item to tag

  • tags (String)

    The tag to apply

  • remove (Boolean) (defaults to: false)

    remove tags?

  • date (Boolean) (defaults to: false)

    Include timestamp?

  • single (Boolean) (defaults to: false)

    Log as a single change?

Returns:

  • (Item)

    updated item

#tag_last(opt = {}) ⇒ Object

Tag the last entry or X entries

Parameters:

  • opt (Hash) (defaults to: {})

    Additional Options (see

    filter_items for filtering

    options)

Raises:

  • (NoResults)

See Also:

#tag_times(format: :text, sort_by_name: false, sort_order: 'asc') ⇒ Object

Get total elapsed time for all tags in selection

Parameters:

  • format (String) (defaults to: :text)

    return format (html, json, or text)

  • sort_by_name (Boolean) (defaults to: false)

    Sort by name if true, otherwise by time

  • sort_order (String) (defaults to: 'asc')

    The sort order (asc or desc)

#today(times = true, output = nil, opt = {}) ⇒ Object

Show all entries from the current day

Parameters:

  • times (Boolean) (defaults to: true)

    show times

  • output (String) (defaults to: nil)

    output format

  • opt (Hash) (defaults to: {})

    Options

#update_item(old_item, new_item) ⇒ Object

Update an item in the index with a modified item

Parameters:

  • old_item

    The old item

  • new_item

    The new item

Raises:

  • (ItemNotFound)

#viewsArray

List available views

Returns:

#write(file = nil, backup: true) ⇒ Object

Write content to file or STDOUT

Parameters:

  • file (String) (defaults to: nil)

    The filepath to write to

#yesterday(section, times = nil, output = nil, opt = {}) ⇒ Object

Show entries from the previous day

Parameters:

  • section (String)

    The section

  • times (Bool) (defaults to: nil)

    Show times

  • output (String) (defaults to: nil)

    Output format

  • opt (Hash) (defaults to: {})

    Additional Options

#yn(question, default_response: false) ⇒ Bool

Ask a yes or no question in the terminal

Parameters:

  • question (String)

    The question to ask

  • default_response (Bool) (defaults to: false)

    default response if no input

Returns:

  • (Bool)

    yes or no