mirror of
https://gitlab.silvrtree.co.uk/martind2000/rss-braider.git
synced 2025-02-10 20:39:15 +00:00
Adding support for plugins dir(s) in configs. Updated unit tests
This commit is contained in:
parent
bfadf61cc9
commit
72971c5c33
@ -1,7 +1,7 @@
|
||||
var feed = {
|
||||
"feed_name" : "feed",
|
||||
"default_count" : 1,
|
||||
"no_cdata_fields" : [],
|
||||
"feed_name" : "feed",
|
||||
"default_count" : 1,
|
||||
"no_cdata_fields" : [],
|
||||
"meta" : {
|
||||
"title": "NPR Braided Feed",
|
||||
"description": "This is a test of two NPR sources from file"
|
||||
|
@ -28,15 +28,18 @@ RssBraider.prototype.loadPlugins = function () {
|
||||
var self = this;
|
||||
|
||||
if (self.plugins_directories.length < 1) {
|
||||
logger.info("No plugins_directories specified. No plugins loaded.");
|
||||
// logger.info("No plugins_directories specified. No plugins loaded.");
|
||||
}
|
||||
|
||||
self.plugins_directories.forEach(function(dir){
|
||||
self.plugins_directories.forEach(function(path){
|
||||
// load up each file and assign it to the plugins
|
||||
var filenames = fs.readdirSync(path);
|
||||
filenames.forEach(function(filename){
|
||||
var plugin_name = filename.replace(/.js$/, '');
|
||||
if (self.plugins[plugin_name]) {
|
||||
logger.warn("Duplicate plugin name: ", plugin_name, "Overwriting with newer plugin");
|
||||
}
|
||||
self.plugins[plugin_name] = require(path + '/' + plugin_name);
|
||||
// logger.info("plugin loaded:", plugin_name);
|
||||
// logger.info("plugin registered:", plugin_name);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -32,9 +32,10 @@ test('braid feed from file with plugins', function(t) {
|
||||
var feeds = {};
|
||||
feeds.sample_feed = require("./feeds/sample_feed_plugins").feed;
|
||||
var braider_options = {
|
||||
feeds : feeds,
|
||||
indent : " ",
|
||||
date_sort_order : "desc"
|
||||
feeds : feeds,
|
||||
indent : " ",
|
||||
date_sort_order : "desc",
|
||||
plugins_directories : [__dirname + '/../lib/plugins/']
|
||||
};
|
||||
var rss_braider = RssBraider.createClient(braider_options);
|
||||
|
||||
@ -52,9 +53,10 @@ test('deduplicate feed from file', function(t) {
|
||||
var feeds = {};
|
||||
feeds.sample_feed = require("./feeds/sample_feed_duplicates").feed;
|
||||
var braider_options = {
|
||||
feeds : feeds,
|
||||
indent : " ",
|
||||
dedupe_fields : ["title", "guid"]
|
||||
feeds : feeds,
|
||||
indent : " ",
|
||||
dedupe_fields : ["title", "guid"],
|
||||
plugins_directories : [__dirname + '/../lib/plugins/']
|
||||
};
|
||||
var rss_braider = RssBraider.createClient(braider_options);
|
||||
|
||||
@ -72,9 +74,10 @@ test('sort by date desc', function(t) {
|
||||
var feeds = {};
|
||||
feeds.sample_feed = require("./feeds/date_sort").feed;
|
||||
var braider_options = {
|
||||
feeds : feeds,
|
||||
indent : " ",
|
||||
date_sort_order : "desc"
|
||||
feeds : feeds,
|
||||
indent : " ",
|
||||
date_sort_order : "desc",
|
||||
plugins_directories : [__dirname + '/../lib/plugins/']
|
||||
};
|
||||
var rss_braider = RssBraider.createClient(braider_options);
|
||||
|
||||
@ -92,9 +95,10 @@ test('sort by date asc', function(t) {
|
||||
var feeds = {};
|
||||
feeds.sample_feed = require("./feeds/date_sort").feed;
|
||||
var braider_options = {
|
||||
feeds : feeds,
|
||||
indent : " ",
|
||||
date_sort_order : "asc"
|
||||
feeds : feeds,
|
||||
indent : " ",
|
||||
date_sort_order : "asc",
|
||||
plugins_directories : [__dirname + '/../lib/plugins/']
|
||||
};
|
||||
var rss_braider = RssBraider.createClient(braider_options);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user