opi 0.3.11 → 0.3.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/opi/api.rb +3 -2
- data/lib/opi/context.rb +5 -3
- data/lib/opi/loader.rb +0 -2
- data/lib/opi/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09b8df30901e0e79a902246bc575f64e1c864659
|
4
|
+
data.tar.gz: a84fb9fbe8d3230683b9229ef57e45a7752565f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87ee5a7dd3d2b495ac2ed08dba3055d14291a760e212f85c4c0d5813018c51eec7dc8ababc34cb08805312a3b76dedb0627a087f3d94914f45e383066af7582d
|
7
|
+
data.tar.gz: 397f07bd4faf2c386f6f63d442b8ee68dd013a07db3f468da778d44d19185b338db8cf2e5d1594c2beae35d02304db18e5676e058fd431b5235f02b2e6531f06
|
data/lib/opi/api.rb
CHANGED
@@ -11,7 +11,7 @@ module Opi
|
|
11
11
|
route 'POST', path, options, block
|
12
12
|
end
|
13
13
|
|
14
|
-
def put(path, &block)
|
14
|
+
def put(path, options={}, &block)
|
15
15
|
route 'PUT', path, options, block
|
16
16
|
end
|
17
17
|
|
@@ -79,7 +79,7 @@ module Opi
|
|
79
79
|
|
80
80
|
if route
|
81
81
|
logger.debug "#{request.method} #{request.path} => route #{route.inspect}".green
|
82
|
-
context = Context.new(env, route, request, response, self.class.before_filters, self.class.after_filters)
|
82
|
+
context = Context.new(env, logger, route, request, response, self.class.before_filters, self.class.after_filters)
|
83
83
|
response = context.run
|
84
84
|
else
|
85
85
|
logger.debug "#{request.method} #{request.path} => route not found".red
|
@@ -87,6 +87,7 @@ module Opi
|
|
87
87
|
end
|
88
88
|
|
89
89
|
rescue Exception => e
|
90
|
+
logger.error "#{e.message.red}\n #{e.backtrace[0..9].join("\n ").yellow}"
|
90
91
|
response.internal_server_error!(e)
|
91
92
|
end
|
92
93
|
|
data/lib/opi/context.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module Opi
|
2
2
|
class Context
|
3
3
|
|
4
|
-
attr_reader :env, :route, :request, :response, :before, :after, :error
|
4
|
+
attr_reader :env, :logger, :route, :request, :response, :before, :after, :error
|
5
5
|
|
6
|
-
def initialize(env, route, request, response, before, after)
|
6
|
+
def initialize(env, logger, route, request, response, before, after)
|
7
7
|
@env = env
|
8
|
+
@logger = logger
|
8
9
|
@route = route
|
9
10
|
@request = request
|
10
11
|
@response = response
|
@@ -50,6 +51,7 @@ module Opi
|
|
50
51
|
else
|
51
52
|
response.status = 400
|
52
53
|
response.body = [action.errors.symbolic.to_json, "\n"]
|
54
|
+
logger.error "Reponse: #{action.errors.symbolic.to_json}".red
|
53
55
|
end
|
54
56
|
else
|
55
57
|
response.status = 200
|
@@ -65,4 +67,4 @@ module Opi
|
|
65
67
|
end
|
66
68
|
|
67
69
|
end
|
68
|
-
end
|
70
|
+
end
|
data/lib/opi/loader.rb
CHANGED
data/lib/opi/version.rb
CHANGED