Class: Merb::Generators::AppGenerator

Inherits:
NamedGenerator show all
Defined in:
lib/merb-gen/app_generator.rb

Instance Method Summary collapse

Methods inherited from NamedGenerator

#class_name, #file_name, #symbol_name, #test_class_name

Methods inherited from Generator

#go_up, source_root, #with_modules

Methods included from ColorfulMessages

#error, #success, #warning

Constructor Details

#initialize(*args) ⇒ AppGenerator

Returns a new instance of AppGenerator.



6
7
8
9
# File 'lib/merb-gen/app_generator.rb', line 6

def initialize(*args)
  Merb.disable(:initfile)
  super
end

Instance Method Details

#gems_for_orm(orm) ⇒ Object

ORM gem dependencies

Adds ORM plugin dependency ‘merb_#orm’ if we use any ORM.

Params

orm<Symbol>

ORM to use

Returns

String

Gem dependencies



28
29
30
# File 'lib/merb-gen/app_generator.rb', line 28

def gems_for_orm(orm)
  orm.to_sym == :none ? '' : %Q{gem "merb_#{orm}"}
end

#gems_for_template_engine(template_engine) ⇒ Object

Template enging gem dependencies

When using something else than erb we add merb plugin dependency for the template engine.

Params

template_engine<Symbol>

Template engine to use

Returns

String

Gem dependencies



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/merb-gen/app_generator.rb', line 42

def gems_for_template_engine(template_engine)
  gems = ''
  if template_engine != :erb
    if template_engine.in?(:haml, :builder)
      template_engine_plugin = "merb-#{template_engine}"
    else
      template_engine_plugin = "merb_#{template_engine}"
    end
    gems = %Q{gem "#{template_engine_plugin}"}
  end
  gems
end

#gems_for_testing_framework(testing_framework) ⇒ Object

Testing framework gem dependencies

If we use any other test framework than RSpec we must add dependency to the Gemfile. Merb depends on the RSpec so it’s default dependency.

Params

test_framework<Symbol>

Testing framework to use

Returns

String

Gem dependencies



65
66
67
# File 'lib/merb-gen/app_generator.rb', line 65

def gems_for_testing_framework(testing_framework)
  testing_framework == :rspec ? '' : %Q{gem "#{testing_framework}", :group => :test}  
end

#merb_gems_versionObject

Helper to get Merb version

Returns

String

Merb version



15
16
17
# File 'lib/merb-gen/app_generator.rb', line 15

def merb_gems_version
  Merb::VERSION
end