Class: Ing::Commands::Generate

Inherits:
Object
  • Object
show all
Includes:
Boot, Ing::CommonOptions
Defined in:
lib/ing/commands/generate.rb

Overview

This is the boot command invoked from ‘ing generate …`

Constant Summary collapse

DEFAULTS =
{
   namespace: 'object',
   ing_file:  'ing.rb',
   gen_root:  ENV.fetch('ING_GENERATOR_ROOT', '~/.ing/generators')
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Ing::CommonOptions

#debug, #debug?, included, #ing_file, #namespace, #require_ing_file, #require_libs, #requires

Methods included from Boot

#after, #call, #configure_command

Constructor Details

#initialize(options) ⇒ Generate

Returns a new instance of Generate.



30
31
32
# File 'lib/ing/commands/generate.rb', line 30

def initialize(options)
  self.options = options
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



29
30
31
# File 'lib/ing/commands/generate.rb', line 29

def options
  @options
end

Class Method Details

.specify_options(parser) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/ing/commands/generate.rb', line 14

def self.specify_options(parser)
  parser.text "Run a generator task"
  parser.opt :gen_root, "Generators root directory", 
             :type => :string, :short => 'r', 
             :default => DEFAULTS[:gen_root]
  parser.stop_on_unknown
end

Instance Method Details

#before(*args) ⇒ Object

Require libs and ing_file, then locate and require the generator ruby file identified by the first arg, before dispatching to it.



37
38
39
40
41
# File 'lib/ing/commands/generate.rb', line 37

def before(*args)
  require_libs
  require_ing_file      
  require_generator args.first
end

#generator_rootObject



25
26
27
# File 'lib/ing/commands/generate.rb', line 25

def generator_root
  @generator_root ||= File.expand_path(options[:gen_root])
end