From 0a009e2a152a47fdc7ef8694a8386275aae7dbdc Mon Sep 17 00:00:00 2001 From: Mark Hindess Date: Wed, 3 Sep 2014 13:18:26 +0100 Subject: [PATCH] Rename RED.utils to RED.util. Fixes #364. --- nodes/core/io/22-websocket.js | 2 +- nodes/core/social/61-email.js | 2 +- nodes/core/storage/65-redisout.js | 2 +- red/red.js | 4 ++-- red/{utils.js => util.js} | 0 test/red/{utils_spec.js => util_spec.js} | 12 ++++++------ 6 files changed, 11 insertions(+), 11 deletions(-) rename red/{utils.js => util.js} (100%) rename test/red/{utils_spec.js => util_spec.js} (80%) diff --git a/nodes/core/io/22-websocket.js b/nodes/core/io/22-websocket.js index d21225dda..87b25e004 100644 --- a/nodes/core/io/22-websocket.js +++ b/nodes/core/io/22-websocket.js @@ -160,7 +160,7 @@ module.exports = function(RED) { delete msg._session; payload = JSON.stringify(msg); } else { - payload = RED.utils.ensureString(msg.payload); + payload = RED.util.ensureString(msg.payload); } if (msg._session && msg._session.type == "websocket") { node.serverConfig.send(msg._session.id,payload); diff --git a/nodes/core/social/61-email.js b/nodes/core/social/61-email.js index 2f0e98a7e..125ad70be 100644 --- a/nodes/core/social/61-email.js +++ b/nodes/core/social/61-email.js @@ -73,7 +73,7 @@ module.exports = function(RED) { if (msg != null) { if (smtpTransport) { node.status({fill:"blue",shape:"dot",text:"sending"}); - var payload = RED.utils.ensureString(msg.payload); + var payload = RED.util.ensureString(msg.payload); smtpTransport.sendMail({ from: node.userid, // sender address diff --git a/nodes/core/storage/65-redisout.js b/nodes/core/storage/65-redisout.js index fabb2bbcd..6f51bd311 100644 --- a/nodes/core/storage/65-redisout.js +++ b/nodes/core/storage/65-redisout.js @@ -83,7 +83,7 @@ module.exports = function(RED) { var k = this.key || msg.topic; if (k) { if (this.structtype == "string") { - this.client.set(k,RED.utils.ensureString(msg.payload)); + this.client.set(k,RED.util.ensureString(msg.payload)); } else if (this.structtype == "hash") { var r = hashFieldRE.exec(msg.payload); if (r) { diff --git a/red/red.js b/red/red.js index 559eb96bf..7ce627f24 100644 --- a/red/red.js +++ b/red/red.js @@ -19,7 +19,7 @@ var nodes = require("./nodes"); var library = require("./library"); var comms = require("./comms"); var log = require("./log"); -var utils = require("./utils"); +var util = require("./util"); var fs = require("fs"); var settings = null; var credentials = require("./nodes/credentials"); @@ -49,7 +49,7 @@ var RED = { events: events, log: log, comms: comms, - utils: utils, + util: util, version: function () { var p = require(path.join(process.env.NODE_RED_HOME,"package.json")); if (fs.existsSync(path.join(process.env.NODE_RED_HOME,".git"))) { diff --git a/red/utils.js b/red/util.js similarity index 100% rename from red/utils.js rename to red/util.js diff --git a/test/red/utils_spec.js b/test/red/util_spec.js similarity index 80% rename from test/red/utils_spec.js rename to test/red/util_spec.js index b39db5c26..c42aec01e 100644 --- a/test/red/utils_spec.js +++ b/test/red/util_spec.js @@ -14,25 +14,25 @@ * limitations under the License. **/ var should = require("should"); -var utils = require("../../red/utils"); +var util = require("../../red/util"); -describe("red/utils", function() { +describe("red/util", function() { describe('ensureString', function() { it('strings are preserved', function() { - utils.ensureString('string').should.equal('string'); + util.ensureString('string').should.equal('string'); }); it('Buffer is converted', function() { - var s = utils.ensureString(new Buffer('foo')); + var s = util.ensureString(new Buffer('foo')); s.should.equal('foo'); (typeof s).should.equal('string'); }); it('Object is converted to JSON', function() { - var s = utils.ensureString({foo: "bar"}); + var s = util.ensureString({foo: "bar"}); (typeof s).should.equal('string'); should.deepEqual(JSON.parse(s), {foo:"bar"}); }); it('stringifies other things', function() { - var s = utils.ensureString(123); + var s = util.ensureString(123); (typeof s).should.equal('string'); s.should.equal('123'); });