jt-rails-toolbox 2.2.1 → 2.2.2

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: 0def6e9f02f0f92926dae61892361bbcd484e4d6
4
- data.tar.gz: 9ad82a888f55ed5e99289b424dc3fa5c26229416
3
+ metadata.gz: 78d43b033b06e5390c515e531f76ebdca76f1eb2
4
+ data.tar.gz: 53b1033d1c6de87cc331f179444152e074dac671
5
5
  SHA512:
6
- metadata.gz: f7b8d40bd2c321af8d74c68850fe2bae1a17f08a94dfe57b81838f530a3a64c34a062170814b4b4bd5703b4c0eff93c3fa44983ede871e063bd52db07161ecfa
7
- data.tar.gz: b079ab4e41d7dc4f3e9199de2d9b0f0a7de7fd3903a04990f9822a1925ddd3c057d9f867444b1ae3e9f334d4ee19783c164e4bdd21984f77dcbee61aa2687ec8
6
+ metadata.gz: 0b2d76d7c769cc7c9cce91341a520a35f0e9dccc3802b332093d6d993079f34a9167f1057879146a57475dee97e27cb35f16b2086a2d0054322278a8bed07247
7
+ data.tar.gz: 9043fd28bb4701a9bcdb9d3a338a312a6f14f4c1bba14c8a7d53ea1c235121f089f11e23cd681202221c433bfc7e3401d41516d121bb215ec49ff241078cc9a6
data/README.md CHANGED
@@ -19,36 +19,37 @@ Create a `jt-toolbox.yml` file:
19
19
  A simple configuration of `jt-toolbox.yml` file:
20
20
 
21
21
  ```yml
22
- production:
23
- airbrake:
24
- project_host: "https://errbit.example.com"
25
- project_id: 1
26
- project_key: 12345678901234567890
27
- exception:
28
- slack_webhook_url: https://hooks.slack.com/services/XXXXXXXX
29
- email_prefix: '[ERROR]'
30
- sender_address: "Your website <error@example.com>"
31
- exception_recipients:
22
+ production:
23
+ exception:
24
+ airbrake:
25
+ project_host: "https://errbit.example.com"
26
+ project_id: 1
27
+ project_key: 12345678901234567890
28
+ slack:
29
+ webhook_url: https://hooks.slack.com/services/XXXXXXXX
30
+ email_prefix: '[ERROR]'
31
+ sender_address: "Your website <error@example.com>"
32
+ exception_recipients:
32
33
  - my_email_for_errors@example.com
33
- files:
34
- folder: upload
35
- mail:
36
- from: "Your website <contact@example.com>"
37
- delivery_method: smtp
38
- smtp_settings:
39
- address: smtp.gmail.com
40
- port: 587
41
- domain: example.com
42
- user_name: username
43
- password: password
44
- authentication: plain
45
- enable_starttls_auto: true
46
- hosts:
47
- host: https://www.example.com
48
- asset_host: https://asset.example.com
49
- cdn_host: https://cdn.example.com
50
- sidekiq:
51
- redis_url: redis://localhost:6379/my_app
34
+ files:
35
+ folder: upload
36
+ mail:
37
+ from: "Your website <contact@example.com>"
38
+ delivery_method: smtp
39
+ smtp_settings:
40
+ address: smtp.gmail.com
41
+ port: 587
42
+ domain: example.com
43
+ user_name: username
44
+ password: password
45
+ authentication: plain
46
+ enable_starttls_auto: true
47
+ hosts:
48
+ host: https://www.example.com
49
+ asset_host: https://asset.example.com
50
+ cdn_host: https://cdn.example.com
51
+ sidekiq:
52
+ redis_url: redis://localhost:6379/my_app
52
53
  ```
53
54
 
54
55
  ## What's in it?
@@ -3,7 +3,7 @@ Gem::Specification.new do |s|
3
3
  s.summary = "Common libs used for Ruby On Rails development."
4
4
  s.description = "JTRailsToolbox contains a list of common libs used for Ruby On Rails development."
5
5
  s.homepage = 'https://github.com/jonathantribouharet/jt-rails-toolbox'
6
- s.version = '2.2.1'
6
+ s.version = '2.2.2'
7
7
  s.files = `git ls-files`.split("\n")
8
8
  s.require_paths = ['lib']
9
9
  s.authors = ['Jonathan TRIBOUHARET']
@@ -9,18 +9,19 @@
9
9
  # cdn_host: same as host
10
10
  # sidekiq:
11
11
  # redis_url: redis://localhost:6379/nameoftheapp
12
- #
12
+ #
13
13
  # production:
14
- # airbrake:
15
- # project_host: "https://errbit.example.com"
16
- # project_id: 1
17
- # project_key: 12345678901234567890
18
14
  # exception:
19
- # slack_webhook_url: https://hooks.slack.com/services/XXXXXXXX
15
+ # airbrake:
16
+ # project_host: "https://errbit.example.com"
17
+ # project_id: 1
18
+ # project_key: 12345678901234567890
19
+ # slack:
20
+ # webhook_url: https://hooks.slack.com/services/XXXXXXXX
20
21
  # email_prefix: '[ERROR]'
21
22
  # sender_address: "Your website <error@example.com>"
22
23
  # exception_recipients:
