class WB::Config
Constants
- DEFAULT_DATE_FORMAT
- DEFAULT_EXTENSION_FORMAT
Attributes
config[R]
path[R]
Public Class Methods
new(config_path)
click to toggle source
# File lib/wb/config.rb, line 11 def initialize(config_path) @path = config_path @config = YAML.safe_load(IO.read(config_path)) end
Public Instance Methods
extension()
click to toggle source
# File lib/wb/config.rb, line 48 def extension @extension ||= begin fetch_config(key: "extension", default: DEFAULT_EXTENSION_FORMAT) end end
notes()
click to toggle source
# File lib/wb/config.rb, line 16 def notes local_notes = Dir[File.join(WB.config.project_root, "*")] global_notes = [WB.config.personal_workbook, WB.config.work_workbook] [*local_notes, *global_notes].each_with_index.map do |note, index| WB::Note.new(note, index) end end
personal_workbook()
click to toggle source
# File lib/wb/config.rb, line 29 def personal_workbook @personal_workbook ||= workbook.fetch("personal") end
project_date_format()
click to toggle source
# File lib/wb/config.rb, line 41 def project_date_format @project_date_format ||= begin date_format = fetch_config(key: "date_format", default: DEFAULT_DATE_FORMAT) Filename.generate(date_format) end end
project_root()
click to toggle source
# File lib/wb/config.rb, line 37 def project_root @project_root ||= project.fetch("note_folder") end
work_workbook()
click to toggle source
# File lib/wb/config.rb, line 33 def work_workbook @work_workbook ||= workbook.fetch("work") end
working_hours()
click to toggle source
# File lib/wb/config.rb, line 25 def working_hours @working_hours ||= workbook.fetch("working_hours").split("-") end
Private Instance Methods
fetch_config(key:, default:)
click to toggle source
# File lib/wb/config.rb, line 72 def fetch_config(key:, default:) project.fetch(key) do workbook.fetch(key) do default end end end
project()
click to toggle source
# File lib/wb/config.rb, line 68 def project @_project ||= workbook.fetch("project") end
workbook()
click to toggle source
# File lib/wb/config.rb, line 64 def workbook @_workbook ||= config.fetch("workbook") end