class Exhaust::Runner

Attributes

configuration[R]

Public Class Methods

new(configuration=Exhaust::Configuration.new) click to toggle source
# File lib/exhaust/runner.rb, line 5
def initialize(configuration=Exhaust::Configuration.new)
  @configuration = configuration
end

Public Instance Methods

ember_host() click to toggle source
# File lib/exhaust/runner.rb, line 26
def ember_host
  "http://localhost:#{ember_port}"
end
ember_path() click to toggle source
# File lib/exhaust/runner.rb, line 38
def ember_path
  configuration.ember_path
end
ember_port() click to toggle source
# File lib/exhaust/runner.rb, line 30
def ember_port
  configuration.ember_port.to_s
end
ember_server() click to toggle source
# File lib/exhaust/runner.rb, line 46
def ember_server
  @ember_server ||= begin
    Dir.chdir(ember_path) do
      @ember_server = IO.popen([{"API_HOST" => "http://localhost:#{rails_port}"}, "ember", "server", "--port", ember_port, "--live-reload", "false", :err => [:child, :out]])
    end
  end
end
rails_path() click to toggle source
# File lib/exhaust/runner.rb, line 42
def rails_path
  configuration.rails_path
end
rails_port() click to toggle source
# File lib/exhaust/runner.rb, line 34
def rails_port
  configuration.rails_port.to_s
end
rails_server() click to toggle source
# File lib/exhaust/runner.rb, line 54
def rails_server
  @rails_server ||= begin
    Dir.chdir(rails_path) do
      @rails_server = IO.popen(['rails', 'server', '--port', rails_port, '--environment', 'test', :err => [:child, :out]])
    end
  end
end
run() click to toggle source
# File lib/exhaust/runner.rb, line 9
def run
  Timeout::timeout(30) do
    while running = ember_server.gets
      if running =~ /build successful/i
        break
      end
    end

    while running = rails_server.gets
      puts running
      if running =~ /info/i
        break
      end
    end
  end
end
shutdown!() click to toggle source
# File lib/exhaust/runner.rb, line 62
def shutdown!
  Process.kill(9, ember_server.pid, rails_server.pid)
end