uninclude 1.2.0 → 1.3.0
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/.travis.yml +4 -0
- data/README.md +15 -0
- data/lib/uninclude/block.rb +52 -0
- data/lib/uninclude/version.rb +1 -1
- data/spec/uninclude_spec.rb +3 -5
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3aa09b356c198f58864dd17372554755b4c8ba15
|
4
|
+
data.tar.gz: b9a4d6ef26be9affba3fa4e81320ff63b5ad8616
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 403ec16ed0601df7d2954a38e509e4af79feabef77a58ac6556fb1870b1fd9a6b771f2ad6bb52f406864bcfe1601eab1c9431a8091d045bcd25caf11c547535b
|
7
|
+
data.tar.gz: b81169d1ccfa269681ca357f2e4d2766c2fd2f53570cda344f794a4efd81bb20b239824ce8919808b6dcb5c207e11bf8798889b71e92bfe8276ee860b1281d82
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -8,6 +8,7 @@ Implement Module#uninclude and Object#unextend
|
|
8
8
|
|
9
9
|
## Tested ruby versions
|
10
10
|
|
11
|
+
- 2.2.3
|
11
12
|
- 2.2.0
|
12
13
|
- 2.1.4
|
13
14
|
- 2.1.0
|
@@ -59,6 +60,20 @@ foo.unextend(Bar)
|
|
59
60
|
p foo.singleton_class.ancestors # => [Foo, Object, Kernel, BasicObject]
|
60
61
|
```
|
61
62
|
|
63
|
+
### `uninclude/block`
|
64
|
+
|
65
|
+
Make `#include` / `#uninclude` accepts blocks.
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
require 'uninclude/block' # This feature is optional. Please require 'uninclude/block' first.
|
69
|
+
|
70
|
+
Foo.include(Bar) do
|
71
|
+
p Foo.ancestors # => [Foo, Bar, Object, Kernel, BasicObject]
|
72
|
+
end
|
73
|
+
|
74
|
+
p Foo.ancestors # => [Foo, Object, Kernel, BasicObject]
|
75
|
+
```
|
76
|
+
|
62
77
|
## Contributing
|
63
78
|
|
64
79
|
1. Fork it
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'uninclude'
|
3
|
+
|
4
|
+
class Module
|
5
|
+
alias_method :__include, :include
|
6
|
+
alias_method :__uninclude, :uninclude
|
7
|
+
|
8
|
+
def include(mod)
|
9
|
+
__include(mod)
|
10
|
+
|
11
|
+
if block_given?
|
12
|
+
yield(self)
|
13
|
+
__uninclude(mod)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def uninclude(mod)
|
18
|
+
return unless ancestors.include?(mod)
|
19
|
+
|
20
|
+
__uninclude(mod)
|
21
|
+
|
22
|
+
if block_given?
|
23
|
+
yield(self)
|
24
|
+
__include(mod)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Object
|
30
|
+
alias_method :__extend, :extend
|
31
|
+
alias_method :__unextend, :unextend
|
32
|
+
|
33
|
+
def extend(mod)
|
34
|
+
__extend(mod)
|
35
|
+
|
36
|
+
if block_given?
|
37
|
+
yield(self)
|
38
|
+
__unextend(mod)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def unextend(mod)
|
43
|
+
return unless singleton_class.ancestors.include?(mod)
|
44
|
+
|
45
|
+
__unextend(mod)
|
46
|
+
|
47
|
+
if block_given?
|
48
|
+
yield(self)
|
49
|
+
__extend(mod)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/uninclude/version.rb
CHANGED
data/spec/uninclude_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uninclude
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sho Kusano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- ext/uninclude/extconf.rb
|
71
71
|
- ext/uninclude/uninclude.c
|
72
72
|
- lib/uninclude.rb
|
73
|
+
- lib/uninclude/block.rb
|
73
74
|
- lib/uninclude/version.rb
|
74
75
|
- spec/spec_helper.rb
|
75
76
|
- spec/uninclude_spec.rb
|
@@ -94,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
95
|
version: '0'
|
95
96
|
requirements: []
|
96
97
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.4.5
|
98
|
+
rubygems_version: 2.4.5.1
|
98
99
|
signing_key:
|
99
100
|
specification_version: 4
|
100
101
|
summary: Implement Module#uninclude and Object#unextend
|