syro 0.0.6 → 0.0.7
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 +4 -0
- data/README.md +2 -3
- data/lib/syro.rb +5 -2
- data/syro.gemspec +1 -1
- data/test/all.rb +16 -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: 5c99f760ad13757ab2f0f96fe37ae31d2c49c510
|
4
|
+
data.tar.gz: 4d97a565d503043a8ac2f6aa5c453a5c3af11012
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34f6e40a4a5c6e29b7e1618c5b6923189d06bd165659b61a8b355440840fa0858db949892fe66d4cc8739fbf199cc77294f00bb9564fdf4245cd4eefb3f7d39b
|
7
|
+
data.tar.gz: 65cfb5aebaccc4e4b7000966f93784a5b3ac06ac1e21161857c4979a7a904cd3dad82abfa382787c387b8c03c8c072177241718a3b5c5bd6bf524761467d4c5c
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -219,9 +219,8 @@ for rendering.
|
|
219
219
|
Trivia
|
220
220
|
------
|
221
221
|
|
222
|
-
|
223
|
-
|
224
|
-
broke backward compatibility, but in the end my friends suggested
|
222
|
+
An initial idea was to release a new version of [Cuba](http://cuba.is)
|
223
|
+
that broke backward compatibility, but in the end my friends suggested
|
225
224
|
to release this as a separate library. In the future, some ideas
|
226
225
|
of this library could be included in Cuba as well.
|
227
226
|
|
data/lib/syro.rb
CHANGED
@@ -24,6 +24,8 @@ require "rack"
|
|
24
24
|
require "seg"
|
25
25
|
|
26
26
|
class Syro
|
27
|
+
INBOX = "syro.inbox".freeze
|
28
|
+
|
27
29
|
class Response
|
28
30
|
LOCATION = "Location".freeze
|
29
31
|
DEFAULT = "text/html".freeze
|
@@ -125,8 +127,9 @@ class Syro
|
|
125
127
|
def run(app, inbox = {})
|
126
128
|
env[Rack::PATH_INFO] = @syro_path.curr
|
127
129
|
env[Rack::SCRIPT_NAME] = @syro_path.prev
|
130
|
+
env[Syro::INBOX] = inbox
|
128
131
|
|
129
|
-
halt(app.call(env
|
132
|
+
halt(app.call(env))
|
130
133
|
end
|
131
134
|
|
132
135
|
def halt(response)
|
@@ -208,7 +211,7 @@ class Syro
|
|
208
211
|
@code = code
|
209
212
|
end
|
210
213
|
|
211
|
-
def call(env, inbox = {})
|
214
|
+
def call(env, inbox = env.fetch(Syro::INBOX, {}))
|
212
215
|
@deck.new(@code).call(env, inbox)
|
213
216
|
end
|
214
217
|
end
|
data/syro.gemspec
CHANGED
data/test/all.rb
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
class RackApp
|
2
|
+
def call(env)
|
3
|
+
[200, {"Content-Type" => "text/html"}, ["GET /rack"]]
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
1
7
|
class TextualDeck < Syro::Deck
|
2
8
|
def text(str)
|
3
9
|
res[Rack::CONTENT_TYPE] = "text/plain"
|
@@ -90,6 +96,10 @@ app = Syro.new {
|
|
90
96
|
run(platforms, id: 42)
|
91
97
|
}
|
92
98
|
|
99
|
+
on("rack") {
|
100
|
+
run(RackApp.new)
|
101
|
+
}
|
102
|
+
|
93
103
|
on("users") {
|
94
104
|
on(:id) {
|
95
105
|
res.write(sprintf("GET /users/%s", inbox[:id]))
|
@@ -173,6 +183,12 @@ test "mounted app + inbox" do |f|
|
|
173
183
|
assert_equal 200, f.last_response.status
|
174
184
|
end
|
175
185
|
|
186
|
+
test "run rack app" do |f|
|
187
|
+
f.get("/rack")
|
188
|
+
assert_equal "GET /rack", f.last_response.body
|
189
|
+
assert_equal 200, f.last_response.status
|
190
|
+
end
|
191
|
+
|
176
192
|
test "root" do |f|
|
177
193
|
f.get("/")
|
178
194
|
assert_equal "GET /", f.last_response.body
|
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: 0.0.7
|
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-
|
11
|
+
date: 2015-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: seg
|