class StandupMD::Config::File

The configuration class for StandupMD::File

Constants

DEFAULTS

The default options.

@return [Hash]

Attributes

bullet_character[R]

Character used as bullets for list entries.

@return [String] either - (dash) or * (asterisk)

@default “-” (dash)

create[RW]

Should the file be created if it doesn't exist?

@param [Boolean] create

@return [boolean]

current_header[RW]

String to be used as “Current” header.

@param [String] header

@return [String]

@default “Current”

directory[R]

The directory in which the files are located.

@return [String]

@default “~/.cache/standup_md”

header_date_format[RW]

The date format for entry headers. Will be parsed by strftime.

@param [String] format

@return [String]

header_depth[R]

Number of octothorps that should preface entry headers.

@return [Integer] between 1 and 5

@default 1

impediments_header[RW]

String to be used as “Impediments” header.

@param [String] header

@return [String]

@default “Impediments”

name_format[RW]

Format to be used for standup file names. Should be parse-able by strftime, and should be a monthly date.

@param [String] name_format

@return [String]

@default “%Y_%m.md”

notes_header[RW]

String to be used as “Notes” header.

@param [String] header

@return [String]

@default “Notes”

previous_header[RW]

String to be used as “Previous” header.

@param [String] header

@return [String]

@default “Previous”

sub_header_depth[R]

Number of octothorps that should preface sub-headers.

@return [Integer] between 2 and 6

@default 2

sub_header_order[RW]

Preferred order for sub-headers.

@param [Array] sub_header_order

@return [Array]

@default %w[previous current impediment notes]

Public Class Methods

new() click to toggle source

Initializes the config with default values.

# File lib/standup_md/config/file.rb, line 140
def initialize
  reset
end

Public Instance Methods

bullet_character=(char) click to toggle source

Setter for bullet_character. Must be * (asterisk) or - (dash).

@param [String] character

@return [String]

# File lib/standup_md/config/file.rb, line 189
def bullet_character=(char)
  raise 'Must be "-" or "*"' unless %w[- *].include?(char)
  @bullet_character = char
end
directory=(directory) click to toggle source

Setter for directory. Must be expanded in case the user uses `~` for home. If the directory doesn't exist, it will be created. To reset instance variables after changing the directory, you'll need to call load.

@param [String] directory

@return [String]

# File lib/standup_md/config/file.rb, line 202
def directory=(directory)
  @directory = ::File.expand_path(directory).tap do |directory|
    FileUtils.mkdir_p(directory) unless ::File.directory?(directory)
  end
end
header_depth=(depth) click to toggle source

Number of octothorps (#) to use before the main header.

@param [Integer] depth

@return [Integer]

# File lib/standup_md/config/file.rb, line 158
def header_depth=(depth)
  if !depth.between?(1, 5)
    raise 'Header depth out of bounds (1..5)'
  elsif depth >= sub_header_depth
    @sub_header_depth = depth + 1
  end
  @header_depth = depth
end
reset() click to toggle source

Sets all config values back to their defaults.

@return [Hash]

# File lib/standup_md/config/file.rb, line 148
def reset
  DEFAULTS.each { |k, v| instance_variable_set("@#{k}", v) }
end
sub_header_depth=(depth) click to toggle source

Number of octothorps (#) to use before sub headers (Current, Previous, etc).

@param [Integer] depth

@return [Integer]

# File lib/standup_md/config/file.rb, line 174
def sub_header_depth=(depth)
  if !depth.between?(2, 6)
    raise 'Sub-header depth out of bounds (2..6)'
  elsif depth <= header_depth
    @header_depth = depth - 1
  end
  @sub_header_depth = depth
end