Parent

Included Modules

Merb::Generators::Generator

Public Class Methods

new(*args) click to toggle source
    # File lib/merb-gen/generator.rb, line 32
32:       def initialize(*args)
33:         Merb::Config.setup({
34:           :log_level        => :fatal,
35:           :log_delimiter    => " ~ ",
36:           :log_auto_flush   => false,
37:           :reload_templates => false,
38:           :reload_classes   => false
39:         })
40: 
41:         Merb::BootLoader::Logger.run
42:         Merb::BootLoader::BuildFramework.run
43:         Merb::BootLoader::Dependencies.run
44:         
45:         super
46:         options[:orm] ||= Merb.orm
47:         options[:testing_framework] ||= Merb.test_framework
48:         options[:template_engine] ||= Merb.template_engine
49:       end
source_root() click to toggle source
    # File lib/merb-gen/generator.rb, line 77
77:       def self.source_root
78:         File.join(File.dirname(__FILE__), '..', 'generators', 'templates')
79:       end

Public Instance Methods

go_up(num) click to toggle source

Returns a string of num times ’..’, useful for example in tests for namespaced generators to find the spec_helper higher up in the directory structure.

@param num number of directories up @return concatenated string

    # File lib/merb-gen/generator.rb, line 73
73:       def go_up(num)
74:         (["'..'"] * num).join(', ')
75:       end
with_modules(modules, options={}, &block) click to toggle source

Inside a template, wraps a block of code properly in modules, keeping the indentation correct

@param modules an array of modules to use for nesting @option indent number of integers to indent the modules by

    # File lib/merb-gen/generator.rb, line 55
55:       def with_modules(modules, options={}, &block)
56:         indent = options[:indent] || 0
57:         text = capture(&block)
58:         modules.each_with_index do |mod, i|
59:           concat(("  " * (indent + i)) + "module #{mod}\n", block.binding)
60:         end
61:         text = Array(text).map{ |line| ("  " * modules.size) + line }.join
62:         concat(text, block.binding)
63:         modules.reverse.each_with_index do |mod, i|
64:           concat(("  " * (indent + modules.size - i - 1)) + "end # #{mod}\n", block.binding)
65:         end
66:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.