module Mirage

Public Class Methods

running?(options_or_url = {:port => 7001}) click to toggle source

Detect if Mirage is running on a URL or a local port

Example Usage:

Mirage.running? -> boolean indicating whether Mirage is running on *locally* on port 7001
Mirage.running? :port => port -> boolean indicating whether Mirage is running on *locally* on the given port
Mirage.running? url -> boolean indicating whether Mirage is running on the given URL
# File lib/mirage/client/runner.rb, line 44
def running? options_or_url = {:port => 7001}
  url = options_or_url.kind_of?(Hash) ? "http://localhost:#{options_or_url[:port]}" : options_or_url
  HTTParty.get(url) and return true
rescue Errno::ECONNREFUSED
  return false
end
start(options={}) click to toggle source

Start Mirage locally on a given port Example Usage:

Mirage.start :port => 9001 -> Configured MirageClient ready to use.
# File lib/mirage/client/runner.rb, line 13
def start options={}
  options={:port => 7001}.merge(options)
  Runner.new.invoke(:start, [], options)
  Mirage::Client.new(options)
end
stop(options={:port => []}) click to toggle source

Stop locally running instance(s) of Mirage

Example Usage:

Mirage.stop -> Will stop mirage if there is only instance running. Can be running on any port.
Mirage.stop :port => port -> stop mirage on a given port
Mirage.stop :port => [port1, port2...] -> stops multiple running instances of Mirage
# File lib/mirage/client/runner.rb, line 25
def stop options={:port => []}
  options = {:port => :all} if options == :all

  if options[:port]
    options[:port] = [options[:port]] unless options[:port].is_a?(Array)
  end

  Runner.new.invoke(:stop, [], options)
rescue ClientError
  raise ClientError.new("Mirage is running multiple ports, please specify the port(s) see api/tests for details")
end