Class: Spring::Commands::RailsRunner

Inherits:
Rails
  • Object
show all
Defined in:
lib/spring/commands/rails.rb

Instance Method Summary collapse

Methods inherited from Rails

#description

Instance Method Details

#callObject



37
38
39
40
# File 'lib/spring/commands/rails.rb', line 37

def call
  ARGV.replace extract_environment(ARGV).first
  super
end

#command_nameObject



46
47
48
# File 'lib/spring/commands/rails.rb', line 46

def command_name
  "runner"
end

#env(args) ⇒ Object



42
43
44
# File 'lib/spring/commands/rails.rb', line 42

def env(args)
  extract_environment(args).last
end

#extract_environment(args) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/spring/commands/rails.rb', line 50

def extract_environment(args)
  environment = nil

  args = args.select.with_index { |arg, i|
    case arg
    when "-e"
      false
    when /--environment=(\w+)/
      environment = $1
      false
    else
      if i > 0 && args[i - 1] == "-e"
        environment = arg
        false
      else
        true
      end
    end
  }

  [args, environment]
end