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 =
{ calendars: ['primary'], day: { start: 8, end: 18, }, defaults: { day_offset: 'next weekday', day_buffer: 1, duration: 30, align_to: 15, }, 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
31 32 33 |
# File 'lib/schedule/config.rb', line 31 def self.config_file file('config.yml') end |
.file(*args) ⇒ Object
27 28 29 |
# File 'lib/schedule/config.rb', line 27 def self.file(*args) File.join(CONFIG_DIR, *args) end |
.setup! ⇒ Object
35 36 37 38 |
# File 'lib/schedule/config.rb', line 35 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
40 41 42 |
# File 'lib/schedule/config.rb', line 40 def self.value(*args) values.dig *args end |
.values ⇒ Object
44 45 46 |
# File 'lib/schedule/config.rb', line 44 def self.values @values ||= YAML.load(File.read(config_file)) # rubocop:disable Security/YAMLLoad end |