Skip to content

Commit 1fbbf36

Browse files
committed
Clairify README
1 parent 9c0b980 commit 1fbbf36

File tree

2 files changed

+40
-23
lines changed

2 files changed

+40
-23
lines changed

README.md

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,36 @@
22

33
This is a little application, written in [Ruby](https://ruby-lang.org), using the [Sinatra](https://sinatrarb.com/) framework. It allows users to see the whereabouts of the International Space Station, using the [OpenNotify APIs](http://api.open-notify.org/).
44

5+
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.
6+
7+
It is important to attempt the all the tasks, even if you don't finish them.
8+
9+
During the interview, you should be prepared to walk us through the code on your machine via screen share.
10+
11+
If you get stuck, please do get in touch and we'll do our best to help.
12+
513
## What we're expecting
614

7-
* You should spend 2-3 hours on this challenge, and attempt all three tasks.
8-
* Please send back your code by the end of Sunday 4th June, either as a link to a Github/Gitlab repo, or a zip/tar of your code.
15+
* You should spend no more than 3 hours on this challenge, and attempt all three tasks.
16+
* Please send back your code by the end of **Sunday 4th June**, either as a link to a Github/Gitlab repo, or as a zip file containing your code.
917

10-
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 task by 4th June, so we are able to make allowances.
18+
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 4th June, so we are able to make allowances.
1119

12-
It is important to attempt the tasks, even if you don't finish them.
20+
The challenge only needs to be runnable in a local environment; it doesn't need to be hosted anywhere.
1321

14-
If you need help with the task, for whatever reason, please drop us an email and we will do our best to assist.
22+
If you need help with the challenge, for whatever reason, please do drop us an email and we will do our best to assist.
1523

1624
## Tasks
1725

26+
Please do not spend any more than 3 hours completeing these tasks.
27+
1828
1. Build a page to show the current astronauts that are in space, using the `OpenNotify#astros` method.
19-
2. Style the application using HTML and CSS to allow the information to be presented clearly.
20-
3. Add new endpoints, or modify the existing ones, to return the ISS position data as JSON, instead of an HTML page.
21-
e.g. `http://localhost:4567/iss_position.json` should return JSON in the following format:
29+
* Use the existing `position` page as a guide to when adding this new page.
30+
2. Add some style the application using HTML and CSS prioritising clear information presentation.
31+
* Location data should be shown on the `position` page.
32+
* Astronauts and their space ships could be shown in a table, or a list.
33+
* Add a stylesheet and some simple CSS to make the layout really clear.
34+
3. Add new 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:
2235

2336
```json
2437
{"iss_position": {"longitude": "-3.4941", "latitude": "-37.5113"}, "timestamp": 1684502291, "message": "success"}
@@ -28,7 +41,7 @@ If you need help with the task, for whatever reason, please drop us an email and
2841

2942
Firstly you'll want to download and unzip the code into a directory or folder of your choice.
3043

31-
Next if you've not already got Ruby, you'll need to [install it](https://www.ruby-lang.org/en/documentation/installation/). There are a number of different ways to do it depending on your operating system. **NB** Apple Macs already have it installed, but the version is quite old, so we'd recommend installing a more up-to-date one.
44+
Next if you've not already got Ruby, you'll need to [install it](https://www.ruby-lang.org/en/documentation/installation/). There are a number of different ways to do it depending on your operating system. The challenge needs **at least Ruby v3** to run.
3245

3346
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.
3447

@@ -57,12 +70,16 @@ and you should be able to see it at http://localhost:4567. **NB** When you make
5770

5871
## Useful documentation
5972

73+
* Installing ruby on
74+
* [MacOS using Homebrew](https://stackify.com/install-ruby-on-your-mac-everything-you-need-to-get-going/)
75+
* [Windows using RubyInstaller](https://stackify.com/install-ruby-on-windows-everything-you-need-to-get-going/)
76+
* [other OSs](https://www.ruby-lang.org/en/documentation/installation/)
6077
* [Getting started with Sinatra](https://sinatrarb.com/intro.html)
6178
* Various useful Ruby classes and modules:
6279
* [Array](https://ruby-doc.org/3.2.2/Array.html)
6380
* [Hash](https://ruby-doc.org/3.2.2/Hash.html)
6481
* [String](https://ruby-doc.org/3.2.2/String.html)
65-
* [Comparable](https://ruby-doc.org/3.2.2/Comparable.html) (handy if you're sorting things)
82+
* [Comparable](https://ruby-doc.org/3.2.2/Comparable.html) (handy if you're sorting things, e.g Hashes and Arrays)
6683
* [Enumerable](https://ruby-doc.org/3.2.2/Enumerable.html) (full of useful methods that both Hash and Array can use)
67-
* [ERB Templating](https://ruby-doc.org/3.2.2/stdlibs/erb/ERB.html)
84+
* [ERB Templating](https://ruby-doc.org/3.2.2/stdlibs/erb/ERB.html) (what we use in our views to execute Ruby)
6885

open_notify.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
require 'json'
44
require 'faraday'
55

6-
# Fetch data from the OpenNotify API service at
7-
# http://api.open-notify.org/
8-
#
9-
# To allow this to work without internet access, the read data method just
10-
# loads and parses the data
6+
# Fetch data from the OpenNotify API service at http://api.open-notify.org/
117
module OpenNotify
128
BASE_DIR = __dir__
139

10+
# To allow this to work without internet access, the read data method just
11+
# loads and parses the data
12+
#
13+
# Change this to 'yes' if you want to use the live data.
14+
USE_LIVE_DATA = 'no'
15+
1416
def iss_now
1517
fetch_data(api: 'iss-now')
1618
end
@@ -19,19 +21,17 @@ def astros
1921
fetch_data(api: 'astros')
2022
end
2123

22-
# This method would really fetch data from the live API, but for our
23-
# purposes, a static file makes sense.
2424
def fetch_data(api:)
25-
if ENV['USE_LIVE_DATA'] == 'yes'
25+
if USE_LIVE_DATA == 'yes'
2626
conn = Faraday.new('http://api.open-notify.org/') do |f|
2727
f.response :json
2828
end
2929

30-
conn.get("#{api}.json").body
31-
else
32-
filepath = File.join(BASE_DIR, 'data', "#{api}.json")
33-
JSON.parse(File.read(filepath))
30+
return conn.get("#{api}.json").body
3431
end
32+
33+
filepath = File.join(BASE_DIR, 'data', "#{api}.json")
34+
JSON.parse(File.read(filepath))
3535
end
3636

3737
module_function :iss_now, :astros, :fetch_data

0 commit comments

Comments
 (0)