inline.rb

Path: lib/inline.rb
Last Update: Fri Oct 15 21:48:59 +0000 2010

Ruby Inline is a framework for writing ruby extensions in foreign languages.

SYNOPSIS

  require 'inline'
  class MyClass
    inline do |builder|
      builder.include "<math.h>"
      builder.c %q{
        long factorial(int max) {
          int i=max, result=1;
          while (i >= 2) { result *= i--; }
          return result;
        }
      }
    end
  end

DESCRIPTION

Inline allows you to write foreign code within your ruby code. It automatically determines if the code in question has changed and builds it only when necessary. The extensions are then automatically loaded into the class/module that defines it.

You can even write extra builders that will allow you to write inlined code in any language. Use Inline::C as a template and look at Module#inline for the required API.

PACKAGING

To package your binaries into a gem, use hoe‘s INLINE and FORCE_PLATFORM env vars.

Example:

  rake package INLINE=1

or:

  rake package INLINE=1 FORCE_PLATFORM=mswin32

See hoe for more details.

Required files

rbconfig   digest/md5   fileutils   rubygems   zentest_mapping  

Methods

Public Class methods

rootdir can be forced using INLINEDIR variable if not defined, it should store in user HOME folder

Under Windows user data can be stored in several locations:

 HOME
 HOMEDRIVE + HOMEPATH
 APPDATA
 USERPROFILE

Perform a check in that other to see if the environment is defined and if so, use it. only try this on Windows.

[Validate]