Skip to content

Instantly share code, notes, and snippets.

View banister's full-sized avatar
🇳🇱

John Mair banister

🇳🇱
View GitHub Profile
class Class
def pure_virtual_function(name)
class_eval %{
def #{name}(*args, &block)
raise NotImplementedError, "this function needs an implementation"
end
}
end
end
>> module Horse
>> def neigh
>> puts "neigh"
>> end
>> end
=> nil
>> class Bink
>> include Horse
>> def neigh
>> super
require 'rubygems'
require 'test/unit'
require 'mixology'
# in 1.9.1 the test/unit library seems to mix in PP:ObjectMixin automatically so i added
# that module into the list of modules to test for when checking the inheritance chains
# i also didn't have dust installed (and have no idea what it is) but created a self.test method
# that i think may perform at least some of the function; anyway this test suite passes 100% on my setup
class MixologyTest < Test::Unit::TestCase
/* this C file, */
int bink = 9;
assembles to this:
.file "love.c"
.globl bink
.data
.align 4
.type bink, @object
.size bink, 4
static VALUE
rb_yield_0(val, self, klass, flags, avalue)
VALUE val, self, klass; /* OK */
int flags, avalue;
{
NODE *node;
volatile VALUE result = Qnil;
volatile VALUE old_cref;
volatile VALUE old_wrapper;
One of my favourite C extensions for Ruby 1.8.6 is Mixology. Mixology makes it possible to dynamically mix and unmix modules from inheritance chains and can be used to do some very interesting things. Just some of the applications utilizing this kind of functionality include _why’s mixico, the decorator pattern, and the state pattern.
Unfortunately Mixology has not yet been ported to 1.9.1. Nonetheless I’ve been wanting to try my hand at writing an extension for 1.9.1 and so I thought I’d give it a go myself.
The first thing to do when porting an extension from an earlier version of Ruby to Ruby 1.9.1 is to just try compiling it and examine the errors that result. I did the following in a shell:
One of my favourite C extensions for Ruby 1.8.6 is Mixology. Mixology makes it possible to dynamically mix and unmix
modules from inheritance chains and can be used to do some very interesting things. Just some of the applications
utilizing this kind of functionality include _why’s mixico, the decorator pattern, and the state pattern.
Unfortunately Mixology has not yet been ported to 1.9.1. Nonetheless I’ve been wanting to try my hand at writing an
extension for 1.9.1 and so I thought I’d give it a go myself.
The first thing to do when porting an extension from an earlier version of Ruby to Ruby 1.9.1 is to just try
compiling it and examine the errors that result. I did the following in a shell:
Template
Strategy
Observer
Composite
Iterator
Command
Adapter
Proxy
Decorator
Singleton
Initializing nautilus-open-terminal extension
Initializing nautilus-share extension
seahorse nautilus module initialized
Initializing nautilus-dropbox 0.5.0
** (nautilus:6182): WARNING **: Unable to add monitor: Not supported
Segmentation fault
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 8.04.1
Release: 8.04
Codename: hardy