Class: Jira::Auto::Tool::Config

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/jira/auto/tool/config.rb,
lib/jira/auto/tool/config/options.rb

Defined Under Namespace

Classes: Options

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tool) ⇒ Config



13
14
15
# File 'lib/jira/auto/tool/config.rb', line 13

def initialize(tool)
  @tool = tool
end

Instance Attribute Details

#toolObject (readonly)

Returns the value of attribute tool.



11
12
13
# File 'lib/jira/auto/tool/config.rb', line 11

def tool
  @tool
end

Instance Method Details

#<=>(other) ⇒ Object



30
31
32
# File 'lib/jira/auto/tool/config.rb', line 30

def <=>(other)
  value_store <=> (other.is_a?(Config) ? other.value_store : other)
end

#[](key) ⇒ Object



22
23
24
# File 'lib/jira/auto/tool/config.rb', line 22

def [](key)
  value_store[sanitize_key(key)]
end

#[]=(key, value) ⇒ Object



17
18
19
20
# File 'lib/jira/auto/tool/config.rb', line 17

def []=(key, value)
  value_store[sanitize_key(key)] = value
  save
end

#dirObject



38
39
40
41
42
# File 'lib/jira/auto/tool/config.rb', line 38

def dir
  config_dir = File.join(Dir.home, ".config/#{tool_name}")
  FileUtils.makedirs(config_dir)
  config_dir
end

#key?(key) ⇒ Boolean



26
27
28
# File 'lib/jira/auto/tool/config.rb', line 26

def key?(key)
  value_store.key?(sanitize_key(key))
end

#pathObject



34
35
36
# File 'lib/jira/auto/tool/config.rb', line 34

def path
  File.join(dir, "#{tool_name}.config.yml")
end

#tool_nameObject



44
45
46
# File 'lib/jira/auto/tool/config.rb', line 44

def tool_name
  "jira-auto-tool"
end