Parent

Methods

Included Modules

Less::Loader

Public Class Methods

new() click to toggle source
# File lib/less/loader.rb, line 6
def initialize
  lock do
    @cxt = V8::Context.new
    @path = Pathname(__FILE__).dirname.join('js','lib')
    @exports = {
      "path" => Path.new,
      "sys" => Sys.new,
      "fs" => Fs.new
    }
    @process = Process.new
    @cxt['console'] = Console.new
  end
end

Public Instance Methods

require(path) click to toggle source
# File lib/less/loader.rb, line 20
def require(path)
  unless exports = @exports[path]
    filename = path =~ /\.js$/ ? path : "#{path}.js"
    filepath = @path.join(filename)
    fail LoadError, "no such file: #{filename}" unless filepath.exist?
    lock do
      load = @cxt.eval("(function(process, require, exports, __dirname) {require.paths = [];#{File.read(filepath)}})", filepath.expand_path)
      @exports[path] = exports = @cxt['Object'].new
      load.call(@process, method(:require), exports, Dir.pwd)
    end
  end
  return exports
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.