syro 2.1.1 → 2.1.2

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/lib/syro.rb +5 -8
  5. data/syro.gemspec +1 -1
  6. data/test/all.rb +13 -0
  7. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f857bcf1e2b031415f2d9182a062f6dd242f17a0
4
- data.tar.gz: 13fb027d2ee19067a1e1da120ee80af13c56d3fe
3
+ metadata.gz: f3e9816a3e376c56d374956eb7f2d9d0ff5d95ab
4
+ data.tar.gz: 9bd2f9385cd52519943f5bf27b6d6e0de417beba
5
5
  SHA512:
6
- metadata.gz: fd3d9434647854b6a12c0b543772a0c01141bf52cf653858216132ead9494d9bbf08d7f644d3bc1c767ddda46feff973a9aab30be7e6784aa1f38674e060cc38
7
- data.tar.gz: e728e0711a44eaae11c440f2989998f288e50a7668db1ad0ed0a5cda0ad61b6a992ed6a0682c2d20631e0db19830ba8af34179c27eb54ce02070f2944779acab
6
+ metadata.gz: eac119bca99e13bff0577c7abcfd5cee3f9d38801bee397e07c59cb32f4e6d7afb93ff6ef7906bcd4c2c143d04f08996a6cd859eedaf3af64f4dd2b2734f670d
7
+ data.tar.gz: 47548850181e467ed3187e4e706004d39c45512448489a868c31d15ef525458b8f6238ed15dff218578ae4df538b24be02d3b6bc8cb6866e79346f0bf752b342
data/.gems CHANGED
@@ -1,4 +1,4 @@
1
1
  rack -v 1.6.4
2
2
  rack-test -v 0.6.3
3
- cutest -v 1.2.2
3
+ cutest -v 1.2.3
4
4
  seg -v 0.0.1
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 2.1.2
2
+
3
+ * Always set default content type if body is set.
4
+
1
5
  2.1.1
2
6
 
3
7
  * Change gemspec to accept pre-release versions of Rack 2
data/lib/syro.rb CHANGED
@@ -140,13 +140,10 @@ class Syro
140
140
  # # => [200, { "Content-Type" => "text/html" }, ["syro"]]
141
141
  #
142
142
  def finish
143
- if @status.nil?
144
- if @body.empty?
145
- @status = 404
146
- else
147
- @headers[Rack::CONTENT_TYPE] ||= DEFAULT
148
- @status = 200
149
- end
143
+ @status ||= (@body.empty?) ? 404 : 200
144
+
145
+ if @body.any?
146
+ @headers[Rack::CONTENT_TYPE] ||= DEFAULT
150
147
  end
151
148
 
152
149
  [@status, @headers, @body]
@@ -221,7 +218,7 @@ class Syro
221
218
  # res.status = 200
222
219
  # res["Content-Type"] = "text/html"
223
220
  # res.write("<h1>Welcome back!</h1>")
224
- #
221
+ #
225
222
  def res
226
223
  @syro_res
227
224
  end
data/syro.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "syro"
3
- s.version = "2.1.1"
3
+ s.version = "2.1.2"
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
@@ -193,6 +193,11 @@ app = Syro.new do
193
193
  on "json" do
194
194
  run(json)
195
195
  end
196
+
197
+ on "private" do
198
+ res.status = 401
199
+ res.write("Unauthorized")
200
+ end
196
201
  end
197
202
 
198
203
  setup do
@@ -320,3 +325,11 @@ test "custom request and response class" do |f|
320
325
 
321
326
  assert_equal params, f.last_response.body
322
327
  end
328
+
329
+ test "set content type if body is set" do |f|
330
+ f.get("/private")
331
+
332
+ assert_equal 401, f.last_response.status
333
+ assert_equal "Unauthorized", f.last_response.body
334
+ assert_equal "text/html", f.last_response.headers["Content-Type"]
335
+ 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: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michel Martens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-04 00:00:00.000000000 Z
11
+ date: 2016-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: seg