Class: Kuby::RailsCommands

Inherits:
Object
  • Object
show all
Defined in:
lib/kuby/rails_commands.rb

Constant Summary collapse

PREFIX =
%w(bundle exec).freeze
SERVER_ARG_ALIASES =
[['--binding', '-b'], ['-p', '--port']].freeze

Class Method Summary collapse

Class Method Details

.run(args = ARGV) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/kuby/rails_commands.rb', line 42

def run(args = ARGV)
  command = args[0]

  if command == 'rails'
    subcommand = args[1]
    arglist = nil

    case subcommand
      when 'server', 's'
        arglist = Args.new([*PREFIX, *args], SERVER_ARG_ALIASES)
        arglist['-b'] ||= '0.0.0.0'
        arglist['-p'] ||= '3000'
    end
  end

  setup

  arglist ||= Args.new([*PREFIX, *args])
  tasks = Kuby::Tasks.new(environment)
  tasks.remote_exec(arglist.args)
end