Class: Wakame::Template2::Base
- Inherits:
-
Object
- Object
- Wakame::Template2::Base
show all
- Defined in:
- lib/wakame/template.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
85
86
|
# File 'lib/wakame/template.rb', line 85
def initialize()
end
|
Instance Attribute Details
#tmp_output_basedir ⇒ Object
Returns the value of attribute tmp_output_basedir.
83
84
85
|
# File 'lib/wakame/template.rb', line 83
def tmp_output_basedir
@tmp_output_basedir
end
|
Instance Method Details
#load(path) ⇒ Object
106
107
108
109
110
|
# File 'lib/wakame/template.rb', line 106
def load(path)
path = path.sub(/^\//, '')
return File.readlines(File.expand_path(path, Wakame.config.config_template_root), "r").join('')
end
|
#post_render ⇒ Object
97
98
99
|
# File 'lib/wakame/template.rb', line 97
def post_render
end
|
#pre_render ⇒ Object
89
90
91
92
|
# File 'lib/wakame/template.rb', line 89
def pre_render
@tmp_output_basedir = File.expand_path(Util.gen_id, Wakame.config.config_tmp_root)
FileUtils.mkdir_p @tmp_output_basedir
end
|
#render(service_instance) ⇒ Object
94
95
|
# File 'lib/wakame/template.rb', line 94
def render(service_instance)
end
|
#save(path, buf) ⇒ Object
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/wakame/template.rb', line 112
def save(path, buf)
path = path.sub(/^\//, '')
destpath = File.expand_path(path, @tmp_output_basedir)
FileUtils.mkpath(File.dirname(destpath)) unless File.directory?(File.dirname(destpath))
File.open(destpath, "w", 0644) {|f|
f.write(buf)
}
end
|
#sync_src ⇒ Object
Returns source path which to be synced to the agent host
102
103
|
# File 'lib/wakame/template.rb', line 102
def sync_src
end
|
#update(path, &blk) ⇒ Object
123
124
125
126
127
|
# File 'lib/wakame/template.rb', line 123
def update(path, &blk)
buf = load(path)
buf = yield buf if block_given?
save(path, buf)
end
|