Module: Jenkins::Config

Extended by:
Config
Included in:
Config
Defined in:
lib/jenkins/config.rb

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object



5
6
7
# File 'lib/jenkins/config.rb', line 5

def [](key)
  config[key]
end

#configObject



9
10
11
12
13
14
15
# File 'lib/jenkins/config.rb', line 9

def config
  @config ||= if File.exist?(config_file)
    JSON.parse(File.read(config_file))
  else
    {}
  end
end

#config_fileObject



23
24
25
# File 'lib/jenkins/config.rb', line 23

def config_file
  @config_file ||= "#{ENV['HOME']}/.jenkins/jenkinsrb-config.json"
end

#store!Object



17
18
19
20
21
# File 'lib/jenkins/config.rb', line 17

def store!
  @config ||= {}
  FileUtils.mkdir_p(File.dirname(config_file))
  File.open(config_file, "w") { |file| file << @config.to_json }
end