include 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
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
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.9.2
3
+ - 1.9.3
4
+ - ruby-head
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in include.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Piotr Niełacny
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,41 @@
1
+ # Include
2
+
3
+ Include a class to class
4
+
5
+ [![BuildStatus](http://travis-ci.org/LTe/include.png)](http://github.com/LTe/include)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'include'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install include
20
+
21
+ ## Usage
22
+
23
+ Include class to the class
24
+
25
+ ```ruby
26
+ require 'include'
27
+
28
+ class MyClass
29
+ include Array.to_module
30
+ end
31
+
32
+ MyClass.new # => []
33
+ ```
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create new Pull Request
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new(:test) do |test|
6
+ test.pattern = 'test/**/*_test.rb'
7
+ test.libs << 'lib' << 'test'
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/include/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Piotr Niełacny"]
6
+ gem.email = ["piotr.nielacny@gmail.com"]
7
+ gem.description = %q{Include a class to class}
8
+ gem.summary = %q{Include a class to class}
9
+ gem.homepage = "https://github.com/LTe/include"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "include"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Include::VERSION
17
+ end
@@ -0,0 +1,4 @@
1
+ require "include/version"
2
+ require "include/internals"
3
+ require "include/object"
4
+ require "include/class"
@@ -0,0 +1,12 @@
1
+ class Class
2
+ def to_module
3
+ result = self.clone
4
+ o = RubyInternal::RObject.new(result.internal_ptr)
5
+ o.flags &= ~ RubyInternal::FL_SINGLETON
6
+ o.flags &= ~ RubyInternal::T_MASK
7
+ o.flags |= RubyInternal::T_MODULE
8
+ o.klass = Module.internal_ptr.to_i
9
+ return result
10
+ end
11
+ alias :to_m :to_module
12
+ end
@@ -0,0 +1,34 @@
1
+ require 'dl'
2
+ require 'dl/import'
3
+ require 'dl/struct'
4
+
5
+ module RubyInternal
6
+ extend DL::Importer
7
+ dlload
8
+
9
+ T_MASK = 0x1f
10
+ T_MODULE = 0x03
11
+
12
+ FL_USHIFT = 12
13
+ FL_USER0 = 1 << (FL_USHIFT + 0)
14
+ FL_SINGLETON = FL_USER0
15
+
16
+ typealias "VALUE", "unsigned long"
17
+ typealias "ID", "unsigned long"
18
+
19
+ Basic = [
20
+ "VALUE flags",
21
+ "VALUE klass"
22
+ ]
23
+
24
+ RBasic = struct(Basic)
25
+
26
+ object_struct = [
27
+ 'long numiv',
28
+ 'VALUE *ivptr',
29
+ 'st_table *iv_index_tbl',
30
+ 'VALUE ara[3]'
31
+ ]
32
+
33
+ RObject = struct(Basic + object_struct)
34
+ end
@@ -0,0 +1,6 @@
1
+ class Object
2
+ def internal_ptr(*args)
3
+ pos = self.object_id * 2
4
+ DL::CPtr.new(pos, *args)
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module Include
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,17 @@
1
+ require 'test_helper'
2
+
3
+ class IncludeTest < MiniTest::Unit::TestCase
4
+ def setup
5
+ @klass = Class.new
6
+ @klass.send(:include, Array.to_module)
7
+ @klass.send(:include, MyClass.to_m)
8
+ end
9
+
10
+ def test_initialize
11
+ assert @klass.new, Array.new
12
+ end
13
+
14
+ def test_my_class_method
15
+ assert @klass.new.my_method, :my_method
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ require 'minitest/autorun'
2
+ require 'include'
3
+
4
+ class MyClass
5
+ def my_method
6
+ :my_method
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: include
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Piotr Niełacny
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-17 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Include a class to class
15
+ email:
16
+ - piotr.nielacny@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - .travis.yml
23
+ - Gemfile
24
+ - LICENSE
25
+ - README.md
26
+ - Rakefile
27
+ - include.gemspec
28
+ - lib/include.rb
29
+ - lib/include/class.rb
30
+ - lib/include/internals.rb
31
+ - lib/include/object.rb
32
+ - lib/include/version.rb
33
+ - test/include_test.rb
34
+ - test/test_helper.rb
35
+ homepage: https://github.com/LTe/include
36
+ licenses: []
37
+ post_install_message:
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 1.8.17
56
+ signing_key:
57
+ specification_version: 3
58
+ summary: Include a class to class
59
+ test_files:
60
+ - test/include_test.rb
61
+ - test/test_helper.rb