blob: 80c8b269372ddafd6ef51aac78205ab37061d70b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# Coding Exercise: Data Storage API
Implement a small HTTP service to store objects organized by repository.
Clients of this service should be able to GET, PUT, and DELETE objects.
## Expectations
We ask that you spend no more than 2 hours on this exercise. We value your time and don't want to set unreasonable expectations on how long you should work on this exercise.
We ask you complete this exercise so you have an opportunity to build a service in your own time rather than an in-person interview, coding on a whiteboard.
## General Requirements
* The service should de-duplicate data objects by repository.
* The service should listen on port `8282`.
* The included tests should pass without modification.
* The service must implement the API as described below.
* The data can be persisted in memory, on disk, or wherever you like.
* Do not include any extra dependencies.
## Suggestions
* Your code will be read by humans, so organize it sensibly.
* Use this repository to store your work. Committing just the final solution is *ok* but we'd love to see your incremental progress. We suggest taking a look at [GitHub flow](https://guides.github.com/introduction/flow/) to structure your commits.
* [Submit a pull request](https://help.github.com/articles/creating-a-pull-request/) once you are happy with your work.
## API
### Upload an Object
```
PUT /data/{repository}
```
#### Response
```
Status: 201 Created
{
"oid": "2845f5a412dbdfacf95193f296dd0f5b2a16920da5a7ffa4c5832f223b03de96",
"size": 1234
}
```
### Download an Object
```
GET /data/{repository}/{objectID}
```
#### Response
```
Status: 200 OK
{object data}
```
Objects that are not on the server will return a `404 Not Found`.
### Delete an Object
```
DELETE /data/{repository}/{objectID}
```
#### Response
```
Status: 200 OK
```
## Getting started and Testing
In server-rack.rb you'll find a naive first draft of the answer to the exercise written for you. Please improve this draft so that it passes the test written in test.rb. You might need to install rack:
```
gem install rack rack-test
```
You can test that this works by running:
```
ruby test.rb
```
Once you have a good version of `server-rack.rb` please submit that file in a pull request.
Behind the scenes we add the following `.travis.yml` file to your code:
```
language: ruby
rvm:
- 2.4.4
before_script:
- cd ./ruby
- gem install rack rack-test
script:
- ruby test.rb
```
So please don't move tests or add in dependencies.
|