Class: Doing::WWID
- Includes:
- Color
- Defined in:
- lib/doing/wwid/wwid.rb,
 lib/doing/wwid/tags.rb,
 lib/doing/wwid/guess.rb,
 lib/doing/wwid/editor.rb,
 lib/doing/wwid/filter.rb,
 lib/doing/wwid/modify.rb,
 lib/doing/wwid/timers.rb,
 lib/doing/wwid/display.rb,
 lib/doing/wwid/wwidutil.rb,
 lib/doing/wwid/filetools.rb,
 lib/doing/wwid/interactive.rb
Overview
Main "What Was I Doing" methods
Constant Summary
Constants included from Color
Color::ATTRIBUTES, Color::ATTRIBUTE_NAMES, Color::ESCAPE_REGEX
Instance Attribute Summary collapse
- 
  
    
      #additional_configs  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Local configuration files detected at initialization. 
- 
  
    
      #config  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    For backwards compatibility where @wwid.config was accessed instead of Doing.config.settings. 
- 
  
    
      #config_file  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    The location of the main config file. 
- 
  
    
      #content  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    The Items object into which all entries are read. 
- 
  
    
      #current_section  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    The Currently section defined in configuration. 
- 
  
    
      #default_option  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    [Boolean] the default option to provide in Y/N dialogs. 
- 
  
    
      #doing_file  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    The location of the Doing file defined in configuration. 
- 
  
    
      #initial_content  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    A frozen copy of the content object before any modification. 
Instance Method Summary collapse
- 
  
    
      #act_on(items, opt)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Perform actions on a set of entries. 
- 
  
    
      #add_item(title, section = nil, opt)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Adds an entry. 
- #add_with_editor(**options) ⇒ Object
- 
  
    
      #all_tags(items, opt: {}, counts: false)  ⇒ Hash, Array 
    
    
  
  
  
  
  
  
  
  
  
    List all tags that exist on given items. 
- 
  
    
      #archive(section = Doing.setting('current_section'), options)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Move entries from a section to Archive or other specified section. 
- 
  
    
      #autotag(string)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Uses 'autotag' configuration to turn keywords into tags for time tracking. 
- 
  
    
      #changes  ⇒ Hash 
    
    
  
  
  
  
  
  
  
  
  
    Return a hash of changes between initial file read and current Items object. 
- 
  
    
      #choose_section(include_all: false)  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    Generate a menu of sections and allow user selection. 
- 
  
    
      #choose_section_tag  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    Generate a menu of sections and tags and allow user selection. 
- 
  
    
      #choose_tag(section = 'All', items: nil, include_all: false)  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    Generate a menu of tags and allow user selection. 
- 
  
    
      #choose_view  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    Generate a menu of views and allow user selection. 
- 
  
    
      #configure(filename = nil)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Load configuration files and updated the @settings attribute with a Doing::Configuration object. 
- 
  
    
      #create(filename = nil)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Create a new doing file. 
- 
  
    
      #dedup(items, no_overlap: false)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Remove items from an array that already exist in :content based on start and end times. 
- 
  
    
      #delete_items(items, force: false)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Delete a set of items from the main index. 
- #edit_items(items) ⇒ Object
- 
  
    
      #edit_last(section: 'All', options: {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Edit the last entry. 
- 
  
    
      #filter_items(items = Items.new, opt: {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Filter items based on search criteria. 
- 
  
    
      #fork_editor(input = '', message: :default)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Create a process for an editor and wait for the file handle to return. 
- 
  
    
      #format_input(input)  ⇒ Array 
    
    
  
  
  
  
  
  
  
  
  
    Takes a multi-line string and formats it as an entry. 
- #fuzzy_filter_args(query, case_type) ⇒ Object
- 
  
    
      #fuzzy_filter_items(items, query, case_type: :smart)  ⇒ Items 
    
    
  
  
  
  
  
  
  
  
  
    Use fzf to filter an Items object with a search query. 
- 
  
    
      #get_diff(filename = nil)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Get difference between current content and last backup. 
