Class: Eastrails::Commands::Add

Inherits:
Base
  • Object
show all
Defined in:
lib/eastrails/commands/add.rb

Constant Summary collapse

ALIASES =
{
  "tdd" => ["rspec", "cucumber"],
  "default" => ["tdd", "haml", "devise", "twitter_bootstrap"]
}

Instance Attribute Summary

Attributes inherited from Base

#parameter

Instance Method Summary collapse

Methods inherited from Base

#initialize, #run_in_shell

Methods inherited from Generator

#initialize

Constructor Details

This class inherits a constructor from Eastrails::Commands::Base

Instance Method Details

#executeObject



4
5
6
7
8
9
# File 'lib/eastrails/commands/add.rb', line 4

def execute
  components = expand_aliases(parameter.component.split(",")).map do |name|
    Eastrails::Components.class_for(name).new
  end
  components.map(&:add)
end

#expand_aliases(names) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/eastrails/commands/add.rb', line 16

def expand_aliases(names)
  index = 0
  while index < names.length
    name = names[index]
    if ALIASES[name]
      names.delete_at index
      names.insert index, *ALIASES[name]
    else
      index += 1
    end
  end  
  names
end