Sha256: 625c7e1c5944b56ecb8d4230f1c1d410b4ab42ba0adeeb41d38b770784a49c11
Contents?: true
Size: 1.56 KB
Versions: 1
Compression:
Stored size: 1.56 KB
Contents
module Merb module Generators extend Templater::Manifold desc <<-DESC Generate components for your application or entirely new applications. DESC class Generator < Templater::Generator def initialize(*args) super options[:orm] ||= Merb.orm_generator_scope options[:testing_framework] ||= Merb.test_framework_generator_scope options[:orm] = :none if options[:orm] == :merb_default # FIXME: temporary until this is fixed in merb-core end # Inside a template, wraps a block of code properly in modules, keeping the indentation correct # TODO: spec me def with_modules(modules, options={}, &block) indent = options[:indent] || 0 text = capture(&block) modules.each_with_index do |mod, i| concat((" " * (indent + i)) + "module #{mod}\n", block.binding) end text = text.to_a.map{ |line| (" " * modules.size) + line }.join concat(text, block.binding) modules.reverse.each_with_index do |mod, i| concat((" " * (indent + modules.size - i - 1)) + "end # #{mod}\n", block.binding) end end def self.source_root File.join(File.dirname(__FILE__), '..', '..', 'templates') end end class ApplicationGenerator < Generator def self.source_root File.join(super, 'application') end end class ComponentGenerator < Generator def self.source_root File.join(super, 'component') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
thorero-gen-0.9.4 | lib/merb-gen/generator.rb |