Skip to content

Commit

Permalink
Merge branch 'upstream-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
braizhas committed Oct 19, 2016
2 parents 001785b + 943f38c commit 0b5ca80
Show file tree
Hide file tree
Showing 43 changed files with 3,099 additions and 515 deletions.
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Type of issue
<!-- Is this a bug, feature request, question, etc. ? -->

## Description
<!-- Describe the issue -->

## Steps to reproduce
<!--
If this is a bug, please provide a list of steps to reproduce the issue and
if possible a link to a test page or minimal demo of the problem via
https://jsfiddle.net, http://jsbin.com or similar.
-->

### Expected results

### Actual results

## Platform details
<!-- Which versions of Prebid.js, browser / OS, node, npm, etc. -->

## Other information
<!-- References to related issue or PR #s, etc. -->
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ This README is for developers who want to contribute to Prebid.js. For user-fac

## Install

$ git clone https://github.com/prebid/Prebid.js.git
$ cd Prebid.js
$ npm install

If you experience errors after a version update, try a fresh install:
Expand Down
2 changes: 2 additions & 0 deletions adapters.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"appnexus",
"appnexusAst",
"getintent",
"hiromedia",
"indexExchange",
"kruxlink",
"openx",
Expand All @@ -28,6 +29,7 @@
"underdogmedia",
"memeglobal",
"centro",
"roxot",
{
"appnexus": {
"alias": "brealtime"
Expand Down
26 changes: 23 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var uglify = require('gulp-uglify');
var jshint = require('gulp-jshint');
var clean = require('gulp-clean');
var karma = require('gulp-karma');
var mocha = require('gulp-mocha');
var opens = require('open');
var webpackConfig = require('./webpack.conf.js');
var helpers = require('./gulpHelpers');
Expand Down Expand Up @@ -36,7 +37,7 @@ gulp.task('serve', ['clean', 'quality', 'devpack', 'webpack', 'watch', 'test']);

gulp.task('serve-nw', ['clean', 'quality', 'devpack', 'webpack', 'watch', 'e2etest']);

gulp.task('run-tests', ['clean', 'quality', 'webpack', 'test']);
gulp.task('run-tests', ['clean', 'quality', 'webpack', 'test', 'mocha']);

gulp.task('build', ['clean', 'quality', 'webpack', 'devpack', 'zip']);

Expand Down Expand Up @@ -131,6 +132,17 @@ gulp.task('test', function () {
}));
});

gulp.task('mocha', ['webpack'], function() {
return gulp.src(['test/spec/loaders/**/*.js'], { read: false })
.pipe(mocha({
reporter: 'spec',
globals: {
expect: require('chai').expect
}
}))
.on('error', gutil.log);
});

