Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a REPL for testing #28

Closed
faultyserver opened this issue Sep 15, 2016 · 1 comment
Closed

Create a REPL for testing #28

faultyserver opened this issue Sep 15, 2016 · 1 comment

Comments

@faultyserver
Copy link
Member

There should be a system that allows developers to run an instance of Shark that exposes a REPL, allowing them to interact with and inspect Events as the pass through the system. Ideally, the REPL could be inserted anywhere above Agency in the Middleware stack, but will default to the end of the stack.

Running the REPL should be simple, something akin to

ruby shark.rb --repl [--insert-after <MiddlewareClassName>]

An example of a session with the REPL:

$ ruby shark.rb --repl
>> last_event
<Event:0x... @topic="vehicles.4004">
>> event = last_event(topic: "routes.1B")
<Event0x... @topic="routes.1B">
>> event.type
:update
>> event.originator
<Shark::Route:0x... @identifier="routes.1B">
>> exit
$

Essentially, the REPL should be an instance of IRB (or rather, Ripl) with a few helpers defined to make interacting with events simpler.

faultyserver added a commit that referenced this issue Sep 16, 2016
IMPORTANT: This commit breaks the old execution path of yore. Instead of running `ruby shark.rb`, instead run `bin/shark -c config/citybus.rb`. Run `bin/shark -h` for other options.

`Runner` (the runtime manager) is responsible for preparing the run environment, loading configurations, and starting the agency services. It is a generalization of the previous `shark.rb` into a more configurable system. (Thinking about it, `Runner` should `include Configurable`...)

The reason for these changes, other than for configurability, is to accomodate what will become the `test` environment, capturing all events and providing a REPL to interact with them. See #28.
@faultyserver
Copy link
Member Author

FWIW, this is done. The REPL is automatically started when Shark is run in the test environment.

Example:

$ bin/shark -c config/citybus.rb -e test
| Loading configuration
| Loading agency
| Preparing environment
| Ready
>> fetch 'vehicles.4008'
=> #<Shark::Vehicle:0x007ffed30aaaa8 @associated_objects={}, @name="4008", @latitude=40.4191925, @longitude=-86.894239666667, @route="routes.1B", @last_station="stations.BUS215">
>> 

With that, I'm going to close this issue. It doesn't mean that the REPL is finished, just that there is a working REPL with helpers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant