Class: StandupMD::Config::File
- Inherits:
-
Object
- Object
- StandupMD::Config::File
- Defined in:
- lib/standup_md/config/file.rb
Overview
The configuration class for StandupMD::File
Constant Summary collapse
- DEFAULTS =
The default options.
{ 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.
DEFAULTS.keys.freeze
Instance Attribute Summary collapse
-
#bullet_character ⇒ String
Character used as bullets for list entries.
-
#create ⇒ boolean
Should the file be created if it doesn’t exist?.
-
#current_header ⇒ String
String to be used as “Current” header.
-
#directory ⇒ String
The directory in which the files are located.
-
#header_date_format ⇒ String
The date format for entry headers.
-
#header_depth ⇒ Integer
Number of octothorps that should preface entry headers.
-
#impediments_header ⇒ String
String to be used as “Impediments” header.
-
#indent_width ⇒ Integer
Number of spaces used for each nested task level.
-
#name_format ⇒ String
Format to be used for standup file names.
-
#notes_header ⇒ String
String to be used as “Notes” header.
-
#previous_header ⇒ String
String to be used as “Previous” header.
-
#sub_header_depth ⇒ Integer
Number of octothorps that should preface sub-headers.
-
#sub_header_order ⇒ Array
Preferred order for sub-headers.
Instance Method Summary collapse
-
#copy ⇒ StandupMD::Config::File
Builds an independent copy of this file config.
-
#copy_from(config) ⇒ StandupMD::Config::File
Copies values from another file config.
-
#initialize ⇒ File
constructor
Initializes the config with default values.
-
#reset ⇒ Hash
Sets all config values back to their defaults.
Constructor Details
#initialize ⇒ File
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_character ⇒ String
Character used as bullets for list entries.
64 65 66 |
# File 'lib/standup_md/config/file.rb', line 64 def bullet_character @bullet_character end |
#create ⇒ boolean
Should the file be created if it doesn’t exist?
149 150 151 |
# File 'lib/standup_md/config/file.rb', line 149 def create @create end |
#current_header ⇒ String
String to be used as “Current” header.
82 83 84 |
# File 'lib/standup_md/config/file.rb', line 82 def current_header @current_header end |
#directory ⇒ String
The directory in which the files are located.
56 57 58 |
# File 'lib/standup_md/config/file.rb', line 56 def directory @directory end |
#header_date_format ⇒ String
The date format for entry headers. Will be parsed by strftime.
141 142 143 |
# File 'lib/standup_md/config/file.rb', line 141 def header_date_format @header_date_format end |
#header_depth ⇒ Integer
Number of octothorps that should preface entry headers.
40 41 42 |
# File 'lib/standup_md/config/file.rb', line 40 def header_depth @header_depth end |
#impediments_header ⇒ String
String to be used as “Impediments” header.
102 103 104 |
# File 'lib/standup_md/config/file.rb', line 102 def impediments_header @impediments_header end |
#indent_width ⇒ Integer
Number of spaces used for each nested task level.
72 73 74 |
# File 'lib/standup_md/config/file.rb', line 72 def indent_width @indent_width end |
#name_format ⇒ String
Format to be used for standup file names. Should be parse-able by strftime, and should be a monthly date.
133 134 135 |
# File 'lib/standup_md/config/file.rb', line 133 def name_format @name_format end |
#notes_header ⇒ String
String to be used as “Notes” header.
112 113 114 |
# File 'lib/standup_md/config/file.rb', line 112 def notes_header @notes_header end |
#previous_header ⇒ String
String to be used as “Previous” header.
92 93 94 |
# File 'lib/standup_md/config/file.rb', line 92 def previous_header @previous_header end |
#sub_header_depth ⇒ Integer
Number of octothorps that should preface sub-headers.
48 49 50 |
# File 'lib/standup_md/config/file.rb', line 48 def sub_header_depth @sub_header_depth end |
#sub_header_order ⇒ Array
Preferred order for sub-headers.
122 123 124 |
# File 'lib/standup_md/config/file.rb', line 122 def sub_header_order @sub_header_order end |
Instance Method Details
#copy ⇒ StandupMD::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.
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 |
#reset ⇒ Hash
Sets all config values back to their defaults.
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 |