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
-
.running?(options_or_url = {:port => 7001}) ⇒ Boolean
Detect if Mirage is running on a URL or a local port.
-
.start(options = {}) ⇒ Object
Start Mirage locally on a given port Example Usage:.
-
.stop(options = {:port => []}) ⇒ Object
Stop locally running instance(s) of Mirage.
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
44 45 46 47 48 49 |
# File 'lib/mirage/client/runner.rb', line 44 def running? = {:port => 7001} url = .kind_of?(Hash) ? "http://localhost:#{[:port]}" : 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 ={} ={:port => 7001}.merge() Runner.new.invoke(:start, [], ) Mirage::Client.new() 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 ={:port => []} = {:port => :all} if == :all if [:port] [:port] = [[:port]] unless [:port].is_a?(Array) end Runner.new.invoke(:stop, [], ) rescue ClientError raise ClientError.new("Mirage is running multiple ports, please specify the port(s) see api/tests for details") end |