syro 2.1.0 → 2.1.1

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.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +4 -0
  3. data/README.md +44 -44
  4. data/syro.gemspec +2 -2
  5. data/test/all.rb +87 -87
  6. metadata +10 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef99afaf8d8d2f03d42a66cf16b3aa8e76c91a66
4
- data.tar.gz: 416d45ed7ca4d2c8e995e1b71d7a603f6b655d80
3
+ metadata.gz: f857bcf1e2b031415f2d9182a062f6dd242f17a0
4
+ data.tar.gz: 13fb027d2ee19067a1e1da120ee80af13c56d3fe
5
5
  SHA512:
6
- metadata.gz: c755f0d05b8c8c8e7ffa3b1b811e658c7b9182a0632d9b5d15031414295cd97630166c773fc505d87c186d2c2a92e437512b8da6880bd8ae0c903223de7d98c6
7
- data.tar.gz: 4cf42a210e82910a6997a7f7b54273ff98c2c0442978797d87f98a22aeac21355962f1eaca8024ae9b316a0aa0378e913fab54d41ac3d8ee308edd9052c27993
6
+ metadata.gz: fd3d9434647854b6a12c0b543772a0c01141bf52cf653858216132ead9494d9bbf08d7f644d3bc1c767ddda46feff973a9aab30be7e6784aa1f38674e060cc38
7
+ data.tar.gz: e728e0711a44eaae11c440f2989998f288e50a7668db1ad0ed0a5cda0ad61b6a992ed6a0682c2d20631e0db19830ba8af34179c27eb54ce02070f2944779acab
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 2.1.1
2
+
3
+ * Change gemspec to accept pre-release versions of Rack 2
4
+
1
5
  2.1.0
2
6
 
3
7
  * Add matchers for head and options
data/README.md CHANGED
@@ -33,17 +33,17 @@ Usage
33
33
  An example of a modular application would look like this:
34
34
 
35
35
  ```ruby
36
- admin = Syro.new {
37
- get {
36
+ Admin = Syro.new do
37
+ get do
38
38
  res.write "Hello from admin!"
39
- }
40
- }
41
-
42
- app = Syro.new {
43
- on("admin") {
44
- run(admin)
45
- }
46
- }
39
+ end
40
+ end
41
+
42
+ App = Syro.new do
43
+ on "admin" do
44
+ run(Admin)
45
+ end
46
+ end
47
47
  ```
48
48
 
49
49
  The block is evaluated in a sandbox where the following methods are
@@ -138,11 +138,11 @@ class TextualDeck < Syro::Deck
138
138
  end
139
139
  end
140
140
 
141
- App = Syro.new(TextualDeck) {
142
- get {
141
+ App = Syro.new(TextualDeck) do
142
+ get do
143
143
  text("hello world")
144
- }
145
- }
144
+ end
145
+ end
146
146
  ```
147
147
 
148
148
  The example is simple enough to showcase the concept, but maybe too
@@ -159,47 +159,47 @@ In the following examples, the response string represents
159
159
  the request path that was sent.
160
160
 
161
161
  ```ruby
