add postgresql

This commit is contained in:
Artur Gurgul1 2025-08-06 16:50:03 +02:00
parent 953985a3ea
commit 2578cd7a6d
10 changed files with 164 additions and 2 deletions

20
lib/templates.rb Normal file
View file

@ -0,0 +1,20 @@
require 'erb'
module Templates
def render(name, locals = {})
# caller_module = Module.nesting.first.to_s.split('::').last&.downcase || 'common'
caller_file = caller_locations(1, 1)[0].absolute_path
inferred_dir = File.basename(caller_file).sub(/^install-/, '').sub(/\.rb$/, '')
puts "caller name: #{inferred_dir}"
template_path = File.join(__dir__, 'data', 'templates', inferred_dir, "#{name}.erb")
template = File.read(template_path)
erb = ERB.new(template)
# erb.result(binding)
context = Struct.new(*locals.keys).new(*locals.values)
erb.result(context.instance_eval { binding })
end
end