pretzel 0.3.1 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee5e3bc80aa999576fae2177ab694c7555971a4b
4
- data.tar.gz: d86bf5a30e4ca9d5a0eadac0aaca1fe06cb6246a
3
+ metadata.gz: 81e143d3c8ea2f451136beb158163b75a1baa056
4
+ data.tar.gz: 12c83627128243363bbfc1f56dbd7f6841add9c3
5
5
  SHA512:
6
- metadata.gz: 0c5534198d485b80df79e9533cb8130f967eff849b4d26a5e78fcb8b8d536d6d167203dae5ec0661fa5139ce5be01e1eaffd7af76d57aa68143eee1ed935abc6
7
- data.tar.gz: 76297ba54929a2d318cef28b7124c077ca8dedef337e01930a7c0d25b97c0847759c180d897a29055b46061975ec19b395689bcacce3d98661f41b32d68d39d9
6
+ metadata.gz: 48bfd0980ec88710147432191d3beac6ccd3fe152224caacce1d4881b2b421abc3f3677f49bb769dae16f6fccb04e14bf8ef611c83d559ef9d7a2f9e90ed5eda
7
+ data.tar.gz: 89dd7c25583ab99eb552c2bb6a0628e8e40776bd89c63cf70d669451420b7ad5f7e642e5f1d658a00edad3208efc896669e349164e40705c1354de21fc004284
@@ -73,7 +73,15 @@ module Pretzel
73
73
  def halt(*res)
74
74
  response.status = res.detect{|x| x.is_a?(Fixnum) } || 200
75
75
  response.header.merge!(res.detect{|x| x.is_a?(Hash) } || {})
76
- response.body = [res.detect{|x| x.is_a?(String) } || ""]
76
+
77
+ if self.class.routes[response.status].empty?
78
+ response.body = [res.detect{|x| x.is_a?(String) } || ""]
79
+ else
80
+ self.class.routes[response.status].each do |route, block|
81
+ response.write instance_eval(&block)
82
+ end
83
+ end
84
+
77
85
  throw :halt, response
78
86
  end
79
87
  end # end class
@@ -44,7 +44,7 @@ module Pretzel
44
44
  end
45
45
  end
46
46
 
47
- halt 404, "Not found."
47
+ halt 404
48
48
  end
49
49
  end
50
50
 
@@ -15,6 +15,9 @@ module Pretzel
15
15
  end
16
16
  end
17
17
 
18
+ def error(code, &block)
19
+ routes[code] << ["", block]
20
+ end
18
21
  end
19
22
  end
20
23
  end
@@ -1,3 +1,3 @@
1
1
  module Pretzel
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -10,8 +10,7 @@ class ScrapApplication < Pretzel::Core
10
10
  end
11
11
 
12
12
  ScrapApplication.get "/" do
13
- some_class_stuff "classy test"
14
- some_instance_stuff "Test!"
13
+ halt 500
15
14
  end
16
15
 
17
16
  ScrapApplication.get "/yolo/" do
@@ -24,5 +23,4 @@ ScrapApplication.get "/test/:name" do
24
23
  }
25
24
  end
26
25
 
27
-
28
26
  Rack::Handler::Thin.run ScrapApplication.new
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pretzel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Blechinger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-11 00:00:00.000000000 Z
11
+ date: 2015-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack