Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 122 lines (80 sloc) 2.543 kb
f956f5c Patrick Van Stee Generate gem with bundler
authored
1 # Hovercraft
2
2be882b Patrick Van Stee Setup travis ci
authored
3 [![Build Status](https://secure.travis-ci.org/vanstee/hovercraft.png)](http://travis-ci.org/vanstee/hovercraft)
a2fc4aa Patrick Van Stee Add dependency status badge
authored
4 [![Dependency Status](https://gemnasium.com/vanstee/hovercraft.png)](https://gemnasium.com/vanstee/hovercraft)
2be882b Patrick Van Stee Setup travis ci
authored
5
5a70a8f Patrick Van Stee Update description and README
authored
6 Generate a RESTful API from a directory of ActiveRecord models.
f956f5c Patrick Van Stee Generate gem with bundler
authored
7
8cff7c1 Patrick Van Stee Spruce up the README with more complete examples
authored
8 ## Short Disclaimer
9
10 I am not yet running this in production and the gem is not very
11 extensible at this point. Consider it a proof of concept.
12
5a70a8f Patrick Van Stee Update description and README
authored
13 ## Get Up and Running
f956f5c Patrick Van Stee Generate gem with bundler
authored
14
5a70a8f Patrick Van Stee Update description and README
authored
15 1. Throw this in your Gemfile:
f956f5c Patrick Van Stee Generate gem with bundler
authored
16
8cff7c1 Patrick Van Stee Spruce up the README with more complete examples
authored
17 ```ruby
18 gem 'hovercraft'
19 ```
f956f5c Patrick Van Stee Generate gem with bundler
authored
20
5a70a8f Patrick Van Stee Update description and README
authored
21 2. Put your ActiveRecord models in `models/` (make sure the file names
22 are the same as the class names).
f956f5c Patrick Van Stee Generate gem with bundler
authored
23
8cff7c1 Patrick Van Stee Spruce up the README with more complete examples
authored
24 Here's an example:
25
26 ```ruby
27 # models/employee.rb
28
29 class Employee < ActiveRecord::Base
30 attr_accessible :name, :career
31 end
32 ```
33
34 If you need help setting up an entire sinatra app here's a full
35 example: http://github.com/vanstee/hovercraft_example
36
5a70a8f Patrick Van Stee Update description and README
authored
37 3. Create a rackup file that generates the application:
f956f5c Patrick Van Stee Generate gem with bundler
authored
38
5a70a8f Patrick Van Stee Update description and README
authored
39 ```ruby
8cff7c1 Patrick Van Stee Spruce up the README with more complete examples
authored
40 # config.ru
41
42 require 'bundler'
43 Bundler.require
44
5a70a8f Patrick Van Stee Update description and README
authored
45 run Hovercraft::Server.new
8cff7c1 Patrick Van Stee Spruce up the README with more complete examples
authored
46 ```
47
48 If you need more setup I'd recommend using an `application.rb` file
49 and requiring that in the `config.ru` instead.
f956f5c Patrick Van Stee Generate gem with bundler
authored
50
5a70a8f Patrick Van Stee Update description and README
authored
51 4. Run the application like normal:
f956f5c Patrick Van Stee Generate gem with bundler
authored
52
8cff7c1 Patrick Van Stee Spruce up the README with more complete examples
authored
53 ```
54 bundle exec rackup
55 ```
56
57 5. Make some requests:
58
59 Create a record:
60
61 ```bash
62 curl -H 'Content-type: application/json' \
63 -X POST \
64 -d '{ "employee": { "name": "Philip J. Fry", "career": "Delivery Boy 1st Class" } }' \
65 http://localhost:9292/employees.json
66 ```
67
68 Show all records:
69
70 ```bash
71 curl http://localhost:9292/employees.json
72 ```
73
74 Show a single record:
75
76 ```bash
77 curl http://localhost:9292/employees/1.json
78 ```
79
80 Update a record:
81
82 ```bash
83 curl -H "Content-type: application/json" \
84 -X PUT \
85 -d '{ "employee": { "name": "Philip J. Fry", "career": "Executive Delivery Boy" } }' \
86 http://localhost:9292/employees/1.json
87 ```
88
89 Delete a record:
90
91 ```bash
92 curl -X DELETE http://localhost:9292/employees/1.json
93 ```
f956f5c Patrick Van Stee Generate gem with bundler
authored
94
5a70a8f Patrick Van Stee Update description and README
authored
95 ## Give Back
f956f5c Patrick Van Stee Generate gem with bundler
authored
96
8cff7c1 Patrick Van Stee Spruce up the README with more complete examples
authored
97 1. Fork it:
98
99 https://help.github.com/articles/fork-a-repo
100
101 2. Create your feature branch:
102
103 ```bash
104 git checkout -b fixes_horrible_spelling_errors
105 ```
106
107 3. Commit your changes:
108
109 ```bash
110 git commit -am 'Really? You spelled application as "applickachon"?'
111 ```
112
113 4. Push the branch:
114
115 ```bash
116 git push origin fixes_horrible_spelling_errors
117 ```
118
119 5. Create a pull request:
120
121 https://help.github.com/articles/using-pull-requests
Something went wrong with that request. Please try again.