Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rkh/convinius
Convenience library for Rubinius-only projects.
https://github.com/rkh/convinius
Last synced: about 1 month ago
JSON representation
Convenience library for Rubinius-only projects.
- Host: GitHub
- URL: https://github.com/rkh/convinius
- Owner: rkh
- Created: 2011-01-26T11:24:41.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2011-02-03T23:57:05.000Z (almost 14 years ago)
- Last Synced: 2023-04-10T08:23:08.901Z (over 1 year ago)
- Language: Ruby
- Size: 102 KB
- Stars: 16
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Convinius
=========Convenience library for Rubinius-only projects.
Use `require 'convinius'` to get all features.Installation:
gem install convinius
Running tests:
gem install rspec
rspec specSubclassing from arbitrary Objects
----------------------------------
in: `convinius/to_class`If you subclass from an object, first call `to_class` on that object and
subclass the result instead:RandomClass = Object.new
def RandomClass.to_class
[Hash, Object, Set].at rand(3)
end
class Foo < RandomClass
puts superclass
endA more realistic example:
module Awesome
def self.to_class
Class.new { include Awesome }
end
end
class Foo < Awesome
end
class Bar < Something
include Awesome
endCreating own subclass of Class
------------------------------
in: `convinius/subclass_class`class MyClass < Class
endFoo = MyClass.new Bar
Foo.new.class # => Foo
Foo.class # => MyClass (without patch this would be Class)Import constants from Rubinius
------------------------------
in: `convinius/globals`Defines global constants `Tuple` and `Fiber`.
Convenience for Rubinius::Generator
-----------------------------------
in: `convinius/generator`Method for generating tuples (like `make_array`):
class MyNode < Rubinius::AST::Node
def bytecode(g)
(1..5).each { |i| g.push i }
g.make_tuple 5
end
endByte Code Generator DSL
-----------------------
in: `convinius/asm`Example:
include Convinius::ASM
compiled = asm do
push 1
push 2
send :+, 1
end
p compiled.callIf block takes an argument, it won't use `instance_eval`:
Convinius::ASM.new do |g|
g.push 1
g.push 2
g.send :+, 1
end