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



49
50
51
52
# File 'lib/spring/commands/rails.rb', line 49

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

#command_nameObject



58
59
60
# File 'lib/spring/commands/rails.rb', line 58

def command_name
  "runner"
end

#env(args) ⇒ Object



54
55
56
# File 'lib/spring/commands/rails.rb', line 54

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

#extract_environment(args) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/spring/commands/rails.rb', line 62

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