jt-rails-toolbox 2.2.1 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +30 -29
- data/jt-rails-toolbox.gemspec +1 -1
- data/lib/generators/jt/toolbox/templates/jt-toolbox.yml +8 -7
- data/lib/jt-rails-toolbox.rb +39 -42
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78d43b033b06e5390c515e531f76ebdca76f1eb2
|
4
|
+
data.tar.gz: 53b1033d1c6de87cc331f179444152e074dac671
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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?
|
data/jt-rails-toolbox.gemspec
CHANGED
@@ -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.
|
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
|
-
#
|
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
|
-
#
|
24
|
+
# - my_email_for_errors@example.com
|
24
25
|
# files:
|
25
26
|
# folder: upload
|
26
27
|
# mail:
|
data/lib/jt-rails-toolbox.rb
CHANGED
@@ -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 +=
|
114
|
+
config.ignored_exceptions += %w{ActionController::InvalidCrossOriginRequest ActionController::InvalidAuthenticityToken}
|
82
115
|
|
83
|
-
if
|
116
|
+
if @params['exception']['slack']
|
84
117
|
config.add_notifier :slack, {
|
85
|
-
webhook_url: params['exception']['
|
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']
|