mojito-dimensions-base
Advanced tools
Comparing version 0.0.1 to 0.0.3
@@ -13,3 +13,2 @@ /* | ||
var libfs = require('fs'), | ||
libyub = require('yub'), | ||
libpath = require('path'), | ||
@@ -161,2 +160,3 @@ liburl = require('url'), | ||
this.afterHostMethod('parseResourceVersion', this.parseResourceVersion, this); | ||
this.onHostEvent('resolveMojitDetails', this.resolveMojitDetails, this); | ||
}, | ||
@@ -271,3 +271,4 @@ | ||
type: 'super-bundle', | ||
bundleName: subdir | ||
dimension: dimensionName, | ||
bundle: subdir | ||
}; | ||
@@ -307,3 +308,3 @@ self.store._preloadDirBundle(path, pkg); | ||
if (source.pkg.type === 'super-bundle') { | ||
bundleSelector = source.pkg.bundleName; | ||
bundleSelector = source.pkg.bundle; | ||
res.selector = (res.selector === '*') ? bundleSelector : bundleSelector + '_' + res.selector; | ||
@@ -337,3 +338,3 @@ | ||
if (res.type === 'mojit' && res.source.pkg.type === 'super-bundle') { | ||
res.selector = res.source.pkg.bundleName; | ||
res.selector = res.source.pkg.bundle; | ||
} | ||
@@ -343,2 +344,16 @@ }, | ||
/** | ||
* Add dimension info to the mojit resource details | ||
*/ | ||
resolveMojitDetails: function (event) { | ||
var mojitRes = event.args.mojitRes, | ||
mojitDetails = event.mojitDetails, | ||
pkg = mojitRes.source.pkg; | ||
if (pkg.type === 'super-bundle') { | ||
mojitDetails.dimensionName = pkg.dimension; | ||
mojitDetails.dimensionValue = pkg.bundle; | ||
} | ||
}, | ||
/** | ||
* Register plugin into rs.config addon, before rs.preloadResourceVersions', | ||
@@ -345,0 +360,0 @@ * this way rs addons have the chance to modify and reload configs AFTER they are loaded, |
@@ -7,1 +7,9 @@ CHANGELOG | ||
* Initial commit | ||
Version 0.0.2 | ||
------------- | ||
* Removed unused dependencies | ||
Version 0.0.3 | ||
------------- | ||
* Expose experiment package's dimension name and value at runtime through properties `dimensionName` and `dimensionValue` of the mojit details metadata. |
{ | ||
"name": "mojito-dimensions-base", | ||
"description": "Mojito bucket testing infrastrcture Super Bundle Addon", | ||
"version": "0.0.1", | ||
"description": "Mojito bucket testing infrastructure Super Bundle Addon", | ||
"version": "0.0.3", | ||
"author": "David Gomez <dgomez@yahoo-inc.com>", | ||
@@ -17,3 +17,4 @@ "contributors": [ | ||
"mojito": ">=0.7.3", | ||
"mojito-cli": "0.1.x" | ||
"mojito-cli": "0.1.x", | ||
"istanbul": "0.1.x" | ||
}, | ||
@@ -20,0 +21,0 @@ "scripts": { |
# mojito-dimensions-base | ||
Build Status | ||
------------ | ||
[![Build Status](https://travis-ci.org/yahoo/mojito-dimensions-base.png)](https://travis-ci.org/yahoo/mojito-dimensions-base) | ||
Usage | ||
----- | ||
A-B _(a.k.a. bucket)_ testing infrastructure for mojito applications. | ||
@@ -4,0 +12,0 @@ |
@@ -20,4 +20,4 @@ /* | ||
superBundleDim = 'experiment_ad', | ||
superBundleName = 'test-dimensions-' + superBundleDim, | ||
superBundleDimension = 'experiment_ad', | ||
superBundleName = 'test-dimensions-' + superBundleDimension, | ||
superBundlePath = libpath.join(__dirname, 'fixtures', superBundleName), | ||
@@ -58,3 +58,4 @@ | ||
"type": "super-bundle", | ||
"bundleName": "blue" | ||
"bundle": "blue", | ||
"dimension": superBundleDimension | ||
} | ||
@@ -101,3 +102,4 @@ }, | ||
}; | ||
this._validDims[superBundleDim] = true; | ||
this._validDims[superBundleDimension] = true; | ||
this.publish('resolveMojitDetails', {emitFacade: true, preventable: false}); | ||
}, | ||
@@ -139,2 +141,18 @@ | ||
//to be tested on addon (plugin) | ||
}, | ||
resolveMojitDetails: function (env, posl, type, ress, mojitRes) { | ||
var details = {}; | ||
//should trigger RSAddonSuperBundle.resolveMojitDetails through AOP | ||
this.fire('resolveMojitDetails', { | ||
args: { | ||
env: env, | ||
posl: posl, | ||
type: type, | ||
ress: ress, | ||
mojitRes: mojitRes | ||
}, | ||
mojitDetails: details | ||
}); | ||
return details; | ||
} | ||
@@ -230,3 +248,3 @@ }); | ||
OA.ownsKey(path, store._dirBundlesLoaded, 'Bundle loaded'); | ||
A.areEqual(name, store._dirBundlesLoaded[path].bundleName, 'Bundle name'); | ||
A.areEqual(name, store._dirBundlesLoaded[path].bundle, 'Bundle name'); | ||
}); | ||
@@ -238,3 +256,3 @@ }, | ||
A.areEqual(source.pkg.bundleName, res.selector, "Dynamic selector"); | ||
A.areEqual(source.pkg.bundle, res.selector, "Dynamic selector"); | ||
A.areEqual("/test_static_prefix/TestMojit/assets/testMojit-base.blue.css", | ||
@@ -246,3 +264,3 @@ res.url, "Resource static url"); | ||
var testSelector = 'TEST', | ||
expectedSelector = source.pkg.bundleName + '_' + testSelector, | ||
expectedSelector = source.pkg.bundle + '_' + testSelector, | ||
res = store.parseResourceVersion(source, type, subtype, mojitType, testSelector); | ||
@@ -261,3 +279,3 @@ | ||
A.areEqual(source.pkg.bundleName, res.selector, "Dynamic selector"); | ||
A.areEqual(source.pkg.bundle, res.selector, "Dynamic selector"); | ||
A.areEqual("/test_static_prefix/TestMojit/assets/testMojit-base.iphone.blue.css", | ||
@@ -269,3 +287,3 @@ res.url, "Resource static url"); | ||
var testSelector = 'TEST', | ||
expectedSelector = source.pkg.bundleName + '_' + testSelector, | ||
expectedSelector = source.pkg.bundle + '_' + testSelector, | ||
res = store.parseResourceVersion(source, type, subtype, mojitType, testSelector); | ||
@@ -330,3 +348,5 @@ | ||
lang: 'es-MX', | ||
langs: 'foo' | ||
langs: 'foo', | ||
//should be ignored | ||
foo: null | ||
}, | ||
@@ -370,3 +390,3 @@ | ||
type: 'super-bundle', | ||
bundleName: 'blue_1' | ||
bundle: 'blue_1' | ||
} | ||
@@ -376,3 +396,3 @@ } | ||
store.addResourceVersion(res); | ||
A.areEqual(res.source.pkg.bundleName, res.selector, 'Resource selector'); | ||
A.areEqual(res.source.pkg.bundle, res.selector, 'Resource selector'); | ||
}, | ||
@@ -392,2 +412,16 @@ | ||
A.areEqual('foo', res.selector, 'Resource selector'); | ||
}, | ||
'resolveMojitDetails should add dimension name and value to mojit details': function () { | ||
var env = {}, | ||
posl = {}, | ||
type = "FooMojit", | ||
ress = [], | ||
mojitRes = { | ||
source: source | ||
}, | ||
details = store.resolveMojitDetails(env, posl, type, ress, mojitRes); | ||
A.areEqual(source.pkg.dimension, details.dimensionName, "Mojit details dimension name"); | ||
A.areEqual(source.pkg.bundle, details.dimensionValue, "Mojit details dimension value"); | ||
} | ||
@@ -394,0 +428,0 @@ })); |
41770
764
186
3