deprecations 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 +4 -4
- data/README.md +2 -0
- data/lib/deprecations.rb +2 -0
- data/lib/deprecations/extension.rb +29 -27
- 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: 42b4cf87903a557ef44e7fa0f7d8e7cbda134c7f
|
4
|
+
data.tar.gz: 23360fbe0f87964cde7e0987c7df5ae10c3cd172
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64409aa1740a08d1cabe23694cfaf86ca95eb0348ca9f0ff90f5589dc9cbe771d5696f631f1dab038bf0b1c945f1c0524d2322dd086b8f9ab6801207178a49d4
|
7
|
+
data.tar.gz: e2b7f0edbbbb9df6f32f10210b02c3cc2c8c3160b8831ba1f15c14a2874c70925b0797741d2597ff7a329fb66f5ef1ceeb4f091e98e6de15cb949efa6c51a275
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
This gem provides transparent declaration of deprecated methods and classes.
|
4
4
|
|
5
|
+
[![Code Climate](https://codeclimate.com/github/mblumtritt/deprecations.png)](https://codeclimate.com/github/mblumtritt/deprecations)
|
6
|
+
|
5
7
|
## Installation
|
6
8
|
|
7
9
|
The simplest way to install Deprecations gem is to use [Bundler](http://gembundler.com/).
|
data/lib/deprecations.rb
CHANGED
@@ -17,19 +17,22 @@ module Deprecations
|
|
17
17
|
nil
|
18
18
|
end
|
19
19
|
|
20
|
-
def __define_deprecated(
|
21
|
-
alias_name =
|
22
|
-
|
23
|
-
|
24
|
-
)
|
25
|
-
alias_method(alias_name, opts[:name])
|
26
|
-
private(alias_name)
|
27
|
-
define_method(opts[:name]) do |*a, &b|
|
28
|
-
Deprecations.call(opts[:decorated], opts[:alternative], opts[:outdated])
|
20
|
+
def __define_deprecated(name, decorated_name, scope, alternative, outdated)
|
21
|
+
alias_name = __private_alias(name, decorated_name )
|
22
|
+
define_method(name) do |*a, &b|
|
23
|
+
Deprecations.call(decorated_name, alternative, outdated)
|
29
24
|
send(alias_name, *a, &b)
|
30
25
|
end
|
31
|
-
send(
|
32
|
-
|
26
|
+
send(scope, name)
|
27
|
+
name
|
28
|
+
end
|
29
|
+
|
30
|
+
def __private_alias(name, decorated_name)
|
31
|
+
alias_name = "deprecated_#{name}"
|
32
|
+
private_method_defined?(alias_name) and raise(ScriptError, "method is already deprecated - #{decorated_name}")
|
33
|
+
alias_method(alias_name, name)
|
34
|
+
private(alias_name)
|
35
|
+
alias_name
|
33
36
|
end
|
34
37
|
end
|
35
38
|
|
@@ -40,11 +43,11 @@ module Deprecations
|
|
40
43
|
def deprecated(method_name, alternative_method_name = nil, outdated = nil)
|
41
44
|
method_scope = __method_scope(method_name) or __not_found!(method_name)
|
42
45
|
__define_deprecated(
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
outdated
|
46
|
+
method_name,
|
47
|
+
"#{self.inspect[8..-2]}.#{method_name}",
|
48
|
+
method_scope,
|
49
|
+
__decorated(alternative_method_name),
|
50
|
+
outdated
|
48
51
|
)
|
49
52
|
ensure
|
50
53
|
$@ and $@.delete_if{ |s| s.index(__FILE__) }
|
@@ -69,21 +72,21 @@ module Deprecations
|
|
69
72
|
def deprecated!(alternative = nil, outdated = nil)
|
70
73
|
singleton_class.send(
|
71
74
|
:__define_deprecated,
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
alternative
|
76
|
-
outdated
|
75
|
+
:new,
|
76
|
+
name,
|
77
|
+
:public,
|
78
|
+
alternative ? "#{alternative}" : nil,
|
79
|
+
outdated
|
77
80
|
)
|
78
81
|
end
|
79
82
|
|
80
83
|
def deprecated(method_name, alternative_method_name = nil, outdated = nil)
|
81
84
|
method_scope = __method_scope(method_name) and return __define_deprecated(
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
outdated
|
85
|
+
method_name,
|
86
|
+
"#{name}##{method_name}",
|
87
|
+
method_scope,
|
88
|
+
__decorated(alternative_method_name),
|
89
|
+
outdated
|
87
90
|
)
|
88
91
|
singleton_class.send(:deprecated, method_name, alternative_method_name, outdated)
|
89
92
|
ensure
|
@@ -98,5 +101,4 @@ module Deprecations
|
|
98
101
|
end
|
99
102
|
|
100
103
|
infect(Module)
|
101
|
-
TOPLEVEL_BINDING.eval('DeprecationError = Class.new(ScriptError)')
|
102
104
|
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: 1.0.
|
4
|
+
version: 1.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: 2014-
|
11
|
+
date: 2014-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|