'use strict';
var Filter = require('broccoli-filter');
var RSVP = require('rsvp');
var less = require('less');
var Minimatch = require('minimatch').Minimatch;

function LessFilter(inputTree, options) {
	if (!(this instanceof LessFilter)) {
		return new LessFilter(inputTree, options);
	}

	this.inputTree = inputTree;
  this.includeFiles = options.include || [];
  delete options.include;
	this.options = options || {};
}

LessFilter.prototype = Object.create(Filter.prototype);
LessFilter.prototype.constructor = LessFilter;

LessFilter.prototype.extensions = ['less'];
LessFilter.prototype.targetExtension = 'css';

var canProcessFile = LessFilter.prototype.canProcessFile;

LessFilter.prototype.canProcessFile = function(relativePath) {

    // If not using include, then default to previous behavior of processing
    // everything
    //
    if (this.includeFiles == []) {
        return canProcessFile.apply(this, [relativePath]);
    }

    var includedFiles =
        this.includeFiles.filter(function(pattern) {
            if (this._includeFile(relativePath, new Minimatch(pattern))) {
                return true;
            }
        }.bind(this));

    return includedFiles.length > 0;
};

LessFilter.prototype._includeFile = function(relativePath, pattern) {
    return pattern.match(relativePath);
}

LessFilter.prototype.processString = function (str, relativePath) {

    this.options.filename = this.options.filename || relativePath;

    return less.render(str, this.options).then(function(output) {
        return output.css;
    }).catch(function(error) {
        console.error("Error processing file ", error.filename, "at line ", error.line);
        console.error(error.message);
        console.error("Near:");
        console.error(error.extract.join('\n'));
    });
};

module.exports = LessFilter;

@@ -151,16 +151,68 @@
 nimatch;
+%0Avar fs = require('fs');%0Avar path = require('path');
 %0A%0Afuncti
@@ -1358,24 +1358,666 @@
 vePath);%0A%7D%0A%0A
+%0ALessFilter.prototype.processFile = function (srcDir, destDir, relativePath) %7B%0A  var self = this%0A  var inputEncoding = (this.inputEncoding === undefined) ? 'utf8' : this.inputEncoding%0A  var outputEncoding = (this.outputEncoding === undefined) ? 'utf8' : this.outputEncoding%0A  var string = fs.readFileSync(srcDir + '/' + relativePath, %7B encoding: inputEncoding %7D)%0A  return RSVP.Promise.resolve(this.processString(string, srcDir, relativePath))%0A    .then(function (outputString) %7B%0A      var outputPath = self.getDestFilePath(relativePath)%0A      fs.writeFileSync(destDir + '/' + outputPath, outputString, %7B encoding: outputEncoding %7D)%0A    %7D)%0A%7D%0A%0A
 LessFilter.p
@@ -2055,16 +2055,24 @@
 on (str,
+ srcDir,
  relativ
@@ -2147,16 +2147,137 @@
 ivePath;
+%0A    this.options.paths = this.options.paths.map(function(relative) %7B%0A        return path.join(srcDir, relative);%0A    %7D);
 %0A%0A    re

Use absolute path for includePaths option