From 3aa171fbaf05d0ee5b82673443da51ed43719475 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 25 Sep 2015 17:36:53 -0400 Subject: moving things around --- lib/fortune.js | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 lib/fortune.js (limited to 'lib/fortune.js') diff --git a/lib/fortune.js b/lib/fortune.js deleted file mode 100644 index 7adba5a..0000000 --- a/lib/fortune.js +++ /dev/null @@ -1,28 +0,0 @@ -function choice (a){ return a[ Math.floor(Math.random()*a.length) ] } - -var fs = require("fs"), path = require("path") -var fortunes = {} -var dir = "fortune" - -fs.readdirSync(path.resolve(dir)).forEach(function(fn){ - - var file = dir + '/' + fn - var stat = fs.statSync(file) - - if (stat && ! stat.isDirectory()) { - fortunes[fn] = fs.readFileSync(file) - .toString() - .split("\n") - .filter(function(s){ return !! s }) - } - -}) - -module.exports = function(tag){ - if (tag in fortunes) { - return choice(fortunes[tag]) - } - else { - return "bucky" - } -} \ No newline at end of file -- cgit v1.2.3-70-g09d2