Class: StandupMD::Config::File

Inherits:
Object
  • Object
show all
Defined in:
lib/standup_md/config/file.rb

Overview

The configuration class for StandupMD::File

Constant Summary collapse

DEFAULTS =

The default options.

Returns:

  • (Hash)
{
  header_date_format: "%Y-%m-%d",
  header_depth: 1,
  sub_header_depth: 2,
  current_header: "Current",
  previous_header: "Previous",
  impediments_header: "Impediments",
  notes_header: "Notes",
  sub_header_order: %w[previous current impediments notes],
  directory: ::File.join(ENV["HOME"], ".cache", "standup_md"),
  bullet_character: "-",
  indent_width: 2,
  name_format: "%Y_%m.md",
  create: true
}.freeze
CONFIG_ATTRIBUTES =

Attributes copied into request-scoped config snapshots.

Returns:

  • (Array<Symbol>)
DEFAULTS.keys.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFile

Initializes the config with default values.



153
154
155
# File 'lib/standup_md/config/file.rb', line 153

def initialize
  reset
end

Instance Attribute Details

#bullet_characterString

Character used as bullets for list entries.

Returns:

  • (String)

    either - (dash) or * (asterisk)



64
65
66
# File 'lib/standup_md/config/file.rb', line 64

def bullet_character
  @bullet_character
end

#createboolean

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

Parameters:

  • create (Boolean)

Returns:

  • (boolean)


149
150
151
# File 'lib/standup_md/config/file.rb', line 149

def create
  @create
end

#current_headerString

String to be used as “Current” header.

Parameters:

  • header (String)

Returns:

  • (String)


82
83
84
# File 'lib/standup_md/config/file.rb', line 82

def current_header
  @current_header
end

#directoryString

The directory in which the files are located.

Returns:

  • (String)


56
57
58
# File 'lib/standup_md/config/file.rb', line 56

def directory
  @directory
end

#header_date_formatString

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

Parameters:

  • format (String)

Returns:

  • (String)


141
142
143
# File 'lib/standup_md/config/file.rb', line 141

def header_date_format
  @header_date_format
end

#header_depthInteger

Number of octothorps that should preface entry headers.

Returns:

  • (Integer)

    between 1 and 5



40
41
42
# File 'lib/standup_md/config/file.rb', line 40

def header_depth
  @header_depth
end

#impediments_headerString

String to be used as “Impediments” header.

Parameters:

  • header (String)

Returns:

  • (String)


102
103
104
# File 'lib/standup_md/config/file.rb', line 102

def impediments_header
  @impediments_header
end

#indent_widthInteger

Number of spaces used for each nested task level.

Returns:

  • (Integer)


72
73
74
# File 'lib/standup_md/config/file.rb', line 72

def indent_width
  @indent_width
end

#name_formatString

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

Parameters:

  • name_format (String)

Returns:

  • (String)


133
134
135
# File 'lib/standup_md/config/file.rb', line 133

def name_format
  @name_format
end

#notes_headerString

String to be used as “Notes” header.

Parameters:

  • header (String)

Returns:

  • (String)


112
113
114
# File 'lib/standup_md/config/file.rb', line 112

def notes_header
  @notes_header
end

#previous_headerString

String to be used as “Previous” header.

Parameters:

  • header (String)

Returns:

  • (String)


92
93
94
# File 'lib/standup_md/config/file.rb', line 92

def previous_header
  @previous_header
end

#sub_header_depthInteger

Number of octothorps that should preface sub-headers.

Returns:

  • (Integer)

    between 2 and 6



48
49
50
# File 'lib/standup_md/config/file.rb', line 48

def sub_header_depth
  @sub_header_depth
end

#sub_header_orderArray

Preferred order for sub-headers.

Parameters:

  • sub_header_order (Array)

Returns:

  • (Array)


122
123
124
# File 'lib/standup_md/config/file.rb', line 122

def sub_header_order
  @sub_header_order
end

Instance Method Details

#copyStandupMD::Config::File

Builds an independent copy of this file config.



169
170
171
# File 'lib/standup_md/config/file.rb', line 169

def copy
  self.class.new.copy_from(self)
end

#copy_from(config) ⇒ StandupMD::Config::File

Copies values from another file config.

Parameters:

Returns:



179
180
181
182
183
184
185
186
187
# File 'lib/standup_md/config/file.rb', line 179

def copy_from(config)
  CONFIG_ATTRIBUTES.each do |attribute|
    instance_variable_set(
      "@#{attribute}",
      copy_default(config.public_send(attribute))
    )
  end
  self
end

#resetHash

Sets all config values back to their defaults.

Returns:

  • (Hash)


161
162
163
# File 'lib/standup_md/config/file.rb', line 161

def reset
  DEFAULTS.each { |k, v| instance_variable_set("@#{k}", copy_default(v)) }
end