jt-rails-toolbox 1.3.1 → 2.0.0
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 +2 -32
- data/jt-rails-toolbox.gemspec +2 -6
- data/lib/generators/jt/toolbox/templates/jt-toolbox.yml +1 -7
- data/lib/jt-rails-toolbox.rb +14 -62
- metadata +7 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd810e9c7430c064cb9abd1596be503f87790889
|
4
|
+
data.tar.gz: a9c86ad1ec79f41101272716950317673522fe0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 299d02c266b4253a03670a683d5878d1f85c07a5f43c081eb2560f9ac5bde0461961164e7d803be03b82e45e374d110e249a610e0742b5ed24fdfdef0e0f8446
|
7
|
+
data.tar.gz: 090817f784b76f394f867fc3ce4f7326c25582f9b71ffce1abae6b0fad0808beb636b27d5653fd600daaedb411e4b6b727bab4179309eecc1007709365de7534
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ JTRailsToolbox is distributed as a gem, which is how it should be used in your a
|
|
10
10
|
|
11
11
|
Include the gem in your Gemfile:
|
12
12
|
|
13
|
-
gem 'jt-rails-toolbox', '~>
|
13
|
+
gem 'jt-rails-toolbox', '~> 2.0'
|
14
14
|
|
15
15
|
Create a `jt-toolbox.yml` file:
|
16
16
|
|
@@ -21,12 +21,6 @@ A simple configuration of `jt-toolbox.yml` file:
|
|
21
21
|
```yml
|
22
22
|
production:
|
23
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
24
|
email_prefix: '[ERROR]'
|
31
25
|
sender_address: "Your website <error@example.com>"
|
32
26
|
exception_recipients:
|
@@ -54,13 +48,8 @@ A simple configuration of `jt-toolbox.yml` file:
|
|
54
48
|
|
55
49
|
## What's in it?
|
56
50
|
|
57
|
-
- [
|
58
|
-
- [dotenv](https://github.com/bkeepers/dotenv), load environment variables from .env file
|
59
|
-
- [Exception Notification](https://github.com/smartinez87/exception_notification),
|
60
|
-
send notifications when errors occur (email, slack)
|
61
|
-
- [Airbrake](https://github.com/airbrake/airbrake), send notifications when errors occur to [Airbrake](https://airbrake.io/) or [Errbit](http://errbit.com/)
|
51
|
+
- [Exception Notification](https://github.com/smartinez87/exception_notification), send email notifications when errors occur
|
62
52
|
- [paperclip](https://github.com/thoughtbot/paperclip), manage file upload
|
63
|
-
- [quiet_assets](https://github.com/evrone/quiet_assets), silence assets in log
|
64
53
|
- [sidekiq](https://github.com/mperham/sidekiq), manage background jobs
|
65
54
|
- [validates_email_format_of](https://github.com/validates-email-format-of/validates_email_format_of), who doesn't need to validate email format?
|
66
55
|
- [rails-i18n](https://github.com/svenfuchs/rails-i18n) Default locale data
|
@@ -69,21 +58,6 @@ send notifications when errors occur (email, slack)
|
|
69
58
|
- [jt-rails-tokenizable](https://github.com/jonathantribouharet/jt-rails-tokenizable) Generate tokens for ActiveRecord models
|
70
59
|
- simplified configuration of hostnames and `ActionMailer` with a YAML file
|
71
60
|
|
72
|
-
### http_accept_language
|
73
|
-
|
74
|
-
To install `http_accept_language` you just have to add a line in your `ApplicationController`
|
75
|
-
|
76
|
-
```ruby
|
77
|
-
class ApplicationController < ActionController::Base
|
78
|
-
include HttpAcceptLanguage::AutoLocale
|
79
|
-
|
80
|
-
end
|
81
|
-
```
|
82
|
-
|
83
|
-
### Dotenv
|
84
|
-
|
85
|
-
It's a good practice to not include credentials for third party services in your code. You can defined it in a `.env` file which I recommend to not include in your git repository.
|
86
|
-
|
87
61
|
### Exception Notification
|
88
62
|
|
89
63
|
If `exception` is not set in `jt-toolbox.yml` file, Exception Notification is disabled.
|
@@ -92,10 +66,6 @@ In addition to the default ignored exceptions, the following exceptions are also
|
|
92
66
|
- `ActionController::InvalidCrossOriginRequest`
|
93
67
|
- `ActionController::InvalidAuthenticityToken`
|
94
68
|
|
95
|
-
### Airbrake
|
96
|
-
|
97
|
-
If `airbrake` is not set in `jt-toolbox.yml` file, Airbrake is disabled.
|
98
|
-
|
99
69
|
### Paperclip
|
100
70
|
|
101
71
|
- `convert_options` is set to `-strip`, which means all metadata of images are removed, this is used for reduced the weight of images.
|
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 = '
|
6
|
+
s.version = '2.0.0'
|
7
7
|
s.files = `git ls-files`.split("\n")
|
8
8
|
s.require_paths = ['lib']
|
9
9
|
s.authors = ['Jonathan TRIBOUHARET']
|
@@ -11,14 +11,10 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.license = 'MIT'
|
12
12
|
s.platform = Gem::Platform::RUBY
|
13
13
|
|
14
|
-
s.add_dependency('
|
15
|
-
s.add_dependency('http_accept_language')
|
14
|
+
s.add_dependency('rails', '~> 5.0')
|
16
15
|
|
17
16
|
s.add_dependency('exception_notification', '~> 4.1')
|
18
|
-
s.add_dependency('airbrake', '~> 5.0')
|
19
|
-
|
20
17
|
s.add_dependency('paperclip', '~> 4.2')
|
21
|
-
s.add_dependency('quiet_assets', '~> 1.1')
|
22
18
|
s.add_dependency('validates_email_format_of', '~> 1.6')
|
23
19
|
s.add_dependency('rails-i18n', '~> 4.0')
|
24
20
|
s.add_dependency('jt-rails-meta', '~> 1.0')
|
@@ -12,16 +12,10 @@
|
|
12
12
|
#
|
13
13
|
# production:
|
14
14
|
# exception:
|
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
|
21
15
|
# email_prefix: '[ERROR]'
|
22
16
|
# sender_address: "Your website <error@example.com>"
|
23
17
|
# exception_recipients:
|
24
|
-
#
|
18
|
+
# - my_email_for_errors@example.com
|
25
19
|
# files:
|
26
20
|
# folder: upload
|
27
21
|
# mail:
|
data/lib/jt-rails-toolbox.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'http_accept_language'
|
1
|
+
require 'exception_notification'
|
3
2
|
require 'paperclip'
|
4
3
|
require 'sidekiq'
|
5
4
|
require 'validates_email_format_of'
|
@@ -8,19 +7,14 @@ require 'jt-rails-meta'
|
|
8
7
|
require 'jt-rails-generator-user'
|
9
8
|
require 'jt-rails-tokenizable'
|
10
9
|
|
11
|
-
require '
|
12
|
-
|
13
|
-
if Rails.env.development?
|
14
|
-
require 'quiet_assets'
|
15
|
-
end
|
10
|
+
require 'exception_notification/rails'
|
11
|
+
require 'exception_notification/sidekiq'
|
16
12
|
|
17
|
-
|
18
|
-
require 'airbrake'
|
19
|
-
require 'airbrake/sidekiq/error_handler'
|
13
|
+
require 'yaml'
|
20
14
|
|
21
15
|
module JTRailsToolbox
|
22
16
|
|
23
|
-
class
|
17
|
+
class Railtie < ::Rails::Railtie
|
24
18
|
|
25
19
|
initializer "jt-rails-toolbox" do |app|
|
26
20
|
@params = {}
|
@@ -78,58 +72,14 @@ module JTRailsToolbox
|
|
78
72
|
def configure_exception_notification(app)
|
79
73
|
return if @params['exception'].nil?
|
80
74
|
|
81
|
-
if @params['exception']['airbrake']
|
82
|
-
|
83
|
-
Airbrake.configure do |c|
|
84
|
-
if @params['exception']['airbrake']['host']
|
85
|
-
c.host = @params['exception']['airbrake']['host']
|
86
|
-
end
|
87
|
-
|
88
|
-
c.project_id = @params['exception']['airbrake']['project_id']
|
89
|
-
c.project_key = @params['exception']['airbrake']['project_key']
|
90
|
-
|
91
|
-
c.environment = Rails.env
|
92
|
-
|
93
|
-
if @params['exception']['airbrake']['ignore_environments']
|
94
|
-
c.ignore_environments = @params['exception']['airbrake']['ignore_environments']
|
95
|
-
else
|
96
|
-
c.ignore_environments = %w(development test)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
# Default ignored exceptions in Exception Notification
|
101
|
-
exceptions_to_ignore = %w{ActiveRecord::RecordNotFound Mongoid::Errors::DocumentNotFound AbstractController::ActionNotFound ActionController::RoutingError ActionController::UnknownFormat ActionController::UrlGenerationError}
|
102
|
-
|
103
|
-
# Additionnal exceptions to ignore
|
104
|
-
exceptions_to_ignore.push *%w{ActionController::InvalidCrossOriginRequest ActionController::InvalidAuthenticityToken}
|
105
|
-
|
106
|
-
Airbrake.add_filter do |notice|
|
107
|
-
if notice[:errors].any? { |error| exceptions_to_ignore.include?(error[:type]) }
|
108
|
-
notice.ignore!
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
require 'exception_notification'
|
114
|
-
require 'exception_notification/rails'
|
115
|
-
require 'exception_notification/sidekiq'
|
116
|
-
|
117
75
|
ExceptionNotification.configure do |config|
|
118
|
-
config.ignored_exceptions +=
|
119
|
-
|
120
|
-
if @params['exception']['slack']
|
121
|
-
config.add_notifier :slack, {
|
122
|
-
webhook_url: @params['exception']['slack']['webhook_url'],
|
123
|
-
}
|
124
|
-
end
|
76
|
+
config.ignored_exceptions += ['ActionController::InvalidCrossOriginRequest', 'ActionController::InvalidAuthenticityToken']
|
125
77
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
}
|
132
|
-
end
|
78
|
+
config.add_notifier :email, {
|
79
|
+
email_prefix: @params['exception']['email_prefix'],
|
80
|
+
sender_address: @params['exception']['sender_address'],
|
81
|
+
exception_recipients: @params['exception']['exception_recipients']
|
82
|
+
}
|
133
83
|
end
|
134
84
|
end
|
135
85
|
|
@@ -160,6 +110,8 @@ module JTRailsToolbox
|
|
160
110
|
def configure_sidekiq(app)
|
161
111
|
Sidekiq.configure_server do |config|
|
162
112
|
config.redis = { url: @params['sidekiq']['redis_url'], namespace: @params['sidekiq']['namespace'] }
|
113
|
+
|
114
|
+
config.error_handlers << Proc.new {|ex, ctx_hash| ExceptionNotifier.notify_exception(ex, data: ctx_hash) }
|
163
115
|
end
|
164
116
|
|
165
117
|
Sidekiq.configure_client do |config|
|
@@ -170,5 +122,5 @@ module JTRailsToolbox
|
|
170
122
|
end
|
171
123
|
|
172
124
|
end
|
173
|
-
|
125
|
+
|
174
126
|
end
|
metadata
CHANGED
@@ -1,43 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jt-rails-toolbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan TRIBOUHARET
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - '>='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: http_accept_language
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '>='
|
17
|
+
- - ~>
|
32
18
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
19
|
+
version: '5.0'
|
34
20
|
type: :runtime
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|
38
|
-
- -
|
24
|
+
- - ~>
|
39
25
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
26
|
+
version: '5.0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: exception_notification
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,20 +38,6 @@ dependencies:
|
|
52
38
|
- - ~>
|
53
39
|
- !ruby/object:Gem::Version
|
54
40
|
version: '4.1'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: airbrake
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '5.0'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ~>
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '5.0'
|
69
41
|
- !ruby/object:Gem::Dependency
|
70
42
|
name: paperclip
|
71
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,20 +52,6 @@ dependencies:
|
|
80
52
|
- - ~>
|
81
53
|
- !ruby/object:Gem::Version
|
82
54
|
version: '4.2'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: quiet_assets
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ~>
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '1.1'
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ~>
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '1.1'
|
97
55
|
- !ruby/object:Gem::Dependency
|
98
56
|
name: validates_email_format_of
|
99
57
|
requirement: !ruby/object:Gem::Requirement
|