Last active
August 29, 2015 14:10
-
-
Save marcellodesales/6ec634ca20ca285e194f to your computer and use it in GitHub Desktop.
From JSON to XML Todos for compatible with http://todos.sourceforge.net/manual.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"file": "/home/mdesales/dev/github-intuit/sp-quality/src/test_tasks.js", | |
"text": "Find a workaround to install https://github.com/badges/shields locally as a module", | |
"kind": "FIXME", | |
"line": 49 | |
} | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @module lib/Todos Docs */ | |
"use strict"; | |
var builder = require("xmlbuilder"); | |
/** | |
* @param {object} todosJson is instance of the json report. | |
* @return {object} An XML representation of the todos based on sourceforge's todo. | |
*/ | |
module.exports.serialize = function(todosJson) { | |
// Generate the XML following the convention http://todos.sourceforge.net/samples/simple.xml | |
var commentsXml = builder.create("comments"); | |
commentsXml.att("xmlns", "http://todos.sourceforge.net"); | |
commentsXml.att("version", "0.1.0"); | |
// Loop through all of them | |
todosJson.forEach(function(todo) { | |
var commentXml = commentsXml.ele("comment", todo.text); | |
commentXml.att("file", todo.file); | |
commentXml.att("line", todo.line); | |
commentXml.att("pattern", todo.kind); | |
}); | |
// Generate the XML file | |
commentsXml = commentsXml.end({ pretty: true}); | |
return commentsXml; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<comments xmlns="http://todos.sourceforge.net" version="0.1.0"> | |
<comment file="/home/mdesales/dev/github-intuit/sp-quality/src/test_tasks.js" line="49" pattern="FIXME">Find a workaround to install https://github.com/badges/shields locally as a module</comment> | |
</comments> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment