java-properties
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -22,8 +22,13 @@ /* | ||
/* adds a file to the properties */ | ||
var addFile = function(file) { | ||
var data = fs.readFileSync(file, 'utf-8'); | ||
var items = data.split(/\r?\n/); | ||
items.forEach(makeKeys); | ||
}; | ||
for (var i=0; i < arguments.length; i++) { | ||
var data = fs.readFileSync(arguments[i], 'utf-8'); | ||
var items = data.split(/\r?\n/); | ||
items.forEach(makeKeys); | ||
addFile(arguments[i]); | ||
} | ||
var get = function(key) { | ||
@@ -54,3 +59,8 @@ if (objs.hasOwnProperty(key)) { | ||
}; | ||
/* reset the properties */ | ||
var reset = function() { | ||
objs = {}; | ||
}; | ||
return { | ||
@@ -60,4 +70,6 @@ get: get, | ||
interpolate: interpolate, | ||
getKeys : getKeys | ||
getKeys : getKeys, | ||
reset : reset, | ||
addFile : addFile | ||
}; | ||
}; |
{ | ||
"name": "java-properties", | ||
"description": "Reads and interpolates Java .properties files", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"homepage": "http://github.com/mattdsteele/java-properties", | ||
@@ -6,0 +6,0 @@ "author": { |
# java-properties | ||
Read Java .properties files | ||
Reads and interpolates Java .properties files | ||
@@ -11,4 +11,13 @@ ## Getting Started | ||
var properties = require('java-properties'); | ||
var values = properties.of('values.properties'); | ||
//Read a value from the properties file | ||
values.get('a.key'); //returns value of a.key | ||
//Add an additional file's properties | ||
values.add('anotherfile.properties'); | ||
//Clear out all values | ||
values.reset(); | ||
``` | ||
@@ -18,6 +27,3 @@ ## Contributing | ||
## Release History | ||
0.1.0 Initial commit | ||
## License | ||
Licensed under the MIT license. |
@@ -126,3 +126,30 @@ 'use strict'; | ||
test.done(); | ||
}, | ||
'reset' : function(test) { | ||
test.expect(1); | ||
props.reset(); | ||
test.equals(0, props.getKeys()); | ||
test.done(); | ||
}, | ||
'addFile' : function(test) { | ||
test.expect(6); | ||
// Reset and add manually the 2 first files | ||
props.reset(); | ||
props.addFile('test/fixtures/example.properties'); | ||
props.addFile('test/fixtures/example2.properties'); | ||
test.equal('14.47', props.get('extra.property')); | ||
test.equal('444', props.get('another.property')); | ||
test.equal('7', props.get('referenced.property')); | ||
// 'value.1' must not be defined cause it is unix.properties file | ||
test.equal(undefined, props.get('value.1')); | ||
// add the unix.properties file | ||
props.addFile('test/fixtures/unix.properties'); | ||
// check that value.1 is now defined | ||
test.equal('value 1', props.get('value.1')); | ||
// and that old values are still there | ||
test.equal('444', props.get('another.property')); | ||
test.done(); | ||
} | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11535
254
28