pliny 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pliny/errors.rb +7 -4
- data/lib/pliny/middleware/rescue_errors.rb +2 -8
- data/lib/pliny/version.rb +1 -1
- data/template/lib/endpoints/base.rb +4 -0
- data/test/extensions/instruments_test.rb +4 -0
- metadata +25 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59e9993f316b4360e09b0e9e60c9227daad19a00
|
4
|
+
data.tar.gz: 4de44f2103e728082c0c611d97d5e4a43695588e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4361dee922785399136ce3a3a76e3ac6ec6d075700a4eb485fe6f6536bd9535676bee13424d41e7593110d8ef55843d9de23cce7da8c0ee155645f1ea1951fbf
|
7
|
+
data.tar.gz: 1a72822bb718edb5d5c5918b18b8b032272cc4c19c25c415cfb50a0cd1fa19700822bb1a01683034bd4f73922e8c3756f2b6ea09b1a134e4f58a764170d6540f
|
data/lib/pliny/errors.rb
CHANGED
@@ -3,6 +3,12 @@ module Pliny
|
|
3
3
|
class Error < StandardError
|
4
4
|
attr_accessor :id
|
5
5
|
|
6
|
+
def self.render(error)
|
7
|
+
headers = { "Content-Type" => "application/json; charset=utf-8" }
|
8
|
+
data = { id: error.id, message: error.message, status: error.status }
|
9
|
+
[error.status, headers, [MultiJson.encode(data)]]
|
10
|
+
end
|
11
|
+
|
6
12
|
def initialize(message, id)
|
7
13
|
@id = id
|
8
14
|
super(message)
|
@@ -10,10 +16,7 @@ module Pliny
|
|
10
16
|
end
|
11
17
|
|
12
18
|
class HTTPStatusError < Error
|
13
|
-
|
14
|
-
|
15
|
-
# so that Sinatra respects are status code when catching an exception
|
16
|
-
alias :http_status :status
|
19
|
+
attr_accessor :status
|
17
20
|
|
18
21
|
def initialize(message = nil, id = nil, status = nil)
|
19
22
|
meta = Pliny::Errors::META[self.class]
|
@@ -8,13 +8,13 @@ module Pliny::Middleware
|
|
8
8
|
def call(env)
|
9
9
|
@app.call(env)
|
10
10
|
rescue Pliny::Errors::Error => e
|
11
|
-
render(e
|
11
|
+
Pliny::Errors::Error.render(e)
|
12
12
|
rescue Exception => e
|
13
13
|
if @raise
|
14
14
|
raise
|
15
15
|
else
|
16
16
|
dump_error(e, env)
|
17
|
-
render(Pliny::Errors::InternalServerError.new
|
17
|
+
Pliny::Errors::Error.render(Pliny::Errors::InternalServerError.new)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -25,11 +25,5 @@ module Pliny::Middleware
|
|
25
25
|
message = ["#{e.class} - #{e.message}:", *e.backtrace].join("\n\t")
|
26
26
|
env['rack.errors'].puts(message)
|
27
27
|
end
|
28
|
-
|
29
|
-
def render(e, env)
|
30
|
-
headers = { "Content-Type" => "application/json; charset=utf-8" }
|
31
|
-
error = { id: e.id, message: e.message, status: e.status }
|
32
|
-
[e.status, headers, [MultiJson.encode(error)]]
|
33
|
-
end
|
34
28
|
end
|
35
29
|
end
|
data/lib/pliny/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pliny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandur Leach
|
@@ -175,6 +175,9 @@ dependencies:
|
|
175
175
|
name: rake
|
176
176
|
requirement: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0.8'
|
178
181
|
- - ">="
|
179
182
|
- !ruby/object:Gem::Version
|
180
183
|
version: 0.8.7
|
@@ -182,6 +185,9 @@ dependencies:
|
|
182
185
|
prerelease: false
|
183
186
|
version_requirements: !ruby/object:Gem::Requirement
|
184
187
|
requirements:
|
188
|
+
- - "~>"
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '0.8'
|
185
191
|
- - ">="
|
186
192
|
- !ruby/object:Gem::Version
|
187
193
|
version: 0.8.7
|
@@ -189,6 +195,9 @@ dependencies:
|
|
189
195
|
name: rack-test
|
190
196
|
requirement: !ruby/object:Gem::Requirement
|
191
197
|
requirements:
|
198
|
+
- - "~>"
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '0.6'
|
192
201
|
- - ">="
|
193
202
|
- !ruby/object:Gem::Version
|
194
203
|
version: 0.6.2
|
@@ -196,6 +205,9 @@ dependencies:
|
|
196
205
|
prerelease: false
|
197
206
|
version_requirements: !ruby/object:Gem::Requirement
|
198
207
|
requirements:
|
208
|
+
- - "~>"
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: '0.6'
|
199
211
|
- - ">="
|
200
212
|
- !ruby/object:Gem::Version
|
201
213
|
version: 0.6.2
|
@@ -203,6 +215,9 @@ dependencies:
|
|
203
215
|
name: rr
|
204
216
|
requirement: !ruby/object:Gem::Requirement
|
205
217
|
requirements:
|
218
|
+
- - "~>"
|
219
|
+
- !ruby/object:Gem::Version
|
220
|
+
version: '1.1'
|
206
221
|
- - ">="
|
207
222
|
- !ruby/object:Gem::Version
|
208
223
|
version: 1.1.2
|
@@ -210,6 +225,9 @@ dependencies:
|
|
210
225
|
prerelease: false
|
211
226
|
version_requirements: !ruby/object:Gem::Requirement
|
212
227
|
requirements:
|
228
|
+
- - "~>"
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: '1.1'
|
213
231
|
- - ">="
|
214
232
|
- !ruby/object:Gem::Version
|
215
233
|
version: 1.1.2
|
@@ -217,6 +235,9 @@ dependencies:
|
|
217
235
|
name: timecop
|
218
236
|
requirement: !ruby/object:Gem::Requirement
|
219
237
|
requirements:
|
238
|
+
- - "~>"
|
239
|
+
- !ruby/object:Gem::Version
|
240
|
+
version: '0.7'
|
220
241
|
- - ">="
|
221
242
|
- !ruby/object:Gem::Version
|
222
243
|
version: 0.7.1
|
@@ -224,6 +245,9 @@ dependencies:
|
|
224
245
|
prerelease: false
|
225
246
|
version_requirements: !ruby/object:Gem::Requirement
|
226
247
|
requirements:
|
248
|
+
- - "~>"
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '0.7'
|
227
251
|
- - ">="
|
228
252
|
- !ruby/object:Gem::Version
|
229
253
|
version: 0.7.1
|