- 
  
    
      #get_interval(item, formatted: true, record: true)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Gets the interval between entry's start date and @done date. 
- 
  
    
      #get_view(title, fallback: nil)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Gets a view from configuration. 
- 
  
    
      #guess_section(frag, guessed: false, suggest: false)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Attempt to match a string with an existing section. 
- 
  
    
      #guess_view(frag, guessed: false, suggest: false)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Attempt to match a string with an existing view. 
- 
  
    
      #import(paths, opt)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Imports external entries. 
- 
  
    
      #init_doing_file(path = nil)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Initializes the doing file. 
- 
  
    
      #initialize  ⇒ WWID 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    Initializes the object. 
- 
  
    
      #interactive(opt)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Display an interactive menu of entries. 
- 
  
    
      #last(times: true, section: nil, options: {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Show the last entry. 
- 
  
    
      #last_entry(opt)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Get the last entry. 
- 
  
    
      #last_note(section = 'All')  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Return the content of the last note for a given section. 
- 
  
    
      #list_date(dates, section, times = nil, output = nil, opt)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Display entries within a date range. 
- 
  
    
      #list_section(opt, items: Items.new)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Display contents of a section based on options. 
- 
  
    
      #logger  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Logger. 
- 
  
    
      #recent(count = 10, section = nil, opt)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Show recent entries. 
- #rename_view_keys(view) ⇒ Object
- 
  
    
      #repeat_item(item, opt)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Duplicate an item and add it as a new item. 
- 
  
    
      #repeat_last(opt)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Restart the last entry. 
- 
  
    
      #reset_item(item, date: nil, finish_date: nil, resume: false)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Reset start date to current time, optionally remove done tag (resume). 
- 
  
    
      #rotate(opt)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Rename doing file with date and start fresh one. 
- 
  
    
      #sections  ⇒ Array 
    
    
  
  
  
  
  
  
  
  
  
    List sections. 
- 
  
    
      #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. 
- #tag_groups(items, opt: {}) ⇒ Object
- 
  
    
      #tag_last(opt)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Tag the last entry or X entries. 
- 
  
    
      #tag_times(format: :text, sort_by: :time, sort_order: :asc)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Get total elapsed time for all tags in selection. 
- 
  
    
      #today(times = true, output = nil, opt)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Show all entries from the current day. 
- 
  
    
      #verify_duration(date, finish_date, title: nil)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Interactively verify an item modification if elapsed time is greater than configured threshold. 
- #view_to_options(title) ⇒ Object
- 
  
    
      #views  ⇒ Array 
    
    
  
  
  
  
  
  
  
  
  
    List available views. 
- 
  
    
      #write(file = nil, backup: true)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Write content to file or STDOUT. 
- 
  
    
      #yesterday(section, times = nil, output = nil, opt)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Show entries from the previous day. 
