syro 0.0.8 → 1.0.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG +6 -0
- data/lib/syro.rb +6 -2
- data/syro.gemspec +1 -1
- data/test/all.rb +28 -0
- 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: 72ccaea865ce6b7f9dd3c646ff3fffbe74ef3a26
|
4
|
+
data.tar.gz: 0254961f899a3579960d806aaeee163517064c09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1450ad36901c308e28a71ea2a085df6d9803ccfa095dec59bd55cc27f65339d0c876e957faebb9e0579de7f21fda9181c516e979d040a4ec7e7b635e88d8c057
|
7
|
+
data.tar.gz: 936d26d701776b2064a5913b686f5660efb389399500048262ebd78357cd377b6960ccb9792b57524cbd10f6b4fe85cf4fedce7b20ad0bb09183180c4bdb3e9c
|
data/CHANGELOG
CHANGED
data/lib/syro.rb
CHANGED
@@ -110,10 +110,14 @@ class Syro
|
|
110
110
|
@syro_inbox
|
111
111
|
end
|
112
112
|
|
113
|
+
def default_headers
|
114
|
+
return {}
|
115
|
+
end
|
116
|
+
|
113
117
|
def call(env, inbox)
|
114
118
|
@syro_env = env
|
115
119
|
@syro_req = Rack::Request.new(env)
|
116
|
-
@syro_res = Syro::Response.new
|
120
|
+
@syro_res = Syro::Response.new(default_headers)
|
117
121
|
@syro_path = Seg.new(env.fetch(Rack::PATH_INFO))
|
118
122
|
@syro_inbox = inbox
|
119
123
|
|
@@ -151,7 +155,7 @@ class Syro
|
|
151
155
|
|
152
156
|
def on(arg)
|
153
157
|
if match(arg)
|
154
|
-
yield
|
158
|
+
yield(inbox[arg])
|
155
159
|
|
156
160
|
halt(res.finish)
|
157
161
|
end
|
data/syro.gemspec
CHANGED
data/test/all.rb
CHANGED
@@ -11,12 +11,20 @@ class TextualDeck < Syro::Deck
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
class DefaultHeaders < Syro::Deck
|
15
|
+
def default_headers
|
16
|
+
{ Rack::CONTENT_TYPE => "text/html" }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
14
20
|
textual = Syro.new(TextualDeck) {
|
15
21
|
get {
|
16
22
|
text("GET /textual")
|
17
23
|
}
|
18
24
|
}
|
19
25
|
|
26
|
+
default_headers = Syro.new(DefaultHeaders) { }
|
27
|
+
|
20
28
|
admin = Syro.new {
|
21
29
|
get {
|
22
30
|
res.write("GET /admin")
|
@@ -106,6 +114,12 @@ app = Syro.new {
|
|
106
114
|
}
|
107
115
|
}
|
108
116
|
|
117
|
+
on("articles") {
|
118
|
+
on(:id) { |id|
|
119
|
+
res.write(sprintf("GET /articles/%s", id))
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
109
123
|
on("posts") {
|
110
124
|
@path = path.prev
|
111
125
|
|
@@ -137,6 +151,10 @@ app = Syro.new {
|
|
137
151
|
on("textual") {
|
138
152
|
run(textual)
|
139
153
|
}
|
154
|
+
|
155
|
+
on("headers") {
|
156
|
+
run(default_headers)
|
157
|
+
}
|
140
158
|
}
|
141
159
|
|
142
160
|
setup do
|
@@ -199,6 +217,10 @@ test "captures" do |f|
|
|
199
217
|
f.get("/users/42")
|
200
218
|
assert_equal "GET /users/42", f.last_response.body
|
201
219
|
assert_equal 200, f.last_response.status
|
220
|
+
|
221
|
+
f.get("/articles/23")
|
222
|
+
assert_equal "GET /articles/23", f.last_response.body
|
223
|
+
assert_equal 200, f.last_response.status
|
202
224
|
end
|
203
225
|
|
204
226
|
test "post values" do |f|
|
@@ -242,3 +264,9 @@ test "custom deck" do |f|
|
|
242
264
|
assert_equal "text/plain", f.last_response.headers["Content-Type"]
|
243
265
|
assert_equal 200, f.last_response.status
|
244
266
|
end
|
267
|
+
|
268
|
+
test "default headers" do |f|
|
269
|
+
f.get("/headers")
|
270
|
+
|
271
|
+
assert_equal "text/html", f.last_response.headers["Content-Type"]
|
272
|
+
end
|
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: 0.0
|
4
|
+
version: 1.0.0
|
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-10-
|
11
|
+
date: 2015-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: seg
|