// Small task to load coverage reports in the browser
gulp.task('coverage', function (done) {
var coveragePort = 1999;
Expand All @@ -154,10 +166,18 @@ gulp.task('coveralls', ['test'], function() { // 2nd arg is a dependency: 'test'
// Watch Task with Live Reload
gulp.task('watch', function () {

gulp.watch(['test/spec/**/*.js'], ['quality', 'webpack', 'devpack', 'test']);
gulp.watch([
'src/**/*.js',
'test/spec/**/*.js',
'!test/spec/loaders/**/*.js'
], ['quality', 'webpack', 'devpack', 'test']);
gulp.watch([
'loaders/**/*.js',
'test/spec/loaders/**/*.js'
], ['quality', 'mocha']);
gulp.watch(['integrationExamples/gpt/*.html'], ['test']);
gulp.watch(['src/**/*.js'], ['quality', 'webpack', 'devpack', 'test']);
connect.server({
https: argv.https,
port: port,
root: './',
livereload: true
Expand Down
4 changes: 3 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ module.exports = function (config) {
],

// list of files to exclude
exclude: [],
exclude: [
'test/spec/loaders/**/*.js'
],

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
Expand Down
2 changes: 1 addition & 1 deletion loaders/adapterLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const fs = require('fs');
const blockLoader = require('block-loader');
const getAdapters = require('./getAdapters');

const adapters = getAdapters('../adapters.json');
const adapters = getAdapters();
const files = fs.readdirSync('src/adapters').map((file) => file.replace(/\.[^/.]+$/, ''));
const adapterNames = adapters.map(getNames).filter(getUniques);
const aliases = adapters.filter(getAliases);
Expand Down
36 changes: 23 additions & 13 deletions loaders/getAdapters.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,32 @@ const fs = require('fs');
const path = require('path');
const argv = require('yargs').argv;

const jsonPath = argv['adapters'] || '';
const defaultAdapters = 'adapters.json';

module.exports = function getAdapters(all) {
const json = path.resolve(process.cwd(), jsonPath);

let adapters;
function load(file) {
try {
fs.statSync(json);
adapters = require(json);
const buffer = fs.readFileSync(file);
return JSON.parse(buffer.toString());
} catch (e) {
if (jsonPath) {
console.log(`Prebid Warning: custom adapters config cannot be loaded from ${json}, ` +
'using default adapters.json');
}
adapters = require(all);
return [];
}
}

module.exports = function getAdapters() {
let customAdapters = argv.adapters;

if (!customAdapters) {
return load(defaultAdapters);
}

return adapters;
customAdapters = path.resolve(process.cwd(), customAdapters);

try {
fs.statSync(customAdapters);
return load(customAdapters);
} catch (e) {
console.log(`Prebid Warning: custom adapters config cannot be loaded from ${customAdapters}, ` +
'using default adapters.json');
return load(defaultAdapters);
}
};
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "prebid.js",
"version": "0.13.1-pre",
"version": "0.14.0-pre",
"description": "Header Bidding Management Library",
"main": "src/prebid.js",
"scripts": {
"test": "gulp test"
"test": "gulp test && gulp mocha"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -36,6 +36,7 @@
"gulp-jsdoc-to-markdown": "^1.2.1",
"gulp-jshint": "^1.8.4",
"gulp-karma": "0.0.4",
"gulp-mocha": "^2.2.0",
"gulp-rename": "^1.2.0",
"gulp-replace": "^0.4.0",
"gulp-shell": "^0.5.2",
Expand Down Expand Up @@ -73,8 +74,10 @@
"mkpath": "^1.0.0",
"mocha": "^1.21.4",
"nightwatch": "^0.9.5",
"mock-fs": "^3.11.0",
"open": "0.0.5",
"phantomjs": "^1.9.18",
"proxyquire": "^1.7.10",
"querystringify": "0.0.3",
"requirejs": "^2.1.20",
"sinon": "^1.12.1",
Expand Down
3 changes: 2 additions & 1 deletion src/adaptermanager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @module adaptermanger */

import { flatten, getBidderCodes } from './utils';
import { mapSizes } from './sizeMapping';

var utils = require('./utils.js');
var CONSTANTS = require('./constants.json');
Expand All @@ -18,7 +19,7 @@ function getBids({ bidderCode, requestId, bidderRequestId, adUnits }) {
.map(bid => Object.assign(bid, {
placementCode: adUnit.code,
mediaType: adUnit.mediaType,
sizes: adUnit.sizes,
sizes: mapSizes(adUnit),
bidId: utils.getUniqueIdentifierStr(),
bidderRequestId,
requestId
Expand Down
19 changes: 19 additions & 0 deletions src/adapters/analytics/roxot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ajax } from 'src/ajax';
import adapter from 'AnalyticsAdapter';

const utils = require('../../utils');

const url = '//d.rxthdr.com/analytics';
const analyticsType = 'endpoint';

export default utils.extend(adapter(
{
url,
analyticsType
}
),
{
track({ eventType, args }) {
ajax(url, (result) => utils.logInfo('Event ' + eventType + ' sent to roxot analytics with result ' + result), JSON.stringify({ eventType, args }));
}
});
Loading

0 comments on commit 0b5ca80

Please sign in to comment.