Class: Rails::Engine::CommandsTasks
- Inherits:
-
Object
- Object
- Rails::Engine::CommandsTasks
- 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
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
Instance Method Summary collapse
- #destroy ⇒ Object
- #generate ⇒ Object
- #help ⇒ Object
-
#initialize(argv) ⇒ CommandsTasks
constructor
A new instance of CommandsTasks.
- #run_command!(command) ⇒ Object
- #test ⇒ Object
- #version ⇒ Object
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
#argv ⇒ Object (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
#destroy ⇒ Object
47 48 49 |
# File 'lib/rails/engine/commands_tasks.rb', line 47 def destroy generate_or_destroy(:destroy) end |
#generate ⇒ Object
43 44 45 |
# File 'lib/rails/engine/commands_tasks.rb', line 43 def generate generate_or_destroy(:generate) end |
#help ⇒ Object
60 61 62 63 |
# File 'lib/rails/engine/commands_tasks.rb', line 60 def help 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 |
#test ⇒ Object
51 52 53 |
# File 'lib/rails/engine/commands_tasks.rb', line 51 def test require_command!("test") end |
#version ⇒ Object
55 56 57 58 |
# File 'lib/rails/engine/commands_tasks.rb', line 55 def version argv.unshift '--version' require_command!("application") end |