class ComposeEnv::Builder
Attributes
options[R]
Public Class Methods
new(options)
click to toggle source
# File lib/compose_env/builder.rb, line 5 def initialize(options) @options = options end
Public Instance Methods
build_compose_files()
click to toggle source
# File lib/compose_env/builder.rb, line 9 def build_compose_files parse_all do |current_env, raw_yaml| File.write(environment_file_name(current_env), raw_yaml) end end
Also aliased as: build_compose_files!
parse_all() { |*result| ... }
click to toggle source
# File lib/compose_env/builder.rb, line 16 def parse_all options.envs.map do |current_env| result = [current_env, parse_file(current_env)] yield(*result) if block_given? result end.to_h end
Private Instance Methods
basename()
click to toggle source
# File lib/compose_env/builder.rb, line 31 def basename @basename ||= File.basename(options.file).split('.').first end
dirname()
click to toggle source
# File lib/compose_env/builder.rb, line 35 def dirname @dirname ||= File.dirname(options.file) end
environment_file_name(current_env)
click to toggle source
# File lib/compose_env/builder.rb, line 27 def environment_file_name(current_env) Pathname.new(dirname).join("#{basename}.#{current_env}.yml").to_s end
erb_template()
click to toggle source
# File lib/compose_env/builder.rb, line 45 def erb_template @erb_template ||= ::ERB.new(File.read(options.file)) end
parse_file(current_env)
click to toggle source
# File lib/compose_env/builder.rb, line 39 def parse_file(current_env) env_context = Context.new(options, current_env).get_binding raw_yaml = erb_template.result(env_context) ::YAML.load(raw_yaml).to_yaml end