This is a little application, written in Ruby, using the Sinatra framework. It allows users to see the whereabouts of the International Space Station, using the OpenNotify APIs.
The aim of the exercise is for you to demonstrate how you would talk through your code and design decisions to peers, and will be used as a prompt for further discussions. We won't ask you to write any code during the interview itself, but we might ask specific questions about the code that you show us and how you might approach work on additional features or changes.
It is important to attempt all of the tasks, even if you don't finish them.
During the interview, you should be prepared to walk us through the code on your machine via screen share (Google Meet).
If you get stuck, please do get in touch and we'll do our best to help.
- You should spend no more than 3 hours on this challenge, and attempt all three tasks.
- Please send back your code (by the date specified in the email from us) either as a link to a GitHub / Gitlab repository, or within a zip file.
We understand that you will have other commitments and time constraints, please let us know as soon as possible if you will be unable to complete this challenge by the deadline so that we are able to make allowances.
The challenge only needs to be runnable in a local environment; it doesn't need to be hosted anywhere.
If you need help with the challenge, for whatever reason, please do drop us an email and we will do our best to assist.
- Build a page to show the current astronauts that are in space.
- You can either add to this codebase using the
OpenNotify#astros
method and use the existingposition
page as a guide when adding this new page. - Alternatively you could obtain the data from the
http://localhost:4567/astros
endpoint and use this codebase as an API utilising whatever framework you choose as the frontend.
- Add some style to the application using HTML and CSS, prioritising clear information presentation.
- Location data should be shown on the
position
page. - Astronauts and their space ships could be shown in a table, or a list.
- Add a stylesheet and some CSS to make the layout really clear.
- Add a new endpoint to return the ISS position data as JSON, instead of an HTML page.
http://localhost:4567/iss_position.json
should return JSON in the following format:
{"iss_position": {"longitude": "-3.4941", "latitude": "-37.5113"}, "timestamp": 1684502291, "message": "success"}
Firstly you'll want to download and unzip the code into a directory or folder of your choice.
Next if you've not already got Ruby, you'll need to install it. There are a number of different ways to do it depending on your operating system. The challenge needs at least Ruby v3 to run.
Once you've installed Ruby, you can install the dependencies for this project in a terminal. You should open a terminal in the directory or folder where your code has been checked out.
bundle config path vendor/bundle
bundle install
Then to start it:
bundle exec ruby app.rb
You should be able to see it at http://localhost:4567. NB When you make changes to your code, you'll need to stop the app, using ctrl+c
and then restart it using the same command above.
app.rb
- Our Sinatra applicationopen_notify.rb
- OpenNotify libraryGemfile
- list of Ruby libraries (Gems) that our app depends on.Gemfile.lock
- automatically generated "lockfile" for our dependencies.public/
- directory where "static" assets, e.g. images, CSS files can be kept.data/
- directory with static data from OpenNotify to allow development without internet access.views/
- directory containing the views (templates) for use by Sinatra. These are all usingerb
.
- Installing Ruby on
- Getting started with Sinatra
- Various useful Ruby classes and modules:
- Array
- Hash
- String
- Comparable (handy if you're sorting things, e.g Hashes and Arrays)
- Enumerable (full of useful methods that both Hash and Array can use)
- ERB Templating (what we use in our views to execute Ruby)