postmark 1.23.0 → 1.24.0

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: dfce0fc58365a91800f896d2d16c8d62d1a601f7a1a8d5350c6270cae3f12be3
4
- data.tar.gz: 3d8b2761c884f6ca1f3c81efe7c30dda1432b6d7da740d18d6cc55f5cc062d23
3
+ metadata.gz: 36d183adb014f24f30c12f04f65d01d9a4565e46bac544fcf499f1834d98b15f
4
+ data.tar.gz: 23d80a64a061b7bce98a7040a0b64b7e56611aea995894764d201e5ee71fdf69
5
5
  SHA512:
6
- metadata.gz: 4082d74e41c4d74378f4e46bb43d0b8dd967489125865cd9379fbc3928dfd0be7369408cfcdcc6a979822739b8734045fba8a66021591848dff801286ef183d9
7
- data.tar.gz: 5c93b937e1749584f52c1a1f5e0a4a9eabc6ea579e02c26f20d709ea5b89873d666acd6b8c2e7733a5e18885df370c1f2ca26e9c96c23cc44448d95c4f0da309
6
+ metadata.gz: a132d891995e587fc6324cbed9626799a7919f0314b4402910593e47afb02281b25fd6b8971a20197774dd37d48c7221389047699b9cbf98a2cdfecce3e247b6
7
+ data.tar.gz: 26b78de0eefb4c6055e2edee3f787ddab17c49f49fbbd4e8bf02100f85202cc46d57ff4c140617f0c1cd7c325875e602fc952c8b9a528a9ad9feed25ee9d76b1
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,8 @@
1
1
  = Changelog
2
2
 
3
+ == 1.24.0
4
+ * Added configurable warnings when referencing deprecated classes.
5
+
3
6
  == 1.23.0
4
7
  * Deprecated `InvalidEmailAddressError`. New name is `InvalidEmailRequestError`.
5
8
 
data/README.md CHANGED
@@ -48,6 +48,15 @@ Without Bundler:
48
48
  gem install postmark
49
49
  ```
50
50
 
51
+ ## Deprecations
52
+
53
+ Deprecations can be either silenced or set to raise using:
54
+
55
+ ```rb
56
+ Postmark::Deprecations.behavior = :silence
57
+ Postmark::Deprecations.behavior = :raise
58
+ ```
59
+
51
60
  ## Note on Patches/Pull Requests
52
61
 
53
62
  See [CONTRIBUTING.md](CONTRIBUTING.md) file for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.23.0
1
+ 1.24.0
@@ -0,0 +1,35 @@
1
+ module Postmark
2
+ def self.const_missing(const_name)
3
+ replacement = Deprecations.deprecated_constants.fetch(const_name, nil) || super
4
+ Deprecations.report("DEPRECATION WARNING: the class #{const_name} is deprecated. Use #{replacement} instead.")
5
+ replacement
6
+ end
7
+
8
+ module Deprecations
9
+ DEFAULT_BEHAVIORS = {
10
+ :raise => lambda { |message| raise message },
11
+ :log => lambda { |message| warn message },
12
+ :silence => lambda { |message| },
13
+ }
14
+
15
+ def self.report(message)
16
+ DEFAULT_BEHAVIORS.fetch(behavior).call(message)
17
+ end
18
+
19
+ def self.deprecated_constants
20
+ @deprecated_constants ||= {}
21
+ end
22
+
23
+ def self.behavior
24
+ @behavior ||= :log
25
+ end
26
+
27
+ def self.behavior=(behavior)
28
+ @behavior = behavior
29
+ end
30
+
31
+ def self.add_constants(mappings)
32
+ deprecated_constants.merge!(mappings)
33
+ end
34
+ end
35
+ end
@@ -1,3 +1,5 @@
1
+ require 'postmark/deprecations'
2
+
1
3
  module Postmark
2
4
  class Error < ::StandardError; end
3
5
 
@@ -126,8 +128,10 @@ module Postmark
126
128
  class UnexpectedHttpResponseError < HttpServerError; end
127
129
 
128
130
  # Backwards compatible aliases
129
- DeliveryError = Error
130
- InvalidMessageError = ApiInputError
131
- UnknownError = UnexpectedHttpResponseError
132
- InvalidEmailAddressError = InvalidEmailRequestError
131
+ Deprecations.add_constants(
132
+ :DeliveryError => Error,
133
+ :InvalidMessageError => ApiInputError,
134
+ :UnknownError => UnexpectedHttpResponseError,
135
+ :InvalidEmailAddressError => InvalidEmailRequestError
136
+ )
133
137
  end
@@ -1,3 +1,3 @@
1
1
  module Postmark
2
- VERSION = '1.23.0'
2
+ VERSION = '1.24.0'
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -15,6 +15,8 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'support', 'shared_e
15
15
  require File.join(File.expand_path(File.dirname(__FILE__)), 'support', 'custom_matchers.rb')
16
16
  require File.join(File.expand_path(File.dirname(__FILE__)), 'support', 'helpers.rb')
17
17
 
18
+ Postmark::Deprecations.behavior = :silence
19
+
18
20
  if ENV['JSONGEM']
19
21
  # `JSONGEM=Yajl rake spec`
20
22
  Postmark.response_parser_class = ENV['JSONGEM'].to_sym
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postmark
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.23.0
4
+ version: 1.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomek Maszkowski
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2023-01-23 00:00:00.000000000 Z
16
+ date: 2023-04-07 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: json
@@ -88,6 +88,7 @@ files:
88
88
  - lib/postmark/api_client.rb
89
89
  - lib/postmark/bounce.rb
90
90
  - lib/postmark/client.rb
91
+ - lib/postmark/deprecations.rb
91
92
  - lib/postmark/error.rb
92
93
  - lib/postmark/handlers/mail.rb
93
94
  - lib/postmark/helpers/hash_helper.rb