howsmydriving-dummy
Advanced tools
Comparing version 0.1.10 to 0.1.13
@@ -13,3 +13,15 @@ { | ||
"debug-filter": { "type": "logLevelFilter", "appender": "debug", "level": "debug", "maxLevel": "debug" }, | ||
"result": { "type": "dateFile", "filename": "log/app.log", "maxLogSize": 1048576, "numBackups": 2 }, | ||
"result": { | ||
"type": "dateFile", | ||
"filename": "log/app.log", | ||
"maxLogSize": 1048576, | ||
"numBackups": 2, | ||
"layout": { | ||
"type":"pattern", | ||
"pattern": "[%p] [%c] %x{module} blah %m%n", | ||
"tokens": { | ||
"module": "function(logEvent) {return this.constructor.name;}" | ||
} | ||
} | ||
}, | ||
"result-filter": { "type": "logLevelFilter", "appender": "result", "level": "info", "maxLevel": "fatal" }, | ||
@@ -16,0 +28,0 @@ "error": { "type": "dateFile", "filename": "log/err.log", "maxLogSize": 1048576, "numBackups": 2 }, |
@@ -1,3 +0,1 @@ | ||
import { IRegion } from 'howsmydriving-utils'; | ||
declare var Region: IRegion; | ||
export { Region as default }; | ||
export { Region } from './src/dummyregion'; |
import { Citation } from 'howsmydriving-utils'; | ||
import { ICitation } from 'howsmydriving-utils'; | ||
import { IRegion } from 'howsmydriving-utils'; | ||
import { Region } from 'howsmydriving-utils'; | ||
export declare var RegionName: string; | ||
export declare class DummyRegion extends Region { | ||
@@ -10,1 +10,4 @@ constructor(name: string); | ||
} | ||
declare var RegionInstance: IRegion; | ||
export { RegionInstance as default }; | ||
export { RegionInstance as Region }; |
@@ -13,3 +13,15 @@ { | ||
"debug-filter": { "type": "logLevelFilter", "appender": "debug", "level": "debug", "maxLevel": "debug" }, | ||
"result": { "type": "dateFile", "filename": "log/app.log", "maxLogSize": 1048576, "numBackups": 2 }, | ||
"result": { | ||
"type": "dateFile", | ||
"filename": "log/app.log", | ||
"maxLogSize": 1048576, | ||
"numBackups": 2, | ||
"layout": { | ||
"type":"pattern", | ||
"pattern": "[%p] [%c] %x{module} blah %m%n", | ||
"tokens": { | ||
"module": "function(logEvent) {return this.constructor.name;}" | ||
} | ||
} | ||
}, | ||
"result-filter": { "type": "logLevelFilter", "appender": "result", "level": "info", "maxLevel": "fatal" }, | ||
@@ -16,0 +28,0 @@ "error": { "type": "dateFile", "filename": "log/err.log", "maxLogSize": 1048576, "numBackups": 2 }, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var dummyregion_1 = require("./src/dummyregion"); | ||
var dummyregion_2 = require("./src/dummyregion"); | ||
var logging_1 = require("./src/logging"); | ||
var path = require("path"); | ||
var Region = new dummyregion_1.DummyRegion(dummyregion_2.RegionName); | ||
exports.default = Region; | ||
var dummyregion_1 = require("./src/dummyregion"); | ||
exports.Region = dummyregion_1.Region; | ||
var pjson = require(path.resolve(__dirname + '/../package.json')); | ||
logging_1.log.info("Module " + pjson.name + " version '" + pjson.version + "' loaded."); |
@@ -20,14 +20,16 @@ "use strict"; | ||
var dummycitation_1 = require("./dummycitation"); | ||
var common_1 = require("./common"); | ||
var logging_1 = require("./logging"); | ||
exports.RegionName = 'DummyRegion'; | ||
// TODO: Consolidate these. | ||
var parkingAndCameraViolationsText = "Total parking and camera violations for #", violationsByYearText = "Violations by year for #", violationsByStatusText = "Violations by status for #", citationQueryText = "License #__LICENSE__ has been queried __COUNT__ times."; | ||
var parkingAndCameraViolationsText = 'Total parking and camera violations for #', violationsByYearText = 'Violations by year for #', violationsByStatusText = 'Violations by status for #', citationQueryText = 'License #__LICENSE__ has been queried __COUNT__ times.'; | ||
var DummyRegion = /** @class */ (function (_super) { | ||
__extends(DummyRegion, _super); | ||
function DummyRegion(name) { | ||
return _super.call(this, name) || this; | ||
var _this = _super.call(this, name) || this; | ||
logging_1.log.debug("Creating instance " + _this.constructor.name + " Region for region " + common_1.__REGION_NAME__ + "."); | ||
return _this; | ||
} | ||
DummyRegion.prototype.GetCitationsByPlate = function (plate, state) { | ||
return new Promise(function (resolve, reject) { | ||
// We take all numeric digits in the license and total the numbers. | ||
// We take all numeric digits in the license and total the numbers. | ||
// If license contains x, y or z, return 0. Otherwise return the total. | ||
@@ -40,3 +42,3 @@ var num_citations_regex = /[0-9]/g; | ||
} | ||
var xyz_found = (/[x-zX-Z]/.exec(plate).length > 0); | ||
var xyz_found = /[x-zX-Z]/.exec(plate).length > 0; | ||
var num_citations = xyz_found ? 0 : total; | ||
@@ -69,3 +71,3 @@ logging_1.log.debug("License " + state + ":" + plate + " has a numeric sum of " + total + " and " + xyz_found + " exists. Creating " + num_citations + " citations."); | ||
// Should never happen. jurisdictions must return at least a dummy citation | ||
throw new Error("Jurisdiction modules must return at least one citation, a dummy one if there are none."); | ||
throw new Error('Jurisdiction modules must return at least one citation, a dummy one if there are none.'); | ||
} | ||
@@ -110,15 +112,15 @@ var license; | ||
howsmydriving_utils_2.formatPlate(license) + | ||
": " + | ||
': ' + | ||
Object.keys(citations).length; | ||
Object.keys(categorizedCitations).forEach(function (key) { | ||
var line = key + ": " + categorizedCitations[key]; | ||
var line = key + ': ' + categorizedCitations[key]; | ||
// Max twitter username is 15 characters, plus the @ | ||
general_summary += "\n"; | ||
general_summary += '\n'; | ||
general_summary += line; | ||
}); | ||
general_summary += "\n\n"; | ||
general_summary += '\n\n'; | ||
general_summary += citationQueryText | ||
.replace('__LICENSE__', howsmydriving_utils_2.formatPlate(license)) | ||
.replace('__COUNT__', query_count.toString()); | ||
var detailed_list = ""; | ||
var detailed_list = ''; | ||
var sortedChronoCitationKeys = Object.keys(chronologicalCitations).sort(function (a, b) { | ||
@@ -133,3 +135,3 @@ //return new Date(a).getTime() - new Date(b).getTime(); | ||
if (first != true) { | ||
detailed_list += "\n"; | ||
detailed_list += '\n'; | ||
} | ||
@@ -140,19 +142,14 @@ first = false; | ||
} | ||
var temporal_summary = violationsByYearText + howsmydriving_utils_2.formatPlate(license) + ":"; | ||
var temporal_summary = violationsByYearText + howsmydriving_utils_2.formatPlate(license) + ':'; | ||
Object.keys(violationsByYear).forEach(function (key) { | ||
temporal_summary += "\n"; | ||
temporal_summary += '\n'; | ||
temporal_summary += key + ": " + violationsByYear[key].toString(); | ||
}); | ||
var type_summary = violationsByStatusText + howsmydriving_utils_2.formatPlate(license) + ":"; | ||
var type_summary = violationsByStatusText + howsmydriving_utils_2.formatPlate(license) + ':'; | ||
Object.keys(violationsByStatus).forEach(function (key) { | ||
type_summary += "\n"; | ||
type_summary += '\n'; | ||
type_summary += key + ": " + violationsByStatus[key]; | ||
}); | ||
// Return them in the order they should be rendered. | ||
return [ | ||
general_summary, | ||
detailed_list, | ||
type_summary, | ||
temporal_summary | ||
]; | ||
return [general_summary, detailed_list, type_summary, temporal_summary]; | ||
}; | ||
@@ -162,1 +159,4 @@ return DummyRegion; | ||
exports.DummyRegion = DummyRegion; | ||
var RegionInstance = new DummyRegion(common_1.__REGION_NAME__); | ||
exports.default = RegionInstance; | ||
exports.Region = RegionInstance; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var howsmydriving_utils_1 = require("howsmydriving-utils"); | ||
var common_1 = require("./common"); | ||
/** | ||
@@ -10,3 +10,3 @@ * Standard logging for HowsMyDriving modules. | ||
* other plugin logs. | ||
**/ | ||
**/ | ||
var log4js = require('log4js'), chokidar = require('chokidar'), path = require('path'); | ||
@@ -18,6 +18,6 @@ var config_path = path.resolve(__dirname + '/../config/log4js.json'); | ||
// config update changes. | ||
exports.log = log4js.getLogger("result", howsmydriving_utils_1.Region.name + ": "); | ||
exports.log = log4js.getLogger('result', common_1.__REGION_NAME__ + ": "); | ||
/** | ||
* Monitor the log4js config file and reloading log instances if the file changes. | ||
**/ | ||
**/ | ||
var watcher = chokidar.watch(config_path, { | ||
@@ -37,3 +37,3 @@ ignored: /(^|[\/\\])\../, | ||
* they update to the new log level? | ||
**/ | ||
**/ | ||
function reloadlog(reason) { | ||
@@ -47,6 +47,8 @@ exports.log.info("Reloading log config due to config file " + reason + "."); | ||
// Handle the change/add events for the log4js config file. | ||
watcher.on('add', function (path) { | ||
watcher | ||
.on('add', function (path) { | ||
reloadlog("add of " + path); | ||
}).on('change', function (path) { | ||
}) | ||
.on('change', function (path) { | ||
reloadlog("change of " + path); | ||
}); |
{ | ||
"name": "howsmydriving-dummy", | ||
"version": "0.1.10", | ||
"version": "0.1.13", | ||
"description": "Dummy region plug-in for @HowsMyDrivingWA.", | ||
@@ -26,3 +26,3 @@ "declaration": true, | ||
"express": "^4.14.0", | ||
"howsmydriving-utils": "^0.1.45", | ||
"howsmydriving-utils": "^0.1.51", | ||
"log4js": "^4.0.2", | ||
@@ -42,2 +42,3 @@ "node-localstorage": "^1.3.1", | ||
"gulp-mocha": "^7.0.2", | ||
"gulp-prettier": "^2.3.0", | ||
"gulp-typescript": "^6.0.0-alpha.1", | ||
@@ -47,2 +48,3 @@ "mocha": "^6.2.2", | ||
"path": "^0.12.7", | ||
"prettier": "^1.19.1", | ||
"sinon": "^7.5.0", | ||
@@ -49,0 +51,0 @@ "standard-version": "^7.0.1", |
19571
18
363
17
Updatedhowsmydriving-utils@^0.1.51