Class: Schedule::Config
- Inherits:
-
Object
- Object
- Schedule::Config
- Defined in:
- lib/schedule/config.rb
Constant Summary collapse
- CONFIG_DIR =
"#{Dir.home}/.schedule-cli/"
- DEFAULT_CONFIG =
{ defaults: { align_to: 15, calendars: ['primary'], day: { start: 8, end: 18, offset: 'next weekday', buffer: 1, }, duration: 30, min_delay: 4, footer: nil, }, events: { call: { duration: 30 }, coffee: { duration: 60 }, }, }.freeze
Class Method Summary collapse
- .config_file ⇒ Object
- .file(*args) ⇒ Object
- .setup! ⇒ Object
- .value(*args) ⇒ Object
- .values ⇒ Object
Class Method Details
.config_file ⇒ Object
33 34 35 |
# File 'lib/schedule/config.rb', line 33 def self.config_file file('config.yml') end |
.file(*args) ⇒ Object
29 30 31 |
# File 'lib/schedule/config.rb', line 29 def self.file(*args) File.join(CONFIG_DIR, *args) end |
.setup! ⇒ Object
37 38 39 40 |
# File 'lib/schedule/config.rb', line 37 def self.setup! FileUtils.mkdir_p CONFIG_DIR File.write(config_file, YAML.dump(DEFAULT_CONFIG)) unless File.file?(config_file) end |
.value(*args) ⇒ Object
42 43 44 |
# File 'lib/schedule/config.rb', line 42 def self.value(*args) values.dig *args end |
.values ⇒ Object
46 47 48 |
# File 'lib/schedule/config.rb', line 46 def self.values @values ||= DEFAULT_CONFIG.merge(YAML.load(File.read(config_file))) # rubocop:disable Security/YAMLLoad end |