hovercraft 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +3 -0
- data/README.md +99 -8
- data/lib/hovercraft/loader.rb +0 -1
- data/lib/hovercraft/version.rb +1 -1
- metadata +5 -4
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,30 +1,121 @@
|
|
1
1
|
# Hovercraft
|
2
2
|
|
3
|
+
[](http://travis-ci.org/vanstee/hovercraft)
|
4
|
+
[](https://gemnasium.com/vanstee/hovercraft)
|
5
|
+
|
3
6
|
Generate a RESTful API from a directory of ActiveRecord models.
|
4
7
|
|
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
|
+
|
5
13
|
## Get Up and Running
|
6
14
|
|
7
15
|
1. Throw this in your Gemfile:
|
8
16
|
|
9
|
-
|
17
|
+
```ruby
|
18
|
+
gem 'hovercraft'
|
19
|
+
```
|
10
20
|
|
11
21
|
2. Put your ActiveRecord models in `models/` (make sure the file names
|
12
22
|
are the same as the class names).
|
13
23
|
|
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
|
+
|
14
37
|
3. Create a rackup file that generates the application:
|
15
38
|
|
16
39
|
```ruby
|
40
|
+
# config.ru
|
41
|
+
|
42
|
+
require 'bundler'
|
43
|
+
Bundler.require
|
44
|
+
|
17
45
|
run Hovercraft::Server.new
|
18
|
-
```
|
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.
|
19
50
|
|
20
51
|
4. Run the application like normal:
|
21
52
|
|
22
|
-
|
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
|
+
```
|
23
94
|
|
24
95
|
## Give Back
|
25
96
|
|
26
|
-
1. Fork it
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
data/lib/hovercraft/loader.rb
CHANGED
data/lib/hovercraft/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hovercraft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra-activerecord
|
@@ -115,6 +115,7 @@ extensions: []
|
|
115
115
|
extra_rdoc_files: []
|
116
116
|
files:
|
117
117
|
- .gitignore
|
118
|
+
- .travis.yml
|
118
119
|
- Gemfile
|
119
120
|
- LICENSE
|
120
121
|
- README.md
|
@@ -146,7 +147,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
146
147
|
version: '0'
|
147
148
|
segments:
|
148
149
|
- 0
|
149
|
-
hash:
|
150
|
+
hash: 1562352661766896187
|
150
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
152
|
none: false
|
152
153
|
requirements:
|
@@ -155,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
156
|
version: '0'
|
156
157
|
segments:
|
157
158
|
- 0
|
158
|
-
hash:
|
159
|
+
hash: 1562352661766896187
|
159
160
|
requirements: []
|
160
161
|
rubyforge_project:
|
161
162
|
rubygems_version: 1.8.23
|