uninclude 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f79263459ef7fa7277c158219544f3aea224485
4
- data.tar.gz: 28000a08eb75952fa64bbee0a8b5cef0fbca6e42
3
+ metadata.gz: 3aa09b356c198f58864dd17372554755b4c8ba15
4
+ data.tar.gz: b9a4d6ef26be9affba3fa4e81320ff63b5ad8616
5
5
  SHA512:
6
- metadata.gz: fe90ab8dae54b66dce47c424f0f7a670490acf81ff18402abc3eed7be827da559851f788e513afbd8639de470c15aa0544050df5c0b3ef51b8a76dfabe3e2018
7
- data.tar.gz: 80890fe920c38978abbc006eac479a1aa28c50643a474e2458d21f87ecc75d76fc64509cc9a1e3d988c59b79373b6161ed227605eefbea600278d2638f297679
6
+ metadata.gz: 403ec16ed0601df7d2954a38e509e4af79feabef77a58ac6556fb1870b1fd9a6b771f2ad6bb52f406864bcfe1601eab1c9431a8091d045bcd25caf11c547535b
7
+ data.tar.gz: b81169d1ccfa269681ca357f2e4d2766c2fd2f53570cda344f794a4efd81bb20b239824ce8919808b6dcb5c207e11bf8798889b71e92bfe8276ee860b1281d82
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - ruby-head
4
+ - 2.2.3
4
5
  - 2.2.0
5
6
  - 2.1.4
6
7
  - 2.1.0
@@ -9,3 +10,6 @@ rvm:
9
10
  - 1.9.2
10
11
  - 1.8.7
11
12
  - ree
13
+ matrix:
14
+ allow_failures:
15
+ - rvm: ruby-head
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
@@ -1,3 +1,3 @@
1
1
  module Uninclude
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -8,11 +8,9 @@ end
8
8
  describe Uninclude do
9
9
  let(:klass) {
10
10
  Class.new do
11
- if respond_to_missing?(:singleton_class, true)
12
- def singleton_class
13
- class << self
14
- self
15
- end
11
+ def singleton_class
12
+ class << self
13
+ self
16
14
  end
17
15
  end
18
16
  end
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.2.0
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-02-02 00:00:00.000000000 Z
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