uninclude 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 96405ddf351f077dad99c174639aab798fb9223d
4
+ data.tar.gz: cfd494ce34a36479896a833aea8dc05c09f1b067
5
+ SHA512:
6
+ metadata.gz: 45e33c9ed24d35548ab329289f382db31e586101839d2882e4a9516ec40ca388360697b6769001960eeddbd9d66d0252e196ee64119d6f4fb437a4047848d1a1
7
+ data.tar.gz: 037da7ea0a1e7dcd2d0789befe0bf34840ddcddc975b60fb9a949dc68f46f84c6de2857d49e201682cd01c749af245e94db9b1657dd1c171882e11df5bc41bb4
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.so
19
+ *.o
20
+ *.bundle
21
+ ext/**/Makefile
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+ - 1.9.2
6
+ - 1.8.7
7
+ - ree
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in uninclude.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Sho Kusano
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,65 @@
1
+ # Uninclude
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/uninclude.png)](http://rubygems.org/gems/uninclude)
4
+ [![Build Status](https://travis-ci.org/rosylilly/uninclude.png?branch=master)](https://travis-ci.org/rosylilly/uninclude)
5
+ [![Dependency Status](https://gemnasium.com/rosylilly/uninclude.png)](https://gemnasium.com/rosylilly/uninclude)
6
+
7
+ Implement Module#uninclude and Object#unextend
8
+
9
+ ## Tested ruby versions
10
+
11
+ - 2.0.0
12
+ - 1.9.3
13
+ - 1.9.2
14
+ - 1.8.7
15
+ - REE
16
+
17
+ see [travis-ci.org](https://travis-ci.org/rosylilly/uninclude)
18
+
19
+ ## Installation
20
+
21
+ Add this line to your application's Gemfile:
22
+
23
+ gem 'uninclude'
24
+
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+ Or install it yourself as:
30
+
31
+ $ gem install uninclude
32
+
33
+ ## Usage
34
+
35
+ ```ruby
36
+ require 'uninclude'
37
+
38
+ module Bar
39
+ end
40
+
41
+ class Foo
42
+ include Bar
43
+ end
44
+
45
+ p Foo.ancestors # => [Foo, Bar, Object, Kernel, BasicObject]
46
+
47
+ Foo.class_eval { uninclude Bar }
48
+ p Foo.ancestors # => [Foo, Object, Kernel, BasicObject]
49
+
50
+ foo = Foo.new
51
+
52
+ foo.extend(Bar)
53
+ p foo.singleton_class.ancestors # => [Bar, Foo, Object, Kernel, BasicObject]
54
+
55
+ foo.unextend(Bar)
56
+ p foo.singleton_class.ancestors # => [Foo, Object, Kernel, BasicObject]
57
+ ```
58
+
59
+ ## Contributing
60
+
61
+ 1. Fork it
62
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
63
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
64
+ 4. Push to the branch (`git push origin my-new-feature`)
65
+ 5. Create new Pull Request
@@ -0,0 +1,24 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rake/clean'
4
+
5
+ GEM_NAME = 'uninclude'.freeze
6
+ DLEXT = RbConfig::CONFIG['DLEXT']
7
+
8
+ CLEAN.include("ext/**/*.{#{DLEXT},log,o}")
9
+ CLEAN.include('ext/**/Makefile')
10
+ CLEAN.include("lib/**/*.#{DLEXT}")
11
+ CLOBBER.include("lib/**/*.#{DLEXT}")
12
+
13
+ file "lib/#{GEM_NAME}/#{GEM_NAME}.#{DLEXT}" => Dir.glob("ext/#{GEM_NAME}/*.{rb, c}") do
14
+ Dir.chdir("ext/#{GEM_NAME}") do
15
+ ruby 'extconf.rb'
16
+ sh 'make'
17
+ end
18
+ cp "ext/#{GEM_NAME}/#{GEM_NAME}.#{DLEXT}", "lib/#{GEM_NAME}/#{GEM_NAME}.#{DLEXT}"
19
+ end
20
+
21
+ RSpec::Core::RakeTask.new(:spec)
22
+ task :spec => "lib/#{GEM_NAME}/#{GEM_NAME}.#{DLEXT}"
23
+
24
+ task :default => :spec
@@ -0,0 +1,11 @@
1
+ require 'mkmf'
2
+
3
+ RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
4
+
5
+ $CFLAGS << " #{ENV["CFLAGS"]}"
6
+
7
+ if RUBY_VERSION >= '1.9.3'
8
+ $CFLAGS << ' -DHAVE_RUBY_BACKWARD_CLASSEXT_H'
9
+ end
10
+
11
+ create_makefile('uninclude/uninclude')
@@ -0,0 +1,37 @@
1
+ #include <ruby.h>
2
+
3
+ #ifdef HAVE_RUBY_BACKWARD_CLASSEXT_H
4
+ #include <ruby/backward/classext.h>
5
+ #endif
6
+
7
+ #ifndef RCLASS_M_TBL
8
+ #define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl)
9
+ #endif
10
+
11
+ static void uninclude(VALUE klass, VALUE mod) {
12
+ Check_Type(mod, T_MODULE);
13
+
14
+ VALUE superklass = RCLASS_SUPER(klass);
15
+ for(; superklass; klass = superklass, klass = RCLASS_SUPER(klass)) {
16
+ if(klass == mod || RCLASS_M_TBL(superklass) == RCLASS_M_TBL(mod)) {
17
+ RCLASS_SUPER(klass) = RCLASS_SUPER(superklass);
18
+ rb_clear_cache_by_class(klass);
19
+ break;
20
+ }
21
+ };
22
+ };
23
+
24
+ static VALUE rb_m_uninclude(VALUE self, VALUE mod) {
25
+ uninclude(self, mod);
26
+ return self;
27
+ }
28
+
29
+ static VALUE rb_m_unextend(VALUE self, VALUE mod) {
30
+ uninclude(rb_singleton_class(self), mod);
31
+ return self;
32
+ }
33
+
34
+ void Init_uninclude(void) {
35
+ rb_define_private_method(rb_cModule, "uninclude", RUBY_METHOD_FUNC(rb_m_uninclude), 1);
36
+ rb_define_method(rb_cObject, "unextend", RUBY_METHOD_FUNC(rb_m_unextend), 1);
37
+ }
@@ -0,0 +1,2 @@
1
+ require 'uninclude/version'
2
+ require 'uninclude/uninclude'
@@ -0,0 +1,3 @@
1
+ module Uninclude
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'uninclude'
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ module ExampleMod
4
+ def mod; :mod; end
5
+ end
6
+
7
+ describe Uninclude do
8
+ let(:klass) {
9
+ Class.new do
10
+ end
11
+ }
12
+ let(:instance) { klass.new }
13
+
14
+ describe '.uninclude' do
15
+ it 'should uninclude module' do
16
+ klass.class_eval { include ExampleMod }
17
+ instance.should respond_to(:mod)
18
+ klass.class_eval { uninclude ExampleMod }
19
+ instance.should_not respond_to(:mod)
20
+ end
21
+ end
22
+
23
+ describe '#unextend' do
24
+ it 'should unextend module' do
25
+ instance.extend(ExampleMod)
26
+ instance.should respond_to(:mod)
27
+ instance.unextend(ExampleMod)
28
+ instance.should_not respond_to(:mod)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'uninclude/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "uninclude"
8
+ spec.version = Uninclude::VERSION
9
+ spec.authors = ["Sho Kusano"]
10
+ spec.email = ["rosylilly@aduca.org"]
11
+ spec.description = %q{Implement Module#uninclude and Object#unextend}
12
+ spec.summary = %q{Implement Module#uninclude and Object#unextend}
13
+ spec.homepage = "https://github.com/rosylilly/uninclude"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.extensions = %w{ext/uninclude/extconf.rb}
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec"
25
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: uninclude
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Sho Kusano
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-03-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Implement Module#uninclude and Object#unextend
56
+ email:
57
+ - rosylilly@aduca.org
58
+ executables: []
59
+ extensions:
60
+ - ext/uninclude/extconf.rb
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - .rspec
65
+ - .travis.yml
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - ext/uninclude/extconf.rb
71
+ - ext/uninclude/uninclude.c
72
+ - lib/uninclude.rb
73
+ - lib/uninclude/version.rb
74
+ - spec/spec_helper.rb
75
+ - spec/uninclude_spec.rb
76
+ - uninclude.gemspec
77
+ homepage: https://github.com/rosylilly/uninclude
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.0.0
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Implement Module#uninclude and Object#unextend
101
+ test_files:
102
+ - spec/spec_helper.rb
103
+ - spec/uninclude_spec.rb