deprecation_toolkit 1.0.0 → 1.0.1

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: be80ca28201896a87295673cc5baa19c594b5c7e
4
- data.tar.gz: c3ca846545109f529196299957bba02634003dd9
3
+ metadata.gz: 0e89ce8cb136347a903186eec658e92f2d3e9719
4
+ data.tar.gz: 3282ad364e252d30856de442883c7e10d5ad6c36
5
5
  SHA512:
6
- metadata.gz: 163dc7b2d6d19f339f5a8a38f4eca5088e65555e73b349df1e32644beed2523ca5793062c4efb8b93fa9c3363cd3ff3884b8c6bf1812bbfc56cff5a5cbd7e7d0
7
- data.tar.gz: fc9a5a4db503e157daeb3ddfcd855eec86ccc013515f76498d98a3322f28486546523a1b84c5e2a9ff45dd0ba932b0c6166870ae24d76359df818153006e03d1
6
+ metadata.gz: 48696cf7330bc5df5ef56bdbc96295fbb22a7477d6375389d5fe2ffde30510a05f6af450ed7b7b080f3ebe0634e11e4328a797e14e287d0ff25c5c026318cf38
7
+ data.tar.gz: f2d5a3e940f779eba10f86383ee51fe1415561e8ac57fd44bb27be842706456ff4e5372331136e69c418184a67f1fe6e0ea93b17b4099e384f993d2ae201c67d
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ sudo: false
2
+ cache: bundler
3
+ language: ruby
4
+ before_install:
5
+ - gem update bundler
6
+ rvm:
7
+ - 2.3
8
+ - 2.4
9
+ - 2.5
10
+ notifications:
11
+ email: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- deprecation_toolkit (1.0.0)
4
+ deprecation_toolkit (1.0.1)
5
5
  activesupport (>= 5.0)
6
6
 
7
7
  GEM
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeprecationToolkit
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  end
@@ -2,25 +2,40 @@
2
2
 
3
3
  module DeprecationToolkit
4
4
  module Warning
5
- def warn(str)
6
- if DeprecationToolkit::Configuration.warnings_treated_as_deprecation.any? { |warning| warning =~ str }
7
- ActiveSupport::Deprecation.warn(str)
8
- else
9
- super
10
- end
5
+ extend self
6
+
7
+ def deprecation_triggered?(str)
8
+ DeprecationToolkit::Configuration.warnings_treated_as_deprecation.any? { |warning| warning =~ str }
11
9
  end
12
10
  end
13
11
  end
14
12
 
15
- Warning.singleton_class.prepend(DeprecationToolkit::Warning)
13
+ # Warning is a new feature in ruby 2.5
14
+ module Warning
15
+ def warn(str)
16
+ if DeprecationToolkit::Warning.deprecation_triggered?(str)
17
+ ActiveSupport::Deprecation.warn(str)
18
+ else
19
+ super
20
+ end
21
+ end
22
+ end
16
23
 
17
- # https://bugs.ruby-lang.org/issues/12944
18
- if RUBY_VERSION <= '2.5.0' && RUBY_ENGINE == 'ruby'
24
+ # Support for version older < 2.5
25
+ # Note that the `Warning` module exists in Ruby 2.4 but has a bug https://bugs.ruby-lang.org/issues/12944
26
+ if RUBY_VERSION < '2.5.0' && RUBY_ENGINE == 'ruby'
19
27
  module Kernel
20
- remove_method :warn
28
+ alias_method :__original_warn, :warn
21
29
 
22
30
  def warn(*messages)
23
- Array(messages.flatten).each { |msg| Warning.warn(msg) }
31
+ message = messages.join("\n")
32
+ message += "\n" unless message.end_with?("\n")
33
+
34
+ if DeprecationToolkit::Warning.deprecation_triggered?(message)
35
+ ActiveSupport::Deprecation.warn(message)
36
+ else
37
+ __original_warn(messages)
38
+ end
24
39
  end
25
40
  end
26
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deprecation_toolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-09 00:00:00.000000000 Z
11
+ date: 2018-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -76,6 +76,7 @@ files:
76
76
  - ".gitignore"
77
77
  - ".rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml"
78
78
  - ".rubocop.yml"
79
+ - ".travis.yml"
79
80
  - Gemfile
80
81
  - Gemfile.lock
81
82
  - LICENSE.txt