Class: Pact::MockService::AppRegistration
- Inherits:
-
Object
- Object
- Pact::MockService::AppRegistration
- Includes:
- Logging
- Defined in:
- lib/pact/mock_service/app_manager.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(opts) ⇒ AppRegistration
constructor
A new instance of AppRegistration.
- #is_a_mock_service? ⇒ Boolean
- #kill ⇒ Object
- #not_spawned? ⇒ Boolean
- #spawn ⇒ Object
- #spawned? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(opts) ⇒ AppRegistration
Returns a new instance of AppRegistration.
120 121 122 123 124 125 126 |
# File 'lib/pact/mock_service/app_manager.rb', line 120 def initialize(opts) @max_wait = 10 @port = opts[:port] @host = opts[:host] @app = opts[:app] @spawned = false end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
118 119 120 |
# File 'lib/pact/mock_service/app_manager.rb', line 118 def app @app end |
#host ⇒ Object
Returns the value of attribute host.
118 119 120 |
# File 'lib/pact/mock_service/app_manager.rb', line 118 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
118 119 120 |
# File 'lib/pact/mock_service/app_manager.rb', line 118 def port @port end |
Instance Method Details
#is_a_mock_service? ⇒ Boolean
141 142 143 |
# File 'lib/pact/mock_service/app_manager.rb', line 141 def is_a_mock_service? app.is_a?(Pact::MockService::App) end |
#kill ⇒ Object
128 129 130 131 |
# File 'lib/pact/mock_service/app_manager.rb', line 128 def kill logger.debug "Supposed to be stopping" @spawned = false end |
#not_spawned? ⇒ Boolean
133 134 135 |
# File 'lib/pact/mock_service/app_manager.rb', line 133 def not_spawned? !spawned? end |
#spawn ⇒ Object
149 150 151 152 153 154 155 |
# File 'lib/pact/mock_service/app_manager.rb', line 149 def spawn logger.info "Starting app #{self}..." @server = Pact::Server.new(app, host, port).boot @port = @server.port @spawned = true logger.info "Started on port #{port}" end |
#spawned? ⇒ Boolean
137 138 139 |
# File 'lib/pact/mock_service/app_manager.rb', line 137 def spawned? @spawned end |
#to_s ⇒ Object
145 146 147 |
# File 'lib/pact/mock_service/app_manager.rb', line 145 def to_s "#{app} on port #{port}" end |