Class: Doing::Configuration

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

Overview

Configuration object

Constant Summary collapse

MissingConfigFile =
Class.new(RuntimeError)
DEFAULTS =
{
  'autotag' => {
    'whitelist' => [],
    'synonyms' => {}
  },
  'editors' => {
    'default' => ENV['DOING_EDITOR'] || ENV['GIT_EDITOR'] || ENV['EDITOR'],
    'doing_file' => nil,
    'config' => nil
  },
  'plugins' => {
    'plugin_path' => File.join(Util.user_home, '.config', 'doing', 'plugins'),
    'command_path' => File.join(Util.user_home, '.config', 'doing', 'commands')
  },
  'doing_file' => '~/.local/share/doing/what_was_i_doing.md',
  'backup_dir' => '~/.local/share/doing/doing_backup',
  'current_section' => 'Currently',
  'paginate' => false,
  'never_time' => [],
  'never_finish' => [],
  'date_tags' => ['done', 'defer(?:red)?', 'waiting'],

  'timer_format' => 'text',
  'interval_format' => 'text',

  'templates' => {
    'default' => {
      'date_format' => '%Y-%m-%d %H:%M',
      'template' => '%reset%cyan%shortdate %boldwhite%80║ title %dark%boldmagenta[%boldwhite%-10section%boldmagenta]%reset
        %yellow%interval%boldred%duration%dark%white%80_14┃ note',
      'wrap_width' => 0,
      'order' => 'asc'
    },
    'today' => {
      'date_format' => '%_I:%M%P',
      'template' => '%date: %title %interval%duration%note',
      'wrap_width' => 0,
      'order' => 'asc'
    },
    'last' => {
      'date_format' => '%-I:%M%P on %a',
      'template' => '%title (at %date) %interval%duration%odnote',
      'wrap_width' => 88
    },
    'recent' => {
      'date_format' => '%_I:%M%P',
      'template' => '%reset%cyan%shortdate %boldwhite%80║ title %dark%boldmagenta[%boldwhite%-10section%boldmagenta]%reset
        %yellow%interval%boldred%duration%dark%white%80_14┃ note',
      'wrap_width' => 88,
      'count' => 10,
      'order' => 'asc'
    }
  },

  'export_templates' => {},

  'views' => {
    'done' => {
      'date_format' => '%_I:%M%P',
      'template' => '%date | %title (%section)% 18: note',
      'wrap_width' => 0,
      'section' => 'All',
      'count' => 0,
      'order' => 'desc',
      'tags' => 'done complete cancelled',
      'tags_bool' => 'OR'
    },
    'color' => {
      'date_format' => '%F %_I:%M%P',
      'template' => '%boldblack%date %boldgreen| %boldwhite%title%default%note',
      'wrap_width' => 0,
      'section' => 'Currently',
      'count' => 10,
      'order' => 'asc'
    }
  },
  'marker_tag' => 'flagged',
  'marker_color' => 'red',
  'default_tags' => [],
  'tag_sort' => 'name',
  'search' => {
    'matching' => 'pattern', # fuzzy, pattern, exact
    'distance' => 3,
    'case' => 'smart' # sensitive, ignore, smart
  },
  'include_notes' => true
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file = nil, options: {}) ⇒ Configuration

Returns a new instance of Configuration.

Instance Attribute Details

#config_fileObject

#force_answerObject

#ignore_local=(value) ⇒ Object (writeonly)

Sets the attribute ignore_local

Parameters:

  • value

    the value to set the attribute ignore_local to.

#settingsObject (readonly)

Returns the value of attribute settings.

Instance Method Details

#additional_configsObject

#choose_configString

Present a menu if there are multiple configs found

Returns:

#config_dirObject

#configure(opt = {}) ⇒ Object

Read user configuration and merge with defaults

Parameters:

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

    Additional Options

#default_config_fileObject

#exact_match?Boolean

Check if configuration enforces exact string matching

Returns:

  • (Boolean)

    exact matching enabled

#from(user_config) ⇒ Hash

It takes the input, fills in the defaults where values do not exist.

Parameters:

  • user_config

    a Hash or Configuration of overrides.

Returns:

  • (Hash)

    a Configuration filled with defaults.

#resolve_key_path(keypath, create: false) ⇒ Array

Resolve a fuzzy-matched key path

Parameters:

  • keypath (String)

    A dot-separated key path, e.g. "plugins.plugin_path". Will also work with "plug.path" (fuzzy matched, first match wins)

Returns:

  • (Array)

    ordered array of resolved keys

#update_deprecated_configObject

Method for transitioning from ~/.doingrc to ~/.config/doing/config.yml

#value_for_key(keypath = '') ⇒ Hash

Get the value for a fuzzy-matched key path

Parameters:

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

    A dot-separated key path, e.g. "plugins.plugin_path". Will also work with "plug.path" (fuzzy matched, first match wins)

Returns:

  • (Hash)

    Config value