Sha256: 04f78a956ea6b3fbe6051ab9fe37746f16d47ddde81a2988c893450dbab40130
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
require 'erb' module S3Repo ## # Templates object, represents the generated templates for repo navigation class Templates < Base def update! templates.each do |filename, template| rendered = template.result(template_binding.load_binding) client.upload(filename, rendered) end end private def metadata @options[:metadata] ||= Metadata.new(@options) end def template_binding @template_binding ||= TemplateBinding.new( @options[:template_params].merge(packages: metadata.packages) ) end def templates @templates ||= template_files.map do |x| [File.basename(x), ERB.new(File.read(x), trim_mode: '-')] end end def template_files @template_files ||= Dir.glob("#{template_path}/*") end def template_path @template_path ||= @options[:template_dir] || raise('No template dir') end end ## # Binding object to sandbox template vars class TemplateBinding def initialize(params = {}) params.each { |key, val| instance_variable_set("@#{key}", val) } end def load_binding binding end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
s3repo-3.0.1 | lib/s3repo/templates.rb |