syro 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb3f4305da6d5ee66e017bd8edd112ae30f98891
4
- data.tar.gz: d7befe3d26ed52507decd6b340cabcac3a921e8f
3
+ metadata.gz: 5c99f760ad13757ab2f0f96fe37ae31d2c49c510
4
+ data.tar.gz: 4d97a565d503043a8ac2f6aa5c453a5c3af11012
5
5
  SHA512:
6
- metadata.gz: 8f9fcc63c2f77c4090c9f1252d7ddff0a0b05f27fc3440e135b077f47729dcc38196907e04b3b8d53275824e19023e6212711c0186aea50aaac0f30868ba6dd0
7
- data.tar.gz: 20d7b8cbd9b6ea83465151988d80793ea67880e33417de8ad706be4badbc33740de33aa1cc93a17eb2ccf69f52fa48158309198d8bdf54166ed14116e14ade9b
6
+ metadata.gz: 34f6e40a4a5c6e29b7e1618c5b6923189d06bd165659b61a8b355440840fa0858db949892fe66d4cc8739fbf199cc77294f00bb9564fdf4245cd4eefb3f7d39b
7
+ data.tar.gz: 65cfb5aebaccc4e4b7000966f93784a5b3ac06ac1e21161857c4979a7a904cd3dad82abfa382787c387b8c03c8c072177241718a3b5c5bd6bf524761467d4c5c
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 0.0.7
2
+
3
+ * Change run so that it accepts Rack applications
4
+
1
5
  0.0.6
2
6
 
3
7
  * Add put request method
data/README.md CHANGED
@@ -219,9 +219,8 @@ for rendering.
219
219
  Trivia
220
220
  ------
221
221
 
222
- The name comes from SImple ROuter, so it more or less rhymes with
223
- "zero". An initial idea was to release a new version of Cuba that
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, inbox))
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "syro"
3
- s.version = "0.0.6"
3
+ s.version = "0.0.7"
4
4
  s.summary = "Simple router"
5
5
  s.description = "Simple router for web applications"
6
6
  s.authors = ["Michel Martens"]
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.6
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-05-25 00:00:00.000000000 Z
11
+ date: 2015-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: seg