Module: Mirage

Defined in:
lib/mirage/client/error.rb,
lib/mirage/wait_methods.rb,
lib/mirage/client/client.rb,
lib/mirage/client/runner.rb,
lib/mirage/client/request.rb,
lib/mirage/client/requests.rb,
lib/mirage/client/template.rb,
lib/mirage/client/templates.rb,
lib/mirage/client/cli_bridge.rb,
lib/mirage/client/template/model.rb,
lib/mirage/client/helpers/method_builder.rb,
lib/mirage/client/template/configuration.rb,
lib/mirage/client/template/model/common_methods.rb,
lib/mirage/client/template/model/instance_methods.rb

Defined Under Namespace

Modules: CLIBridge, Helpers, WaitMethods Classes: Client, ClientError, InternalServerException, MirageError, Request, Requests, Runner, Template, TemplateNotFound, Templates, TimeoutException

Class Method Summary collapse

Class Method Details

.running?(options_or_url = {:port => 7001}) ⇒ Boolean

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

Returns:

  • (Boolean)


44
45
46
47
48
49
# 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 = {}) ⇒ Object

Start Mirage locally on a given port Example Usage:

Mirage.start :port => 9001 -> Configured MirageClient ready to use.


13
14
15
16
17
# 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 => []}) ⇒ Object

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


25
26
27
28
29
30
31
32
33
34
35
# 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