Skip to content

ateamlunchbox/robot

Repository files navigation

Included is the "RubyRobot" gem implementing the Netflix Studio Engineering 
Take-home (backend) code exercise.

This project uses the ruby bundler.  Navigate into 'ruby_robot' and run

bundle install

to install dependencies for this gem.

The gem sources include a Rakefile.  The default rake task will run the 
RSpec test suite (please note: I learned RSpec while implementing this
code, so I'm sure my usage is far from idiomatic).

In the 'ruby_robot', directory run

rake -T

to see a list of available tasks.

Run 

rake 

to run the RSpec tests.

Run 

exe/ruby_robot

to start the REPL shell.  Alternately, run "rake install:local" to build the 
gem and install it locally.  If that is done 'ruby_robot' should be on the 
path without providing the full path to it. 'ruby_robot' supports 'tab' 
completion.  Whack tab a few times to see the supported commands.

Also, be advised that the 3rd argument to the 'place' command should be 
uppercase NORTH, SOUTH, EAST, or WEST.

An additional command is supported in the REPL, that being 'QUIT' to exit the 
REPL.

To interact with the classes, run 

bin/console 

from the 'ruby_robot' directory to run IRB w/ the RubyRobot gem preloaded.

============================
JSON-over-HTTP API interface

This was a personal "stretch goal": implementing a HTTP interface to the Robot 
API complete with Swagger.io-enabled API documentation.  The HTTP interface allows any web client to manipulate a singleton robot within the web server
using the same interface as the interactive console.

Run

exe/ruby_robot_web 

(or install the gem and run 'ruby_robot_web') and then browse to 
http://localhost:4567 to view Swagger.io API documentation with GUIs for 
exercising the Robot HTTP API.

JSON schemas for the request/response message formats have also been 
added under the 'doc' directory within the ruby_robot gem.  JSON schemas
have been used with additional RSpec tests to validate inputs and outputs.

HTTP POST /place input is also now validated against the relevant JSON schema.

============================
gRPC API interface

This was a second "stretch goal": exe/ruby_robot_grpc_server in one terminal, then run exe/ruby_robot_grpc_client in another to see the Robot API exercised using a gRPC-based client/server.

Or run 

exe/ruby_robot_grpc_server 

in one terminal, and 

exe/ruby_robot grpc://localhost:31310

in a second one.  This will launch 'ruby_robot' connected over gRPC to the local Robot server running on port 31310.

To make things easier, a gRPC server (with TLS) is up and running at grpcs://netflix.avilla.net:31310.  Run the 'ruby_robot' as a client:

exe/ruby_robot grpcs://netflix.avilla.net:31310

to interact with the Robot running on netflix.avilla.net.