Class: Rails::Engine::CommandsTasks

Inherits:
Object
  • Object
show all
Includes:
RakeProxy
Defined in:
lib/rails/engine/commands_tasks.rb

Overview

:nodoc:

Constant Summary collapse

HELP_MESSAGE =
<<-EOT
Usage: rails COMMAND [ARGS]

The common Rails commands available for engines are:
 generate    Generate new code (short-cut alias: "g")
 destroy     Undo code generated with "generate" (short-cut alias: "d")
 test        Run tests (short-cut alias: "t")

All commands can be run with -h for more information.

If you want to run any commands that need to be run in context
of the application, like `rails server` or `rails console`,
you should do it from application's directory (typically test/dummy).

In addition to those commands, there are:
EOT
COMMAND_WHITELIST =
%w(generate destroy version help test)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ CommandsTasks

Returns a new instance of CommandsTasks.



29
30
31
# File 'lib/rails/engine/commands_tasks.rb', line 29

def initialize(argv)
  @argv = argv
end

Instance Attribute Details

#argvObject (readonly)

Returns the value of attribute argv.



8
9
10
# File 'lib/rails/engine/commands_tasks.rb', line 8

def argv
  @argv
end

Instance Method Details

#destroyObject



47
48
49
# File 'lib/rails/engine/commands_tasks.rb', line 47

def destroy
  generate_or_destroy(:destroy)
end

#generateObject



43
44
45
# File 'lib/rails/engine/commands_tasks.rb', line 43

def generate
  generate_or_destroy(:generate)
end

#helpObject



60
61
62
63
# File 'lib/rails/engine/commands_tasks.rb', line 60

def help
  write_help_message
  write_commands(formatted_rake_tasks)
end

#run_command!(command) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/rails/engine/commands_tasks.rb', line 33

def run_command!(command)
  command = parse_command(command)

  if COMMAND_WHITELIST.include?(command)
    send(command)
  else
    run_rake_task(command)
  end
end

#testObject



51
52
53
# File 'lib/rails/engine/commands_tasks.rb', line 51

def test
  require_command!("test")
end

#versionObject



55
56
57
58
# File 'lib/rails/engine/commands_tasks.rb', line 55

def version
  argv.unshift '--version'
  require_command!("application")
end