jeanine 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jeanine/app.rb +23 -6
- data/lib/jeanine/rescuing.rb +17 -0
- data/lib/jeanine/session.rb +7 -0
- data/lib/jeanine/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9120ffa8994858a7560330fa0afbe1bf18e2f94
|
4
|
+
data.tar.gz: fd326e260cc8c90a5b70b8b8ad4a1cd5b0b9869a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b11b5b73abed4a7df44caf5a7b53ad6d2d52616fc23658e8c0d864239c0dc7b3fdfb6837c6d611f593944ad2518d92cc9af945ec3185a7bdfd783f913c3309c
|
7
|
+
data.tar.gz: 2ca9b7d2196c08e57bda6f983cfb0a1da71c06772bb6b42b76deb0aa941d5cb454eef4041d9834f8b3eeea9644d5a86b22e48de5f6b951a32e39481d9ac631a4
|
data/lib/jeanine/app.rb
CHANGED
@@ -1,18 +1,22 @@
|
|
1
1
|
require 'jeanine/callbacks'
|
2
2
|
require 'jeanine/mimes'
|
3
3
|
require 'jeanine/request'
|
4
|
+
require 'jeanine/rescuing'
|
4
5
|
require 'jeanine/response'
|
5
6
|
require 'jeanine/renderer'
|
6
7
|
require 'jeanine/routing'
|
8
|
+
require 'jeanine/session'
|
7
9
|
|
8
10
|
module Jeanine
|
9
11
|
class App
|
12
|
+
include Session
|
10
13
|
include Routing::Evaluation
|
11
14
|
attr_reader :request, :response
|
15
|
+
|
12
16
|
class << self
|
13
|
-
include Routing::DSL
|
14
17
|
include Callbacks
|
15
|
-
|
18
|
+
include Routing::DSL
|
19
|
+
include Rescuing
|
16
20
|
alias :_new :new
|
17
21
|
def new(*args, &block)
|
18
22
|
initialize!
|
@@ -37,11 +41,24 @@ module Jeanine
|
|
37
41
|
end
|
38
42
|
end
|
39
43
|
|
44
|
+
include Rescuing
|
45
|
+
|
40
46
|
def call(env)
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
47
|
+
begin
|
48
|
+
@env = env
|
49
|
+
@request = Jeanine::Request.new(env)
|
50
|
+
@response = Jeanine::Response.new
|
51
|
+
catch(:halt) { route_eval }
|
52
|
+
rescue => error
|
53
|
+
handler = self.class.rescue_handlers[error.class]
|
54
|
+
raise error unless handler
|
55
|
+
if handler.is_a?(Symbol)
|
56
|
+
@response.write(send(handler, error))
|
57
|
+
else
|
58
|
+
@response.write(instance_exec(error, &handler))
|
59
|
+
end
|
60
|
+
@response.complete!
|
61
|
+
end
|
45
62
|
end
|
46
63
|
|
47
64
|
private
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Jeanine
|
2
|
+
module Rescuing
|
3
|
+
def rescue_from(*exceptions, with: nil, &block)
|
4
|
+
exceptions.each do |exception|
|
5
|
+
if with
|
6
|
+
rescue_handlers[exception] = with
|
7
|
+
else
|
8
|
+
rescue_handlers[exception] = block
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def rescue_handlers
|
14
|
+
@rescue_handlers ||= {}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/jeanine/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jeanine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Brody
|
@@ -87,11 +87,13 @@ files:
|
|
87
87
|
- lib/jeanine/path_proxy.rb
|
88
88
|
- lib/jeanine/renderer.rb
|
89
89
|
- lib/jeanine/request.rb
|
90
|
+
- lib/jeanine/rescuing.rb
|
90
91
|
- lib/jeanine/response.rb
|
91
92
|
- lib/jeanine/router.rb
|
92
93
|
- lib/jeanine/routing.rb
|
93
94
|
- lib/jeanine/routing/dsl.rb
|
94
95
|
- lib/jeanine/routing/evaluation.rb
|
96
|
+
- lib/jeanine/session.rb
|
95
97
|
- lib/jeanine/version.rb
|
96
98
|
- lib/jeanine/view.rb
|
97
99
|
homepage: https://github.com/joshmn/jeanine
|