Class: Slk::Services::Configuration
- Inherits:
-
Object
- Object
- Slk::Services::Configuration
- Defined in:
- lib/slk/services/configuration.rb
Overview
Manages CLI configuration stored in XDG config directory
Instance Attribute Summary collapse
-
#on_warning ⇒ Object
Returns the value of attribute on_warning.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #emoji_dir ⇒ Object
-
#initialize(paths: Support::XdgPaths.new) ⇒ Configuration
constructor
A new instance of Configuration.
- #primary_workspace ⇒ Object
- #primary_workspace=(name) ⇒ Object
- #ssh_key ⇒ Object
- #ssh_key=(path) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(paths: Support::XdgPaths.new) ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 13 |
# File 'lib/slk/services/configuration.rb', line 9 def initialize(paths: Support::XdgPaths.new) @paths = paths @on_warning = nil @data = nil # Lazy load to allow on_warning to be set first end |
Instance Attribute Details
#on_warning ⇒ Object
Returns the value of attribute on_warning.
7 8 9 |
# File 'lib/slk/services/configuration.rb', line 7 def on_warning @on_warning end |
Instance Method Details
#[](key) ⇒ Object
37 38 39 |
# File 'lib/slk/services/configuration.rb', line 37 def [](key) data[key] end |
#[]=(key, value) ⇒ Object
41 42 43 44 |
# File 'lib/slk/services/configuration.rb', line 41 def []=(key, value) data[key] = value save_config end |
#emoji_dir ⇒ Object
33 34 35 |
# File 'lib/slk/services/configuration.rb', line 33 def emoji_dir data['emoji_dir'] end |
#primary_workspace ⇒ Object
15 16 17 |
# File 'lib/slk/services/configuration.rb', line 15 def primary_workspace data['primary_workspace'] end |
#primary_workspace=(name) ⇒ Object
19 20 21 22 |
# File 'lib/slk/services/configuration.rb', line 19 def primary_workspace=(name) data['primary_workspace'] = name save_config end |
#ssh_key ⇒ Object
24 25 26 |
# File 'lib/slk/services/configuration.rb', line 24 def ssh_key data['ssh_key'] end |
#ssh_key=(path) ⇒ Object
28 29 30 31 |
# File 'lib/slk/services/configuration.rb', line 28 def ssh_key=(path) data['ssh_key'] = path save_config end |
#to_h ⇒ Object
46 47 48 |
# File 'lib/slk/services/configuration.rb', line 46 def to_h data.dup end |