Class: Jenkins::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/jenkins-rails/configuration.rb

Instance Method Summary collapse

Constructor Details

#initialize(config_file) ⇒ Configuration

Returns a new instance of Configuration.



3
4
5
6
# File 'lib/jenkins-rails/configuration.rb', line 3

def initialize(config_file)
  raise "Config file #{config_file} is missing!" if !File.exist? config_file
  @config_file = config_file
end

Instance Method Details

#configObject



35
36
37
# File 'lib/jenkins-rails/configuration.rb', line 35

def config
  @config ||= ActiveSupport::HashWithIndifferentAccess.new(YAML.load(ERB.new(File.read(@config_file)).result))
end

#hostObject



16
17
18
# File 'lib/jenkins-rails/configuration.rb', line 16

def host
  config[:host]
end

#jobsObject



24
25
26
# File 'lib/jenkins-rails/configuration.rb', line 24

def jobs
  config[:jobs] ||= []
end

#paramsObject



28
29
30
31
32
33
# File 'lib/jenkins-rails/configuration.rb', line 28

def params
  jobs.each_index do |i|
    jobs[i][:shell_command] = File.read(script_file(jobs[i][:shell_script]))
  end
  jobs
end

#passwordObject



12
13
14
# File 'lib/jenkins-rails/configuration.rb', line 12

def password
  config[:password]
end

#portObject



20
21
22
# File 'lib/jenkins-rails/configuration.rb', line 20

def port
  config[:port]
end

#usernameObject



8
9
10
# File 'lib/jenkins-rails/configuration.rb', line 8

def username
  config[:username]
end