Class: Alonzo::Commands::Gen

Inherits:
Object
  • Object
show all
Defined in:
lib/alonzo/commands/gen.rb

Constant Summary collapse

DEFAULTS =
{
   project_root: Dir.pwd,
  template_type: :rb_class
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cmd_opts_and_args = {}, options = {}) ⇒ Gen

Returns a new instance of Gen.



20
21
22
23
24
25
26
# File 'lib/alonzo/commands/gen.rb', line 20

def initialize(cmd_opts_and_args = {}, options = {})
  cmd_opts_and_args.each do |key, value|
    self.send("#{key}=", value)
  end

  self.output = options.delete(:output) || STDOUT
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



9
10
11
# File 'lib/alonzo/commands/gen.rb', line 9

def args
  @args
end

#globalObject

Returns the value of attribute global.



9
10
11
# File 'lib/alonzo/commands/gen.rb', line 9

def global
  @global
end

#optionsObject

Returns the value of attribute options.



9
10
11
# File 'lib/alonzo/commands/gen.rb', line 9

def options
  @options
end

#outputObject

Returns the value of attribute output.



9
10
11
# File 'lib/alonzo/commands/gen.rb', line 9

def output
  @output
end

Class Method Details

.defaultsObject



16
17
18
# File 'lib/alonzo/commands/gen.rb', line 16

def self.defaults
  DEFAULTS
end

.run(cmd_opts_and_args, options = {}) ⇒ Object



11
12
13
14
# File 'lib/alonzo/commands/gen.rb', line 11

def self.run(cmd_opts_and_args, options = {})
  gen = new(cmd_opts_and_args, options)
  gen.run
end

Instance Method Details

#runObject



28
29
30
# File 'lib/alonzo/commands/gen.rb', line 28

def run
  Generator.generate(args, { output: output, root: options[:root], type: options[:type] })
end