Class: Wakame::Template2::ApacheTemplate

Inherits:
Base
  • Object
show all
Defined in:
lib/wakame/template.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#tmp_output_basedir

Instance Method Summary collapse

Methods inherited from Base

#load, #post_render, #pre_render, #save, #update

Constructor Details

#initialize(suffix) ⇒ ApacheTemplate

Returns a new instance of ApacheTemplate.



154
155
156
157
# File 'lib/wakame/template.rb', line 154

def initialize(suffix)
  super()
  @suffix = suffix
end

Instance Attribute Details

#suffixObject

Returns the value of attribute suffix.



152
153
154
# File 'lib/wakame/template.rb', line 152

def suffix
  @suffix
end

Instance Method Details

#render(service_instance) ⇒ Object



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/wakame/template.rb', line 159

def render(service_instance)
#p service_instance.service_cluster.virtual_hosts
  require 'erb'
  
  FileUtils.mkpath File.expand_path('apache2', tmp_output_basedir)

  ["envvars-#{@suffix}", "apache2.conf"].each { |fname|
    FileUtils.cp_r(File.join(Wakame.config.config_template_root, "apache2/#{fname}"),
                   File.join(tmp_output_basedir, "apache2/#{fname}"),
                   {:preserve=>true})
  }

  ["apache2/system-#{@suffix}.conf", "apache2/sites-#{@suffix}.conf"].each { |path|
    update(path) { |buf|
      ERB.new(buf, nil, '-').result service_instance.export_binding
    }
  }
end

#sync_srcObject



179
180
181
# File 'lib/wakame/template.rb', line 179

def sync_src
  File.join(@tmp_output_basedir, 'apache2')
end