Class: Merb::Generators::Generator
- Inherits:
-
Templater::Generator
- Object
- Templater::Generator
- Merb::Generators::Generator
- Defined in:
- lib/merb-gen/generator.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Generator
constructor
A new instance of Generator.
-
#with_modules(modules, options = {}, &block) ⇒ Object
Inside a template, wraps a block of code properly in modules, keeping the indentation correct TODO: spec me.
Constructor Details
#initialize(*args) ⇒ Generator
Returns a new instance of Generator.
13 14 15 16 17 18 19 |
# File 'lib/merb-gen/generator.rb', line 13 def initialize(*args) super [:orm] ||= Merb.orm_generator_scope [:testing_framework] ||= Merb.test_framework_generator_scope [:orm] = :none if [:orm] == :merb_default # FIXME: temporary until this is fixed in merb-core end |
Class Method Details
.source_root ⇒ Object
36 37 38 |
# File 'lib/merb-gen/generator.rb', line 36 def self.source_root File.join(File.dirname(__FILE__), '..', '..', 'templates') end |
Instance Method Details
#with_modules(modules, options = {}, &block) ⇒ Object
Inside a template, wraps a block of code properly in modules, keeping the indentation correct TODO: spec me
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/merb-gen/generator.rb', line 23 def with_modules(modules, ={}, &block) indent = [: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 |