Class: Andrake::Commands

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run!(argv) ⇒ Object



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

def run!(argv)
  self.new.run(argv)
end

Instance Method Details

#aliasesObject



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

def aliases
  {"g" => "generate", "d" => "destroy" }
end

#parse(argv = nil) ⇒ Object



2
3
4
5
6
7
# File 'lib/andrake/commands.rb', line 2

def parse(argv = nil)
  return {:command => "new"} if argv.nil?
  command = argv.shift
  command = aliases[command] || command
  {:command => command}
end

#run(argv) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/andrake/commands.rb', line 13

def run(argv)
  command = parse(argv)
  case command[:command]
  when 'generate'
    puts 'generate'
  when 'destroy'
    puts 'destroy'
  when 'new'
    Andrake::Generator::Rakefile.run!
  else
    puts "hogehoge"
  end
end