From 8468d77d41362586d87b30ce7639f0b0d480e0a8 Mon Sep 17 00:00:00 2001 From: Dave Bemiller Date: Tue, 27 Jun 2017 13:06:45 -0400 Subject: [PATCH] Made some cosmetic changes to names and documentation. --- src/adServerManager.js | 34 +++++++++++++------------- src/videoCache.js | 16 ++++++------ test/spec/unit/adServerManager_spec.js | 7 +++--- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/adServerManager.js b/src/adServerManager.js index 2c0c64bb2a4..967509660df 100644 --- a/src/adServerManager.js +++ b/src/adServerManager.js @@ -39,28 +39,28 @@ const prebid = getGlobal(); /** * @typedef {Object} VideoSupport * - * @property {string} code The identifying code for this adserver. Note that this contributes to - * the user-facing API. For example, if the adserver code is 'dfp', and the Prebid bundle contains two + * @property {string} name A name which identifies this adserver. Note that this contributes to + * the user-facing API. For example, if the adserver name is 'dfp', and the Prebid bundle contains two * or more ad server modules, then publishers will access its functions through 'pbjs.adservers.dfp'. * - * @method {VideoAdUrlBuilder} buildVideoAdUrl + * @function {VideoAdUrlBuilder} buildVideoAdUrl */ /** * Prepares a namespace on object so that utility functions can be added to it. * - * If this is the only code we've seen, attach functionality to $$PREBID_GLOBAL$$.adServer. - * If we've seen any other codes, attach functionality to $$PREBID_GLOBAL$$.adServers[code]. + * If this is the only name we've seen, attach functionality to $$PREBID_GLOBAL$$.adServer. + * If we've seen any other names, attach functionality to $$PREBID_GLOBAL$$.adServers[name]. * * @param {object} object The object where this function should manage namespaces. - * @param {string} code The code for this ad server. + * @param {string} name The name for this ad server. * @return {object} An object where functions for dealing with this ad server can be added. */ -function prepareNamespaceIn(object, code) { - if (object.adServer && object.adServer.code !== code) { +function prepareNamespaceIn(object, name) { + if (object.adServer && object.adServer.name !== name) { object.adServers = { }; - object.adServers[object.adServer.code] = object.adServer; - delete object.adServer.code; + object.adServers[object.adServer.name] = object.adServer; + delete object.adServer.name; delete object.adServer; } @@ -68,13 +68,13 @@ function prepareNamespaceIn(object, code) { return object.adServer; } if (object.adServers) { - if (!object.adServers[code]) { - object.adServers[code] = { }; + if (!object.adServers[name]) { + object.adServers[name] = { }; } - return object.adServers[code]; + return object.adServers[name]; } else { - object.adServer = { code }; + object.adServer = { name }; return object.adServer; } } @@ -82,9 +82,9 @@ function prepareNamespaceIn(object, code) { /** * Enable video support for the Ad Server. * - * @property {string} code The identifying code for this adserver. + * @property {string} name The identifying name for this adserver. * @property {VideoSupport} videoSupport An object with the functions needed to support video in Prebid. */ -export function registerVideoSupport(code, videoSupport) { - prepareNamespaceIn(prebid, code).buildVideoAdUrl = videoSupport.buildVideoAdUrl; +export function registerVideoSupport(name, videoSupport) { + prepareNamespaceIn(prebid, name).buildVideoAdUrl = videoSupport.buildVideoAdUrl; } diff --git a/src/videoCache.js b/src/videoCache.js index d3a87d1a390..4b56c42d6ff 100644 --- a/src/videoCache.js +++ b/src/videoCache.js @@ -75,11 +75,11 @@ function fromStorageResponse(response) { /** * A function which bridges the APIs between the videoCacheStoreCallback and our ajax function's API. * - * @param {videoCacheStoreCallback} callback A callback to the "store" function. + * @param {videoCacheStoreCallback} done A callback to the "store" function. * @return {Function} A callback which interprets the cache server's responses, and makes up the right * arguments for our callback. */ -function shimStorageCallback(callback) { +function shimStorageCallback(done) { return { success: function(responseBody) { let ids; @@ -87,14 +87,14 @@ function shimStorageCallback(callback) { ids = JSON.parse(responseBody).responses.map(fromStorageResponse) } catch (e) { - callback(e, []); + done(e, []); return; } - callback(null, ids); + done(null, ids); }, error: function(statusText, responseBody) { - callback(new Error('Error storing video ad in the cache: ' + statusText + ': ' + JSON.stringify(responseBody)), []); + done(new Error('Error storing video ad in the cache: ' + statusText + ': ' + JSON.stringify(responseBody)), []); } } } @@ -103,15 +103,15 @@ function shimStorageCallback(callback) { * If the given bid is for a Video ad, generate a unique ID and cache it somewhere server-side. * * @param {CacheableBid[]} bids A list of bid objects which should be cached. - * @param {videoCacheStoreCallback} [callback] An optional callback which should be executed after + * @param {videoCacheStoreCallback} [done] An optional callback which should be executed after * the data has been stored in the cache. */ -export function store(bids, callback) { +export function store(bids, done) { const requestData = { puts: bids.map(toStorageRequest) }; - ajax(PUT_URL, shimStorageCallback(callback), JSON.stringify(requestData), { + ajax(PUT_URL, shimStorageCallback(done), JSON.stringify(requestData), { contentType: 'text/plain', withCredentials: true }); diff --git a/test/spec/unit/adServerManager_spec.js b/test/spec/unit/adServerManager_spec.js index 4754854e118..44dcf47471a 100644 --- a/test/spec/unit/adServerManager_spec.js +++ b/test/spec/unit/adServerManager_spec.js @@ -15,8 +15,7 @@ describe('The ad server manager', () => { registerVideoSupport('dfp', { buildVideoAdUrl: videoSupport }); expect(prebid).to.have.property('adServer'); - expect(prebid.adServer).to.have.property('code'); - expect(prebid.adServer.code).to.equal('dfp'); + expect(prebid.adServer).to.have.property('name', 'dfp'); expect(prebid.adServer).to.have.property('buildVideoAdUrl'); expect(prebid.adServer.buildVideoAdUrl).to.equal(videoSupport); @@ -35,8 +34,8 @@ describe('The ad server manager', () => { expect(prebid.adServers.ast).to.have.property('buildVideoAdUrl'); expect(prebid.adServers).to.have.property('dfp'); expect(prebid.adServers.dfp).to.have.property('buildVideoAdUrl'); - expect(prebid.adServers.ast).not.to.have.property('code'); - expect(prebid.adServers.dfp).not.to.have.property('code'); + expect(prebid.adServers.ast).not.to.have.property('name'); + expect(prebid.adServers.dfp).not.to.have.property('name'); expect(prebid.adServers.dfp.buildVideoAdUrl).to.equal(dfpVideoSupport); expect(prebid.adServers.ast.buildVideoAdUrl).to.equal(astVideoSupport);