162
- app = Syro.new {
163
- get {
162
+ App = Syro.new do
163
+ get do
164
164
  res.write "GET /"
165
- }
165
+ end
166
166
 
167
- post {
167
+ post do
168
168
  res.write "POST /"
169
- }
169
+ end
170
170
 
171
- on("users") {
172
- on(:id) {
171
+ on "users" do
172
+ on :id do
173
173
 
174
174
  # Captured values go to the inbox
175
175
  @user = User[inbox[:id]]
176
176
 
177
- get {
177
+ get do
178
178
  res.write "GET /users/42"
179
- }
179
+ end
180
180
 
181
- put {
181
+ put do
182
182
  res.write "PUT /users/42"
183
- }
183
+ end
184
184
 
185
- patch {
185
+ patch do
186
186
  res.write "PATCH /users/42"
187
- }
187
+ end
188
188
 
189
- delete {
189
+ delete do
190
190
  res.write "DELETE /users/42"
191
- }
192
- }
191
+ end
192
+ end
193
193
 
194
- get {
194
+ get do
195
195
  res.write "GET /users"
196
- }
196
+ end
197
197
 
198
- post {
198
+ post do
199
199
  res.write "POST /users"
200
- }
201
- }
202
- }
200
+ end
201
+ end
202
+ end
203
203
  ```
204
204
 
205
205
  Matches
@@ -234,9 +234,9 @@ a slash and until either another slash or the end of the string.
234
234
  The captured value is stored in the `inbox` hash under the key that
235
235
  was provided as the argument to `on`. For example, after a call to
236
236
  `on(:user_id)`, the value for the segment will be stored at
237
- `inbox[:user_id]`. When mounting an application called `users` with
238
- the command `run(users)`, an inbox can be provided as the second
239
- argument: `run(users, inbox)`. That allows apps to share previous
237
+ `inbox[:user_id]`. When mounting an application called `Users` with
238
+ the command `run(Users)`, an inbox can be provided as the second
239
+ argument: `run(Users, inbox)`. That allows apps to share previous
240
240
  captures.
241
241
 
242
242
  Security
@@ -259,15 +259,15 @@ Syro doesn't support Rack middleware out of the box. If you need them,
259
259
  just use `Rack::Builder`:
260
260
 
261
261
  ```ruby
262
- app = Rack::Builder.new do
262
+ App = Rack::Builder.new do
263
263
 
264
264
  use Rack::Session::Cookie, secret: "..."
265
265
 
266
- run Syro.new {
267
- get {
266
+ run Syro.new do
267
+ get do
268
268
  res.write("Hello, world")
269
- }
270
- }
269
+ end
270
+ end
271
271
 
272
272
  end
