crashbreak 1.0.14 → 1.0.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 904203ea7ed2cd94f8d54f6284cd35e2a4fb8ebd
4
- data.tar.gz: f020c5add4fd7dbf4bb64962417d019c57544335
3
+ metadata.gz: 74e84b99a284bce15c89b8a7c540651735e57e54
4
+ data.tar.gz: 7e89937326e1d084d7963e457d7dcfad3d533374
5
5
  SHA512:
6
- metadata.gz: 2362b171d9a7d138aef122f2a23000c97b48f9db5639323f95447fd5c46b6fce620a27cff8529fcc3f8247a535ddb223f2ac015abbb2aafb3158fe69ef4b408a
7
- data.tar.gz: 87d5b065264b13b7852ed3a44bbdb5dd54383bd65b5eb1d3fbb30f0e2f33de934b10e64131f0824000269d893d8544d8261d4bd08b6f99247497219839fc9ad0
6
+ metadata.gz: f377660ef75f2a7a1bd13e591b2b8b482c7a820aff2eb4afff78ba5c80a91d12e28237f362e4093b88e5ba356ce2cf923b3ef5c98d6ef5f035f73a91c80dfc08
7
+ data.tar.gz: 6746333573e47834aa54d3a44d9d41e0af407b18370b0e45a4f68f33ab299170b657b06e25d693340e89f7e8e5f06b48dd14854cd6f53ac4bec1a7d22635a45f
@@ -1,3 +1,3 @@
1
1
  module Crashbreak
2
- VERSION = '1.0.14'
2
+ VERSION = '1.0.15'
3
3
  end
@@ -1,17 +1,19 @@
1
- class RequestDumper < Crashbreak::BasicFormatter
2
- def dump
3
- sanitized_request_hash
4
- end
1
+ module Crashbreak
2
+ class RequestDumper < Crashbreak::BasicFormatter
3
+ def dump
4
+ sanitized_request_hash
5
+ end
5
6
 
6
- private
7
+ private
7
8
 
8
- def sanitized_request_hash
9
- {}.tap do |sanitized_request_hash|
10
- request_hash.each{|key, value| sanitized_request_hash[key] = value.to_s }
9
+ def sanitized_request_hash
10
+ {}.tap do |sanitized_request_hash|
11
+ request_hash.each{|key, value| sanitized_request_hash[key] = value.to_s }
12
+ end
11
13
  end
12
- end
13
14
 
14
- def request_hash
15
- request.env
15
+ def request_hash
16
+ request.env
17
+ end
16
18
  end
17
19
  end
@@ -2,7 +2,7 @@ require_relative 'test/test_helper.rb'
2
2
 
3
3
  class ErrorRequestTest < ActionDispatch::IntegrationTest
4
4
  def setup
5
- @restorers_data = StateRestorer.new('<%= error_id %>').restore
5
+ @restorers_data = Crashbreak::StateRestorer.new('<%= error_id %>').restore
6
6
  @request_parser = Crashbreak::RequestParser.new @restorers_data[:request]
7
7
  end
8
8
 
@@ -1,6 +1,6 @@
1
1
  describe 'error id: <%= error_id %>', type: :request do
2
2
 
3
- let(:restorers_data) { StateRestorer.new('<%= error_id %>').restore }
3
+ let(:restorers_data) { Crashbreak::StateRestorer.new('<%= error_id %>').restore }
4
4
  let(:request_parser) { Crashbreak::RequestParser.new restorers_data[:request] }
5
5
 
6
6
  it 'sends request' do
@@ -1,9 +1,11 @@
1
- class RequestRestorer
2
- def initialize(request_data)
3
- @request_data = request_data
4
- end
1
+ module Crashbreak
2
+ class RequestRestorer
3
+ def initialize(request_data)
4
+ @request_data = request_data
5
+ end
5
6
 
6
- def restore
7
- @request_data
7
+ def restore
8
+ @request_data
9
+ end
8
10
  end
9
11
  end
@@ -1,37 +1,39 @@
1
- class StateRestorer
2
-
3
- def initialize(error_id)
4
- @error_id = error_id
5
- end
1
+ module Crashbreak
2
+ class StateRestorer
3
+ def initialize(error_id)
4
+ @error_id = error_id
5
+ end
6
6
 
7
- def restore
8
- {}.tap do |restorers_hash|
9
- restorers.each do |restorer|
10
- restorers_hash[key_name(restorer)] = restorer.new(dumper_data(restorer)).restore
7
+ def restore
8
+ {}.tap do |restorers_hash|
9
+ restorers.each do |restorer|
10
+ restorers_hash[key_name(restorer)] = restorer.new(dumper_data(restorer)).restore
11
+ end
11
12
  end
