Sha256: df69e2f4171f4f8fd3cd450e3aa0aa737d65f68b1b7b2a03485e2d93b15e054a
Contents?: true
Size: 1.85 KB
Versions: 14
Compression:
Stored size: 1.85 KB
Contents
class Lono::Template::Dsl class Builder include Lono::Template::Util include Lono::Template::Context::Loader include Fn include Helper # built-in helpers include Lono::Template::Evaluate include Syntax extend Memoist def initialize(path, blueprint, options={}) @path, @blueprint, @options = path, blueprint, options @template = @path.sub("#{Lono.config.templates_path}/",'').sub(/\.rb$/,'') @cfn = {} end def build load_context evaluate_template_path(@path) # modifies @cfn build_template write_output template end # Useful for lono seed to get the template in memory def template load_context evaluate_template_path(@path) # modifies @cfn camelize(@cfn) end memoize :template def build_template @results = YAML.dump(camelize(@cfn)) end def write_output output_path = "#{Lono.config.output_path}/#{@blueprint}/templates" FileUtils.mkdir_p(output_path) path = "#{output_path}/#{@template}.yml" ensure_parent_dir(path) IO.write(path, @results) validate_yaml(path) unless @options[:quiet] pretty_path = path.sub("#{Lono.root}/",'') puts " #{pretty_path}" end end def camelize(data) CfnCamelizer.transform(data) end # Not using Lono::Template::Context because that works differently. # That is used to load a context object that is passed to RenderMePretty's context. # So that we can load context for params files and erb templates. # # In this case builder is actually the dsl context. # We want to load variables and helpers into this builder context directly. # This loads additional context. It looks very similar to Lono::Template::Context def load_context load_variables load_project_helpers end end end
Version data entries
14 entries across 14 versions & 1 rubygems