Skip to content

Commit a3cd3f2

Browse files
author
Ubuntu
committed
init
0 parents  commit a3cd3f2

File tree

6 files changed

+52
-0
lines changed

6 files changed

+52
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
var FS = require('fs');
2+
var Parser = module.exports = {};
3+
4+
Parser.parse = function(xml, callback) {
5+
callback(null, {});
6+
}
7+
8+
Parser.parseURL = function(url, callback) {
9+
return Parser.parse('', callback);
10+
}
11+
12+
Parser.parseFile = function(file, callback) {
13+
FS.readFile(file, 'utf8', function(err, contents) {
14+
return Parser.parse(contents, callback);
15+
})
16+
}

package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "rss-parser",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "mocha"
8+
},
9+
"author": "",
10+
"license": "MIT",
11+
"devDependencies": {
12+
"chai": "^3.4.1"
13+
}
14+
}

test/input/reddit.rss

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

test/output/reddit.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

test/parser.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
var FS = require('fs');
2+
3+
var Parser = require('../index.js');
4+
5+
var Expect = require('chai').expect;
6+
7+
var INPUT_FILE = __dirname + '/input/reddit.rss';
8+
var OUTPUT_FILE = __dirname + '/output/reddit.json';
9+
10+
describe('Parser', function() {
11+
it('should parse Reddit', function(done) {
12+
Parser.parse(INPUT_FILE, function(err, parsed) {
13+
Expect(err).to.equal(null);
14+
var expected = FS.readFileSync(OUTPUT_FILE, 'utf8')
15+
expected = JSON.parse(expected);
16+
Expect(parsed).to.deep.equal(expected)
17+
})
18+
})
19+
})

0 commit comments

Comments
 (0)