273
273
  ```
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "syro"
3
- s.version = "2.1.0"
3
+ s.version = "2.1.1"
4
4
  s.summary = "Simple router"
5
5
  s.description = "Simple router for web applications"
6
6
  s.authors = ["Michel Martens"]
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.files = `git ls-files`.split("\n")
12
12
 
13
13
  s.add_dependency "seg"
14
- s.add_dependency "rack", "~> 1.6.0"
14
+ s.add_dependency "rack", ">= 1.6.0", "< 2.0.0"
15
15
  s.add_development_dependency "cutest"
16
16
  s.add_development_dependency "rack-test"
17
17
  end
@@ -41,159 +41,159 @@ class CustomRequestAndResponse < Syro::Deck
41
41
  end
42
42
  end
43
43
 
44
- textual = Syro.new(TextualDeck) {
45
- get {
44
+ textual = Syro.new(TextualDeck) do
45
+ get do
46
46
  text("GET /textual")
47
- }
48
- }
47
+ end
48
+ end
49
49
 
50
- default_headers = Syro.new(DefaultHeaders) { }
50
+ default_headers = Syro.new(DefaultHeaders) do end
51
51
 
52
- json = Syro.new(CustomRequestAndResponse) {
53
- root {
52
+ json = Syro.new(CustomRequestAndResponse) do
53
+ root do
54
54
  params = req.params
55
55
 
56
56
  res.write(params)
57
- }
58
- }
57
+ end
58
+ end
59
59
 
60
- admin = Syro.new {
61
- get {
60
+ admin = Syro.new do
61
+ get do
62
62
  res.write("GET /admin")
63
- }
64
- }
63
+ end
64
+ end
65
65
 
66
- platforms = Syro.new {
66
+ platforms = Syro.new do
67
67
  @id = inbox.fetch(:id)
68
68
 
69
- get {
69
+ get do
70
70
  res.write "GET /platforms/#{@id}"
71
- }
72
- }
71
+ end
72
+ end
73
73
 
74
- comments = Syro.new {
75
- get {
74
+ comments = Syro.new do
75
+ get do
76
76
  res.write sprintf("GET %s/%s/comments",
77
77
  inbox[:path],
78
78
  inbox[:post_id])
79
- }
80
- }
79
+ end
80
+ end
81
81
 
82
- app = Syro.new {
83
- get {
82
+ app = Syro.new do
83
+ get do
84
84
  res.write "GET /"
85
- }
85
+ end
86
86
 
87
- post {
88
- on(req.POST["user"] != nil) {
87
+ post do
88
+ on req.POST["user"] != nil do
89
89
  res.write "POST / (user)"
90
- }
90
+ end
91
91
 
92
- on(true) {
92
+ on true do
93
93
  res.write "POST / (none)"
94
- }
95
- }
94
+ end
95
+ end
96
96
 
97
- on("foo") {
98
- on("bar") {
99
- on("baz") {
97
+ on "foo" do
98
+ on "bar" do
99
+ on "baz" do
100
100
  res.write("error")
101
- }
101
+ end
102
102
 
103
- get {
103
+ get do
104
104
  res.write("GET /foo/bar")
105
- }
105
+ end
106
106
 
107
- put {
107
+ put do
108
108
  res.write("PUT /foo/bar")
109
- }
109
+ end
110
110
 
111
- head {
111
+ head do
112
112
  res.write("HEAD /foo/bar")
113
- }
113
+ end
114
114
 
115
- post {
115
+ post do
116
116
  res.write("POST /foo/bar")
117
- }
117
+ end
118
118
 
119
- patch {
119
+ patch do
120
120
  res.write("PATCH /foo/bar")
121
- }
121
+ end
122
122
 
123
- delete {
123
+ delete do
124
124
  res.write("DELETE /foo/bar")
125
- }
125
+ end
126
126
 
127
- options {
127
+ options do
128
128
  res.write("OPTIONS /foo/bar")
129
- }
130
- }
131
- }
129
+ end
130
+ end
131
+ end
132
132
 
133
- on("bar/baz") {
134
- get {
133
+ on "bar/baz" do
134
+ get do
135
135
  res.write("GET /bar/baz")
136
- }
137
- }
136
+ end
137
+ end
138
138
 
139
- on("admin") {
139
+ on "admin" do
140
140
  run(admin)
141
- }
141
+ end
142
142
 
143
- on("platforms") {
143
+ on "platforms" do
144
144
  run(platforms, id: 42)
145
- }
145
+ end
146
146
 
147
- on("rack") {
147
+ on "rack" do
148
148
  run(RackApp.new)
149
- }
149
+ end
150
150
 
151
- on("users") {
152
- on(:id) {
151
+ on "users" do
152
+ on :id do
153
153
  res.write(sprintf("GET /users/%s", inbox[:id]))
154
- }
155
- }
154
+ end
155
+ end
156
156
 
157
- on("posts") {
157
+ on "posts" do
158
158
  @path = path.prev
159
159
 
160
- on(:post_id) {
161
- on("comments") {
160
+ on :post_id do
161
+ on "comments" do
162
162
  run(comments, inbox.merge(path: @path))
163
- }
164
- }
165
- }
163
+ end
164
+ end
165
+ end
166
166
 
167
- on("one") {
167
+ on "one" do
168
168
  @one = "1"
169
169
 
170
- get {
170
+ get do
171
171
  res.write(@one)
172
- }
173
- }
172
+ end
173
+ end
174
174
 
175
- on("two") {
176
- get {
175
+ on "two" do
176
+ get do
177
177
  res.write(@one)
178
- }
178
+ end
179
179
 
180
- post {
180
+ post do
181
181
  res.redirect("/one")
182
- }
183
- }
182
+ end
183
+ end
184
184
 
185
- on("textual") {
185
+ on "textual" do
186
186
  run(textual)
187
- }
187
+ end
188
188
 
189
- on("headers") {
189
+ on "headers" do
190
190
  run(default_headers)
191
- }
191
+ end
192
192
 
193
- on("json") {
193
+ on "json" do
194
194
  run(json)
195
- }
196
- }
195
+ end
196
+ end
197
197
 
198
198
  setup do
199
199
  Driver.new(app)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syro
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michel Martens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-12 00:00:00.000000000 Z
11
+ date: 2016-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: seg
@@ -28,16 +28,22 @@ dependencies:
28
28
  name: rack
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.6.0
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: 2.0.0
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
39
42
  - !ruby/object:Gem::Version
40
43
  version: 1.6.0
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: 2.0.0
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: cutest
43
49
  requirement: !ruby/object:Gem::Requirement