mirror of
https://github.com/apache/cordova-android.git
synced 2026-02-21 00:02:46 +08:00
CB-14145 remove old node_modules before patch fix
This commit is contained in:
48
node_modules/properties-parser/README.markdown
generated
vendored
48
node_modules/properties-parser/README.markdown
generated
vendored
@@ -1,48 +0,0 @@
|
||||
# node-properties-parser
|
||||
|
||||
A parser for [.properties](http://en.wikipedia.org/wiki/.properties) files written in javascript. Properties files store key-value pairs. They are typically used for configuration and internationalization in Java applications as well as in Actionscript projects. Here's an example of the format:
|
||||
|
||||
# You are reading the ".properties" entry.
|
||||
! The exclamation mark can also mark text as comments.
|
||||
website = http://en.wikipedia.org/
|
||||
language = English
|
||||
# The backslash below tells the application to continue reading
|
||||
# the value onto the next line.
|
||||
message = Welcome to \
|
||||
Wikipedia!
|
||||
# Add spaces to the key
|
||||
key\ with\ spaces = This is the value that could be looked up with the key "key with spaces".
|
||||
# Unicode
|
||||
tab : \u0009
|
||||
*(taken from [Wikipedia](http://en.wikipedia.org/wiki/.properties#Format))*
|
||||
|
||||
Currently works with any version of node.js.
|
||||
|
||||
## The API
|
||||
|
||||
- `parse(text)`: Parses `text` into key-value pairs. Returns an object containing the key-value pairs.
|
||||
- `read(path[, callback])`: Opens the file specified by `path` and calls `parse` on its content. If the optional `callback` parameter is provided, the result is then passed to it as the second parameter. If an error occurs, the error object is passed to `callback` as the first parameter. If `callback` is not provided, the file specified by `path` is synchronously read and calls `parse` on its contents. The resulting object is immediately returned.
|
||||
- `createEditor([path[, callback]])`: If neither `path` or `callback` are provided an empty editor object is returned synchronously. If only `path` is provided, the file specified by `path` is synchronously read and parsed. An editor object with the results in then immediately returned. If both `path` and `callback` are provided, the file specified by `path` is read and parsed asynchronously. An editor object with the results are then passed to `callback` as the second parameters. If an error occurs, the error object is passed to `callback` as the first parameter.
|
||||
- `Editor`: The editor object is returned by `createEditor`. Has the following API:
|
||||
- `get(key)`: Returns the value currently associated with `key`.
|
||||
- `set(key, [value[, comment]])`: Associates `key` with `value`. An optional comment can be provided. If `value` is not specified or is `null`, then `key` is unset.
|
||||
- `unset(key)`: Unsets the specified `key`.
|
||||
- `save([path][, callback]])`: Writes the current contents of this editor object to a file specified by `path`. If `path` is not provided, then it'll be defaulted to the `path` value passed to `createEditor`. The `callback` parameter is called when the file has been written to disk.
|
||||
- `addHeadComment`: Added a comment to the head of the file.
|
||||
- `toString`: Returns the string representation of this properties editor object. This string will be written to a file if `save` is called.
|
||||
|
||||
## Getting node-properties-parser
|
||||
|
||||
The easiest way to get node-properties-parser is with [npm](http://npmjs.org/):
|
||||
|
||||
npm install properties-parser
|
||||
|
||||
Alternatively you can clone this git repository:
|
||||
|
||||
git://github.com/xavi-/node-properties-parser.git
|
||||
|
||||
## Developed by
|
||||
* Xavi Ramirez
|
||||
|
||||
## License
|
||||
This project is released under [The MIT License](http://www.opensource.org/licenses/mit-license.php).
|
||||
354
node_modules/properties-parser/index.js
generated
vendored
354
node_modules/properties-parser/index.js
generated
vendored
@@ -1,354 +0,0 @@
|
||||
var fs = require("fs");
|
||||
|
||||
function Iterator(text) {
|
||||
var pos = 0, length = text.length;
|
||||
|
||||
this.peek = function(num) {
|
||||
num = num || 0;
|
||||
if(pos + num >= length) { return null; }
|
||||
|
||||
return text.charAt(pos + num);
|
||||
};
|
||||
this.next = function(inc) {
|
||||
inc = inc || 1;
|
||||
|
||||
if(pos >= length) { return null; }
|
||||
|
||||
return text.charAt((pos += inc) - inc);
|
||||
};
|
||||
this.pos = function() {
|
||||
return pos;
|
||||
};
|
||||
}
|
||||
|
||||
var rWhitespace = /\s/;
|
||||
function isWhitespace(chr) {
|
||||
return rWhitespace.test(chr);
|
||||
}
|
||||
function consumeWhiteSpace(iter) {
|
||||
var start = iter.pos();
|
||||
|
||||
while(isWhitespace(iter.peek())) { iter.next(); }
|
||||
|
||||
return { type: "whitespace", start: start, end: iter.pos() };
|
||||
}
|
||||
|
||||
function startsComment(chr) {
|
||||
return chr === "!" || chr === "#";
|
||||
}
|
||||
function isEOL(chr) {
|
||||
return chr == null || chr === "\n" || chr === "\r";
|
||||
}
|
||||
function consumeComment(iter) {
|
||||
var start = iter.pos();
|
||||
|
||||
while(!isEOL(iter.peek())) { iter.next(); }
|
||||
|
||||
return { type: "comment", start: start, end: iter.pos() };
|
||||
}
|
||||
|
||||
function startsKeyVal(chr) {
|
||||
return !isWhitespace(chr) && !startsComment(chr);
|
||||
}
|
||||
function startsSeparator(chr) {
|
||||
return chr === "=" || chr === ":" || isWhitespace(chr);
|
||||
}
|
||||
function startsEscapedVal(chr) {
|
||||
return chr === "\\";
|
||||
}
|
||||
function consumeEscapedVal(iter) {
|
||||
var start = iter.pos();
|
||||
|
||||
iter.next(); // move past "\"
|
||||
var curChar = iter.next();
|
||||
if(curChar === "u") { // encoded unicode char
|
||||
iter.next(4); // Read in the 4 hex values
|
||||
}
|
||||
|
||||
return { type: "escaped-value", start: start, end: iter.pos() };
|
||||
}
|
||||
function consumeKey(iter) {
|
||||
var start = iter.pos(), children = [];
|
||||
|
||||
var curChar;
|
||||
while((curChar = iter.peek()) !== null) {
|
||||
if(startsSeparator(curChar)) { break; }
|
||||
if(startsEscapedVal(curChar)) { children.push(consumeEscapedVal(iter)); continue; }
|
||||
|
||||
iter.next();
|
||||
}
|
||||
|
||||
return { type: "key", start: start, end: iter.pos(), children: children };
|
||||
}
|
||||
function consumeKeyValSeparator(iter) {
|
||||
var start = iter.pos();
|
||||
|
||||
var seenHardSep = false, curChar;
|
||||
while((curChar = iter.peek()) !== null) {
|
||||
if(isEOL(curChar)) { break; }
|
||||
|
||||
if(isWhitespace(curChar)) { iter.next(); continue; }
|
||||
|
||||
if(seenHardSep) { break; }
|
||||
|
||||
seenHardSep = (curChar === ":" || curChar === "=");
|
||||
if(seenHardSep) { iter.next(); continue; }
|
||||
|
||||
break; // curChar is a non-separtor char
|
||||
}
|
||||
|
||||
return { type: "key-value-separator", start: start, end: iter.pos() };
|
||||
}
|
||||
function startsLineBreak(iter) {
|
||||
return iter.peek() === "\\" && isEOL(iter.peek(1));
|
||||
}
|
||||
function consumeLineBreak(iter) {
|
||||
var start = iter.pos();
|
||||
|
||||
iter.next(); // consume \
|
||||
if(iter.peek() === "\r") { iter.next(); }
|
||||
iter.next(); // consume \n
|
||||
|
||||
var curChar;
|
||||
while((curChar = iter.peek()) !== null) {
|
||||
if(isEOL(curChar)) { break; }
|
||||
if(!isWhitespace(curChar)) { break; }
|
||||
|
||||
iter.next();
|
||||
}
|
||||
|
||||
return { type: "line-break", start: start, end: iter.pos() };
|
||||
}
|
||||
function consumeVal(iter) {
|
||||
var start = iter.pos(), children = [];
|
||||
|
||||
var curChar;
|
||||
while((curChar = iter.peek()) !== null) {
|
||||
if(startsLineBreak(iter)) { children.push(consumeLineBreak(iter)); continue; }
|
||||
if(startsEscapedVal(curChar)) { children.push(consumeEscapedVal(iter)); continue; }
|
||||
if(isEOL(curChar)) { break; }
|
||||
|
||||
iter.next();
|
||||
}
|
||||
|
||||
return { type: "value", start: start, end: iter.pos(), children: children };
|
||||
}
|
||||
function consumeKeyVal(iter) {
|
||||
return {
|
||||
type: "key-value",
|
||||
start: iter.pos(),
|
||||
children: [
|
||||
consumeKey(iter),
|
||||
consumeKeyValSeparator(iter),
|
||||
consumeVal(iter)
|
||||
],
|
||||
end: iter.pos()
|
||||
};
|
||||
}
|
||||
|
||||
var renderChild = {
|
||||
"escaped-value": function(child, text) {
|
||||
var type = text.charAt(child.start + 1);
|
||||
|
||||
if(type === "t") { return "\t"; }
|
||||
if(type === "r") { return "\r"; }
|
||||
if(type === "n") { return "\n"; }
|
||||
if(type === "f") { return "\f"; }
|
||||
if(type !== "u") { return type; }
|
||||
|
||||
return String.fromCharCode(parseInt(text.substr(child.start + 2, 4), 16));
|
||||
},
|
||||
"line-break": function (child, text) {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
function rangeToBuffer(range, text) {
|
||||
var start = range.start, buffer = [];
|
||||
|
||||
for(var i = 0; i < range.children.length; i++) {
|
||||
var child = range.children[i];
|
||||
|
||||
buffer.push(text.substring(start, child.start));
|
||||
buffer.push(renderChild[child.type](child, text));
|
||||
start = child.end;
|
||||
}
|
||||
buffer.push(text.substring(start, range.end));
|
||||
|
||||
return buffer;
|
||||
}
|
||||
function rangesToObject(ranges, text) {
|
||||
var obj = Object.create(null); // Creates to a true hash map
|
||||
|
||||
for(var i = 0; i < ranges.length; i++) {
|
||||
var range = ranges[i];
|
||||
|
||||
if(range.type !== "key-value") { continue; }
|
||||
|
||||
var key = rangeToBuffer(range.children[0], text).join("");
|
||||
var val = rangeToBuffer(range.children[2], text).join("");
|
||||
obj[key] = val;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
function stringToRanges(text) {
|
||||
var iter = new Iterator(text), ranges = [];
|
||||
|
||||
var curChar;
|
||||
while((curChar = iter.peek()) !== null) {
|
||||
if(isWhitespace(curChar)) { ranges.push(consumeWhiteSpace(iter)); continue; }
|
||||
if(startsComment(curChar)) { ranges.push(consumeComment(iter)); continue; }
|
||||
if(startsKeyVal(curChar)) { ranges.push(consumeKeyVal(iter)); continue; }
|
||||
|
||||
throw Error("Something crazy happened. text: '" + text + "'; curChar: '" + curChar + "'");
|
||||
}
|
||||
|
||||
return ranges;
|
||||
}
|
||||
|
||||
function isNewLineRange(range) {
|
||||
if(!range) { return false; }
|
||||
|
||||
if(range.type === "whitespace") { return true; }
|
||||
|
||||
if(range.type === "literal") {
|
||||
return isWhitespace(range.text) && range.text.indexOf("\n") > -1;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function Editor(text, path) {
|
||||
text = text || "";
|
||||
|
||||
var ranges = stringToRanges(text);
|
||||
var obj = rangesToObject(ranges, text);
|
||||
var keyRange = Object.create(null); // Creates to a true hash map
|
||||
|
||||
for(var i = 0; i < ranges.length; i++) {
|
||||
var range = ranges[i];
|
||||
|
||||
if(range.type !== "key-value") { continue; }
|
||||
|
||||
var key = rangeToBuffer(range.children[0], text).join("");
|
||||
keyRange[key] = range;
|
||||
}
|
||||
|
||||
this.addHeadComment = function(comment) {
|
||||
if(comment == null) { return; }
|
||||
|
||||
ranges.unshift({ type: "literal", text: "# " + comment.replace(/\n/g, "\n# ") + "\n" });
|
||||
};
|
||||
|
||||
this.get = function(key) { return obj[key]; };
|
||||
this.set = function(key, val, comment) {
|
||||
if(val == null) { this.unset(key); return; }
|
||||
|
||||
obj[key] = val;
|
||||
|
||||
var range = keyRange[key];
|
||||
if(!range) {
|
||||
keyRange[key] = range = { type: "literal", text: key + "=" + val };
|
||||
|
||||
var prevRange = ranges[ranges.length - 1];
|
||||
if(prevRange != null && !isNewLineRange(prevRange)) {
|
||||
ranges.push({ type: "literal", text: "\n" });
|
||||
}
|
||||
ranges.push(range);
|
||||
}
|
||||
|
||||
// comment === null deletes comment. if comment === undefined, it's left alone
|
||||
if(comment !== undefined) {
|
||||
range.comment = comment && "# " + comment.replace(/\n/g, "\n# ") + "\n";
|
||||
}
|
||||
|
||||
if(range.type === "literal") {
|
||||
range.text = key + "=" + val;
|
||||
if(range.comment != null) { range.text = range.comment + range.text; }
|
||||
} else if(range.type === "key-value") {
|
||||
range.children[2] = { type: "literal", text: val };
|
||||
} else {
|
||||
throw "Unknown node type: " + range.type;
|
||||
}
|
||||
};
|
||||
this.unset = function(key) {
|
||||
if(!(key in obj)) { return; }
|
||||
|
||||
var range = keyRange[key];
|
||||
var idx = ranges.indexOf(range);
|
||||
|
||||
ranges.splice(idx, (isNewLineRange(ranges[idx + 1]) ? 2 : 1));
|
||||
|
||||
delete keyRange[key];
|
||||
delete obj[key];
|
||||
};
|
||||
this.valueOf = this.toString = function() {
|
||||
var buffer = [], stack = [].concat(ranges);
|
||||
|
||||
var node;
|
||||
while((node = stack.shift()) != null) {
|
||||
switch(node.type) {
|
||||
case "literal":
|
||||
buffer.push(node.text);
|
||||
break;
|
||||
case "key":
|
||||
case "value":
|
||||
case "comment":
|
||||
case "whitespace":
|
||||
case "key-value-separator":
|
||||
case "escaped-value":
|
||||
case "line-break":
|
||||
buffer.push(text.substring(node.start, node.end));
|
||||
break;
|
||||
case "key-value":
|
||||
Array.prototype.unshift.apply(stack, node.children);
|
||||
if(node.comment) { stack.unshift({ type: "literal", text: node.comment }); }
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return buffer.join("");
|
||||
};
|
||||
this.save = function(newPath, callback) {
|
||||
if(typeof newPath === 'function') {
|
||||
callback = newPath;
|
||||
newPath = path;
|
||||
}
|
||||
newPath = newPath || path;
|
||||
|
||||
if(!newPath) { callback("Unknown path"); }
|
||||
|
||||
fs.writeFile(newPath, this.toString(), callback || function() {});
|
||||
};
|
||||
}
|
||||
function createEditor(path, callback) {
|
||||
if(!path) { return new Editor(); }
|
||||
|
||||
if(!callback) { return new Editor(fs.readFileSync(path).toString(), path); }
|
||||
|
||||
return fs.readFile(path, function(err, text) {
|
||||
if(err) { return callback(err, null); }
|
||||
|
||||
text = text.toString();
|
||||
return callback(null, new Editor(text, path));
|
||||
});
|
||||
}
|
||||
|
||||
function parse(text) {
|
||||
text = text.toString();
|
||||
var ranges = stringToRanges(text);
|
||||
return rangesToObject(ranges, text);
|
||||
}
|
||||
|
||||
function read(path, callback) {
|
||||
if(!callback) { return parse(fs.readFileSync(path)); }
|
||||
|
||||
return fs.readFile(path, function(err, data) {
|
||||
if(err) { return callback(err, null); }
|
||||
|
||||
return callback(null, parse(data));
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = { parse: parse, read: read, createEditor: createEditor };
|
||||
81
node_modules/properties-parser/package.json
generated
vendored
81
node_modules/properties-parser/package.json
generated
vendored
@@ -1,81 +0,0 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "properties-parser@^0.2.3",
|
||||
"scope": null,
|
||||
"escapedName": "properties-parser",
|
||||
"name": "properties-parser",
|
||||
"rawSpec": "^0.2.3",
|
||||
"spec": ">=0.2.3 <0.3.0",
|
||||
"type": "range"
|
||||
},
|
||||
"/Users/steveng/repo/cordova/cordova-android"
|
||||
]
|
||||
],
|
||||
"_from": "properties-parser@>=0.2.3 <0.3.0",
|
||||
"_id": "properties-parser@0.2.3",
|
||||
"_inCache": true,
|
||||
"_location": "/properties-parser",
|
||||
"_npmUser": {
|
||||
"name": "xavi",
|
||||
"email": "xavi.rmz@gmail.com"
|
||||
},
|
||||
"_npmVersion": "1.3.23",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "properties-parser@^0.2.3",
|
||||
"scope": null,
|
||||
"escapedName": "properties-parser",
|
||||
"name": "properties-parser",
|
||||
"rawSpec": "^0.2.3",
|
||||
"spec": ">=0.2.3 <0.3.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/"
|
||||
],
|
||||
"_resolved": "http://registry.npmjs.org/properties-parser/-/properties-parser-0.2.3.tgz",
|
||||
"_shasum": "f7591255f707abbff227c7b56b637dbb0373a10f",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "properties-parser@^0.2.3",
|
||||
"_where": "/Users/steveng/repo/cordova/cordova-android",
|
||||
"bugs": {
|
||||
"url": "https://github.com/xavi-/node-properties-parser/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "A parser for .properties files written in javascript",
|
||||
"devDependencies": {},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "f7591255f707abbff227c7b56b637dbb0373a10f",
|
||||
"tarball": "https://registry.npmjs.org/properties-parser/-/properties-parser-0.2.3.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.3.1"
|
||||
},
|
||||
"homepage": "https://github.com/xavi-/node-properties-parser",
|
||||
"keywords": [
|
||||
"parser",
|
||||
".properties",
|
||||
"properties",
|
||||
"java",
|
||||
"file parser",
|
||||
"actionscript"
|
||||
],
|
||||
"main": "./index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "xavi",
|
||||
"email": "xavi.rmz@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "properties-parser",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/xavi-/node-properties-parser.git"
|
||||
},
|
||||
"version": "0.2.3"
|
||||
}
|
||||
17
node_modules/properties-parser/play-ground.js
generated
vendored
17
node_modules/properties-parser/play-ground.js
generated
vendored
@@ -1,17 +0,0 @@
|
||||
var parser = require("./");
|
||||
var editor = parser.createEditor();
|
||||
|
||||
editor.set("ok", "hi");
|
||||
editor.set("hi", "ok");
|
||||
|
||||
console.log(editor.toString());
|
||||
|
||||
editor.unset("hi");
|
||||
|
||||
console.log("===================");
|
||||
console.log(editor.toString());
|
||||
|
||||
editor.unset("ok");
|
||||
|
||||
console.log("===================");
|
||||
console.log(editor.toString());
|
||||
BIN
node_modules/properties-parser/test/ReadProperties.class
generated
vendored
BIN
node_modules/properties-parser/test/ReadProperties.class
generated
vendored
Binary file not shown.
61
node_modules/properties-parser/test/ReadProperties.java
generated
vendored
61
node_modules/properties-parser/test/ReadProperties.java
generated
vendored
@@ -1,61 +0,0 @@
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class ReadProperties {
|
||||
public static void main(String[] args) throws IOException {
|
||||
if(args.length <= 0) { System.out.println("No file provided."); return; }
|
||||
|
||||
File f = new File(args[0]);
|
||||
|
||||
if(!f.exists()) { System.out.println("File not found: " + args[0]); return; }
|
||||
|
||||
Properties prop = new Properties();
|
||||
prop.load(new FileInputStream(f));
|
||||
|
||||
boolean isFirst = true; // I fucking hate java, why don't they have a native string join function?
|
||||
System.out.print("{");
|
||||
for (Map.Entry<Object, Object> item : prop.entrySet()) {
|
||||
String key = (String) item.getKey();
|
||||
String value = (String) item.getValue();
|
||||
|
||||
if(isFirst) { isFirst = false; }
|
||||
else { System.out.print(","); }
|
||||
|
||||
System.out.print("\"" + escape(key) + "\":\"" + escape(value) + "\"");
|
||||
}
|
||||
System.out.print("}");
|
||||
}
|
||||
|
||||
static String escape(String s) { // Taken from http://code.google.com/p/json-simple/
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for(int i = 0; i < s.length(); i++) {
|
||||
char ch = s.charAt(i);
|
||||
switch(ch) {
|
||||
case '"': sb.append("\\\""); break;
|
||||
case '\\': sb.append("\\\\"); break;
|
||||
case '\b': sb.append("\\b"); break;
|
||||
case '\f': sb.append("\\f"); break;
|
||||
case '\n': sb.append("\\n"); break;
|
||||
case '\r': sb.append("\\r"); break;
|
||||
case '\t': sb.append("\\t"); break;
|
||||
case '/': sb.append("\\/"); break;
|
||||
default:
|
||||
//Reference: http://www.unicode.org/versions/Unicode5.1.0/
|
||||
if (('\u0000' <= ch && ch <= '\u001F')
|
||||
|| ('\u007F' <= ch && ch <= '\u009F')
|
||||
|| ('\u2000' <= ch && ch <= '\u20FF')) {
|
||||
String ss = Integer.toHexString(ch);
|
||||
sb.append("\\u");
|
||||
for(int k = ss.length(); k < 4; k++) {
|
||||
sb.append('0');
|
||||
}
|
||||
sb.append(ss.toUpperCase());
|
||||
} else {
|
||||
sb.append(ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
16
node_modules/properties-parser/test/test-cases-copy.properties
generated
vendored
16
node_modules/properties-parser/test/test-cases-copy.properties
generated
vendored
@@ -1,16 +0,0 @@
|
||||
# You are reading the ".properties" entry.
|
||||
! The exclamation mark can also mark text as comments.
|
||||
lala=whatever
|
||||
website = whatever
|
||||
language = whatever
|
||||
# The backslash below tells the application to continue reading
|
||||
# the value onto the next line.
|
||||
message = whatever
|
||||
# Add spaces to the key
|
||||
key\ with\ spaces = whatever
|
||||
# Unicode
|
||||
tab : whatever
|
||||
long-unicode : whatever
|
||||
space\ separator key val \n three
|
||||
another-test :whatever
|
||||
null-prop
|
||||
18
node_modules/properties-parser/test/test-cases.properties
generated
vendored
18
node_modules/properties-parser/test/test-cases.properties
generated
vendored
@@ -1,18 +0,0 @@
|
||||
# You are reading the ".properties" entry.
|
||||
! The exclamation mark can also mark text as comments.
|
||||
lala=\u210A the foo foo \
|
||||
lalala;
|
||||
website = http://en.wikipedia.org/
|
||||
language = English
|
||||
# The backslash below tells the application to continue reading
|
||||
# the value onto the next line.
|
||||
message = Welcome to \
|
||||
Wikipedia!
|
||||
# Add spaces to the key
|
||||
key\ with\ spaces = This is the value that could be looked up with the key "key with spaces".
|
||||
# Unicode
|
||||
tab : \u0009
|
||||
long-unicode : \u00000009
|
||||
space\ separator key val \n three
|
||||
another-test ::: hihi
|
||||
null-prop
|
||||
123
node_modules/properties-parser/test/test.js
generated
vendored
123
node_modules/properties-parser/test/test.js
generated
vendored
@@ -1,123 +0,0 @@
|
||||
var fs = require("fs");
|
||||
var assert = require("assert");
|
||||
var prop = require("../index.js");
|
||||
|
||||
var syncData = prop.read("./test-cases.properties");
|
||||
prop.read("./test-cases.properties", function(err, data) {
|
||||
assert.deepEqual(data, syncData);
|
||||
assert.equal(data["lala"], 'ℊ the foo foo lalala;');
|
||||
assert.equal(data["website"], 'http://en.wikipedia.org/');
|
||||
assert.equal(data["language"], 'English');
|
||||
assert.equal(data["message"], 'Welcome to Wikipedia!');
|
||||
assert.equal(data["key with spaces"], 'This is the value that could be looked up with the key "key with spaces".');
|
||||
assert.equal(data["tab"], '\t');
|
||||
assert.equal(data["long-unicode"], '\u00000009');
|
||||
assert.equal(data["space separator"], 'key val \n three');
|
||||
assert.equal(data["another-test"], ':: hihi');
|
||||
assert.equal(data["null-prop"], '');
|
||||
assert.ok(data["valueOf"] == null, "Properties are set that shouldn't be (valueOf)");
|
||||
assert.ok(data["toString"] == null, "Properties are set that shouldn't be (toString)");
|
||||
|
||||
console.log("Tests all passed...");
|
||||
|
||||
if(process.argv[2] === "repl") {
|
||||
var repl = require("repl").start("test-repl> ");
|
||||
repl.context.data = data;
|
||||
repl.context.prop = prop;
|
||||
}
|
||||
});
|
||||
|
||||
var editor1 = prop.createEditor();
|
||||
editor1.set("basic", "prop1");
|
||||
assert.equal(editor1.toString(), "basic=prop1");
|
||||
editor1.set("basic", "prop2", "A comment\nmulti-line1");
|
||||
assert.equal(editor1.toString(), "# A comment\n# multi-line1\nbasic=prop2");
|
||||
editor1.set("basic", "prop3", "A comment\nmulti-line2");
|
||||
assert.equal(editor1.toString(), "# A comment\n# multi-line2\nbasic=prop3");
|
||||
editor1.set("basic", "prop4");
|
||||
assert.equal(editor1.toString(), "# A comment\n# multi-line2\nbasic=prop4");
|
||||
editor1.set("basic", "prop5", null); // Delete's comment
|
||||
assert.equal(editor1.toString(), "basic=prop5");
|
||||
editor1.set("basic1", "prop6");
|
||||
assert.equal(editor1.toString(), "basic=prop5\nbasic1=prop6");
|
||||
editor1.addHeadComment("Head Comment");
|
||||
assert.equal(editor1.toString(), "# Head Comment\nbasic=prop5\nbasic1=prop6");
|
||||
assert.ok(editor1.get("valueOf") == null);
|
||||
assert.ok(editor1.get("toString") == null);
|
||||
|
||||
var editor2 = prop.createEditor("./test-cases.properties");
|
||||
assert.equal(fs.readFileSync("./test-cases.properties").toString(), editor2.toString());
|
||||
editor2.set("lala", "prop1");
|
||||
assert.ok(editor2.toString().indexOf("lala=prop1") > -1);
|
||||
editor2.set("lala", "prop2", "A comment\nmulti-line1");
|
||||
assert.ok(editor2.toString().indexOf("# A comment\n# multi-line1\nlala=prop2") > -1);
|
||||
editor2.set("lala", "prop3", "A comment\nmulti-line2");
|
||||
assert.ok(editor2.toString().indexOf("# A comment\n# multi-line2\nlala=prop3") > -1);
|
||||
editor2.set("lala", "prop4");
|
||||
assert.ok(editor2.toString().indexOf("# A comment\n# multi-line2\nlala=prop4") > -1);
|
||||
editor2.set("lala", "prop5", null); // Delete's comment
|
||||
assert.ok(editor2.toString().indexOf("! The exclamation mark can also mark text as comments.\nlala=prop5") > -1);
|
||||
editor2.set("basic-non-existing", "prop6");
|
||||
assert.ok(editor2.toString().indexOf("\nbasic-non-existing=prop6") > -1);
|
||||
editor2.addHeadComment("Head Comment");
|
||||
assert.equal(editor2.toString().indexOf("# Head Comment\n"), 0);
|
||||
assert.ok(editor2.get("valueOf") == null);
|
||||
assert.ok(editor2.get("toString") == null);
|
||||
|
||||
var editor3 = prop.createEditor();
|
||||
editor3.set("stay", "ok");
|
||||
|
||||
editor3.unset("key");
|
||||
editor3.unset("key", null);
|
||||
editor3.unset("key", undefined);
|
||||
assert.equal(editor3.toString().trim(), "stay=ok");
|
||||
|
||||
editor3.set("key", "val");
|
||||
editor3.unset("key");
|
||||
assert.equal(editor3.toString().trim(), "stay=ok");
|
||||
|
||||
editor3.set("key", "val");
|
||||
editor3.set("key", null);
|
||||
assert.equal(editor3.toString().trim(), "stay=ok");
|
||||
|
||||
editor3.set("key", "val");
|
||||
editor3.set("key", undefined);
|
||||
assert.equal(editor3.toString().trim(), "stay=ok");
|
||||
|
||||
prop.createEditor("./test-cases.properties", function(err, editor) {
|
||||
var properties = {};
|
||||
properties.lala = 'whatever';
|
||||
properties.website = 'whatever';
|
||||
properties.language = 'whatever';
|
||||
properties.message = 'whatever';
|
||||
properties['key with spaces'] = 'whatever';
|
||||
properties.tab = 'whatever';
|
||||
properties['long-unicode'] = 'whatever';
|
||||
properties['another-test'] = 'whatever';
|
||||
for (var item in properties) {
|
||||
editor.set(item, properties[item]);
|
||||
}
|
||||
|
||||
assert.equal(
|
||||
editor.toString(),
|
||||
'# You are reading the ".properties" entry.\n' +
|
||||
'! The exclamation mark can also mark text as comments.\n' +
|
||||
'lala=whatever\n' +
|
||||
'website = whatever\n' +
|
||||
'language = whatever\n' +
|
||||
'# The backslash below tells the application to continue reading\n' +
|
||||
'# the value onto the next line.\n' +
|
||||
'message = whatever\n' +
|
||||
'# Add spaces to the key\n' +
|
||||
'key\\ with\\ spaces = whatever\n' +
|
||||
'# Unicode\n' +
|
||||
'tab : whatever\n' +
|
||||
'long-unicode : whatever\n' +
|
||||
'space\\ separator key val \\n three\n' +
|
||||
'another-test :whatever\n' +
|
||||
' null-prop'
|
||||
);
|
||||
});
|
||||
|
||||
// java ReadProperties test-cases.properties
|
||||
// javac ReadProperties.java
|
||||
Reference in New Issue
Block a user