'use strict';

function FakeGulp(tasks) {
	this.taskRegistry = tasks || {};
}

FakeGulp.prototype.task = function (name, runner) {
	if (typeof name === 'function') {
		runner = name;
		name = runner.displayName || runner.name;
	}
	if (typeof name === 'string' && typeof runner === 'function') {
		this.taskRegistry[name] = runner;
	}
	return this.taskRegistry[name];
};

FakeGulp.prototype.registry = function (registry) {
	if (!registry) {
		return this._registry;
	}
	this._registry = registry;
	registry.init(this);
};

module.exports = FakeGulp;

'use strict';

var _ = require('lodash');

var base = process.cwd();
var Registry = require(base + '/src/core/registry');

function FakeGulp() {
	this._registry = new Registry();
}

FakeGulp.prototype.task = function (name, runner) {
	if (typeof name === 'function') {
		runner = name;
		name = runner.displayName || runner.name;
	}
	if (typeof name === 'string' && typeof runner === 'function') {
		this._registry.set(name, runner);
	}
	return this._registry.get(name);
};

FakeGulp.prototype.registry = function (registry) {
	var tasks;

	if (!registry) {
		return this._registry;
	}
	tasks = this._registry.tasks();
	this._registry = _.reduce(tasks, setTasks, registry);
	this._registry.init(this);

	function setTasks(registry, task, name) {
		registry.set(name, task);
		return registry;
	}
};

module.exports = FakeGulp;

make FakeGulp more like real one