Class: Spring::Client::Rails

Inherits:
Command
  • Object
show all
Defined in:
lib/spring/client/rails.rb

Constant Summary collapse

COMMANDS =
Set.new %w(console runner generate)
ALIASES =
{
  "c" => "console",
  "r" => "runner",
  "g" => "generate"
}

Instance Attribute Summary

Attributes inherited from Command

#args, #env

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

call, #initialize

Constructor Details

This class inherits a constructor from Spring::Client::Command

Class Method Details

.descriptionObject



14
15
16
# File 'lib/spring/client/rails.rb', line 14

def self.description
  "Run a rails command. The following sub commands will use spring: #{COMMANDS.to_a.join ', '}."
end

Instance Method Details

#callObject



18
19
20
21
22
23
24
25
26
# File 'lib/spring/client/rails.rb', line 18

def call
  command_name = ALIASES[args[1]] || args[1]

  if COMMANDS.include?(command_name)
    Run.call(["rails_#{command_name}", *args.drop(2)])
  else
    exec "bundle", "exec", *args
  end
end