From e7e88b4fef638131db0a230c44a9541d7f6963f3 Mon Sep 17 00:00:00 2001 From: Manuel Bieh Date: Sun, 17 Apr 2016 01:12:11 +0200 Subject: [PATCH 1/2] added convenience methods plan.option() and plan.hosts() --- lib/index.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/index.js b/lib/index.js index cad7627..2039a31 100644 --- a/lib/index.js +++ b/lib/index.js @@ -451,6 +451,33 @@ Flightplan.prototype.availableTargets = function() { return Object.keys(this._targets); }; +/** + * Convenience method to allow easier access to runtime options + * + * ```javascript + * plan.option('myOption'); + * ``` + * + * @method option(key) + */ +Flightplan.prototype.option = function(key) { + return this.runtime.options && this.runtime.options[key]; +}; + +/** + * Convenience method to allow easier access to runtime hosts + * + * ```javascript + * plan.hosts(); + * plan.hosts(0); + * ``` + * + * @method hosts([index]) + */ +Flightplan.prototype.hosts = function(index) { + return typeof index === 'number' ? this.runtime.hosts[index] : this.runtime.hosts; +}; + Flightplan.prototype.availableTasks = function() { return this._flights.reduce(function(result, f) { f.tasks.forEach(function(task) { From e9eead7ec9294bf122fc6a98543a3d9048e9b371 Mon Sep 17 00:00:00 2001 From: Manuel Bieh Date: Sun, 17 Apr 2016 18:26:12 +0200 Subject: [PATCH 2/2] renamed options() -> options() --- lib/index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/index.js b/lib/index.js index 2039a31..cc69725 100644 --- a/lib/index.js +++ b/lib/index.js @@ -455,12 +455,16 @@ Flightplan.prototype.availableTargets = function() { * Convenience method to allow easier access to runtime options * * ```javascript - * plan.option('myOption'); + * plan.options(); // get all options + * plan.options('myOption'); // get one specific option * ``` * - * @method option(key) + * @method options(key) */ -Flightplan.prototype.option = function(key) { +Flightplan.prototype.options = function(key) { + if(typeof key === 'undefined') { + return this.runtime.options; + } return this.runtime.options && this.runtime.options[key]; };