pliny 0.20.2 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pliny/config_helpers.rb +5 -0
- data/lib/pliny/error_reporters/rollbar.rb +5 -3
- data/lib/pliny/middleware/rescue_errors.rb +2 -1
- data/lib/pliny/version.rb +1 -1
- data/lib/template/.ruby-version +1 -1
- data/lib/template/Gemfile +2 -2
- data/spec/error_reporters/rollbar_spec.rb +56 -0
- data/spec/middleware/rescue_errors_spec.rb +11 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a17e76a1800d179c9271ab0bf1b67dad549e7fed
|
4
|
+
data.tar.gz: badd208c4a7ad6e3b58735cd3d8edde7b485bab2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc9b96fad0c7fca0f0ced728dc148cda49ac22b330cb45614b0068ee166ed528ada6d8f331bafbf6be5ac340ac6cd6d569e97b6c83270684b82da814e59cd4a6
|
7
|
+
data.tar.gz: 6b7f260a8c291e1435920ba61d6ac5aa63246b1efc3dffbbc01b2adb1c2cec8f61954096b71780ed3b0ed1d9fe5b1422dd6d94bb22067c696b38ac9248d5e41b
|
data/lib/pliny/config_helpers.rb
CHANGED
@@ -96,6 +96,11 @@ module Pliny
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
+
# DEPRECATED: ConfigHelpers was a slightly more primitive version
|
100
|
+
# of CastingConfigHelpers above that didn't contain any of the
|
101
|
+
# latter's features around typing. It's been left here for
|
102
|
+
# backwards compatibility in apps based on old templates that may
|
103
|
+
# be using it.
|
99
104
|
module ConfigHelpers
|
100
105
|
def optional(*attrs)
|
101
106
|
attrs.each do |attr|
|
@@ -18,9 +18,11 @@ module Pliny
|
|
18
18
|
private
|
19
19
|
|
20
20
|
def fetch_scope(context:, rack_env:)
|
21
|
-
{
|
22
|
-
|
23
|
-
|
21
|
+
scope = {}
|
22
|
+
if rack_env.respond_to?(:body)
|
23
|
+
scope[:request] = proc { extract_request_data_from_rack(rack_env) }
|
24
|
+
end
|
25
|
+
scope
|
24
26
|
rescue Exception => e
|
25
27
|
report_exception_to_rollbar(rack_env, e)
|
26
28
|
raise
|
@@ -3,6 +3,7 @@ module Pliny::Middleware
|
|
3
3
|
def initialize(app, options = {})
|
4
4
|
@app = app
|
5
5
|
@raise = options[:raise]
|
6
|
+
@message = options[:message]
|
6
7
|
end
|
7
8
|
|
8
9
|
def call(env)
|
@@ -13,7 +14,7 @@ module Pliny::Middleware
|
|
13
14
|
raise if @raise
|
14
15
|
|
15
16
|
Pliny::ErrorReporters.notify(e, rack_env: env)
|
16
|
-
Pliny::Errors::Error.render(Pliny::Errors::InternalServerError.new)
|
17
|
+
Pliny::Errors::Error.render(Pliny::Errors::InternalServerError.new(@message))
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
data/lib/pliny/version.rb
CHANGED
data/lib/template/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.3
|
data/lib/template/Gemfile
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "rollbar"
|
3
|
+
require "pliny/error_reporters/rollbar"
|
4
|
+
|
5
|
+
describe Pliny::ErrorReporters::Rollbar do
|
6
|
+
subject(:reporter) { described_class.new }
|
7
|
+
|
8
|
+
describe "#notify" do
|
9
|
+
let(:exception) { StandardError.new("Something went wrong") }
|
10
|
+
let(:context) { {} }
|
11
|
+
let(:rack_env) { double(:rack_env, body: StringIO.new) }
|
12
|
+
|
13
|
+
subject(:notify) do
|
14
|
+
reporter.notify(exception, context: context, rack_env: rack_env)
|
15
|
+
end
|
16
|
+
|
17
|
+
before do
|
18
|
+
allow(::Rollbar).to receive(:reset_notifier!)
|
19
|
+
allow(::Rollbar).to receive(:scoped).and_yield
|
20
|
+
allow(reporter).to receive(:report_exception_to_rollbar)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "resets the rollbar notifier" do
|
24
|
+
notify
|
25
|
+
expect(::Rollbar).to have_received(:reset_notifier!).once
|
26
|
+
end
|
27
|
+
|
28
|
+
it "scopes the rollbar notification" do
|
29
|
+
notify
|
30
|
+
expect(::Rollbar).to have_received(:scoped).once.with(hash_including(
|
31
|
+
request: instance_of(Proc)
|
32
|
+
))
|
33
|
+
end
|
34
|
+
|
35
|
+
it "delegates to #report_exception_to_rollbar" do
|
36
|
+
notify
|
37
|
+
expect(reporter).to have_received(:report_exception_to_rollbar)
|
38
|
+
.once.with(rack_env, exception)
|
39
|
+
end
|
40
|
+
|
41
|
+
context "given an empty rack_env" do
|
42
|
+
let(:rack_env) { {} }
|
43
|
+
|
44
|
+
it "reports to Rollbar with an empty scope" do
|
45
|
+
notify
|
46
|
+
expect(Rollbar).to have_received(:scoped).once.with({})
|
47
|
+
end
|
48
|
+
|
49
|
+
it "delegates to #report_exception_to_rollbar" do
|
50
|
+
notify
|
51
|
+
expect(reporter).to have_received(:report_exception_to_rollbar)
|
52
|
+
.once.with(rack_env, exception)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -43,12 +43,22 @@ describe Pliny::Middleware::RescueErrors do
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
it "uses a custom error message with the message option" do
|
47
|
+
@app = new_rack_app(message: "Please stand by")
|
48
|
+
allow(Pliny::ErrorReporters).to receive(:notify)
|
49
|
+
get "/"
|
50
|
+
assert_equal 500, last_response.status
|
51
|
+
error_json = MultiJson.decode(last_response.body)
|
52
|
+
assert_equal "internal_server_error", error_json["id"]
|
53
|
+
assert_equal "Please stand by", error_json["message"]
|
54
|
+
end
|
55
|
+
|
46
56
|
private
|
47
57
|
|
48
58
|
def new_rack_app(options = {})
|
49
59
|
Rack::Builder.new do
|
50
60
|
use Rack::Lint
|
51
|
-
use Pliny::Middleware::RescueErrors, raise: options[:raise]
|
61
|
+
use Pliny::Middleware::RescueErrors, raise: options[:raise], message: options[:message]
|
52
62
|
run BadMiddleware.new
|
53
63
|
end
|
54
64
|
end
|
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.
|
4
|
+
version: 0.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandur Leach
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-12-
|
12
|
+
date: 2016-12-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -265,6 +265,20 @@ dependencies:
|
|
265
265
|
- - ">="
|
266
266
|
- !ruby/object:Gem::Version
|
267
267
|
version: '0'
|
268
|
+
- !ruby/object:Gem::Dependency
|
269
|
+
name: pry-byebug
|
270
|
+
requirement: !ruby/object:Gem::Requirement
|
271
|
+
requirements:
|
272
|
+
- - ">="
|
273
|
+
- !ruby/object:Gem::Version
|
274
|
+
version: '0'
|
275
|
+
type: :development
|
276
|
+
prerelease: false
|
277
|
+
version_requirements: !ruby/object:Gem::Requirement
|
278
|
+
requirements:
|
279
|
+
- - ">="
|
280
|
+
- !ruby/object:Gem::Version
|
281
|
+
version: '0'
|
268
282
|
- !ruby/object:Gem::Dependency
|
269
283
|
name: pg
|
270
284
|
requirement: !ruby/object:Gem::Requirement
|
@@ -445,6 +459,7 @@ files:
|
|
445
459
|
- spec/commands/updater_spec.rb
|
446
460
|
- spec/config_helpers_spec.rb
|
447
461
|
- spec/db_support_spec.rb
|
462
|
+
- spec/error_reporters/rollbar_spec.rb
|
448
463
|
- spec/error_reporters_spec.rb
|
449
464
|
- spec/errors_spec.rb
|
450
465
|
- spec/helpers/encode_spec.rb
|