From e33b44586bc0ffd4f1f3e5b7127dbbb3b4e15151 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 8 Dec 2016 23:39:24 -0500 Subject: Hoist doc-comments out of functions. --- jarmon/jarmon.js | 263 +++++++++++++++++++++++++------------------------- jarmon/jarmon.test.js | 128 ++++++++++++------------ 2 files changed, 195 insertions(+), 196 deletions(-) diff --git a/jarmon/jarmon.js b/jarmon/jarmon.js index 8594fda..9eeb280 100644 --- a/jarmon/jarmon.js +++ b/jarmon/jarmon.js @@ -27,15 +27,15 @@ if(typeof(jarmon) === 'undefined') { var jarmon = {}; } +/** + * Download a binary file asynchronously using the jQuery.ajax function + * + * @method downloadBinary + * @param url {String} The url of the object to be downloaded + * @return {Object} A deferred which will callback with an instance of + * javascriptrrd.BinaryFile + */ jarmon.downloadBinary = function(url) { - /** - * Download a binary file asynchronously using the jQuery.ajax function - * - * @method downloadBinary - * @param url {String} The url of the object to be downloaded - * @return {Object} A deferred which will callback with an instance of - * javascriptrrd.BinaryFile - */ var d = jQuery.Deferred(); $.ajax({ url: url, @@ -67,16 +67,16 @@ jarmon.downloadBinary = function(url) { }; +/** + * Copied from jquery.flot.js and modified to allow timezone + * adjustment. + * + * @method localTimeFormatter + * @param v {Number} The timestamp to be formatted + * @param axis {Object} A hash containing information about the time axis + * @return {String} The formatted datetime string + **/ jarmon.localTimeFormatter = function (v, axis) { - /** - * Copied from jquery.flot.js and modified to allow timezone - * adjustment. - * - * @method localTimeFormatter - * @param v {Number} The timestamp to be formatted - * @param axis {Object} A hash containing information about the time axis - * @return {String} The formatted datetime string - **/ // map of app. size of time units in milliseconds var timeUnitSize = { "second": 1000, @@ -139,25 +139,24 @@ jarmon.RrdQuery = function(rrd, unit) { this.unit = unit; }; +/** + * Generate a Flot compatible data object containing rows between start and + * end time. The rows are taken from the first RRA whose data spans the + * requested time range. + * + * @method getData + * @param startTimeJs {Number} start timestamp in microseconds + * @param endTimeJs {Number} end timestamp in microseconds + * @param dsId {Variant} identifier of the RRD datasource (string or number) + * @param cfName {String} The name of an RRD consolidation function (CF) + * eg AVERAGE, MIN, MAX + * @param transformer {Function} A callable which performs a + * tranfsformation of the values returned from the RRD file. + * @return {Object} A Flot compatible data series + * eg label: '', data: [], unit: '' + **/ jarmon.RrdQuery.prototype.getData = function(startTimeJs, endTimeJs, dsId, cfName, transformer) { - /** - * Generate a Flot compatible data object containing rows between start and - * end time. The rows are taken from the first RRA whose data spans the - * requested time range. - * - * @method getData - * @param startTimeJs {Number} start timestamp in microseconds - * @param endTimeJs {Number} end timestamp in microseconds - * @param dsId {Variant} identifier of the RRD datasource (string or number) - * @param cfName {String} The name of an RRD consolidation function (CF) - * eg AVERAGE, MIN, MAX - * @param transformer {Function} A callable which performs a - * tranfsformation of the values returned from the RRD file. - * @return {Object} A Flot compatible data series - * eg label: '', data: [], unit: '' - **/ - if (startTimeJs >= endTimeJs) { throw RangeError( ['starttime must be less than endtime.', @@ -261,13 +260,13 @@ jarmon.RrdQuery.prototype.getData = function(startTimeJs, endTimeJs, }; +/** + * Return a list of RRD Data Source names + * + * @method getDSNames + * @return {Array} An array of DS names. + **/ jarmon.RrdQuery.prototype.getDSNames = function() { - /** - * Return a list of RRD Data Source names - * - * @method getDSNames - * @return {Array} An array of DS names. - **/ return this.rrd.getDSNames(); }; @@ -335,21 +334,21 @@ jarmon.RrdQueryRemote.prototype._callRemote = function(methodName, args) { }; +/** + * Return a Flot compatible data series asynchronously. + * + * @method getData + * @param startTime {Number} The start timestamp + * @param endTime {Number} The end timestamp + * @param dsId {Variant} identifier of the RRD datasource (string or number) + * @param cfName {String} The name of an RRD consolidation function (CF) + * eg AVERAGE, MIN, MAX + * @param transformer {Function} A callable which performs a + * tranfsformation of the values returned from the RRD file. + * @return {Object} A Deferred which calls back with a flot data series. + **/ jarmon.RrdQueryRemote.prototype.getData = function(startTime, endTime, dsId, cfName, transformer) { - /** - * Return a Flot compatible data series asynchronously. - * - * @method getData - * @param startTime {Number} The start timestamp - * @param endTime {Number} The end timestamp - * @param dsId {Variant} identifier of the RRD datasource (string or number) - * @param cfName {String} The name of an RRD consolidation function (CF) - * eg AVERAGE, MIN, MAX - * @param transformer {Function} A callable which performs a - * tranfsformation of the values returned from the RRD file. - * @return {Object} A Deferred which calls back with a flot data series. - **/ if(this.lastUpdate < endTime/1000) { this._download = null; } @@ -357,13 +356,13 @@ jarmon.RrdQueryRemote.prototype.getData = function(startTime, endTime, }; +/** + * Return a list of RRD Data Source names + * + * @method getDSNames + * @return {Object} A Deferred which calls back with an array of DS names. + **/ jarmon.RrdQueryRemote.prototype.getDSNames = function() { - /** - * Return a list of RRD Data Source names - * - * @method getDSNames - * @return {Object} A Deferred which calls back with an array of DS names. - **/ return this._callRemote('getDSNames'); }; @@ -384,15 +383,15 @@ jarmon.RrdQueryDsProxy = function(rrdQuery, dsId, transformer) { this.transformer = transformer; }; +/** + * Call I{RrdQueryRemote.getData} with a particular dsId + * + * @method getData + * @param startTime {Number} A unix timestamp marking the start time + * @param endTime {Number} A unix timestamp marking the start time + * @return {Object} A Deferred which calls back with a flot data series. + **/ jarmon.RrdQueryDsProxy.prototype.getData = function(startTime, endTime) { - /** - * Call I{RrdQueryRemote.getData} with a particular dsId - * - * @method getData - * @param startTime {Number} A unix timestamp marking the start time - * @param endTime {Number} A unix timestamp marking the start time - * @return {Object} A Deferred which calls back with a flot data series. - **/ return this.rrdQuery.getData(startTime, endTime, this.dsId, undefined, this.transformer); }; @@ -515,32 +514,32 @@ jarmon.Chart.prototype.setup = function() { } }; +/** + * Add details of a remote RRD data source whose data will be added to this + * chart. + * + * @method addData + * @param label {String} The label for this data which will be shown in the + * chart legend + * @param db {String} The url of the remote RRD database + * @param enabled {Boolean} true if you want this data plotted on the chart, + * false if not. + **/ jarmon.Chart.prototype.addData = function(label, db, enabled) { - /** - * Add details of a remote RRD data source whose data will be added to this - * chart. - * - * @method addData - * @param label {String} The label for this data which will be shown in the - * chart legend - * @param db {String} The url of the remote RRD database - * @param enabled {Boolean} true if you want this data plotted on the chart, - * false if not. - **/ if(typeof(enabled) === 'undefined') { enabled = true; } this.data.push([label, db, enabled]); }; +/** + * Enable / Disable a single data source + * + * @method switchDataEnabled + * @param label {String} The label of the data source to be enabled / + * disabled. + **/ jarmon.Chart.prototype.switchDataEnabled = function(label) { - /** - * Enable / Disable a single data source - * - * @method switchDataEnabled - * @param label {String} The label of the data source to be enabled / - * disabled. - **/ for(var i=0; i starttime and + * <= endTime + **/ test_getData: function () { - /** - * The generated rrd file should have values 0-9 at 300s intervals - * starting at 1980-01-01 00:00:00 - * Result should include a data points with times > starttime and - * <= endTime - **/ var self = this; this.d.done( function(rrd) { @@ -266,11 +266,11 @@ YUI({ logInclude: { TestRunner: true } }).use('console', 'test', function(Y) { this.wait(); }, + /** + * If the requested time range is outside the range of the RRD file + * we should not get any values back + **/ test_getDataUnknownValues: function () { - /** - * If the requested time range is outside the range of the RRD file - * we should not get any values back - **/ var self = this; this.d.done( function(rrd) { @@ -287,11 +287,11 @@ YUI({ logInclude: { TestRunner: true } }).use('console', 'test', function(Y) { return v * 10; }, + /** + * RrdQuery can be passed a transformer function which may + * manipulate the values from the RRDFile + **/ test_transformerFunction: function () { - /** - * RrdQuery can be passed a transformer function which may - * manipulate the values from the RRDFile - **/ var self = this; this.d.done( function(rrd) { @@ -318,10 +318,10 @@ YUI({ logInclude: { TestRunner: true } }).use('console', 'test', function(Y) { this.rq = new jarmon.RrdQueryRemote('build/test.rrd', ''); }, + /** + * The starttime must be less than the endtime + **/ test_getDataTimeRangeOverlapError: function () { - /** - * The starttime must be less than the endtime - **/ var self = this; this.rq.getData(1, 0).fail( function(res) { @@ -333,11 +333,11 @@ YUI({ logInclude: { TestRunner: true } }).use('console', 'test', function(Y) { }, + /** + * Error is raised if the rrd file doesn't contain an RRA with the + * requested consolidation function (CF) + **/ test_getDataUnknownCfError: function () { - /** - * Error is raised if the rrd file doesn't contain an RRA with the - * requested consolidation function (CF) - **/ var self = this; this.rq.getData(RRD_STARTTIME, RRD_ENDTIME, 0, 'FOO').always( function(res) { @@ -349,13 +349,13 @@ YUI({ logInclude: { TestRunner: true } }).use('console', 'test', function(Y) { }, + /** + * The generated rrd file should have values 0-9 at 300s intervals + * starting at 1980-01-01 00:00:00 + * Result should include a data points with times > starttime and + * <= endTime + **/ test_getData: function () { - /** - * The generated rrd file should have values 0-9 at 300s intervals - * starting at 1980-01-01 00:00:00 - * Result should include a data points with times > starttime and - * <= endTime - **/ var self = this; this.rq.getData(RRD_STARTTIME + (RRD_STEP+1) * 1000, RRD_ENDTIME - (RRD_STEP-1) * 1000).always( @@ -396,11 +396,11 @@ YUI({ logInclude: { TestRunner: true } }).use('console', 'test', function(Y) { this.wait(); }, + /** + * If the requested time range is outside the range of the RRD file + * we should not get any values back + **/ test_getDataUnknownValues: function () { - /** - * If the requested time range is outside the range of the RRD file - * we should not get any values back - **/ var self = this; this.rq.getData(RRD_ENDTIME, RRD_ENDTIME+1000).always( function(data) { -- cgit v1.2.3