Class: NewlineHw::Config
- Inherits:
-
Object
- Object
- NewlineHw::Config
- Defined in:
- lib/newline_hw/config.rb
Constant Summary collapse
- CONFIG_PATH =
File.("~/.newline_hw.yaml").freeze
- DEFAULTS =
{ "editor" => "atom", "terminal" => "Terminal", "launch_editor" => true, "homework_dir" => "~/theironyard/homework", "log_file" => "~/Library/Logs/newline_hw/newlinehw.log" }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #config ⇒ Object
- #config_file ⇒ Object
- #editor ⇒ Object
- #homework_dir ⇒ Object
- #launch_editor ⇒ Object
- #log_file ⇒ Object
- #terminal ⇒ Object
- #update(options) ⇒ Object
Class Method Details
.install_default ⇒ Object
48 49 50 51 52 |
# File 'lib/newline_hw/config.rb', line 48 def self.install_default File.open(CONFIG_PATH, "w+") do |f| f.write DEFAULTS.to_yaml end end |
Instance Method Details
#config ⇒ Object
18 19 20 |
# File 'lib/newline_hw/config.rb', line 18 def config @config ||= DEFAULTS.merge(config_file) end |
#config_file ⇒ Object
22 23 24 25 26 |
# File 'lib/newline_hw/config.rb', line 22 def config_file YAML.load_file(CONFIG_PATH) || DEFAULTS rescue Errno::ENOENT DEFAULTS end |
#editor ⇒ Object
28 29 30 |
# File 'lib/newline_hw/config.rb', line 28 def editor config["editor"] end |
#homework_dir ⇒ Object
40 41 42 |
# File 'lib/newline_hw/config.rb', line 40 def homework_dir config["homework_dir"] end |
#launch_editor ⇒ Object
44 45 46 |
# File 'lib/newline_hw/config.rb', line 44 def launch_editor config["launch_editor"] end |
#log_file ⇒ Object
36 37 38 |
# File 'lib/newline_hw/config.rb', line 36 def log_file config["log_file"] end |
#terminal ⇒ Object
32 33 34 |
# File 'lib/newline_hw/config.rb', line 32 def terminal config["terminal"] end |
#update(options) ⇒ Object
14 15 16 |
# File 'lib/newline_hw/config.rb', line 14 def update() @config = config.merge() end |