Class: LazyRails::CommandBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/lazy_rails.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app_name) ⇒ CommandBuilder

Returns a new instance of CommandBuilder.



37
38
39
40
# File 'lib/lazy_rails.rb', line 37

def initialize(app_name)
  @app_name = app_name
  @options = []
end

Instance Attribute Details

#app_nameObject

Returns the value of attribute app_name.



35
36
37
# File 'lib/lazy_rails.rb', line 35

def app_name
  @app_name
end

#optionsObject

Returns the value of attribute options.



35
36
37
# File 'lib/lazy_rails.rb', line 35

def options
  @options
end

Instance Method Details

#base_commandObject



56
57
58
# File 'lib/lazy_rails.rb', line 56

def base_command
  ["rails new #{app_name}"]
end

#buildObject



42
43
44
45
46
47
48
# File 'lib/lazy_rails.rb', line 42

def build
  if block_given?
    yield self
  end
  command = base_command + build_options
  command.compact.join(" ").strip
end

#build_optionsObject



50
51
52
53
54
# File 'lib/lazy_rails.rb', line 50

def build_options
  options.flatten.map do |option|
    NewCommand::OPTIONS[option]
  end
end