mirror of
https://gitlab.silvrtree.co.uk/martind2000/rss-braider.git
synced 2025-02-11 06:09:19 +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 = {
|
var feed = {
|
||||||
"feed_name" : "feed",
|
"feed_name" : "feed",
|
||||||
"default_count" : 1,
|
"default_count" : 1,
|
||||||
"no_cdata_fields" : [],
|
"no_cdata_fields" : [],
|
||||||
"meta" : {
|
"meta" : {
|
||||||
"title": "NPR Braided Feed",
|
"title": "NPR Braided Feed",
|
||||||
"description": "This is a test of two NPR sources from file"
|
"description": "This is a test of two NPR sources from file"
|
||||||
|
@ -28,15 +28,18 @@ RssBraider.prototype.loadPlugins = function () {
|
|||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (self.plugins_directories.length < 1) {
|
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(path){
|
||||||
self.plugins_directories.forEach(function(dir){
|
|
||||||
// load up each file and assign it to the plugins
|
// load up each file and assign it to the plugins
|
||||||
|
var filenames = fs.readdirSync(path);
|
||||||
filenames.forEach(function(filename){
|
filenames.forEach(function(filename){
|
||||||
var plugin_name = filename.replace(/.js$/, '');
|
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);
|
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 = {};
|
var feeds = {};
|
||||||
feeds.sample_feed = require("./feeds/sample_feed_plugins").feed;
|
feeds.sample_feed = require("./feeds/sample_feed_plugins").feed;
|
||||||
var braider_options = {
|
var braider_options = {
|
||||||
feeds : feeds,
|
feeds : feeds,
|
||||||
indent : " ",
|
indent : " ",
|
||||||
date_sort_order : "desc"
|
date_sort_order : "desc",
|
||||||
|
plugins_directories : [__dirname + '/../lib/plugins/']
|
||||||
};
|
};
|
||||||
var rss_braider = RssBraider.createClient(braider_options);
|
var rss_braider = RssBraider.createClient(braider_options);
|
||||||
|
|
||||||
@ -52,9 +53,10 @@ test('deduplicate feed from file', function(t) {
|
|||||||
var feeds = {};
|
var feeds = {};
|
||||||
feeds.sample_feed = require("./feeds/sample_feed_duplicates").feed;
|
feeds.sample_feed = require("./feeds/sample_feed_duplicates").feed;
|
||||||
var braider_options = {
|
var braider_options = {
|
||||||
feeds : feeds,
|
feeds : feeds,
|
||||||
indent : " ",
|
indent : " ",
|
||||||
dedupe_fields : ["title", "guid"]
|
dedupe_fields : ["title", "guid"],
|
||||||
|
plugins_directories : [__dirname + '/../lib/plugins/']
|
||||||
};
|
};
|
||||||
var rss_braider = RssBraider.createClient(braider_options);
|
var rss_braider = RssBraider.createClient(braider_options);
|
||||||
|
|
||||||
@ -72,9 +74,10 @@ test('sort by date desc', function(t) {
|
|||||||
var feeds = {};
|
var feeds = {};
|
||||||
feeds.sample_feed = require("./feeds/date_sort").feed;
|
feeds.sample_feed = require("./feeds/date_sort").feed;
|
||||||
var braider_options = {
|
var braider_options = {
|
||||||
feeds : feeds,
|
feeds : feeds,
|
||||||
indent : " ",
|
indent : " ",
|
||||||
date_sort_order : "desc"
|
date_sort_order : "desc",
|
||||||
|
plugins_directories : [__dirname + '/../lib/plugins/']
|
||||||
};
|
};
|
||||||
var rss_braider = RssBraider.createClient(braider_options);
|
var rss_braider = RssBraider.createClient(braider_options);
|
||||||
|
|
||||||
@ -92,9 +95,10 @@ test('sort by date asc', function(t) {
|
|||||||
var feeds = {};
|
var feeds = {};
|
||||||
feeds.sample_feed = require("./feeds/date_sort").feed;
|
feeds.sample_feed = require("./feeds/date_sort").feed;
|
||||||
var braider_options = {
|
var braider_options = {
|
||||||
feeds : feeds,
|
feeds : feeds,
|
||||||
indent : " ",
|
indent : " ",
|
||||||
date_sort_order : "asc"
|
date_sort_order : "asc",
|
||||||
|
plugins_directories : [__dirname + '/../lib/plugins/']
|
||||||
};
|
};
|
||||||
var rss_braider = RssBraider.createClient(braider_options);
|
var rss_braider = RssBraider.createClient(braider_options);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user