toast 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -16
- data/lib/toast/config_dsl/association.rb +2 -2
- data/lib/toast/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50d88f29268283ea8b037037c3b0bf95df8b639b
|
4
|
+
data.tar.gz: 8fce6e446f54b375c90ef90cbccc00f746142d2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4966d74e26040d21f39286c65e1ed2211557ea094eddbd3a0e85f9439cf6e4ed96e5417ca108c9dbeec7af0245c14c31aff82ca448e91f6353906e80ab121aae
|
7
|
+
data.tar.gz: d7039b45831ffd6e25dd35ee76b1219461495c74707040811660deb4062bc79b926af42df66e87fe8954176116e36c34b2dec5d5e4c021828f941f54ed58a776
|
data/README.md
CHANGED
@@ -8,16 +8,16 @@ Toast is a Rack application that hooks into Ruby on Rails. It exposes ActiveReco
|
|
8
8
|
* what models and attributes are to be exposed
|
9
9
|
* what methods are supported (GET, PATCH, DELETE, POST,...)
|
10
10
|
* hooks to handle authorization
|
11
|
-
* customized handlers
|
11
|
+
* customized handlers
|
12
12
|
|
13
|
-
When using Toast there's no Rails controller involved. Model classes and the API configuration is sufficient.
|
13
|
+
When using Toast there's no Rails controller involved. Model classes and the API configuration is sufficient.
|
14
14
|
|
15
|
-
Toast uses a REST/hypermedia style API, which is an own interpretation of the REST idea, not compatible with others like JSON API, Siren etc. It's design is much simpler and based on the idea of traversing opaque URIs.
|
15
|
+
Toast uses a REST/hypermedia style API, which is an own interpretation of the REST idea, not compatible with others like JSON API, Siren etc. It's design is much simpler and based on the idea of traversing opaque URIs.
|
16
16
|
|
17
17
|
Other features are:
|
18
18
|
|
19
19
|
* windowing of collections via _Range/Content-Range_ headers (paging)
|
20
|
-
* attribute selection per request
|
20
|
+
* attribute selection per request
|
21
21
|
* processing of URI parameters
|
22
22
|
|
23
23
|
See the [User Manual](https://robokopp.github.io/toast) for a detailed description.
|
@@ -27,7 +27,7 @@ Releases
|
|
27
27
|
|
28
28
|
## Toast version ≥ 1.0.2
|
29
29
|
|
30
|
-
Works with Rails
|
30
|
+
Works with Rails from version 4.2.9+ up to 6. This version will be tested with upcoming new Rails releases and receives bugfixes and new features.
|
31
31
|
|
32
32
|
## Toast version 0.9.*
|
33
33
|
|
@@ -89,13 +89,13 @@ Then we can define the API like this (in `config/toast-api/banana.rb`):
|
|
89
89
|
via_patch {
|
90
90
|
allow do |user, model, uri_params|
|
91
91
|
true
|
92
|
-
end
|
92
|
+
end
|
93
93
|
}
|
94
94
|
|
95
95
|
via_delete {
|
96
96
|
allow do |user, model, uri_params|
|
97
97
|
true
|
98
|
-
end
|
98
|
+
end
|
99
99
|
}
|
100
100
|
|
101
101
|
collection(:less_than_100) {
|
@@ -141,13 +141,13 @@ Then we can define the API like this (in `config/toast-api/banana.rb`):
|
|
141
141
|
allow do |user, model, uri_params|
|
142
142
|
true
|
143
143
|
end
|
144
|
-
}
|
144
|
+
}
|
145
145
|
|
146
146
|
via_link {
|
147
147
|
allow do |user, model, uri_params|
|
148
148
|
true
|
149
149
|
end
|
150
|
-
}
|
150
|
+
}
|
151
151
|
}
|
152
152
|
|
153
153
|
association(:apple) {
|
@@ -155,7 +155,7 @@ Then we can define the API like this (in `config/toast-api/banana.rb`):
|
|
155
155
|
allow do |user, model, uri_params|
|
156
156
|
true
|
157
157
|
end
|
158
|
-
}
|
158
|
+
}
|
159
159
|
}
|
160
160
|
}
|
161
161
|
|
@@ -172,7 +172,7 @@ The above definition exposes the model Banana as such:
|
|
172
172
|
"coconuts": "http://www.example.com/bananas/23/coconuts",
|
173
173
|
"apple": "http://www.example.com/bananas/23/apple" }'
|
174
174
|
|
175
|
-
The representation of a record is a flat JSON map: _name_ → _value_, in case of associations _name_ → _URI_. The special key _self_ contains the URI from which this record can be fetch alone. _self_ can be treated as a unique ID of the record (globally unique, if under a FQDN).
|
175
|
+
The representation of a record is a flat JSON map: _name_ → _value_, in case of associations _name_ → _URI_. The special key _self_ contains the URI from which this record can be fetch alone. _self_ can be treated as a unique ID of the record (globally unique, if under a FQDN).
|
176
176
|
|
177
177
|
### Get a collection (the :all collection)
|
178
178
|
GET http://www.example.com/bananas
|
@@ -197,7 +197,7 @@ Any _scope_ or class method returning a relation can be published this way.
|
|
197
197
|
GET http://www.example.com/bananas/23/coconuts?max_weight=3
|
198
198
|
--> 200, '[{COCONUT},{COCONUT},...]',
|
199
199
|
|
200
|
-
The COCONUT model must be exposed too. URI parameters can be processed in custom handlers for sorting and filtering.
|
200
|
+
The COCONUT model must be exposed too. URI parameters can be processed in custom handlers for sorting and filtering.
|
201
201
|
|
202
202
|
### Update a single resource:
|
203
203
|
PATCH http://www.example.com/bananas/23, '{"name": "Barney", "number": 44, "foo" => "bar"}'
|
@@ -208,7 +208,7 @@ Any _scope_ or class method returning a relation can be published this way.
|
|
208
208
|
"coconuts": "http://www.example.com/bananas/23/coconuts",
|
209
209
|
"apple": "http://www.example.com/bananas/23/apple"}'
|
210
210
|
|
211
|
-
Toast ingores unknown attributes, but prints warnings in it's log file. Only attributes from the 'writables' list will be updated.
|
211
|
+
Toast ingores unknown attributes, but prints warnings in it's log file. Only attributes from the 'writables' list will be updated.
|
212
212
|
|
213
213
|
### Create a new record
|
214
214
|
POST http://www.example.com/bananas, '{"name": "Johnny", "number": 888}'
|
@@ -223,18 +223,18 @@ Toast ingores unknown attributes, but prints warnings in it's log file. Only att
|
|
223
223
|
POST http://www.example.com/bananas/23/coconuts, '{COCONUT}'
|
224
224
|
--> 201, {"self":"http://www.example.com/coconuts/432, ...}
|
225
225
|
|
226
|
-
|
226
|
+
|
227
227
|
### Delete records
|
228
228
|
DELETE http://www.example.com/bananas/23
|
229
229
|
--> 200
|
230
230
|
|
231
231
|
### Linking records
|
232
232
|
|
233
|
-
LINK "http://www.example.com/bananas/23/coconuts",
|
233
|
+
LINK "http://www.example.com/bananas/23/coconuts",
|
234
234
|
Link: "http://www.example.com/coconuts/31"
|
235
235
|
--> 200
|
236
236
|
|
237
|
-
Toast uses the (unusual) HTTP verbs LINK and UNLINK in order to express the action of linking or unlinking existing resources. The above request will add _Coconut#31_ to the association _Banana#coconuts_.
|
237
|
+
Toast uses the (unusual) HTTP verbs LINK and UNLINK in order to express the action of linking or unlinking existing resources. The above request will add _Coconut#31_ to the association _Banana#coconuts_.
|
238
238
|
|
239
239
|
|
240
240
|
|
@@ -60,10 +60,10 @@ class Toast::ConfigDSL::Association
|
|
60
60
|
|
61
61
|
def max_window size
|
62
62
|
stack_push 'max_window' do
|
63
|
-
if size.is_a?(
|
63
|
+
if size.is_a?(Integer) and size > 0
|
64
64
|
@config_data.max_window = size
|
65
65
|
elsif size == :unlimited
|
66
|
-
@config_data.max_window = 10**6 # yes that's inifinity
|
66
|
+
@config_data.max_window = 10**6 # yes that's inifinity
|
67
67
|
else
|
68
68
|
raise_config_error 'max_window must a positive integer or :unlimited'
|
69
69
|
end
|
data/lib/toast/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- robokopp (Robert Annies)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|