Skip to content

Commit

Permalink
chore(build): latest build as per changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vheissu committed Mar 1, 2016
1 parent e2a9a83 commit 536a00b
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 66 deletions.
32 changes: 18 additions & 14 deletions dist/amd/configure.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define(['exports', 'core-js', 'aurelia-dependency-injection', 'aurelia-http-client', 'aurelia-event-aggregator'], function (exports, _coreJs, _aureliaDependencyInjection, _aureliaHttpClient, _aureliaEventAggregator) {
define(['exports', 'core-js', 'aurelia-dependency-injection', 'aurelia-loader'], function (exports, _coreJs, _aureliaDependencyInjection, _aureliaLoader) {
'use strict';

exports.__esModule = true;
Expand All @@ -15,18 +15,17 @@ define(['exports', 'core-js', 'aurelia-dependency-injection', 'aurelia-http-clie
var CASCADE_MODE = new WeakMap();

var Configure = (function () {
function Configure(http, ea) {
function Configure(loader) {
_classCallCheck(this, _Configure);

this.http = http;
this.ea = ea;
this.loader = loader;

CONFIG_OBJECT.set(this, {});

ENVIRONMENT.set(this, 'default');
ENVIRONMENTS.set(this, false);
DIRECTORY.set(this, 'config');
CONFIG_FILE.set(this, 'application.json');
CONFIG_FILE.set(this, 'config.json');
CASCADE_MODE.set(this, true);
}

Expand Down Expand Up @@ -151,10 +150,21 @@ define(['exports', 'core-js', 'aurelia-dependency-injection', 'aurelia-http-clie
var _parent2 = splitKey[0];
var child = splitKey[1];

if (this.obj[_parent2] === undefined) {
this.obj[_parent2] = {};
}

this.obj[_parent2][child] = val;
}
};

Configure.prototype.merge = function merge(obj) {
var currentConfig = CONFIG_OBJECT.get(this);
var merged = Object.assign(currentConfig, obj);

CONFIG_OBJECT.set(this, merged);
};

Configure.prototype.setAll = function setAll(obj) {
CONFIG_OBJECT.set(this, obj);
};
Expand All @@ -164,14 +174,8 @@ define(['exports', 'core-js', 'aurelia-dependency-injection', 'aurelia-http-clie
};

Configure.prototype.loadConfig = function loadConfig() {
var _this = this;

return new Promise(function (resolve, reject) {
_this.http.get(_this.directory + '/' + _this.config).then(function (response) {
resolve(response.content);
})['catch'](function () {
return reject(new Error('Configuration file could not be found or loaded.'));
});
return this.loader.loadText(this.directory + '/' + this.config)['catch'](function () {
return reject(new Error('Configuration file could not be found or loaded.'));
});
};

Expand Down Expand Up @@ -208,7 +212,7 @@ define(['exports', 'core-js', 'aurelia-dependency-injection', 'aurelia-http-clie
}]);

var _Configure = Configure;
Configure = _aureliaDependencyInjection.inject(_aureliaHttpClient.HttpClient, _aureliaEventAggregator.EventAggregator)(Configure) || Configure;
Configure = _aureliaDependencyInjection.inject(_aureliaLoader.Loader)(Configure) || Configure;
return Configure;
})();

Expand Down
1 change: 1 addition & 0 deletions dist/amd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ define(['exports', './configure'], function (exports, _configure) {

return new Promise(function (resolve, reject) {
instance.loadConfig().then(function (data) {
data = JSON.parse(data);
instance.setAll(data);
resolve();
});
Expand Down
34 changes: 18 additions & 16 deletions dist/commonjs/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ require('core-js');

var _aureliaDependencyInjection = require('aurelia-dependency-injection');

var _aureliaHttpClient = require('aurelia-http-client');

var _aureliaEventAggregator = require('aurelia-event-aggregator');
var _aureliaLoader = require('aurelia-loader');

var ENVIRONMENT = new WeakMap();
var ENVIRONMENTS = new WeakMap();
Expand All @@ -22,18 +20,17 @@ var CONFIG_OBJECT = new WeakMap();
var CASCADE_MODE = new WeakMap();

var Configure = (function () {
function Configure(http, ea) {
function Configure(loader) {
_classCallCheck(this, _Configure);

this.http = http;
this.ea = ea;
this.loader = loader;

CONFIG_OBJECT.set(this, {});

ENVIRONMENT.set(this, 'default');
ENVIRONMENTS.set(this, false);
DIRECTORY.set(this, 'config');
CONFIG_FILE.set(this, 'application.json');
CONFIG_FILE.set(this, 'config.json');
CASCADE_MODE.set(this, true);
}

Expand Down Expand Up @@ -158,10 +155,21 @@ var Configure = (function () {
var _parent2 = splitKey[0];
var child = splitKey[1];

if (this.obj[_parent2] === undefined) {
this.obj[_parent2] = {};
}

this.obj[_parent2][child] = val;
}
};

Configure.prototype.merge = function merge(obj) {
var currentConfig = CONFIG_OBJECT.get(this);
var merged = Object.assign(currentConfig, obj);

CONFIG_OBJECT.set(this, merged);
};

Configure.prototype.setAll = function setAll(obj) {
CONFIG_OBJECT.set(this, obj);
};
Expand All @@ -171,14 +179,8 @@ var Configure = (function () {
};

Configure.prototype.loadConfig = function loadConfig() {
var _this = this;

return new Promise(function (resolve, reject) {
_this.http.get(_this.directory + '/' + _this.config).then(function (response) {
resolve(response.content);
})['catch'](function () {
return reject(new Error('Configuration file could not be found or loaded.'));
});
return this.loader.loadText(this.directory + '/' + this.config)['catch'](function () {
return reject(new Error('Configuration file could not be found or loaded.'));
});
};

Expand Down Expand Up @@ -215,7 +217,7 @@ var Configure = (function () {
}]);

var _Configure = Configure;
Configure = _aureliaDependencyInjection.inject(_aureliaHttpClient.HttpClient, _aureliaEventAggregator.EventAggregator)(Configure) || Configure;
Configure = _aureliaDependencyInjection.inject(_aureliaLoader.Loader)(Configure) || Configure;
return Configure;
})();

Expand Down
1 change: 1 addition & 0 deletions dist/commonjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function configure(aurelia, configCallback) {

return new Promise(function (resolve, reject) {
instance.loadConfig().then(function (data) {
data = JSON.parse(data);
instance.setAll(data);
resolve();
});
Expand Down
60 changes: 43 additions & 17 deletions dist/es6/configure.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import 'core-js';

import {inject} from 'aurelia-dependency-injection';
import {HttpClient} from 'aurelia-http-client';
import {EventAggregator} from 'aurelia-event-aggregator';
import {Loader} from 'aurelia-loader';

// Secure references that can't be changed outside of Configure singleton class
const ENVIRONMENT = new WeakMap();
Expand All @@ -12,24 +11,24 @@ const CONFIG_FILE = new WeakMap();
const CONFIG_OBJECT = new WeakMap();
const CASCADE_MODE = new WeakMap();

@inject(HttpClient, EventAggregator)
@inject(Loader)
export class Configure {
constructor(http, ea) {
constructor(loader) {
// Injected dependencies
this.http = http;
this.ea = ea;
this.loader = loader;

CONFIG_OBJECT.set(this, {});

ENVIRONMENT.set(this, 'default');
ENVIRONMENTS.set(this, false);
DIRECTORY.set(this, 'config');
CONFIG_FILE.set(this, 'application.json');
CONFIG_FILE.set(this, 'config.json');
CASCADE_MODE.set(this, true);
}

/**
* Set Directory
*
* Sets the location to look for the config file
*
* @param path
Expand All @@ -40,6 +39,7 @@ export class Configure {

/**
* Set Config
*
* Sets the filename to look for in the defined directory
*
* @param name
Expand All @@ -50,6 +50,7 @@ export class Configure {

/**
* Set Environment
*
* Changes the environment value
*
* @param environment
Expand All @@ -60,6 +61,7 @@ export class Configure {

/**
* Set Environments
*
* Specify multiple environment domains to allow for
* dynamic environment switching.
*
Expand All @@ -76,6 +78,7 @@ export class Configure {

/**
* Set Cascade Mode
*
* By default if a environment config value is not found, it will
* go looking up the config file to find it (a la inheritance style). Sometimes
* you just want a config value from a specific environment and nowhere else
Expand All @@ -89,6 +92,7 @@ export class Configure {

/**
* Get Config
*
* Returns the entire configuration object pulled and parsed from file
*
* @returns {V}
Expand All @@ -99,6 +103,7 @@ export class Configure {

/**
* Get Environment
*
* Gets the current environment value
*
* @returns {V}
Expand All @@ -109,6 +114,7 @@ export class Configure {

/**
* Get Environments
*
* Gets any user supplied environment mappings
*
* @returns {array}
Expand All @@ -119,6 +125,7 @@ export class Configure {

/**
* Get Cascade Mode
*
* Gets the current cascade mode boolean
* @returns {boolean}
*/
Expand All @@ -128,6 +135,7 @@ export class Configure {

/**
* Get Directory
*
* Gets the current directory
*
* @returns {V}
Expand All @@ -138,6 +146,7 @@ export class Configure {

/**
* Get Config
*
* Get the config file name
*
* @returns {V}
Expand All @@ -148,6 +157,7 @@ export class Configure {

/**
* Is
*
* A method for determining if the current environment
* equals that of the supplied environment value*
* @param environment
Expand Down Expand Up @@ -278,14 +288,36 @@ export class Configure {
let parent = splitKey[0];
let child = splitKey[1];

if (this.obj[parent] === undefined) {
this.obj[parent] = {};
}

this.obj[parent][child] = val;
}
}

/**
* Merge
*
* Allows you to merge in configuration options
* this method might be used to merge in server-loaded
* configuration options with local ones.
*
* @param obj
*
*/
merge(obj) {
let currentConfig = CONFIG_OBJECT.get(this);
let merged = Object.assign(currentConfig, obj);

CONFIG_OBJECT.set(this, merged);
}

/**
* Set All
* A dangerous method that sets the entire config object
* only used during bootstrapping phase
* Sets and overwrites the entire configuration object
* used internally, but also can be used to set the configuration
* from outside of the usual JSON loading logic.
*
* @param obj
*/
Expand All @@ -311,13 +343,7 @@ export class Configure {
* @returns {Promise}
*/
loadConfig() {
return new Promise((resolve, reject) => {
this.http
.get(`${this.directory}/${this.config}`)
.then(response => {
resolve(response.content);
})
.catch(() => reject(new Error('Configuration file could not be found or loaded.')));
});
return this.loader.loadText(`${this.directory}/${this.config}`)
.catch(() => reject(new Error('Configuration file could not be found or loaded.')));
}
}
1 change: 1 addition & 0 deletions dist/es6/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export function configure(aurelia, configCallback) {

return new Promise((resolve, reject) => {
instance.loadConfig().then(data => {
data = JSON.parse(data);
instance.setAll(data);
resolve();
});
Expand Down
Loading

0 comments on commit 536a00b

Please sign in to comment.