crashbreak 1.0.19 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +39 -21
  3. data/lib/crashbreak.rb +20 -16
  4. data/lib/crashbreak/config/configurator.rb +5 -0
  5. data/lib/{dumpers → crashbreak/dumpers}/database_dumper.rb +5 -5
  6. data/lib/{dumpers → crashbreak/dumpers}/request_dumper.rb +3 -3
  7. data/lib/crashbreak/exception_notifier.rb +2 -2
  8. data/lib/crashbreak/repositories/base_repository.rb +9 -0
  9. data/lib/crashbreak/{deploys_repository.rb → repositories/deploys_repository.rb} +1 -3
  10. data/lib/crashbreak/{dumpers_data_repository.rb → repositories/dumpers_data_repository.rb} +1 -7
  11. data/lib/crashbreak/{exceptions_repository.rb → repositories/exceptions_repository.rb} +1 -7
  12. data/lib/{restorers → crashbreak/restorers}/database_restorer.rb +3 -3
  13. data/lib/{restorers → crashbreak/restorers}/request_restorer.rb +0 -0
  14. data/lib/{restorers → crashbreak/restorers}/state_restorer.rb +0 -1
  15. data/lib/crashbreak/{formatters/basic_information_formatter.rb → serializers/basic_information_serializer.rb} +1 -1
  16. data/lib/crashbreak/{formatters/basic_formatter.rb → serializers/basic_serializer.rb} +1 -1
  17. data/lib/crashbreak/{formatters/default_summary_formatter.rb → serializers/default_summary_serializer.rb} +1 -1
  18. data/lib/crashbreak/{formatters/environment_variables_formatter.rb → serializers/environment_variables_serializer.rb} +1 -1
  19. data/lib/crashbreak/{formatters/hash_formatter.rb → serializers/hash_serializer.rb} +1 -1
  20. data/lib/crashbreak/{formatters/summary_formatter.rb → serializers/summary_serializer.rb} +1 -1
  21. data/lib/crashbreak/tiny_exception_notifier.rb +1 -1
  22. data/lib/crashbreak/version.rb +1 -1
  23. data/lib/generators/crashbreak/templates/crashbreak.rb +23 -3
  24. data/spec/features/sending_error_report_spec.rb +4 -4
  25. data/spec/{dumpers → lib/dumpers}/request_dumper_spec.rb +0 -0
  26. data/spec/lib/exception_notifier_spec.rb +13 -1
  27. data/spec/{restorers → lib/restorers}/state_restorer_spec.rb +0 -0
  28. data/spec/lib/{formatters/basic_formatter_spec.rb → serializers/basic_serializer_spec.rb} +1 -1
  29. data/spec/lib/{formatters/default_summary_formatter_spec.rb → serializers/default_summary_serializer_spec.rb} +1 -1
  30. data/spec/lib/{formatters/group_formatter_spec.rb → serializers/group_serializer_spec.rb} +3 -3
  31. data/spec/lib/serializers/summary_serializer_spec.rb +13 -0
  32. data/spec/support/test_error_serializer.rb +9 -0
  33. metadata +31 -30
  34. data/spec/lib/formatters/summary_formatter_spec.rb +0 -13
  35. data/spec/support/test_error_formatter.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 971975eddcb1b2a1a941794b53992da1d716e7b5
4
- data.tar.gz: e49b7db2329340b13d4bdc998b9b22b0c97e69ca
3
+ metadata.gz: 48536ecac8f93671f2dfd485c9bf3f9ec2f861f5
4
+ data.tar.gz: 06fb15138866c07a1dbf18ebc4dade65307f22bf
5
5
  SHA512:
