Class: Uc::Unicorn::Config

Inherits:
Object
  • Object
show all
Includes:
Logger
Defined in:
lib/uc/unicorn/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logger

#event_queue, event_stream, #event_stream, logger, #logger, stderr, #stderr

Constructor Details

#initialize(config_hash, paths) ⇒ Config

Returns a new instance of Config.



14
15
16
17
# File 'lib/uc/unicorn/config.rb', line 14

def initialize(config_hash, paths)
  @config = config_hash
  @paths = paths
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



12
13
14
# File 'lib/uc/unicorn/config.rb', line 12

def config
  @config
end

#pathsObject (readonly)

Returns the value of attribute paths.



12
13
14
# File 'lib/uc/unicorn/config.rb', line 12

def paths
  @paths
end

Instance Method Details

#generate_config_fileObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/uc/unicorn/config.rb', line 24

def generate_config_file
  erb = ERB.new(File.read(paths.unicorn_template))
  binding = Kernel.binding
  File.open(paths.unicorn_config, 'w') do |f|
    f.write erb.result(binding)
  end 
  return true
rescue => e
  logger.debug e.message
  raise ::Uc::Error, "unable to generate unicorn config"
end

#generate_onceObject



36
37
38
39
40
# File 'lib/uc/unicorn/config.rb', line 36

def generate_once
  return if @config_generated
  generate_config_file
  @config_generated = true
end

#pathObject



19
20
21
22
# File 'lib/uc/unicorn/config.rb', line 19

def path
  generate_once
  paths.unicorn_config
end