agilibox 1.9.1 → 1.9.3

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
  SHA256:
3
- metadata.gz: 13838c6239bbcb5c4638ea7ae6b0c941bb9f534f8d4d0a80d42e7032bc8101f8
4
- data.tar.gz: 5a5574853314ad1f5eb4cb59da239dab07f42d65adc2226d344e1eacd1687cbb
3
+ metadata.gz: 43edc1602674c41d34d28ab05565875acdcd8205875be814b807e8d6030fd606
4
+ data.tar.gz: 91c4ffe2a7a61e7b49ed725259bc458b3b1d2ae0777c1dfd51020152957f568d
5
5
  SHA512:
6
- metadata.gz: d9f95ad166c9bb997141683ac6cdd34633d002bf0859e967b0ed2fe9eff090d8b3b994c3f21e5e72843b82cd0aa94ba5ae62a30535b17fa15a3f7f2620c93b65
7
- data.tar.gz: 26df1371c8c6aa014790618229d63807bfc472662b0b955bcd68e579d17fac805e7668b8d2aac9cab5e58b38b62405582526d1615b96b6cf96d3e0c0525c3836
6
+ metadata.gz: bd7b588581d44d6f0b46be007712bd3cdffd8bd6bdc4d1e4435248b3b6424c892dd57cea9ea8192a3a1d9dec2dffcb706ce0f86f94f2a1a272010e5333dbbe35
7
+ data.tar.gz: 7dd38de913db48ff9e96781889debf3024d7e1e6e33dd4ffced130963acfea2266c9a87818e10b988c89e8182be42db50d8539990c03c16cba6942429c092b06
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Next version
4
4
 
5
+ ## 1.9.3
6
+ - No change
7
+
8
+ ## 1.9.2
9
+ - ErrorsMiddleware improvements
10
+
5
11
  ## 1.9.1
6
12
  - Add ErrorsMiddleware
7
13
 
@@ -13,7 +13,7 @@ module Agilibox::BackUrlConcern
13
13
  default_back_url,
14
14
  main_app.try(:root_path),
15
15
  "/",
16
- ].select(&:present?).first
16
+ ].find(&:present?)
17
17
 
18
18
  uri = URI.parse(url)
19
19
  uri.host = nil
@@ -5,4 +5,4 @@ module Agilibox::ActiveModelCustomErrorMessages
5
5
  end
6
6
  end
7
7
 
8
- ActiveModel::Errors.send(:prepend, Agilibox::ActiveModelCustomErrorMessages)
8
+ ActiveModel::Errors.prepend(Agilibox::ActiveModelCustomErrorMessages)
@@ -46,7 +46,7 @@ module Agilibox::ActiveModelTypeCast
46
46
  end
47
47
  end
48
48
 
49
- ActiveModel::Type::Date.send(:prepend, Agilibox::ActiveModelTypeCast::Date)
50
- ActiveModel::Type::Boolean.send(:prepend, Agilibox::ActiveModelTypeCast::Boolean)
51
- ActiveModel::Type::Decimal.send(:prepend, Agilibox::ActiveModelTypeCast::Decimal)
52
- ActiveModel::Type::Float.send(:prepend, Agilibox::ActiveModelTypeCast::Decimal)
49
+ ActiveModel::Type::Date.prepend(Agilibox::ActiveModelTypeCast::Date)
50
+ ActiveModel::Type::Boolean.prepend(Agilibox::ActiveModelTypeCast::Boolean)
51
+ ActiveModel::Type::Decimal.prepend(Agilibox::ActiveModelTypeCast::Decimal)
52
+ ActiveModel::Type::Float.prepend(Agilibox::ActiveModelTypeCast::Decimal)
@@ -1,13 +1,15 @@
1
1
  class Agilibox::ErrorsMiddleware
2
2
  MAINTENANCE_ERRORS = [
3
- PG::ConnectionBad,
4
- PG::UnableToSend,
3
+ "ActiveRecord::ConnectionTimeoutError",
4
+ "connections on port 5432",
5
+ "PG::UnableToSend",
5
6
  ]
6
7
 
7
8
  NOT_ACCEPTABLE_ERRORS = [
8
- ActionController::UnknownFormat,
9
- ActionController::UnknownHttpMethod,
10
- ActionView::MissingTemplate,
9
+ "ActionController::BadRequest",
10
+ "ActionController::UnknownFormat",
11
+ "ActionController::UnknownHttpMethod",
12
+ "ActionView::MissingTemplate",
11
13
  ]
12
14
 
13
15
  def initialize(app)
@@ -16,10 +18,18 @@ class Agilibox::ErrorsMiddleware
16
18
 
17
19
  def call(env)
18
20
  @app.call(env)
19
- rescue *MAINTENANCE_ERRORS
20
- respond_with 503, "Maintenance en cours."
21
- rescue *NOT_ACCEPTABLE_ERRORS
22
- respond_with 406, "Not acceptable."
21
+ rescue StandardError => e
22
+ error = "#{e.class} : #{e.message}"
23
+
24
+ if MAINTENANCE_ERRORS.any? { |pattern| error.match?(pattern) }
25
+ return respond_with 503, "Maintenance en cours."
26
+ end
27
+
28
+ if NOT_ACCEPTABLE_ERRORS.any? { |pattern| error.match?(pattern) }
29
+ return respond_with 406, "Not acceptable."
30
+ end
31
+
32
+ raise e
23
33
  end
24
34
 
25
35
  private
@@ -15,4 +15,4 @@ module Agilibox::FormBackUrl
15
15
  end
16
16
  end
17
17
 
18
- ActionView::Helpers::FormTagHelper.send(:prepend, Agilibox::FormBackUrl)
18
+ ActionView::Helpers::FormTagHelper.prepend(Agilibox::FormBackUrl)
@@ -1,3 +1,3 @@
1
1
  module Agilibox
2
- VERSION = "1.9.1"
2
+ VERSION = "1.9.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agilibox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.1
4
+ version: 1.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - agilidée
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-26 00:00:00.000000000 Z
11
+ date: 2020-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails-i18n