syro 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. checksums.yaml +4 -4
  2. data/.gems +1 -1
  3. data/CHANGELOG +4 -0
  4. data/README.md +29 -1
  5. data/lib/syro.rb +4 -0
  6. data/syro.gemspec +1 -1
  7. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c99f760ad13757ab2f0f96fe37ae31d2c49c510
4
- data.tar.gz: 4d97a565d503043a8ac2f6aa5c453a5c3af11012
3
+ metadata.gz: d5bd169764accc1559a997f38c5a350e1b738f10
4
+ data.tar.gz: 6fc78b2e65bd001d3a88bbb216c5f9aa214ab889
5
5
  SHA512:
6
- metadata.gz: 34f6e40a4a5c6e29b7e1618c5b6923189d06bd165659b61a8b355440840fa0858db949892fe66d4cc8739fbf199cc77294f00bb9564fdf4245cd4eefb3f7d39b
7
- data.tar.gz: 65cfb5aebaccc4e4b7000966f93784a5b3ac06ac1e21161857c4979a7a904cd3dad82abfa382787c387b8c03c8c072177241718a3b5c5bd6bf524761467d4c5c
6
+ metadata.gz: 2a6cc7183e4c0b977769b34805e7d5dab8665384f986dae55605be896423db304420fb5309fc75b97b8594a131ea7a5536f9b3d21f642122dbab43dbd3ebbb9d
7
+ data.tar.gz: 73921b5292db07295b5ee25e90d364093cd6e2d60b4dc9a151bad63ab24e568337a8eddb78c3e87706f3b9bb2bddb64ba98eba98f6d9720274690df0464605c5
data/.gems CHANGED
@@ -1,4 +1,4 @@
1
- rack -v 1.6.0
1
+ rack -v 1.6.4
2
2
  rack-test -v 0.6.3
3
3
  cutest -v 1.2.2
4
4
  seg -v 0.0.1
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 0.0.8
2
+
3
+ * Reset PATH_INFO and SCRIPT_NAME after running a subapp
4
+
1
5
  0.0.7
2
6
 
3
7
  * Change run so that it accepts Rack applications
data/README.md CHANGED
@@ -37,7 +37,8 @@ app = Syro.new {
37
37
 
38
38
  The block is evaluated in a sandbox where the following methods are
39
39
  available: `env`, `req`, `res`, `inbox`, `call`, `run`, `halt`,
40
- `match`, `on`, `root?`, `root`,`get`, `post`, `patch` and `delete`.
40
+ `match`, `on`, `root?`, `root`,`get`, `put`, `post`, `patch` and
41
+ `delete`.
41
42
 
42
43
  As a recommendation, user created variables should be instance
43
44
  variables. That way they won't mix with the API methods defined in
@@ -80,6 +81,9 @@ executed only if the request is matched.
80
81
  `get`: Receives a block and calls it only if `root?` and `req.get?` are
81
82
  true.
82
83
 
84
+ `put`: Receives a block and calls it only if `root?` and `req.put?` are
85
+ true.
86
+
83
87
  `post`: Receives a block and calls it only if `root?` and `req.post?`
84
88
  are true.
85
89
 
@@ -146,6 +150,10 @@ app = Syro.new {
146
150
  res.write "GET /users/42"
147
151
  }
148
152
 
153
+ put {
154
+ res.write "PUT /users/42"
155
+ }
156
+
149
157
  patch {
150
158
  res.write "PATCH /users/42"
151
159
  }
@@ -216,6 +224,26 @@ There are no rendering features built into this routing library. A
216
224
  framework that uses this routing library can easily implement helpers
217
225
  for rendering.
218
226
 
227
+ Middleware
228
+ ----------
229
+
230
+ Syro doesn't support Rack middleware out of the box. If you need them,
231
+ just use `Rack::Builder`:
232
+
233
+ ```ruby
234
+ app = Rack::Builder.new do
235
+
236
+ use Rack::Session::Cookie, secret: "..."
237
+
238
+ run Syro.new {
239
+ get {
240
+ res.write("Hello, world")
241
+ }
242
+ }
243
+
244
+ end
245
+ ```
246
+
219
247
  Trivia
220
248
  ------
221
249
 
data/lib/syro.rb CHANGED
@@ -125,11 +125,15 @@ class Syro
125
125
  end
126
126
 
127
127
  def run(app, inbox = {})
128
+ path, script = env[Rack::PATH_INFO], env[Rack::SCRIPT_NAME]
129
+
128
130
  env[Rack::PATH_INFO] = @syro_path.curr
129
131
  env[Rack::SCRIPT_NAME] = @syro_path.prev
130
132
  env[Syro::INBOX] = inbox
131
133
 
132
134
  halt(app.call(env))
135
+ ensure
136
+ env[Rack::PATH_INFO], env[Rack::SCRIPT_NAME] = path, script
133
137
  end
134
138
 
135
139
  def halt(response)
data/syro.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "syro"
3
- s.version = "0.0.7"
3
+ s.version = "0.0.8"
4
4
  s.summary = "Simple router"
5
5
  s.description = "Simple router for web applications"
6
6
  s.authors = ["Michel Martens"]
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.7
4
+ version: 0.0.8
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-07-03 00:00:00.000000000 Z
11
+ date: 2015-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: seg