module Inline

The Inline module is the top-level module used. It is responsible for instantiating the builder for the right language used, compilation/linking when needed, and loading the inlined code into the current namespace.

Constants

DEV_NULL
GEM
RAKE
VERSION
WINDOZE

Public Class Methods

directory() click to toggle source
# File lib/inline.rb, line 132
def self.directory
  unless defined? @@directory then
    version = "#{Gem.ruby_engine}-#{RbConfig::CONFIG['ruby_version']}"

    @@directory = File.join(self.rootdir, ".ruby_inline", version)
  end

  Dir.assert_secure @@directory

  @@directory
end
register(cls) click to toggle source
# File lib/inline.rb, line 77
def self.register cls # for hoe/inline
  registered_inline_classes << cls
  registered_inline_classes.uniq!
end
registered_inline_classes() click to toggle source
# File lib/inline.rb, line 82
def self.registered_inline_classes # for hoe/inline
  @@registered_inline_classes ||= []
end
rootdir() click to toggle source

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.

Note, depending on how you’re using this (eg, a rails app in production), you probably want to use absolute paths.

# File lib/inline.rb, line 102
def self.rootdir
  env = ENV['INLINEDIR'] || ENV['HOME']

  if env.nil? and WINDOZE then
    # try HOMEDRIVE + HOMEPATH combination
    if ENV['HOMEDRIVE'] && ENV['HOMEPATH'] then
      env = ENV['HOMEDRIVE'] + ENV['HOMEPATH']
    end

    # no HOMEDRIVE? use APPDATA
    env = ENV['APPDATA'] if env.nil? and ENV['APPDATA']

    # bummer, still no env? then fall to USERPROFILE
    env = ENV['USERPROFILE'] if env.nil? and ENV['USERPROFILE']
  end

  if env.nil? then
    abort "Define INLINEDIR or HOME in your environment and try again"
  end

  unless defined? @@rootdir and env == @@rootdir and test ?d, @@rootdir then
    rootdir = env
    Dir.mkdir rootdir, 0700 unless test ?d, rootdir
    Dir.assert_secure rootdir
    @@rootdir = rootdir
  end

  @@rootdir
end