6
- metadata.gz: d11c63982a8658a1e43af247cde68b448dac35a78ee291e60c85156326e2c482bfa71bf41915616e1dbec5db47620b37f352ccd9b29c4eebec4cee674865c4ca
7
- data.tar.gz: 9a830cb9aab90537e8dee44b2aa6fb78b0c7105324cbda658b6db4f6178874af84f2e95d5f9b68a789bcba130e05429a0ac2f63894c1fcc888f790e88803dbff
6
+ metadata.gz: bd437a3eb1cd4fa80ab822e7dff89ffa0a989a51ae168d13e8fbfcb392ecb6802626f69a3f8719dd60b9151d0972a888d02c5fb69396b38ab0000a5f2f260fc8
7
+ data.tar.gz: 50af0658221b4bb536037fd1398b4eb2168918b155c28a0888e44c6d33fd3daeb02524ac36caa16686278bad59d1c09f1f428b4fee195fc29d521499c3efcc70
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Crashbreak [![Version](http://img.shields.io/gem/v/crashbreak.svg) ](https://rubygems.org/gems/crashbreak) [![Build Status](https://travis-ci.org/crashbreak/crashbreak.svg?branch=master)](https://travis-ci.org/crashbreak/crashbreak) [![Code Climate](https://codeclimate.com/github/crashbreak/crashbreak/badges/gpa.svg)](https://codeclimate.com/github/crashbreak/crashbreak)
1
+ # CrashBreak [![Version](http://img.shields.io/gem/v/crashbreak.svg) ](https://rubygems.org/gems/crashbreak) [![Build Status](https://travis-ci.org/crashbreak/crashbreak.svg?branch=master)](https://travis-ci.org/crashbreak/crashbreak) [![Code Climate](https://codeclimate.com/github/crashbreak/crashbreak/badges/gpa.svg)](https://codeclimate.com/github/crashbreak/crashbreak)
2
2
 
3
- Crashbreak gem is a exception notifier for integration with [crashbreak.com](http://crashbreak.com) for ruby apllications.
3
+ CrashBreak gem is the exception notifier for integration with [crashbreak.com](http://crashbreak.com) for ruby applications.
4
4
 
5
5
  ## Rails Installation
6
6
 
@@ -12,17 +12,17 @@ And then execute from your rails root:
12
12
 
13
13
  $ bundle
14
14
 
15
- Generate crashbreak initializer:
15
+ Generate CrashBreak initializer:
16
16
 
17
17
  rails generate crashbreak:install your_api_key
18
18
 
19
- If you want to use database dumper add this lines to datbase.yml file:
19
+ If you want to use database dumper add those lines to datbase.yml file:
20
20
 
21
21
  crashbreak_test:
22
22
  <<: *default
23
23
  database: crashbreak-test
24
24
 
25
- ## Example crashbreak.rb (initializer)
25
+ ## Example of crashbreak.rb (initializer)
26
26
  [Rails example](https://github.com/crashbreak/heroku-rails-example/blob/master/config/initializers/crashbreak.rb)
27
27
 
28
28
  [Grape example](https://github.com/crashbreak/grape_example/blob/master/crashbreak.rb)
@@ -33,10 +33,10 @@ If you want to use database dumper add this lines to datbase.yml file:
33
33
  Each serializer converts an exception to JSON request, by customizing this you can create your own exception page in crashbreak.com. There are two types of serializers - summary serializer and hash serializer.
34
34
 
35
35
  #### Summary serializer
36
- Summary serializer specify the first tab on exception show view and data included in email. This is an example of default summary formatter:
36
+ Summary serializer specifies the first tab on the exception show view and data included in email. This is an example of default summary serializer:
37
37
 
38
38
  ```ruby
39
- class DefaultSummaryFormatter < SummaryFormatter
39
+ class DefaultSummarySerializer < SummarySerializer
40
40
  def summary
41
41
  {
42
42
  action: request.env['PATH_INFO'],
@@ -50,10 +50,10 @@ end
50
50
  ```
51
51
 
52
52
  #### Hash serializer
53
- By using hash serializer you can serialize your custom data into hash and display it in new tab on our web page. For example this is a ```EnvironmentVariablesSerializer```:
53
+ By using hash serializer you can serialize your custom data into hash and display it in a new tab on our web page. For example this is the ```EnvironmentVariablesSerializer```:
54
54
 
55
55
  ```ruby
56
- class EnvironmentVariablesFormatter < HashFormatter
56
+ class EnvironmentVariablesSerializer < HashSerializer
57
57
  hash_name :environment
58
58
 
59
59
  def hash_value
@@ -61,10 +61,10 @@ class EnvironmentVariablesFormatter < HashFormatter
61
61
  end
62
62
  end
63
63
  ```
64
- It adds new tab called "Environment" with all ENV variables displayed in "key: value" format.
64
+ It adds a new tab called "Environment" with all ENV variables displayed in "key: value" format.
65
65
 
66
66
  ### Dumpers (and restorers)
67
- Dumpers are responsible for dump your system and prepare for restore by simulate request test. There are two very important dumpers - request dumper and database dumper. Each dumper is connected to specify restorer (eg ```RequestDumper``` to ```RequestRestorer```) to dump some part of system and restore it in crashbreak test env. This is a part of database dumper:
67
+ Dumpers are responsible for dumping your system and preparing for restoration by a request test. There are two very important dumpers - request dumper and database dumper. Each dumper is connected to specific restorer (eg ```RequestDumper``` to ```RequestRestorer```) to dump some part of the system and restore it in the CrashBreak test env. This is a part of the database dumper:
68
68
 
69
69
  ```ruby
70
70
  # Crashbreak::DatabaseDumper
@@ -74,7 +74,7 @@ def dump
74
74
  upload_dump
75
75
  remove_locally_dump
76
76
 
77
- { file_name: aws_file_name } # only this hash is stored by crashbreak
77
+ { file_name: aws_file_name } # only this hash is stored by CrashBreak
78
78
  end
79
79
 
80
80
  # Crashbreak::DatabaseRestorer
@@ -88,10 +88,10 @@ end
88
88
  ```
89
89
 
90
90
  ### Predefined settings
91
- Dumping your database or any other part of the system requires config for dumpers, for example DatabaseDumper needs a command for dump db (e.g pg_dump for postgresql). There is a file with all predefined settings that you can use if you have standard setup. Please check [this file](https://github.com/crashbreak/crashbreak/blob/master/lib/crashbreak/predefined_settings.rb). For be sure that all commands run corretcly on your staging server please run it manually first and see the result.
91
+ Dumping your database or any other part of the system requires configuration for dumpers, for example DatabaseDumper needs a command for dump db (e.g pg_dump for postgresql). There is a file with all predefined settings that you can use if you have standard setup. Please check [this file](https://github.com/crashbreak/crashbreak/blob/master/lib/crashbreak/predefined_settings.rb). To be sure that all commands run correctly on your staging server please run it manually first and see the result.
92
92
 
93
93
  ### Exception notifier
94
- Dumping your system can take some time, in order to improve request response you can use different exception notifier.
94
+ Dumping your system can take some time. In order to improve request response you can use different exception notifier.
95
95
 
96
96
  ```ruby
97
97
  config.exception_notifier = Crashbreak::ExceptionNotifier.new # default notifier (one thread)
@@ -100,23 +100,24 @@ config.exception_notifier = Crashbreak::ForkExceptionNotifier.new # creates for
100
100
 
101
101
  ## Integrations
102
102
 
103
- ### Github
104
- Crashbreak can automaticaly creates branch with failing request for exception that occurs on your staging / production server. Your part of the job is just pull, run the test and fix the bug!
103
+ ### GitHub
104
+ CrashBreak can automatically create a branch with a failing request for an exception that occurs on your staging / production server. Your part of the job is just to pull, run the test and fix the bug!
105
105
  ```ruby
106
+ config.github_integration = true
106
107
  config.github_login = ENV['GITHUB_USER']
107
108
  config.github_password = ENV['GITHUB_PASSWORD']
108
109
  config.github_repo_name = 'crashbreak/heroku-rails-example'
109
110
  ```
110
111
 
111
112
  ### CI sever
112
- With CI server you can automatically test your fix on external server. If tests succeed just run crashbreak rake task to resolve the error in our system. If you are using the github integration, the rake task can also create a pull request from branch with error to master.
113
+ With the CI server you can automatically test your fix on an external server. If tests succeed, just run the CrashBreak rake task to resolve the error in our system. If you are using the GitHub integration, the rake task can also create a pull request from a branch with error to a master branch.
113
114
  ```ruby
114
115
  after_success:
115
116
  - bundle exec rake crashbreak:resolve_error
116
117
  ```
117
118
 
118
119
  ### AWS
119
- Do not send any private / sensitive data to crashbreak, instead of this use your AWS to store it and send us only url or file name. AWS is required for database dumper and restorer.
120
+ Do not send any private / sensitive data to CrashBreak. Instead of this use your AWS to store it and send us only url or a file name. AWS is required for database dumper and restorer.
120
121
  ```ruby
121
122
  config.dumper_options = {
122
123
  aws_bucket_name: 'cb-test-app',
@@ -126,15 +127,32 @@ config.dumper_options = {
126
127
  }
127
128
  ```
128
129
 
129
- ## Adapt crashbreak to your system and flow!
130
+ ### Deploy tracking
131
+ #### Capistrano 3
132
+ ```ruby
133
+ # Capfile
134
+ require 'crashbreak/capistrano3'
135
+
136
+ # deploy.rb
137
+ set :crashbreak_token, ENV['CRASHBREAK_TOKEN']
138
+ after 'deploy:finished', 'crashbreak:deploy'
139
+ ```
140
+
141
+ #### Heroku
142
+ You can track deploys by enabling free heroku addon:
143
+ ```
144
+ heroku addons:add deployhooks:http --url="http://www.crashbreak.com/api/projects/YOU_API_KEY/deploys/?environment=production"
145
+ ```
146
+
147
+ ## Adapt CrashBreak to your system and flow!
130
148
  Read more about flow and extensions [here](http://www.crashbreak.com/how_we_use_crashbreak/).
131
149
 
132
150
  Create your own plugin and improve current functionality - [become a collaborator!](http://www.crashbreak.com/extensions#contributing)
133
151
 
134
152
  ### Request store
135
- Crashbreak uses [request store gem](https://github.com/steveklabnik/request_store) to store data and pass it to serializers and dumpers. By default it stores controller and exception instance and request object but you can add more.
153
+ CrashBreak uses [request store gem](https://github.com/steveklabnik/request_store) to store data and pass it to serializers and dumpers. By default it stores controller and exception instance and request object but you can add more.
136
154
 
137
- #### All crashbreak options can be found [here](https://github.com/crashbreak/crashbreak/blob/master/lib/crashbreak/config/configurator.rb).
155
+ #### All CrashBreak options can be found [here](https://github.com/crashbreak/crashbreak/blob/master/lib/crashbreak/config/configurator.rb).
138
156
 
139
157
  ## Contributing
140
158
 
@@ -5,18 +5,7 @@ require 'aws-sdk'
5
5
 
6
6
  require 'crashbreak/version'
7
7
  require 'crashbreak/exception_notifier'
8
- require 'crashbreak/formatters/basic_formatter'
9
- require 'crashbreak/formatters/summary_formatter'
10
- require 'crashbreak/formatters/hash_formatter'
11
- require 'crashbreak/formatters/basic_information_formatter'
12
- require 'crashbreak/formatters/environment_variables_formatter'
13
- require 'crashbreak/formatters/default_summary_formatter'
14
- require 'crashbreak/config/configurator'
15
- require 'crashbreak/config/configurable'
16
8
  require 'crashbreak/exception_catcher_middleware'
17
- require 'crashbreak/exceptions_repository'
18
- require 'crashbreak/deploys_repository'
19
- require 'crashbreak/dumpers_data_repository'
20
9
  require 'crashbreak/request_parser'
21
10
  require 'crashbreak/github_integration_service'
22
11
  require 'crashbreak/AWS'
@@ -24,12 +13,27 @@ require 'crashbreak/tiny_exception_notifier'
24
13
  require 'crashbreak/fork_exception_notifier'
25
14
  require 'crashbreak/predefined_settings'
26
15
 
27
- require 'dumpers/database_dumper'
28
- require 'dumpers/request_dumper'
16
+ require 'crashbreak/serializers/basic_serializer'
17
+ require 'crashbreak/serializers/summary_serializer'
18
+ require 'crashbreak/serializers/hash_serializer'
19
+ require 'crashbreak/serializers/basic_information_serializer'
20
+ require 'crashbreak/serializers/environment_variables_serializer'
21
+ require 'crashbreak/serializers/default_summary_serializer'
22
+
23
+ require 'crashbreak/config/configurator'
24
+ require 'crashbreak/config/configurable'
25
+
26
+ require 'crashbreak/repositories/base_repository'
27
+ require 'crashbreak/repositories/exceptions_repository'
28
+ require 'crashbreak/repositories/deploys_repository'
29
+ require 'crashbreak/repositories/dumpers_data_repository'
30
+
31
+ require 'crashbreak/dumpers/database_dumper'
32
+ require 'crashbreak/dumpers/request_dumper'
29
33
 
30
- require 'restorers/database_restorer'
31
- require 'restorers/state_restorer'
32
- require 'restorers/request_restorer'
34
+ require 'crashbreak/restorers/database_restorer'
35
+ require 'crashbreak/restorers/state_restorer'
36
+ require 'crashbreak/restorers/request_restorer'
33
37
 
34
38
  require 'crashbreak/railtie' if defined?(Rails::Railtie)
35
39
 
@@ -12,6 +12,7 @@ module Crashbreak
12
12
  attr_accessor :request_spec_run_command
13
13
  attr_accessor :project_root
14
14
 
15
+ attr_accessor :github_integration
15
16
  attr_accessor :github_login
16
17
  attr_accessor :github_password
17
18
  attr_accessor :github_repo_name
@@ -42,6 +43,10 @@ module Crashbreak
42
43
  @request_spec_template_path ||= "#{Crashbreak.root}/lib/generators/crashbreak/templates/rspec_test.rb"
43
44
  end
44
45
 
46
+ def github_integration
47
+ @github_integration ||= false
48
+ end
49
+
45
50
  def github_development_branch
46
51
  @github_development_branch ||= 'master'
47
52
  end
@@ -1,7 +1,7 @@
1
1
  require 'fileutils'
2
2
 
3
3
  module Crashbreak
4
- class DatabaseDumper < BasicFormatter
4
+ class DatabaseDumper < BasicSerializer
5
5
  include Crashbreak::AWS
6
6
 
7
7
  def dump
@@ -21,7 +21,7 @@ module Crashbreak
21
21
  end
22
22
 
23
23
  def dump_database
24
- system(gsub_error_id(dump_command))
24
+ system(dump_command)
25
25
  end
26
26
 
27
27
  def upload_dump
@@ -37,14 +37,14 @@ module Crashbreak
37
37
  end
38
38
 
39
39
  def dump_location
40
- gsub_error_id(Crashbreak.configure.dumper_options[:dump_location])
40
+ inject_error_id(Crashbreak.configure.dumper_options[:dump_location])
41
41
  end
42
42
 
43
43
  def dump_command
44
- Crashbreak.configure.dumper_options[:dump_command]
44
+ inject_error_id(Crashbreak.configure.dumper_options[:dump_command])
45
45
  end
46
46
 
47
- def gsub_error_id(text)
47
+ def inject_error_id(text)
48
48
  text.gsub(':error_id:', error_id)
49
49
  end
50
50
 
@@ -1,12 +1,12 @@
1
1
  module Crashbreak
2
- class RequestDumper < Crashbreak::BasicFormatter
2
+ class RequestDumper < Crashbreak::BasicSerializer
3
3
  def dump
4
- sanitized_request_hash
4
+ sanitize_request_hash
5
5
  end
6
6
 
7
7
  private
8
8
 
9
- def sanitized_request_hash
9
+ def sanitize_request_hash
10
10
  {}.tap do |sanitized_request_hash|
11
11
  request_hash.each{|key, value| sanitized_request_hash[key] = value.to_s }
12
12
  end
@@ -6,7 +6,7 @@ module Crashbreak
6
6
  if created_error_is_unique?
7
7
  dump_system_and_update_report
8
8
 
9
- GithubIntegrationService.new(server_response).push_test if Crashbreak.configure.github_repo_name.present?
9
+ GithubIntegrationService.new(server_response).push_test if Crashbreak.configure.github_integration
10
10
  end
11
11
  end
12
12
 
@@ -35,7 +35,7 @@ module Crashbreak
35
35
  end
36
36
 
37
37
  def serializers
38
- [BasicInformationFormatter.new] + Crashbreak.configure.error_serializers
38
+ [BasicInformationSerializer.new] + Crashbreak.configure.error_serializers
39
39
  end
40
40
 
41
41
  def exceptions_repository
@@ -0,0 +1,9 @@
1
+ module Crashbreak
2
+ class BaseRepository
3
+ BASE_URL = 'https://crashbreak.herokuapp.com/api'
4
+
5
+ def project_token
6
+ Crashbreak.configure.api_key
7
+ end
8
+ end
9
+ end
@@ -1,9 +1,7 @@
1
1
  require 'json'
2
2
 
3
3
  module Crashbreak
4
- class DeploysRepository
5
- BASE_URL = 'http://crashbreak.herokuapp.com/api'
6
-
4
+ class DeploysRepository < BaseRepository
7
5
  def initialize(project_token, deploy_hash)
8
6
  @project_token = project_token
9
7
  @deploy_hash = deploy_hash
@@ -1,7 +1,5 @@
1
1
  module Crashbreak
2
- class DumpersDataRepository
3
- BASE_URL = 'http://crashbreak.herokuapp.com/api'
4
-
2
+ class DumpersDataRepository < BaseRepository
5
3
  def initialize(error_id)
6
4
  @error_id = error_id
7
5
  end
@@ -26,9 +24,5 @@ module Crashbreak
26
24
  def request_url
27
25
  "#{BASE_URL}/projects/#{project_token}/errors/#{@error_id}/dumpers_data"
28
26
  end
29
-
30
- def project_token
31
- Crashbreak.configure.api_key
32
- end
33
27
  end
34
28
  end
@@ -1,7 +1,5 @@
1
1
  module Crashbreak
2
- class ExceptionsRepository
3
- BASE_URL = 'http://crashbreak.herokuapp.com/api'
4
-
2
+ class ExceptionsRepository < BaseRepository
5
3
  def create(error_report_hash)
6
4
  JSON.parse(post_request(error_report_hash).body)
7
5
  end
@@ -47,9 +45,5 @@ module Crashbreak
47
45
  def resolve_request_url(error_id)
48
46
  "#{BASE_URL}/projects/#{project_token}/errors/#{error_id}"
49
47
  end
50
-
51
- def project_token
52
- Crashbreak.configure.api_key
53
- end
54
48
  end
55
49
  end
@@ -46,7 +46,7 @@ module Crashbreak
46
46
  end
47
47
 
48
48
  def restore_command
49
- gsub_error_id(Crashbreak.configure.restorer_options[:restore_command])
49
+ inject_error_id(Crashbreak.configure.restorer_options[:restore_command])
50
50
  end
51
51
 
52
52
  def drop_test_database_command
@@ -58,10 +58,10 @@ module Crashbreak
58
58
  end
59
59
 
60
60
  def restore_location
61
- gsub_error_id(Crashbreak.configure.dumper_options[:dump_location])
61
+ inject_error_id(Crashbreak.configure.dumper_options[:dump_location])
62
62
  end
63
63
 
64
- def gsub_error_id(text)
64
+ def inject_error_id(text)
65
65
  text.gsub(':error_id:', @error_id)
66
66
  end
67
67
  end
@@ -35,5 +35,4 @@ module Crashbreak
35
35
  restorer.to_s.gsub('Crashbreak::', '').gsub('Restorer', '').underscore.to_sym
36
36
  end
37
37
  end
38
-
39
38
  end
@@ -1,5 +1,5 @@
1
1
  module Crashbreak
2
- class BasicInformationFormatter < BasicFormatter
2
+ class BasicInformationSerializer < BasicSerializer
3
3
  def serialize
4
4
  { name: exception.class.to_s, message: exception.message, backtrace: exception.backtrace, environment: ENV['RACK_ENV'] }
5
5
  end
@@ -1,5 +1,5 @@
1
1
  module Crashbreak
2
- class BasicFormatter
2
+ class BasicSerializer
3
3
 
4
4
  protected
5
5
 
@@ -1,5 +1,5 @@
1
1
  module Crashbreak
2
- class DefaultSummaryFormatter < SummaryFormatter
2
+ class DefaultSummarySerializer < SummarySerializer
3
3
  def summary
4
4
  {
5
5
  action: request.env['PATH_INFO'],
@@ -1,5 +1,5 @@
1
1
  module Crashbreak
2
- class EnvironmentVariablesFormatter < HashFormatter
2
+ class EnvironmentVariablesSerializer < HashSerializer
3
3
  hash_name :environment
4
4
 
5
5
  def hash_value
@@ -1,5 +1,5 @@
1
1
  module Crashbreak
2
- class HashFormatter < BasicFormatter
2
+ class HashSerializer < BasicSerializer
3
3
  class << self
4
4
  def hash_name(value)
5
5
  @hash_name = value
@@ -1,5 +1,5 @@
1
1
  module Crashbreak
2
- class SummaryFormatter < BasicFormatter
2
+ class SummarySerializer < BasicSerializer
3
3
  def serialize
4
4
  { summary: summary }
5
5
  end
@@ -8,7 +8,7 @@ module Crashbreak
8
8
  private
9
9
 
10
10
  def serializers
11
- [BasicInformationFormatter.new]
11
+ [BasicInformationSerializer.new]
12
12
  end
13
13
 
14
14
  def dumpers
@@ -1,3 +1,3 @@
1
1
  module Crashbreak
2
- VERSION = '1.0.19'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -1,6 +1,26 @@
1
1
  Crashbreak.configure do |config|
2
2
  config.api_key = '<%= token %>'
3
3
 
4
- # Specify what will be sent to the server by attaching own formatters.
5
- config.error_serializers = [Crashbreak::DefaultSummaryFormatter.new, Crashbreak::EnvironmentVariablesFormatter.new]
6
- end
4
+ # Use Crashbreak::ForkExceptionNotifier if you want to use fork for sending exception data.
5
+ config.exception_notifier = Crashbreak::ExceptionNotifier.new
6
+
7
+ # Serialize an exception in the best way for your project, add custom tabs, change default summary.
8
+ config.error_serializers = [Crashbreak::DefaultSummarySerializer.new, Crashbreak::EnvironmentVariablesSerializer.new]
9
+
10
+ # Specify dumpers list for future restoring process.
11
+ config.dumpers = [Crashbreak::RequestDumper.new, Crashbreak::DatabaseDumper.new]
12
+
13
+ # Config for all dumpers (aws is required for DatabaseDumper)
14
+ config.dumper_options = {
15
+ aws_bucket_name: 'bucket-name-here',
16
+ aws_region: 'us-east-1', # default: ENV['AWS_REGION']
17
+ aws_access_key_id: 'xxx', # default: ENV['AWS_ACCESS_KEY_ID']
18
+ aws_secret_access_key: 'xxx', # default: ENV['AWS_SECRET_ACCESS_KEY']
19
+ }
20
+
21
+ # Config for GitHub integration
22
+ config.github_integration = true
23
+ config.github_login = ENV['GITHUB_USER']
24
+ config.github_password = ENV['GITHUB_PASSWORD']
25
+ config.github_repo_name = ENV['GITHUB_REPO_NAME']
26
+ end
@@ -5,18 +5,18 @@ describe 'Sending error report to server' do
5
5
  let(:project_token) { 'example_project_token' }
6
6
  let(:example_error) { TestError.new }
7
7
  let(:example_request) { double(:example_request, env: { 'PATH_INFO' => 'example_action_name', 'REQUEST_URI' => 'url', 'HTTP_USER_AGENT' => 'agent' } )}
8
- let(:summary_formatter) { Crashbreak::DefaultSummaryFormatter.new }
8
+ let(:summary_serializer) { Crashbreak::DefaultSummarySerializer.new }
9
9
  let(:example_controller) { double(:example_controller) }
10
10
  let(:env) { Hash['action_controller.instance' => example_controller ]}
11
11
 
12
12
  before(:each) do
13
13
  Crashbreak.configure.api_key = project_token
14
- Crashbreak.configure.error_serializers = [summary_formatter, Crashbreak::EnvironmentVariablesFormatter.new, TestErrorFormatter.new]
14
+ Crashbreak.configure.error_serializers = [summary_serializer, Crashbreak::EnvironmentVariablesSerializer.new, Crashbreak::TestErrorSerializer.new]
15
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))
19
- allow_any_instance_of(Crashbreak::BasicFormatter).to receive(:request).and_return(example_request)
19
+ allow_any_instance_of(Crashbreak::BasicSerializer).to receive(:request).and_return(example_request)
20
20
  allow(Crashbreak.configurator).to receive(:ignored_environments).and_return([])
21
21
  end
22
22
 
@@ -30,7 +30,7 @@ describe 'Sending error report to server' do
30
30
  name: example_error.to_s, message: example_error.message, backtrace: example_error.backtrace, environment: 'test',
31
31
  summary: { action: example_request.env['PATH_INFO'], controller_name: example_controller.class.to_s,
32
32
  file: example_error.backtrace[0], url: example_request.env['REQUEST_URI'], user_agent: example_request.env['HTTP_USER_AGENT'] },
33
- additional_data: { environment: ENV.to_hash, test: { formatter: true } }
33
+ additional_data: { environment: ENV.to_hash, test: { example_key: true } }
34
34
  }
35
35
  end
36
36
 
@@ -81,10 +81,22 @@ describe Crashbreak::ExceptionNotifier do
81
81
  context 'github integration' do
82
82
  let(:error_hash) { Hash['id' => 1, 'deploy_revision' => 'test', 'similar' => false] }
83
83
 
84
- it 'passes error hash from request to github integration service' do
84
+ before(:each) do
85
+ Crashbreak.configure.github_integration = true
85
86
  Crashbreak.configure.github_repo_name = 'user/repo'
86
87
 
87
88
  allow_any_instance_of(Crashbreak::ExceptionsRepository).to receive(:create).and_return(error_hash)
89
+ end
90
+
91
+ it 'integrates with github only if user enabled integration' do
92
+ Crashbreak.configure.github_integration = false
93
+
94
+ expect_any_instance_of(Crashbreak::GithubIntegrationService).to_not receive(:initialize)
95
+
96
+ subject.notify
97
+ end
98
+
99
+ it 'passes error hash from request to github integration service' do
88
100
  expect_any_instance_of(Crashbreak::GithubIntegrationService).to receive(:initialize).with(error_hash)
89
101
 
90
102
  subject.notify
@@ -1,4 +1,4 @@
1
- describe Crashbreak::BasicFormatter do
1
+ describe Crashbreak::BasicSerializer do
2
2
  subject { described_class.new }
3
3
 
4
4
  let(:example_request) { double(:request) }
@@ -1,4 +1,4 @@
1
- describe Crashbreak::DefaultSummaryFormatter do
1
+ describe Crashbreak::DefaultSummarySerializer do
2
2
  subject { described_class.new }
3
3
 
4
4
  let(:example_request) { double(:request, env: request_env) }
@@ -1,5 +1,5 @@
1
- describe Crashbreak::HashFormatter do
2
- class TestHashFormatter < Crashbreak::HashFormatter
1
+ describe Crashbreak::HashSerializer do
2
+ class Crashbreak::TestHashSerialzier < Crashbreak::HashSerializer
3
3
  hash_name :example_group
4
4
 
5
5
  def hash_value
@@ -7,7 +7,7 @@ describe Crashbreak::HashFormatter do
7
7
  end
8
8
  end
9
9
 
10
- subject { TestHashFormatter.new }
10
+ subject { Crashbreak::TestHashSerialzier.new }
11
11
 
12
12
  it 'wraps hash in additional_data and group_name key' do
13
13
  expect(subject.serialize).to eq(additional_data: { example_group: subject.hash_value })
@@ -0,0 +1,13 @@
1
+ describe Crashbreak::SummarySerializer do
2
+ class Crashbreak::SummaryTestSerializer < Crashbreak::SummarySerializer
3
+ def summary
4
+ { example: 'true' }
5
+ end
6
+ end
7
+
8
+ subject { Crashbreak::SummaryTestSerializer.new }
9
+
10
+ it 'wraps summary hash' do
11
+ expect(subject.serialize).to eq(summary: subject.summary)
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ module Crashbreak
2
+ class TestErrorSerializer < Crashbreak::HashSerializer
3
+ hash_name :test
4
+
5
+ def hash_value
6
+ { example_key: true }
7
+ end
8
+ end
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crashbreak
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.19
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Janeczek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-04 00:00:00.000000000 Z
11
+ date: 2015-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -199,59 +199,60 @@ files:
199
199
  - lib/crashbreak/capistrano3.rb
200
200
  - lib/crashbreak/config/configurable.rb
201
201
  - lib/crashbreak/config/configurator.rb
202
- - lib/crashbreak/deploys_repository.rb
203
- - lib/crashbreak/dumpers_data_repository.rb
202
+ - lib/crashbreak/dumpers/database_dumper.rb
203
+ - lib/crashbreak/dumpers/request_dumper.rb
204
204
  - lib/crashbreak/exception_catcher_middleware.rb
205
205
  - lib/crashbreak/exception_notifier.rb
206
- - lib/crashbreak/exceptions_repository.rb
207
206
  - lib/crashbreak/fork_exception_notifier.rb
208
- - lib/crashbreak/formatters/basic_formatter.rb
209
- - lib/crashbreak/formatters/basic_information_formatter.rb
210
- - lib/crashbreak/formatters/default_summary_formatter.rb
211
- - lib/crashbreak/formatters/environment_variables_formatter.rb
212
- - lib/crashbreak/formatters/hash_formatter.rb
213
- - lib/crashbreak/formatters/summary_formatter.rb
214
207
  - lib/crashbreak/github_integration_service.rb
215
208
  - lib/crashbreak/predefined_settings.rb
216
209
  - lib/crashbreak/railtie.rb
210
+ - lib/crashbreak/repositories/base_repository.rb
211
+ - lib/crashbreak/repositories/deploys_repository.rb
212
+ - lib/crashbreak/repositories/dumpers_data_repository.rb
213
+ - lib/crashbreak/repositories/exceptions_repository.rb
217
214
  - lib/crashbreak/request_parser.rb
215
+ - lib/crashbreak/restorers/database_restorer.rb
216
+ - lib/crashbreak/restorers/request_restorer.rb
217
+ - lib/crashbreak/restorers/state_restorer.rb
218
+ - lib/crashbreak/serializers/basic_information_serializer.rb
219
+ - lib/crashbreak/serializers/basic_serializer.rb
220
+ - lib/crashbreak/serializers/default_summary_serializer.rb
221
+ - lib/crashbreak/serializers/environment_variables_serializer.rb
222
+ - lib/crashbreak/serializers/hash_serializer.rb
223
+ - lib/crashbreak/serializers/summary_serializer.rb
218
224
  - lib/crashbreak/tiny_exception_notifier.rb
219
225
  - lib/crashbreak/version.rb
220
- - lib/dumpers/database_dumper.rb
221
- - lib/dumpers/request_dumper.rb
222
226
  - lib/generators/crashbreak/install_generator.rb
223
227
  - lib/generators/crashbreak/templates/crashbreak.rb
224
228
  - lib/generators/crashbreak/templates/minitest_test.rb
225
229
  - lib/generators/crashbreak/templates/rspec_test.rb
226
230
  - lib/generators/crashbreak/test_generator.rb
227
- - lib/restorers/database_restorer.rb
228
- - lib/restorers/request_restorer.rb
229
- - lib/restorers/state_restorer.rb
230
231
  - lib/tasks/crashbreak.cap
231
232
  - lib/tasks/crashbreak.rake
232
- - spec/dumpers/request_dumper_spec.rb
233
233
  - spec/features/sending_error_report_spec.rb
234
234
  - spec/lib/config/configurable_spec.rb
235
235
  - spec/lib/config/configurator_spec.rb
236
236
  - spec/lib/deploys_repository_spec.rb
237
+ - spec/lib/dumpers/request_dumper_spec.rb
237
238
  - spec/lib/dumpers_data_repository_spec.rb
238
239
  - spec/lib/exception_catcher_middleware_spec.rb
239
240
  - spec/lib/exception_notifier_spec.rb
240
241
  - spec/lib/exceptions_repository_spec.rb
241
- - spec/lib/formatters/basic_formatter_spec.rb
242
- - spec/lib/formatters/default_summary_formatter_spec.rb
243
- - spec/lib/formatters/group_formatter_spec.rb
244
- - spec/lib/formatters/summary_formatter_spec.rb
245
242
  - spec/lib/generators/install_generator_spec.rb
246
243
  - spec/lib/generators/test_generator_spec.rb
247
244
  - spec/lib/github_integration_service_spec.rb
248
245
  - spec/lib/request_parser_spec.rb
249
- - spec/restorers/state_restorer_spec.rb
246
+ - spec/lib/restorers/state_restorer_spec.rb
247
+ - spec/lib/serializers/basic_serializer_spec.rb
248
+ - spec/lib/serializers/default_summary_serializer_spec.rb
249
+ - spec/lib/serializers/group_serializer_spec.rb
250
+ - spec/lib/serializers/summary_serializer_spec.rb
250
251
  - spec/spec_helper.rb
251
252
  - spec/support/crashbreak_config.rb
252
253
  - spec/support/rspec_config.rb
253
254
  - spec/support/test_error.rb
254
- - spec/support/test_error_formatter.rb
255
+ - spec/support/test_error_serializer.rb
255
256
  homepage: http://crashbreak.com
256
257
  licenses:
257
258
  - MIT
@@ -277,27 +278,27 @@ signing_key:
277
278
  specification_version: 4
278
279
  summary: Take a break from crashes!
279
280
  test_files:
280
- - spec/dumpers/request_dumper_spec.rb
281
281
  - spec/features/sending_error_report_spec.rb
282
282
  - spec/lib/config/configurable_spec.rb
283
283
  - spec/lib/config/configurator_spec.rb
284
284
  - spec/lib/deploys_repository_spec.rb
285
+ - spec/lib/dumpers/request_dumper_spec.rb
285
286
  - spec/lib/dumpers_data_repository_spec.rb
286
287
  - spec/lib/exception_catcher_middleware_spec.rb
287
288
  - spec/lib/exception_notifier_spec.rb
288
289
  - spec/lib/exceptions_repository_spec.rb
289
- - spec/lib/formatters/basic_formatter_spec.rb
290
- - spec/lib/formatters/default_summary_formatter_spec.rb
291
- - spec/lib/formatters/group_formatter_spec.rb
292
- - spec/lib/formatters/summary_formatter_spec.rb
293
290
  - spec/lib/generators/install_generator_spec.rb
294
291
  - spec/lib/generators/test_generator_spec.rb
295
292
  - spec/lib/github_integration_service_spec.rb
296
293
  - spec/lib/request_parser_spec.rb
297
- - spec/restorers/state_restorer_spec.rb
294
+ - spec/lib/restorers/state_restorer_spec.rb
295
+ - spec/lib/serializers/basic_serializer_spec.rb
296
+ - spec/lib/serializers/default_summary_serializer_spec.rb
297
+ - spec/lib/serializers/group_serializer_spec.rb
298
+ - spec/lib/serializers/summary_serializer_spec.rb
298
299
  - spec/spec_helper.rb
299
300
  - spec/support/crashbreak_config.rb
300
301
  - spec/support/rspec_config.rb
301
302
  - spec/support/test_error.rb
302
- - spec/support/test_error_formatter.rb
303
+ - spec/support/test_error_serializer.rb
303
304
  has_rdoc:
@@ -1,13 +0,0 @@
1
- describe Crashbreak::SummaryFormatter do
2
- class SummaryTestFormatter < Crashbreak::SummaryFormatter
3
- def summary
4
- { example: 'true' }
5
- end
6
- end
7
-
8
- subject { SummaryTestFormatter.new }
9
-
10
- it 'wraps summary hash' do
11
- expect(subject.serialize).to eq(summary: subject.summary)
12
- end
13
- end
@@ -1,7 +0,0 @@
1
- class TestErrorFormatter < Crashbreak::HashFormatter
2
- hash_name :test
3
-
4
- def hash_value
5
- { formatter: true }
6
- end
7
- end