Module: JsonRigs::FixtureServerRunner

Defined in:
lib/json-rigs/server.rb

Constant Summary collapse

STARTING_PORT =
3000

Class Method Summary collapse

Class Method Details

.start(fixture_path) ⇒ Object



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/json-rigs/server.rb', line 193

def start(fixture_path)
  puts 'Starting fixture server...'

  port = choose_port()

  FixtureServer.set(:port, port)
  FixtureServer.set(:fixture_path, fixture_path)
  FixtureServer::load_fixtures
  JsonRigs::Fixtures::load_active_fixtures

  # Start listener on fixture path to reload fixtures if necessary.
  listener = Listen.to(fixture_path, only: /\.(json|rb)$/) { |modified, added, removed|
    on_fixture_change(modified, added, removed)
  }
  listener.start

  FixtureServer.run!
end