Sha256: ecd34ca43e5f6c51a2f6b18b19c4bc4e131a7bfbbaf320d1a0c7d64830b64051

Contents?: true

Size: 834 Bytes

Versions: 12

Compression:

Stored size: 834 Bytes

Contents

require "yaml"

class Lono::Template
  class Generator
    include Lono::Blueprint::Root

    def initialize(blueprint, options={})
      @blueprint, @options = blueprint, ActiveSupport::HashWithIndifferentAccess.new(options.dup)
      @template = @options[:template] || @blueprint
      Lono::ProjectChecker.check
      set_blueprint_root(@blueprint)
    end

    def run
      # Examples:
      #   Erb.new(b, options.dup).run
      #   Dsl.new(b, options.dup).run
      generator_class = "Lono::Template::#{template_type.classify}"
      generator_class = Object.const_get(generator_class)
      generator_class.new(@blueprint, @options).run
    end

    def template_type
      meta_config = "#{Lono.blueprint_root}/.meta/config.yml"
      data = YAML.load_file(meta_config)
      data["template_type"] || "dsl"
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
lono-6.1.11 lib/lono/template/generator.rb
lono-6.1.10 lib/lono/template/generator.rb
lono-6.1.9 lib/lono/template/generator.rb
lono-6.1.8 lib/lono/template/generator.rb
lono-6.1.7 lib/lono/template/generator.rb
lono-6.1.6 lib/lono/template/generator.rb
lono-6.1.5 lib/lono/template/generator.rb
lono-6.1.4 lib/lono/template/generator.rb
lono-6.1.3 lib/lono/template/generator.rb
lono-6.1.2 lib/lono/template/generator.rb
lono-6.1.1 lib/lono/template/generator.rb
lono-6.1.0 lib/lono/template/generator.rb