Sha256: 4a0b5cde6719252f189b8d7fddc8bd7252e9ab8d63f18b29942e1d5a8a62f45d
Contents?: true
Size: 1.13 KB
Versions: 4
Compression:
Stored size: 1.13 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), nil, '-')] 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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
s3repo-2.0.3 | lib/s3repo/templates.rb |
s3repo-2.0.2 | lib/s3repo/templates.rb |
s3repo-2.0.1 | lib/s3repo/templates.rb |
s3repo-2.0.0 | lib/s3repo/templates.rb |