invisible 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/Gemfile.lock +1 -1
- data/README.md +18 -24
- data/lib/invisible.rb +25 -17
- data/lib/invisible/version.rb +1 -1
- metadata +4 -3
- data/lib/invisible/CHANGELOG.md +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb5436fd22665d78914881fb0c67242b305ec088048ac2a6ef7d3a424b99451b
|
4
|
+
data.tar.gz: 939c02f69fe6c083315363b6c46531c92b0f5fd74a90421937d886ec0ad452b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d670cc9bedf47de871c96abce0715ac2dbf057beb98df0240683f775a3bc18a0c0e2be91d447ed3891373b3c4fa72c599b228e11b28f49d95c3c4d11112c8975
|
7
|
+
data.tar.gz: 307886f9fc44e83688718d29d931fd63a75a9f5425ae34da3e3a35e9c93949cf87e98e2ee12144e2af12cf5a3af8b9492fc469010212fffb5ef25ae944b5504f
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Invisible Changelog
|
2
|
+
|
3
|
+
## 0.2
|
4
|
+
|
5
|
+
### 0.2.1
|
6
|
+
|
7
|
+
* Change name of attribute accessor in prepended module to `invisible`.
|
8
|
+
([#3](https://github.com/shioyama/invisible/pull/3))
|
9
|
+
|
10
|
+
### 0.2.0
|
11
|
+
|
12
|
+
* Add support for `prepend`. ([#2](https://github.com/shioyama/invisible/pull/2))
|
13
|
+
|
14
|
+
## 0.1
|
15
|
+
|
16
|
+
### 0.1.0
|
17
|
+
|
18
|
+
* Support for `include`.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
[gem]: https://rubygems.org/gems/invisible
|
7
7
|
[travis]: https://travis-ci.com/shioyama/invisible
|
8
8
|
|
9
|
-
Public? Private? Protected? Who cares! I just
|
9
|
+
Public? Private? Protected? Who cares! I just wanna monkey patch that shit!
|
10
10
|
|
11
11
|
No fear: Invisible has your back! This little ten-line gem does away with the problem of maintaining original method visibility, so you can get on with your monkey-patching mayhem.
|
12
12
|
|
@@ -39,19 +39,19 @@ end
|
|
39
39
|
We don't want to care about whether the methods are private or whatever. So we define our module like so:
|
40
40
|
|
41
41
|
```ruby
|
42
|
-
module
|
42
|
+
module WithFoo
|
43
43
|
extend Invisible
|
44
44
|
|
45
45
|
def public_method
|
46
|
-
super + 'foo'
|
46
|
+
super + ' with foo'
|
47
47
|
end
|
48
48
|
|
49
49
|
def protected_method
|
50
|
-
super + 'foo'
|
50
|
+
super + ' with foo'
|
51
51
|
end
|
52
52
|
|
53
53
|
def private_method
|
54
|
-
super + 'foo'
|
54
|
+
super + ' with foo'
|
55
55
|
end
|
56
56
|
end
|
57
57
|
```
|
@@ -60,38 +60,32 @@ Normally, without Invisible, we would have just made methods that were previousl
|
|
60
60
|
|
61
61
|
```ruby
|
62
62
|
class MyClass < Base
|
63
|
-
include
|
63
|
+
include WithFoo
|
64
64
|
end
|
65
65
|
|
66
66
|
instance = MyClass.new
|
67
67
|
|
68
|
-
|
69
|
-
instance.public_method
|
68
|
+
MyClass.public_method_defined?(:public_method) #=> true
|
69
|
+
instance.public_method #=> 'public with foo'
|
70
70
|
|
71
|
-
|
72
|
-
instance.protected_method
|
73
|
-
instance.send(:protected_method)
|
71
|
+
MyClass.protected_method_defined?(:protected_method) #=> true
|
72
|
+
instance.protected_method # raises NoMethodError
|
73
|
+
instance.send(:protected_method) #=> 'protected with foo'
|
74
74
|
|
75
|
-
|
76
|
-
instance.private_method
|
77
|
-
instance.send(:private_method)
|
75
|
+
MyClass.private_method_defined?(:private_method) #=> true
|
76
|
+
instance.private_method # raises NoMethodError
|
77
|
+
instance.send(:private_method) #=> 'private with foo'
|
78
78
|
```
|
79
79
|
|
80
80
|
Also works with `prepend`:
|
81
81
|
|
82
82
|
```ruby
|
83
|
-
|
84
|
-
prepend Foo
|
83
|
+
Base.prepend WithFoo
|
85
84
|
|
86
|
-
|
87
|
-
def private_method
|
88
|
-
super + 'bar'
|
89
|
-
end
|
90
|
-
end
|
85
|
+
instance = Base.new
|
91
86
|
|
92
|
-
|
93
|
-
instance.private_method
|
94
|
-
instance.send(:private_method) #=> 'privatebarfoo'
|
87
|
+
Base.private_method_defined?(:private_method) # raises NoMethodError
|
88
|
+
instance.send(:private_method) #=> 'private with foo'
|
95
89
|
```
|
96
90
|
|
97
91
|
## License
|
data/lib/invisible.rb
CHANGED
@@ -6,7 +6,7 @@ module Invisible
|
|
6
6
|
Extend any module with +Invisible+ and any methods the module overrides will
|
7
7
|
maintain their original visibility.
|
8
8
|
|
9
|
-
@example
|
9
|
+
@example With +include+
|
10
10
|
class Base
|
11
11
|
def public_method
|
12
12
|
'public'
|
@@ -25,38 +25,46 @@ maintain their original visibility.
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
module
|
28
|
+
module WithFoo
|
29
29
|
extend Invisible
|
30
30
|
|
31
31
|
def public_method
|
32
|
-
super + 'foo'
|
32
|
+
super + ' with foo'
|
33
33
|
end
|
34
34
|
|
35
35
|
def protected_method
|
36
|
-
super + 'foo'
|
36
|
+
super + ' with foo'
|
37
37
|
end
|
38
38
|
|
39
39
|
def private_method
|
40
|
-
super + 'foo'
|
40
|
+
super + ' with foo'
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
class MyClass < Base
|
45
|
-
include
|
45
|
+
include WithFoo
|
46
46
|
end
|
47
47
|
|
48
48
|
instance = MyClass.new
|
49
49
|
|
50
|
-
|
51
|
-
instance.public_method
|
50
|
+
MyClass.public_method_defined?(:public_method) #=> true
|
51
|
+
instance.public_method #=> 'publicfoo'
|
52
52
|
|
53
|
-
|
54
|
-
instance.protected_method
|
55
|
-
instance.send(:protected_method)
|
53
|
+
MyClass.protected_method_defined?(:protected_method) #=> true
|
54
|
+
instance.protected_method # raises NoMethodError
|
55
|
+
instance.send(:protected_method) #=> 'protectedfoo'
|
56
56
|
|
57
|
-
|
58
|
-
instance.private_method
|
59
|
-
instance.send(:private_method)
|
57
|
+
MyClass.private_method_defined?(:private_method) #=> true
|
58
|
+
instance.private_method # raises NoMethodError
|
59
|
+
instance.send(:private_method) #=> 'privatefoo'
|
60
|
+
|
61
|
+
@example With +prepend+
|
62
|
+
Base.prepend WithFoo
|
63
|
+
|
64
|
+
instance = Base.new
|
65
|
+
|
66
|
+
Base.private_method_defined?(:private_method) # raises NoMethodError
|
67
|
+
instance.send(:private_method) #=> 'private with foo'
|
60
68
|
|
61
69
|
=end
|
62
70
|
def append_features(base)
|
@@ -64,15 +72,15 @@ maintain their original visibility.
|
|
64
72
|
end
|
65
73
|
|
66
74
|
def prepend_features(base)
|
67
|
-
return super if
|
75
|
+
return super if invisible
|
68
76
|
|
69
77
|
sync_visibility(base, mod = dup)
|
70
|
-
mod.
|
78
|
+
mod.invisible = true
|
71
79
|
base.prepend mod
|
72
80
|
end
|
73
81
|
|
74
82
|
protected
|
75
|
-
attr_accessor :
|
83
|
+
attr_accessor :invisible
|
76
84
|
|
77
85
|
private
|
78
86
|
|
data/lib/invisible/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: invisible
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Salzberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -45,6 +45,7 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
+
- CHANGELOG.md
|
48
49
|
- Gemfile
|
49
50
|
- Gemfile.lock
|
50
51
|
- Guardfile
|
@@ -52,7 +53,6 @@ files:
|
|
52
53
|
- README.md
|
53
54
|
- Rakefile
|
54
55
|
- lib/invisible.rb
|
55
|
-
- lib/invisible/CHANGELOG.md
|
56
56
|
- lib/invisible/version.rb
|
57
57
|
homepage: https://github.com/shioyama/invisible
|
58
58
|
licenses:
|
@@ -60,6 +60,7 @@ licenses:
|
|
60
60
|
metadata:
|
61
61
|
homepage_uri: https://github.com/shioyama/invisible
|
62
62
|
source_code_uri: https://github.com/shioyama/invisible
|
63
|
+
changelog_uri: https://github.com/shioyama/invisible/blob/master/CHANGELOG.md
|
63
64
|
post_install_message:
|
64
65
|
rdoc_options: []
|
65
66
|
require_paths:
|