Skip to content

Commit

Permalink
app skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
janzal committed Mar 29, 2014
1 parent 3ebcdcd commit b772ed1
Show file tree
Hide file tree
Showing 6 changed files with 75,898 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
24 changes: 24 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env node

var commander = require('commander');
var package = require('./package.json');

var Parser = require('./parser');

commander
.version(package.version)
.usage('[options] <file ...>')
.parse(process.argv);

if(commander.args.length === 0) {
console.error('You must specify source file.');
process.exit(1);
}

commander.args.forEach(function(file) {
var parser = new Parser(file);
parser.parse();
});



21 changes: 21 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "zum-nodes",
"version": "0.0.0",
"description": "Parse nodes/edges for ZUMScore",
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/fitak/zum-nodes-parser.git"
},
"author": "Jan Zaloudek",
"license": "BSD",
"readmeFilename": "README.md",
"gitHead": "3ebcdcd1ec1d49c114c177745af9d839ebe9ba94",
"dependencies": {
"cheerio": "~0.13.1",
"commander": "~2.2.0"
}
}
46 changes: 46 additions & 0 deletions parser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
var cheerio = require('cheerio');
var fs = require('fs');


var Parser = function(file_name, options) {
this.file_name = file_name;
this.options = options;

this.dom_ = null;
}

Parser.prototype.getEdgesQueries_ = function() {

}

Parser.prototype.getNodesQueries_ = function() {
if(!this.dom_) {
throw new Error('XML DOM is not loaded');
}

var queries = [];
var self = this;

// this.dom_('nodes').each(function(index, node) {
// console.log(self.dom_('edge', this).toArray());
// });
}

Parser.prototype.parse = function() {
var file = fs.readFileSync(this.file_name, {
encoding: 'ascii'
});

this.dom_ = cheerio.load(file, {
xmlMode: true,
lowerCaseTags: true,
lowerCaseAttributeNames: true
});

var nodes_queries = this.getNodesQueries_() || [];
var edges_queries = this.getEdgesQueries_() || [];

var result
}

module.exports = Parser;
Loading

0 comments on commit b772ed1

Please sign in to comment.