-
-
Save 0x1eef/1e573560cad7dd98cb355df44f0a2c42 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
read_options = ->(env:) do | |
path = File.join(Dir.getwd, "srv", env, "options.yml") | |
Ryo.from(YAML.load_file(path)) | |
end | |
task "config:build", :env do |task, args| | |
options = read_options.call(**args) | |
b = binding.tap { |b| Ryo.each(options) { |k,v| b.local_variable_set(k, v) } } | |
glob = File.join(Dir.getwd, "srv", args[:env], "etc", "*.conf.erb") | |
etc_files = Dir.glob(glob) | |
etc_files.each do |file| | |
File.binwrite File.join(File.dirname(file), File.basename(file, ".erb")), | |
ERB.new(File.binread(file), trim_mode: "-").result(b) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment