Skip to content

Commit

Permalink
adding the handle
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Sep 22, 2008
1 parent 9ad71a3 commit d743c58
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 152 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -1,7 +1,11 @@
.*.swp .*.swp
*.tmproj *.tmproj
*.o
*.bundle
*.log
vendor/zmq-0.3/ vendor/zmq-0.3/
vendor/bin/ vendor/bin/
vendor/include/ vendor/include/
vendor/lib/ vendor/lib/
ext/quail/Makefile
tags tags
149 changes: 0 additions & 149 deletions ext/quail/Makefile

This file was deleted.

Binary file removed ext/quail/native.bundle
Binary file not shown.
6 changes: 3 additions & 3 deletions ext/quail/native.c
@@ -1,10 +1,10 @@
#include <native.h> #include <native.h>


VALUE mQuail;

void Init_native() void Init_native()
{ {
mQuail = rb_define_module("Quail"); VALUE mQuail = rb_define_module("Quail");
rb_const_set(mQuail, rb_intern("LOCAL"), INT2NUM(CZMQ_SCOPE_LOCAL)); rb_const_set(mQuail, rb_intern("LOCAL"), INT2NUM(CZMQ_SCOPE_LOCAL));
rb_const_set(mQuail, rb_intern("GLOBAL"), INT2NUM(CZMQ_SCOPE_GLOBAL)); rb_const_set(mQuail, rb_intern("GLOBAL"), INT2NUM(CZMQ_SCOPE_GLOBAL));

Init_Quail_Handle(mQuail);
} }
1 change: 1 addition & 0 deletions ext/quail/native.h
Expand Up @@ -4,5 +4,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <ruby.h> #include <ruby.h>
#include <czmq.h> #include <czmq.h>
#include <quail_handle.h>


#endif #endif
Binary file removed ext/quail/native.o
Binary file not shown.
18 changes: 18 additions & 0 deletions ext/quail/quail_handle.c
@@ -0,0 +1,18 @@
#include <quail_handle.h>

static void dealloc(void * handle)
{
czmq_destroy(handle);
}

static VALUE new(VALUE klass, VALUE host)
{
void * handle = czmq_create(StringValuePtr(host));
return Data_Wrap_Struct(klass, NULL, dealloc, handle);
}

void Init_Quail_Handle(VALUE mQuail)
{
VALUE cQuailHandle = rb_define_class_under(mQuail, "Handle", rb_cObject);
rb_define_singleton_method(cQuailHandle, "new", new, 1);
}
8 changes: 8 additions & 0 deletions ext/quail/quail_handle.h
@@ -0,0 +1,8 @@
#ifndef QUAIL_HANDLE
#define QUAIL_HANDLE

#include <native.h>

void Init_Quail_Handle(VALUE mQuail);

#endif
2 changes: 2 additions & 0 deletions test/helper.rb
Expand Up @@ -4,6 +4,8 @@
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), path))) $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), path)))
end end


Thread.new { `vendor/bin/zmq_server` }

require 'quail' require 'quail'


module Quail module Quail
Expand Down
11 changes: 11 additions & 0 deletions test/quail/test_handle.rb
@@ -0,0 +1,11 @@
require File.expand_path(File.join(File.dirname(__FILE__), "..", "helper"))

module Quail
class TestHandle < Quail::TestCase
def test_initialize
assert_nothing_raised {
Quail::Handle.new('localhost.local')
}
end
end
end

0 comments on commit d743c58

Please sign in to comment.