Class: WB::Config
- Inherits:
-
Object
- Object
- WB::Config
- Defined in:
- lib/wb/config.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #extension ⇒ Object
-
#initialize(config_path) ⇒ Config
constructor
A new instance of Config.
- #notes ⇒ Object
- #personal_workbook ⇒ Object
- #project_date_format ⇒ Object
- #project_root ⇒ Object
- #work_workbook ⇒ Object
- #working_hours ⇒ Object
Constructor Details
#initialize(config_path) ⇒ Config
Returns a new instance of Config.
11 12 13 14 |
# File 'lib/wb/config.rb', line 11 def initialize(config_path) @path = config_path @config = YAML.safe_load(IO.read(config_path)) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/wb/config.rb', line 9 def path @path end |
Instance Method Details
#extension ⇒ Object
48 49 50 51 52 |
# File 'lib/wb/config.rb', line 48 def extension @extension ||= begin fetch_config(key: "extension", default: DEFAULT_EXTENSION_FORMAT) end end |
#notes ⇒ Object
16 17 18 19 20 21 22 23 |
# 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 ⇒ Object
29 30 31 |
# File 'lib/wb/config.rb', line 29 def personal_workbook @personal_workbook ||= workbook.fetch("personal") end |
#project_date_format ⇒ Object
41 42 43 44 45 46 |
# 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 ⇒ Object
37 38 39 |
# File 'lib/wb/config.rb', line 37 def project_root @project_root ||= project.fetch("note_folder") end |
#work_workbook ⇒ Object
33 34 35 |
# File 'lib/wb/config.rb', line 33 def work_workbook @work_workbook ||= workbook.fetch("work") end |
#working_hours ⇒ Object
25 26 27 |
# File 'lib/wb/config.rb', line 25 def working_hours @working_hours ||= workbook.fetch("working_hours").split("-") end |