Class: Wellcar::Templates::Base
- Inherits:
-
Object
- Object
- Wellcar::Templates::Base
show all
- Includes:
- ERB::Util
- Defined in:
- lib/wellcar/templates/base.rb
Direct Known Subclasses
BuildProductionImage, DatabaseYaml, DockerCompose, DockerEntrypoint, DockerStack, Dockerfile, DockerfileInit, Dockerignore, EnvDevelopmentDatabase, EnvDevelopmentWeb, EnvProductionDatabase, EnvProductionWeb, ReverseProxyConf
Instance Method Summary
collapse
Constructor Details
#initialize(file_path) ⇒ Base
Returns a new instance of Base.
6
7
8
9
|
# File 'lib/wellcar/templates/base.rb', line 6
def initialize(file_path)
@file_path = file_path
@before_write = []
end
|
Instance Method Details
#exist? ⇒ Boolean
17
18
19
|
# File 'lib/wellcar/templates/base.rb', line 17
def exist?
File.exist? file_path
end
|
#render ⇒ Object
21
22
23
|
# File 'lib/wellcar/templates/base.rb', line 21
def render
ERB.new(template).result(binding)
end
|
#write ⇒ Object
11
12
13
14
15
|
# File 'lib/wellcar/templates/base.rb', line 11
def write
@before_write.each {|procedure| procedure.call }
File.open(file_path, 'w') {|file| file.write render }
end
|