Class: Adva::Generators::App

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

Constant Summary collapse

DEFAULT_OPTIONS =
{
  :core_dir  => 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 = {}) ⇒ 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 = {})
  @options = options.reverse_merge!(DEFAULT_OPTIONS)
  @name    = name || File.basename( File.expand_path('../', core_dir) )
  raise ArgumentError, "#{core_dir.inspect} is not a directory" unless File.directory?(core_dir)
end

Instance Method Details

#invoke(&block) ⇒ Object



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

def invoke(&block)
  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