From 4a77556866aeab36cb4124a5663a9522230742dd Mon Sep 17 00:00:00 2001 From: spalger Date: Thu, 19 May 2016 12:47:33 -0700 Subject: [PATCH] tracked down more necessary updated, lots of _.bind() --- docs/configuration.asciidoc | 2 +- docs/host.asciidoc | 2 +- scripts/ci.js | 2 +- scripts/generate/js_api.js | 2 +- scripts/generate/templates/api_file.tmpl | 4 +-- .../templates/configuration_docs.tmpl | 2 +- test/integration/yaml_suite/run.js | 2 +- test/integration/yaml_suite/yaml_doc.js | 36 +++++++++---------- test/integration/yaml_suite/yaml_file.js | 2 +- test/mocks/browser_server.js | 2 +- test/utils/jenkins-reporter.js | 4 +-- 11 files changed, 30 insertions(+), 30 deletions(-) diff --git a/docs/configuration.asciidoc b/docs/configuration.asciidoc index b5ad70a8a..138f3fbc2 100644 --- a/docs/configuration.asciidoc +++ b/docs/configuration.asciidoc @@ -315,7 +315,7 @@ var client = new elasticsearch.Client({ selector: function (hosts) { var myCountry = process.env.COUNTRY; // first try to find a node that is in the same country - var selection = _.find(nodes, function (node) { + var selection = _v4.find(nodes, function (node) { return node.host.country === myCountry; }); diff --git a/docs/host.asciidoc b/docs/host.asciidoc index 98bc353c8..6fb0784d0 100644 --- a/docs/host.asciidoc +++ b/docs/host.asciidoc @@ -88,7 +88,7 @@ var client = new elasticsearch.Client({ selector: function (hosts) { var myCountry = process.env.COUNTRY; // first try to find a node that is in the same country - var selection = _.find(nodes, function (node) { + var selection = _v4.find(nodes, function (node) { return node.host.country === myCountry; }); diff --git a/scripts/ci.js b/scripts/ci.js index 1ea221f0e..ac0c2625f 100644 --- a/scripts/ci.js +++ b/scripts/ci.js @@ -174,7 +174,7 @@ execTask('SETUP', function () { return ENV.RUN .split(',') .map(function (name) { - return _.find(TASKS, { name: name.trim() }); + return _v4.find(TASKS, { name: name.trim() }); }) .filter(Boolean); }); diff --git a/scripts/generate/js_api.js b/scripts/generate/js_api.js index a9a2da981..372b84917 100644 --- a/scripts/generate/js_api.js +++ b/scripts/generate/js_api.js @@ -91,7 +91,7 @@ module.exports = function (branch, done) { clientActionModifier: overrides.clientActionModifier }; - var create = _.assign({}, _.find(apiSpec.actions, { name: 'index' }), { + var create = _.assign({}, _v4.find(apiSpec.actions, { name: 'index' }), { name: 'create', location: 'create', proxy: 'index', diff --git a/scripts/generate/templates/api_file.tmpl b/scripts/generate/templates/api_file.tmpl index 11797a2e5..90612b1ca 100644 --- a/scripts/generate/templates/api_file.tmpl +++ b/scripts/generate/templates/api_file.tmpl @@ -18,12 +18,12 @@ _v4.each(actions, function (action) { api.<%= namespace %> = namespace();<% }%> -<%= partials.client_action(action) %><% +<%= _v4.trimEnd(partials.client_action(action)) %><% }); _v4.each(proxies, function (action) {%> -<%= partials.client_action_proxy(action) %><% +<%= _v4.trimEnd(partials.client_action_proxy(action)) %><% }); %> diff --git a/scripts/generate/templates/configuration_docs.tmpl b/scripts/generate/templates/configuration_docs.tmpl index f554c5cca..5a5691896 100644 --- a/scripts/generate/templates/configuration_docs.tmpl +++ b/scripts/generate/templates/configuration_docs.tmpl @@ -303,7 +303,7 @@ var client = new elasticsearch.Client({ selector: function (hosts) { var myCountry = process.env.COUNTRY; // first try to find a node that is in the same country - var selection = _.find(nodes, function (node) { + var selection = _v4.find(nodes, function (node) { return node.host.country === myCountry; }); diff --git a/test/integration/yaml_suite/run.js b/test/integration/yaml_suite/run.js index 9ec43a994..dddd72efe 100644 --- a/test/integration/yaml_suite/run.js +++ b/test/integration/yaml_suite/run.js @@ -32,7 +32,7 @@ module.exports = function (branch) { return clientManager.get().clearEs(); }); - var files = _.map(require('./yaml_tests_' + _.snakeCase(branch) + '.json'), function (docs, filename) { + var files = _v4.map(require('./yaml_tests_' + _.snakeCase(branch) + '.json'), function (docs, filename) { return new YamlFile(filename, docs); }); diff --git a/test/integration/yaml_suite/yaml_doc.js b/test/integration/yaml_suite/yaml_doc.js index 77dd1c348..f59e2b8c1 100644 --- a/test/integration/yaml_suite/yaml_doc.js +++ b/test/integration/yaml_suite/yaml_doc.js @@ -407,14 +407,14 @@ YamlDoc.prototype = { var clientAction = this.get(clientActionName, client); _.assign(inputParams, args[action]); - var params = _.transform(inputParams, function (params, val, name) { + var params = _.transform(inputParams, _.bind(function (params, val, name) { var camelName = _.camelCase(name); // search through the params and url peices to find this param name var paramName = name; var spec = clientAction && clientAction.spec; var knownParam = spec && spec.params && spec.params[camelName]; - var knownUrlParam = spec && !knownParam && !!_.find(spec.url ? [spec.url] : spec.urls, function (url) { + var knownUrlParam = spec && !knownParam && !!_v4.find(spec.url ? [spec.url] : spec.urls, function (url) { if ((url.opt && url.opt[camelName]) || (url.req && url.req[camelName])) { return true; } @@ -437,12 +437,12 @@ YamlDoc.prototype = { }.bind(this); transformObject(params, val, paramName); - }, {}, this); + }, this), {}); expect(clientAction || clientActionName).to.be.a('function'); - if (_.isNumeric(catcher)) { + if (!isNaN(parseFloat(catcher))) { params.ignore = _.union(params.ignore || [], [catcher]); catcher = null; } @@ -494,9 +494,9 @@ YamlDoc.prototype = { * @return {undefined} */ do_set: function (args) { - _.forOwn(args, function (name, path) { + _.forOwn(args, _.bind(function (name, path) { this._stash[name] = this.get(path); - }, this); + }, this)); }, /** @@ -578,7 +578,7 @@ YamlDoc.prototype = { } }); - _.forOwn(args, function (match, path) { + _.forOwn(args, _.bind(function (match, path) { var origMatch = match; var maybeRE = false; @@ -645,7 +645,7 @@ YamlDoc.prototype = { throw new Error(msg.join('\n')); } - }, this); + }, this)); }, /** @@ -655,9 +655,9 @@ YamlDoc.prototype = { * @return {undefined} */ do_lt: function (args) { - _.forOwn(args, function (num, path) { + _.forOwn(args, _.bind(function (num, path) { expect(this.get(path)).to.be.below(num, 'path: ' + path); - }, this); + }, this)); }, /** @@ -667,9 +667,9 @@ YamlDoc.prototype = { * @return {undefined} */ do_lte: function (args) { - _.forOwn(args, function (num, path) { + _.forOwn(args, _.bind(function (num, path) { expect(this.get(path) <= num).to.be.ok('path: ' + path); - }, this); + }, this)); }, /** @@ -679,9 +679,9 @@ YamlDoc.prototype = { * @return {undefined} */ do_gt: function (args) { - _.forOwn(args, function (num, path) { + _.forOwn(args, _.bind(function (num, path) { expect(this.get(path)).to.be.above(num, 'path: ' + path); - }, this); + }, this)); }, /** @@ -691,9 +691,9 @@ YamlDoc.prototype = { * @return {undefined} */ do_gte: function (args) { - _.forOwn(args, function (num, path) { + _.forOwn(args, _.bind(function (num, path) { expect(this.get(path) >= num).to.be.ok('path: ' + path); - }, this); + }, this)); }, /** @@ -704,8 +704,8 @@ YamlDoc.prototype = { * @return {undefined} */ do_length: function (args) { - _.forOwn(args, function (len, path) { + _.forOwn(args, _.bind(function (len, path) { expect(_.size(this.get(path))).to.eql(len, 'path: ' + path); - }, this); + }, this)); } }; diff --git a/test/integration/yaml_suite/yaml_file.js b/test/integration/yaml_suite/yaml_file.js index b96529fc6..d8458c9cc 100644 --- a/test/integration/yaml_suite/yaml_file.js +++ b/test/integration/yaml_suite/yaml_file.js @@ -18,7 +18,7 @@ function YamlFile(filename, docs) { file.skipping = false; describe(filename, function () { - file.docs = _.map(docs, function (doc) { + file.docs = _v4.map(docs, function (doc) { doc = new YamlDoc(doc, file); if (doc.description === 'setup') { beforeEach(/* doc */function (done) { diff --git a/test/mocks/browser_server.js b/test/mocks/browser_server.js index a10435cce..017ff5bc2 100644 --- a/test/mocks/browser_server.js +++ b/test/mocks/browser_server.js @@ -11,7 +11,7 @@ var server = new XhrServer(function (request) { host: request.urlParts.host, path: request.urlParts.relative }; - var response = _.find(interceptors, reqDetails); + var response = _v4.find(interceptors, reqDetails); if (response) { // remove of tick down the times diff --git a/test/utils/jenkins-reporter.js b/test/utils/jenkins-reporter.js index 4516020d6..3275e06cf 100644 --- a/test/utils/jenkins-reporter.js +++ b/test/utils/jenkins-reporter.js @@ -24,8 +24,8 @@ var log = (function () { }; }()); -var integration = _.find(process.argv, function (arg) { return arg.indexOf('test/integration') > -1; }); -var unit = _.find(process.argv, function (arg) { return arg.indexOf('test/unit') > -1; }); +var integration = _v4.find(process.argv, function (arg) { return arg.indexOf('test/integration') > -1; }); +var unit = _v4.find(process.argv, function (arg) { return arg.indexOf('test/unit') > -1; }); var output; if (unit) {