Class: Slk::Services::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/slk/services/configuration.rb

Overview

Manages CLI configuration stored in XDG config directory

Instance Attribute Summary collapse

Instance Method Summary collapse

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_warningObject

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_dirObject



33
34
35
# File 'lib/slk/services/configuration.rb', line 33

def emoji_dir
  data['emoji_dir']
end

#primary_workspaceObject



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_keyObject



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_hObject



46
47
48
# File 'lib/slk/services/configuration.rb', line 46

def to_h
  data.dup
end