23
- # - my_email_for_errors@example.com
24
+ # - my_email_for_errors@example.com
24
25
  # files:
25
26
  # folder: upload
26
27
  # mail:
@@ -10,6 +10,10 @@ require 'jt-rails-tokenizable'
10
10
 
11
11
  require 'yaml'
12
12
 
13
+ # Don't move this require
14
+ require 'airbrake'
15
+ require 'airbrake/sidekiq/error_handler'
16
+
13
17
  module JTRailsToolbox
14
18
 
15
19
  class Engine < ::Rails::Engine
@@ -26,7 +30,6 @@ module JTRailsToolbox
26
30
 
27
31
  process_params
28
32
  configure_exception_notification(app)
29
- configure_airbrake(app)
30
33
  configure_mail(app)
31
34
  configure_paperclip(app)
32
35
  configure_sidekiq(app)
@@ -71,18 +74,48 @@ module JTRailsToolbox
71
74
  def configure_exception_notification(app)
72
75
  return if @params['exception'].nil?
73
76
 
77
+ if @params['exception']['airbrake']
78
+
79
+ Airbrake.configure do |c|
80
+ if @params['exception']['airbrake']['host']
81
+ c.host = @params['exception']['airbrake']['host']
82
+ end
83
+
84
+ c.project_id = @params['exception']['airbrake']['project_id']
85
+ c.project_key = @params['exception']['airbrake']['project_key']
86
+
87
+ c.environment = Rails.env
88
+
89
+ if @params['exception']['airbrake']['ignore_environments']
90
+ c.ignore_environments = @params['exception']['airbrake']['ignore_environments']
91
+ else
92
+ c.ignore_environments = %w(development test)
93
+ end
94
+ end
95
+
96
+ # Default ignored exceptions in Exception Notification
97
+ exceptions_to_ignore = %w{ActiveRecord::RecordNotFound Mongoid::Errors::DocumentNotFound AbstractController::ActionNotFound ActionController::RoutingError ActionController::UnknownFormat ActionController::UrlGenerationError}
98
+
99
+ # Additionnal exceptions to ignore
100
+ exceptions_to_ignore.push *%w{ActionController::InvalidCrossOriginRequest ActionController::InvalidAuthenticityToken}
101
+
102
+ Airbrake.add_filter do |notice|
103
+ if notice[:errors].any? { |error| exceptions_to_ignore.include?(error[:type]) }
104
+ notice.ignore!
105
+ end
106
+ end
107
+ end
108
+
74
109
  require 'exception_notification'
75
110
  require 'exception_notification/rails'
76
111
  require 'exception_notification/sidekiq'
77
112
 
78
- exceptions_to_ignore = %w{ActionController::InvalidCrossOriginRequest ActionController::InvalidAuthenticityToken}
79
-
80
113
  ExceptionNotification.configure do |config|
81
- config.ignored_exceptions += exceptions_to_ignore
114
+ config.ignored_exceptions += %w{ActionController::InvalidCrossOriginRequest ActionController::InvalidAuthenticityToken}
82
115
 
83
- if !@params['exception']['slack_webhook_url'].blank?
116
+ if @params['exception']['slack']
84
117
  config.add_notifier :slack, {
85
- webhook_url: params['exception']['slack_webhook_url'],
118
+ webhook_url: params['exception']['slack']['webhook_url'],
86
119
  }
87
120
  end
88
121
 
@@ -96,42 +129,6 @@ module JTRailsToolbox
96
129
  end
97
130
  end
98
131
 
99
- def configure_airbrake(app)
100
- return if @params['airbrake'].nil?
101
-
102
- require 'airbrake'
103
- require 'airbrake/sidekiq/error_handler'
104
-
105
- # Default ignored exceptions in Exception Notification
106
- exceptions_to_ignore = %w{ActiveRecord::RecordNotFound Mongoid::Errors::DocumentNotFound AbstractController::ActionNotFound ActionController::RoutingError ActionController::UnknownFormat ActionController::UrlGenerationError}
107
-
108
- # Additionnal exceptions to ignore
109
- exceptions_to_ignore.push *%w{ActionController::InvalidCrossOriginRequest ActionController::InvalidAuthenticityToken}
110
-
111
- Airbrake.configure do |c|
112
- if @params['airbrake']['host']
113
- c.host = @params['airbrake']['host']
114
- end
115
-
116
- c.project_id = @params['airbrake']['project_id']
117
- c.project_key = @params['airbrake']['project_key']
118
-
119
- c.environment = Rails.env
120
-
121
- if @params['airbrake']['ignore_environments']
122
- c.ignore_environments = @params['airbrake']['ignore_environments']
123
- else
124
- c.ignore_environments = %w(development test)
125
- end
126
- end
127
-
128
- Airbrake.add_filter do |notice|
129
- if notice[:errors].any? { |error| exceptions_to_ignore.include?(error[:type]) }
130
- notice.ignore!
131
- end
132
- end
133
- end
134
-
135
132
  def configure_mail(app)
136
133
  ActionMailer::Base.delivery_method = @params['mail']['delivery_method']
137
134
  ActionMailer::Base.smtp_settings = @params['mail']['smtp_settings']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jt-rails-toolbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan TRIBOUHARET