deprecations 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/deprecations/behavior.rb +13 -9
- data/lib/deprecations/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a26b75a093acc26166b2d09ba9541eb26e35ab8
|
4
|
+
data.tar.gz: 5ae799df8b64aa9d2c9ec8a7be46c36fb454d5de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04beb30d068c578ff111dd807fd7fcc45cdd306a5e2cf5a4cbfe7a510ad84bc623f04e61add912c0aa39853a0dbaef59f3d77d88785ab717b2b85f08bf074890
|
7
|
+
data.tar.gz: 4f78d38bfb7e26a6a00c152506cf796932e6530028fc32cceabcbe3a2802f84e103fb74e396e434382ab302cce0637734998167d0f02a164c6d4239b0777b8f9
|
data/CHANGELOG.md
CHANGED
@@ -25,31 +25,35 @@ module Deprecations
|
|
25
25
|
|
26
26
|
def as_behavior(arg)
|
27
27
|
defined?(arg.call) ? arg : BEHAVIOR.fetch(arg) do
|
28
|
-
raise(ArgumentError, "invalid parameter - behavior has to be #{
|
28
|
+
raise(ArgumentError, "invalid parameter - behavior has to be #{valid_behaviors} or need to respond to `call`")
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
32
|
+
def valid_behaviors
|
33
33
|
BEHAVIOR.keys.map(&:inspect).join(' | ')
|
34
34
|
end
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
raise: proc do |subject, alternative|
|
36
|
+
module Raise
|
37
|
+
def self.call(subject, alternative, _outdated)
|
39
38
|
msg = "`#{subject}` is deprecated"
|
40
39
|
alternative and msg << " - use #{alternative} instead"
|
41
|
-
ex =
|
40
|
+
ex = DeprecationError.new(msg)
|
42
41
|
ex.set_backtrace(caller(4))
|
43
42
|
raise(ex)
|
44
|
-
end
|
45
|
-
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
module Warn
|
47
|
+
def self.call(subject, alternative, outdated)
|
46
48
|
location = caller_locations(4, 1).last and location = "#{location.path}:#{location.lineno}: "
|
47
49
|
msg = "#{location}[DEPRECATION] `#{subject}` is deprecated"
|
48
50
|
msg << (outdated ? " and will be outdated #{outdated}." : '.')
|
49
51
|
alternative and msg << " Please use `#{alternative}` instead."
|
50
52
|
::Kernel.warn(msg)
|
51
53
|
end
|
52
|
-
|
54
|
+
end
|
55
|
+
|
56
|
+
BEHAVIOR = {silence: ->(*){}, raise: Raise, warn: Warn}
|
53
57
|
|
54
58
|
end
|
55
59
|
end
|
data/lib/deprecations/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deprecations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Blumtritt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|