12
13
  end
13
- end
14
14
 
15
- private
15
+ private
16
16
 
17
- def dumpers_data
18
- @dumpers_data ||= Crashbreak::DumpersDataRepository.new(@error_id).dumpers_data
19
- end
17
+ def dumpers_data
18
+ @dumpers_data ||= Crashbreak::DumpersDataRepository.new(@error_id).dumpers_data
19
+ end
20
20
 
21
- def restorers
22
- dumpers_data.keys.map {|dumper_name| restorer_class_by_dumper_name(dumper_name)}
23
- end
21
+ def restorers
22
+ dumpers_data.keys.map {|dumper_name| restorer_class_by_dumper_name(dumper_name)}
23
+ end
24
24
 
25
- def restorer_class_by_dumper_name(dumper_name)
26
- dumper_name.gsub('Dumper', 'Restorer').constantize
27
- end
25
+ def restorer_class_by_dumper_name(dumper_name)
26
+ dumper_name.gsub('Dumper', 'Restorer').constantize
27
+ end
28
28
 
29
- def dumper_data(restorer)
30
- dumper_name = restorer.to_s.gsub('Restorer', 'Dumper')
31
- dumpers_data[dumper_name].merge('error_id' => @error_id)
32
- end
29
+ def dumper_data(restorer)
30
+ dumper_name = restorer.to_s.gsub('Restorer', 'Dumper')
31
+ dumpers_data[dumper_name].merge('error_id' => @error_id)
32
+ end
33
33
 
34
- def key_name(restorer)
35
- restorer.to_s.gsub('Restorer', '').underscore.to_sym
34
+ def key_name(restorer)
35
+ restorer.to_s.gsub('Restorer', '').underscore.to_sym
36
+ end
36
37
  end
37
- end
38
+
39
+ end
@@ -1,4 +1,4 @@
1
- describe RequestDumper do
1
+ describe Crashbreak::RequestDumper do
2
2
  subject { described_class.new }
3
3
 
4
4
  let(:example_request) { double(:request, env: Hash['REQUEST_URI' => 'example_uri']) }
@@ -12,7 +12,7 @@ describe 'Sending error report to server' do
12
12
  before(:each) do
13
13
  Crashbreak.configure.api_key = project_token
14
14
  Crashbreak.configure.error_serializers = [summary_formatter, Crashbreak::EnvironmentVariablesFormatter.new, TestErrorFormatter.new]
15
- Crashbreak.configure.dumpers = [RequestDumper.new]
15
+ Crashbreak.configure.dumpers = [Crashbreak::RequestDumper.new]
16
16
 
17
17
  allow(crashing_app).to receive(:call).and_raise(example_error)
18
18
  allow(example_error).to receive(:backtrace).and_return(%w(example backtrace))
@@ -39,7 +39,7 @@ describe 'Sending error report to server' do
39
39
  with(body: dumpers_data.to_json).to_return(status: 200)
40
40
  end
41
41
 
42
- let(:dumpers_data) { Hash[error_report: { dumpers_data: { 'RequestDumper' => example_request.env } }] }
42
+ let(:dumpers_data) { Hash[error_report: { dumpers_data: { 'Crashbreak::RequestDumper' => example_request.env } }] }
43
43
 
44
44
  it 'sends error report on exception' do
45
45
  expect{ catching_middleware.call(env) }.to raise_error(TestError)
@@ -36,11 +36,11 @@ describe Crashbreak::ExceptionNotifier do
36
36
 
37
37
  context 'with dumpers' do
38
38
  let(:dumpers_hash) do
39
- { dumpers_data: { 'RequestDumper' => { request: 'example_request_data' } } }
39
+ { dumpers_data: { 'Crashbreak::RequestDumper' => { request: 'example_request_data' } } }
40
40
  end
41
41
 
42
42
  before(:each) do
43
- allow_any_instance_of(described_class).to receive(:dumpers).and_return([RequestDumper.new])
43
+ allow_any_instance_of(described_class).to receive(:dumpers).and_return([Crashbreak::RequestDumper.new])
44
44
  end
45
45
 
46
46
  it 'sends dump data' do
@@ -1,4 +1,4 @@
1
- describe StateRestorer do
1
+ describe Crashbreak::StateRestorer do
2
2
  subject { described_class.new error_id }
3
3
  let(:error_id) { 1 }
4
4
  let(:project_token) { 'example_project_token'}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crashbreak
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.14
4
+ version: 1.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Janeczek