Class: Adva::Generators::App

Inherits:
Object
  • Object
show all
Defined in:
lib/adva/generators/app.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  :source    => File.expand_path('../../../../..', __FILE__),
  :target    => File.expand_path('.'),
  :template  => File.expand_path('../templates/app/app_template.rb', __FILE__),
  :engines   => [:all],
  :resources => false,
  :migrate   => false,
  :bundle    => false,
  :force     => false
}

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}, &block) ⇒ App

Returns a new instance of App.

Raises:

  • (ArgumentError)


24
25
26
27
28
# File 'lib/adva/generators/app.rb', line 24

def initialize(name, options = {}, &block)
  @options = options.reverse_merge!(DEFAULT_OPTIONS)
  @name    = name || File.basename(source)
  raise ArgumentError, "#{source.inspect} is not a directory" unless File.directory?(source)
end

Instance Method Details

#invokeObject



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/adva/generators/app.rb', line 30

def invoke
  if force? || build?
    build
    generate_resources  if generate_resources?
    bundle              if bundle?
    load_environment    if block_given? || migrate?
    exec(&block)        if block_given?
    install
    migrate             if migrate?
  else
    load_environment
  end
end