include 0.0.1
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.
- data/.gitignore +17 -0
 - data/.travis.yml +4 -0
 - data/Gemfile +4 -0
 - data/LICENSE +22 -0
 - data/README.md +41 -0
 - data/Rakefile +10 -0
 - data/include.gemspec +17 -0
 - data/lib/include.rb +4 -0
 - data/lib/include/class.rb +12 -0
 - data/lib/include/internals.rb +34 -0
 - data/lib/include/object.rb +6 -0
 - data/lib/include/version.rb +3 -0
 - data/test/include_test.rb +17 -0
 - data/test/test_helper.rb +8 -0
 - metadata +61 -0
 
    
        data/.gitignore
    ADDED
    
    
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        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.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,41 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Include
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Include a class to class
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            [](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
         
     | 
    
        data/Rakefile
    ADDED
    
    
    
        data/include.gemspec
    ADDED
    
    | 
         @@ -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
         
     | 
    
        data/lib/include.rb
    ADDED
    
    
| 
         @@ -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,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
         
     | 
    
        data/test/test_helper.rb
    ADDED
    
    
    
        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
         
     |