Methods included from Color
attributes, coloring?, #rgb, #support?, template, uncolor, #uncolor
Constructor Details
#initialize ⇒ WWID
Initializes the object.
Instance Attribute Details
#additional_configs ⇒ Object (readonly)
Local configuration files detected at initialization
#config ⇒ Object
For backwards compatibility where @wwid.config was accessed instead of Doing.config.settings
#config_file ⇒ Object
The location of the main config file
#content ⇒ Object (readonly)
The Items object into which all entries are read
#current_section ⇒ Object (readonly)
The Currently section defined in configuration
#default_option ⇒ Object
[Boolean] the default option to provide in Y/N dialogs
#doing_file ⇒ Object (readonly)
The location of the Doing file defined in configuration
#initial_content ⇒ Object (readonly)
A frozen copy of the content object before any modification
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
#add_item(title, section = nil, opt) ⇒ Object
Adds an entry
#add_with_editor(**options) ⇒ Object
#archive(section = Doing.setting('current_section'), options) ⇒ Object
Move entries from a section to Archive or other specified section
#autotag(string) ⇒ 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
#changes ⇒ Hash
Return a hash of changes between initial file read and current Items object
#choose_section(include_all: false) ⇒ String
Generate a menu of sections and allow user selection
#choose_section_tag ⇒ String
Generate a menu of sections and tags and allow user selection
#choose_tag(section = 'All', items: nil, include_all: false) ⇒ String
Generate a menu of tags and allow user selection
#choose_view ⇒ String
Generate a menu of views and allow user selection
#configure(filename = nil) ⇒ Object
Load configuration files and updated the @settings attribute with a Doing::Configuration object
#create(filename = nil) ⇒ Object
Create a new doing file
#dedup(items, no_overlap: false) ⇒ Object
Remove items from an array that already exist in :content based on start and end times
#delete_items(items, force: false) ⇒ Object
Delete a set of items from the main index
#edit_items(items) ⇒ Object
#edit_last(section: 'All', options: {}) ⇒ Object
Edit the last entry
#filter_items(items = Items.new, opt: {}) ⇒ Object
Filter items based on search criteria
#fork_editor(input = '', message: :default) ⇒ Object
Create a process for an editor and wait for the file handle to return
#format_input(input) ⇒ Array
Takes a multi-line string and formats it as an entry
#fuzzy_filter_args(query, case_type) ⇒ Object
#fuzzy_filter_items(items, query, case_type: :smart) ⇒ Items
Use fzf to filter an Items object with a search query. Faster than #filter_items when all you need is a text search of the title and note
#get_diff(filename = nil) ⇒ Object
Get difference between current content and last backup
#get_interval(item, formatted: true, record: true) ⇒ Object
Gets the interval between entry's start date and @done date
#get_view(title, fallback: nil) ⇒ Object
Gets a view from configuration
#guess_section(frag, guessed: false, suggest: false) ⇒ Object
Attempt to match a string with an existing section
#guess_view(frag, guessed: false, suggest: false) ⇒ Object
Attempt to match a string with an existing view
#import(paths, opt) ⇒ Object
Imports external entries
#init_doing_file(path = nil) ⇒ Object
Initializes the doing file.
#interactive(opt) ⇒ Object
Display an interactive menu of entries
Options hash is shared with #filter_items and #act_on
#last(times: true, section: nil, options: {}) ⇒ Object
Show the last entry
#last_entry(opt) ⇒ Object
Get the last entry
#last_note(section = 'All') ⇒ Object
Return the content of the last note for a given section
#list_date(dates, section, times = nil, output = nil, opt) ⇒ Object
Display entries within a date range
#list_section(opt, items: Items.new) ⇒ Object
Display contents of a section based on options
#logger ⇒ Object
Logger
Responds to :debug, :info, :warn, and :error
Each method takes a topic, and a message or block
Example: debug('Hooks', 'Hook 1 triggered')
#recent(count = 10, section = nil, opt) ⇒ Object
Show recent entries
#rename_view_keys(view) ⇒ Object
#repeat_item(item, opt) ⇒ Object
Duplicate an item and add it as a new item
#repeat_last(opt) ⇒ Object
Restart the last entry
#reset_item(item, date: nil, finish_date: nil, resume: false) ⇒ Object
Reset start date to current time, optionally remove done tag (resume)
#rotate(opt) ⇒ Object
Rename doing file with date and start fresh one
#sections ⇒ Array
List sections
#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)
#tag_groups(items, opt: {}) ⇒ Object
#tag_last(opt) ⇒ Object
Tag the last entry or X entries
hooked
#tag_times(format: :text, sort_by: :time, sort_order: :asc) ⇒ Object
Get total elapsed time for all tags in selection
#today(times = true, output = nil, opt) ⇒ Object
Show all entries from the current day
#verify_duration(date, finish_date, title: nil) ⇒ Object
Interactively verify an item modification if elapsed time is greater than configured threshold
#view_to_options(title) ⇒ Object
#views ⇒ Array
List available views
#write(file = nil, backup: true) ⇒ Object
Write content to file or STDOUT
#yesterday(section, times = nil, output = nil, opt) ⇒ Object
Show entries from the previous day