unmixer 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/example/simple.rb +53 -0
- data/lib/unmixer/core_refine.rb +14 -6
- data/lib/unmixer/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 744abd9d02195ad0c1cbfb95da0ec26474417dba
|
4
|
+
data.tar.gz: 8c9bafa0140645769984aaae48014b6df80cae53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea97559d1ef82901e5641475da7ca286f401b38936576071145d195142e2b58d7df0f82f0020a83635d6a10c2316e2420ed36f73b59bde1b5af77aebfd1c7f92
|
7
|
+
data.tar.gz: e15667eb6ffe2e410232aa6d5b921ac4aa1d3234bebd25ad376a2f1f7f31cf16f2f085c5a1e76be73ee33b61e86fabe2c2bc86da1fce52e9587c67fce3eb795a
|
data/README.md
CHANGED
@@ -87,3 +87,13 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
87
87
|
|
88
88
|
Bug reports and pull requests are welcome on GitHub at https://github.com/osyo-manga/gem-unmixer.
|
89
89
|
|
90
|
+
|
91
|
+
## Release Note
|
92
|
+
|
93
|
+
#### 0.2.0
|
94
|
+
|
95
|
+
* Fix `#extend`/`#unextend` result
|
96
|
+
|
97
|
+
#### 0.1.0
|
98
|
+
* Release
|
99
|
+
|
data/example/simple.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require "unmixer"
|
2
|
+
|
3
|
+
# unmixer is using refinements.
|
4
|
+
using Unmixer
|
5
|
+
|
6
|
+
module M1; end
|
7
|
+
module M2; end
|
8
|
+
module M3; end
|
9
|
+
|
10
|
+
class X
|
11
|
+
include M1
|
12
|
+
prepend M2
|
13
|
+
end
|
14
|
+
|
15
|
+
p X.ancestors
|
16
|
+
# => [M2, X, M1, Object, Kernel, BasicObject]
|
17
|
+
|
18
|
+
# Remove include module.
|
19
|
+
X.instance_eval { uninclude M1 }
|
20
|
+
p X.ancestors
|
21
|
+
# => [M2, X, Object, Kernel, BasicObject]
|
22
|
+
|
23
|
+
# Not remove prepend module. #uninclude is only include modules.
|
24
|
+
X.instance_eval { uninclude M2 }
|
25
|
+
p X.ancestors
|
26
|
+
# => [M2, X, Object, Kernel, BasicObject]
|
27
|
+
|
28
|
+
|
29
|
+
# Remove prepend module.
|
30
|
+
X.instance_eval { unprepend M2 }
|
31
|
+
p X.ancestors
|
32
|
+
# => [X, Object, Kernel, BasicObject]
|
33
|
+
|
34
|
+
|
35
|
+
X.extend M3
|
36
|
+
p X.singleton_class.ancestors
|
37
|
+
# => [#<Class:X>, M3, #<Class:Object>, #<Class:BasicObject>, Class, Module, Object, Kernel, BasicObject]
|
38
|
+
|
39
|
+
# Remove extend module.
|
40
|
+
X.unextend M3
|
41
|
+
p X.singleton_class.ancestors
|
42
|
+
# => [#<Class:X>, #<Class:Object>, #<Class:BasicObject>, Class, Module, Object, Kernel, BasicObject]
|
43
|
+
|
44
|
+
|
45
|
+
# #extend with block
|
46
|
+
X.extend M1 do
|
47
|
+
# mixin only in block.
|
48
|
+
p X.singleton_class.ancestors
|
49
|
+
# => [#<Class:X>, M1, #<Class:Object>, #<Class:BasicObject>, Class, Module, Object, Kernel, BasicObject]
|
50
|
+
end
|
51
|
+
p X.singleton_class.ancestors
|
52
|
+
# => [#<Class:X>, #<Class:Object>, #<Class:BasicObject>, Class, Module, Object, Kernel, BasicObject]
|
53
|
+
|
data/lib/unmixer/core_refine.rb
CHANGED
@@ -21,24 +21,32 @@ module Unmixer
|
|
21
21
|
refine Object do
|
22
22
|
alias_method :unmixer_original_extend, :extend
|
23
23
|
def unmixer_extend mod
|
24
|
-
unmixer_original_extend mod
|
24
|
+
result = unmixer_original_extend mod
|
25
25
|
|
26
26
|
if block_given?
|
27
|
-
|
28
|
-
|
27
|
+
begin
|
28
|
+
yield(self)
|
29
|
+
ensure
|
30
|
+
unmixer_unextend mod
|
31
|
+
end
|
29
32
|
end
|
33
|
+
result
|
30
34
|
end
|
31
35
|
alias_method :extend, :unmixer_extend
|
32
36
|
|
33
37
|
def unmixer_unextend mod
|
34
|
-
return unless singleton_class.ancestors.include? mod
|
38
|
+
return self unless singleton_class.ancestors.include? mod
|
35
39
|
|
36
40
|
singleton_class.__send__ :unmixer_unmixin, mod
|
37
41
|
|
38
42
|
if block_given?
|
39
|
-
|
40
|
-
|
43
|
+
begin
|
44
|
+
yield(self)
|
45
|
+
ensure
|
46
|
+
unmixer_original_extend mod
|
47
|
+
end
|
41
48
|
end
|
49
|
+
self
|
42
50
|
end
|
43
51
|
alias_method :unextend, :unmixer_unextend
|
44
52
|
end
|
data/lib/unmixer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unmixer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- manga_osyo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- Rakefile
|
83
83
|
- bin/console
|
84
84
|
- bin/setup
|
85
|
+
- example/simple.rb
|
85
86
|
- ext/unmixer/2.1.0/internal.h
|
86
87
|
- ext/unmixer/2.2.0/internal.h
|
87
88
|
- ext/unmixer/2.3.0/internal.h
|