plist 0.4.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.jshintrc ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "laxbreak": true,
3
+ "laxcomma": true
4
+ }
package/.travis.yml ADDED
@@ -0,0 +1,32 @@
1
+ language: node_js
2
+ node_js:
3
+ - '0.10'
4
+ - '0.11'
5
+ env:
6
+ global:
7
+ - secure: xlLmWO7akYQjmDgrv6/b/ZMGILF8FReD+k6A/u8pYRD2JW29hhwvRwIQGcKp9+zmJdn4i5M4D1/qJkCeI3pdhAYBDHvzHOHSEwLJz1ESB2Crv6fa69CtpIufQkWvIxmZoU49tCaLpMBaIroGihJ4DAXdIVOIz6Ur9vXLDhGsE4c=
8
+ - secure: aQ46RdxL10xR5ZJJTMUKdH5k4tdrzgZ87nlwHC+pTr6bfRw3UKYC+6Rm7yQpg9wq0Io9O9dYCP007gQGSWstbjr1+jXNu/ubtNG+q5cpWBQZZZ013VHh9QJTf1MnetsZxbv8Yhrjg590s6vruT0oqesOnB2CizO/BsKxnY37Nos=
9
+ matrix:
10
+ include:
11
+ - node_js: '0.10'
12
+ env: BROWSER_NAME=chrome BROWSER_VERSION=latest
13
+ - node_js: '0.10'
14
+ env: BROWSER_NAME=chrome BROWSER_VERSION=29
15
+ - node_js: '0.10'
16
+ env: BROWSER_NAME=firefox BROWSER_VERSION=latest
17
+ - node_js: '0.10'
18
+ env: BROWSER_NAME=opera BROWSER_VERSION=latest
19
+ - node_js: '0.10'
20
+ env: BROWSER_NAME=safari BROWSER_VERSION=latest
21
+ - node_js: '0.10'
22
+ env: BROWSER_NAME=safari BROWSER_VERSION=7
23
+ - node_js: '0.10'
24
+ env: BROWSER_NAME=safari BROWSER_VERSION=6
25
+ - node_js: '0.10'
26
+ env: BROWSER_NAME=safari BROWSER_VERSION=5
27
+ - node_js: '0.10'
28
+ env: BROWSER_NAME=ie BROWSER_VERSION=11
29
+ - node_js: '0.10'
30
+ env: BROWSER_NAME=ie BROWSER_VERSION=10
31
+ - node_js: '0.10'
32
+ env: BROWSER_NAME=ie BROWSER_VERSION=9
package/History.md ADDED
@@ -0,0 +1,112 @@
1
+
2
+ 1.1.0 / 2014-08-27
3
+ ==================
4
+
5
+ * package: update "browserify" to v5.10.1
6
+ * package: update "zuul" to v1.10.2
7
+ * README: add "Sauce Test Status" build badge
8
+ * travis: use new "plistjs" sauce credentials
9
+ * travis: set up zuul saucelabs automated testing
10
+
11
+ 1.0.1 / 2014-06-25
12
+ ==================
13
+
14
+ * add .zuul.yml file for browser testing
15
+ * remove Testling stuff
16
+ * build: fix global variable `val` leak
17
+ * package: use --check-leaks when running mocha tests
18
+ * README: update examples to use preferred API
19
+ * package: add "browser" keyword
20
+
21
+ 1.0.0 / 2014-05-20
22
+ ==================
23
+
24
+ * package: remove "android-browser"
25
+ * test: add <dict> build() test
26
+ * test: re-add the empty string build() test
27
+ * test: remove "fixtures" and legacy "tests" dir
28
+ * test: add some more build() tests
29
+ * test: add a parse() CDATA test
30
+ * test: starting on build() tests
31
+ * test: more parse() tests
32
+ * package: attempt to fix "android-browser" testling
33
+ * parse: better <data> with newline handling
34
+ * README: add Testling badge
35
+ * test: add <data> node tests
36
+ * test: add a <date> parse() test
37
+ * travis: don't test node v0.6 or v0.8
38
+ * test: some more parse() tests
39
+ * test: add simple <string> parsing test
40
+ * build: add support for an optional "opts" object
41
+ * package: test mobile devices
42
+ * test: use multiline to inline the XML
43
+ * package: beautify
44
+ * package: fix "mocha" harness
45
+ * package: more testling browsers
46
+ * build: add the "version=1.0" attribute
47
+ * beginnings of "mocha" tests
48
+ * build: more JSDocs
49
+ * tests: add test that ensures that empty string conversion works
50
+ * build: update "xmlbuilder" to v2.2.1
51
+ * parse: ignore comment and cdata nodes
52
+ * tests: make the "Newlines" test actually contain a newline
53
+ * parse: lint
54
+ * test travis
55
+ * README: add Travis CI badge
56
+ * add .travis.yml file
57
+ * build: updated DTD to reflect name change
58
+ * parse: return falsey values in an Array plist
59
+ * build: fix encoding a typed array in the browser
60
+ * build: add support for Typed Arrays and ArrayBuffers
61
+ * build: more lint
62
+ * build: slight cleanup and optimizations
63
+ * build: use .txt() for the "date" value
64
+ * parse: always return a Buffer for <data> nodes
65
+ * build: don't interpret Strings as base64
66
+ * dist: commit prebuilt plist*.js files
67
+ * parse: fix typo in deprecate message
68
+ * parse: fix parse() return value
69
+ * parse: add jsdoc comments for the deprecated APIs
70
+ * parse: add `parse()` function
71
+ * node, parse: use `util-deprecate` module
72
+ * re-implemented parseFile to be asynchronous
73
+ * node: fix jsdoc comment
74
+ * Makefile: fix "node" require stubbing
75
+ * examples: add "browser" example
76
+ * package: tweak "main"
77
+ * package: remove "engines" field
78
+ * Makefile: fix --exclude command for browserify
79
+ * package: update "description"
80
+ * lib: more styling
81
+ * Makefile: add -build.js and -parse.js dist files
82
+ * lib: separate out the parse and build logic into their own files
83
+ * Makefile: add makefile with browserify build rules
84
+ * package: add "browserify" as a dev dependency
85
+ * plist: tabs to spaces (again)
86
+ * add a .jshintrc file
87
+ * LICENSE: update
88
+ * node-webkit support
89
+ * Ignore tests/ in .npmignore file
90
+ * Remove duplicate devDependencies key
91
+ * Remove trailing whitespace
92
+ * adding recent contributors. Bumping npm package number (patch release)
93
+ * Fixed node.js string handling
94
+ * bumping version number
95
+ * Fixed global variable plist leak
96
+ * patch release 0.4.1
97
+ * removed temporary debug output file
98
+ * flipping the cases for writing data and string elements in build(). removed the 125 length check. Added validation of base64 encoding for data fields when parsing. added unit tests.
99
+ * fixed syntax errors in README examples (issue #20)
100
+ * added Sync versions of calls. added deprecation warnings for old method calls. updated documentation. If the resulting object from parseStringSync is an array with 1 element, return just the element. If a plist string or file doesnt have a <plist> tag as the document root element, fail noisily (issue #15)
101
+ * incrementing package version
102
+ * added cross platform base64 encode/decode for data elements (issue #17.) Comments and hygiene.
103
+ * refactored the code to use a DOM parser instead of SAX. closes issues #5 and #16
104
+ * rolling up package version
105
+ * updated base64 detection regexp. updated README. hygiene.
106
+ * refactored the build function. Fixes issue #14
107
+ * refactored tests. Modified tests from issue #9. thanks @sylvinus
108
+ * upgrade xmlbuilder package version. this is why .end() was needed in last commit; breaking change to xmlbuilder lib. :/
109
+ * bug fix in build function, forgot to call .end() Refactored tests to use nodeunit
110
+ * Implemented support for real, identity tests
111
+ * Refactored base64 detection - still sloppy, fixed date building. Passing tests OK.
112
+ * Implemented basic plist builder that turns an existing JS object into plist XML. date, real and data types still need to be implemented.
package/LICENSE CHANGED
@@ -1,4 +1,6 @@
1
- Copyright (c) 2010-2011- Nathan Rajlich
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2010-2014 Nathan Rajlich <nathan@tootallnate.net>
2
4
 
3
5
  Permission is hereby granted, free of charge, to any person
4
6
  obtaining a copy of this software and associated documentation
package/Makefile ADDED
@@ -0,0 +1,76 @@
1
+
2
+ # get Makefile directory name: http://stackoverflow.com/a/5982798/376773
3
+ THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
4
+ THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd)
5
+
6
+ # BIN directory
7
+ BIN := $(THIS_DIR)/node_modules/.bin
8
+
9
+ # applications
10
+ NODE ?= node
11
+ NPM ?= $(NODE) $(shell which npm)
12
+ BROWSERIFY ?= $(NODE) $(BIN)/browserify
13
+ MOCHA ?= $(NODE) $(BIN)/mocha
14
+ ZUUL ?= $(NODE) $(BIN)/zuul
15
+
16
+ REPORTER ?= spec
17
+
18
+ all: dist/plist.js dist/plist-build.js dist/plist-parse.js
19
+
20
+ install: node_modules
21
+
22
+ clean:
23
+ @rm -rf node_modules dist
24
+
25
+ dist:
26
+ @mkdir -p $@
27
+
28
+ dist/plist-build.js: node_modules lib/build.js dist
29
+ @$(BROWSERIFY) \
30
+ --standalone plist \
31
+ lib/build.js > $@
32
+
33
+ dist/plist-parse.js: node_modules lib/parse.js dist
34
+ @$(BROWSERIFY) \
35
+ --standalone plist \
36
+ lib/parse.js > $@
37
+
38
+ dist/plist.js: node_modules lib/*.js dist
39
+ @$(BROWSERIFY) \
40
+ --standalone plist \
41
+ --ignore lib/node.js \
42
+ lib/plist.js > $@
43
+
44
+ node_modules: package.json
45
+ @NODE_ENV= $(NPM) install
46
+ @touch node_modules
47
+
48
+ test:
49
+ @if [ "x$(BROWSER_NAME)" = "x" ]; then \
50
+ $(MAKE) test-node; \
51
+ else \
52
+ $(MAKE) test-zuul; \
53
+ fi
54
+
55
+ test-node:
56
+ @$(MOCHA) \
57
+ --reporter $(REPORTER) \
58
+ test/*.js
59
+
60
+ test-zuul:
61
+ @if [ "x$(BROWSER_PLATFORM)" = "x" ]; then \
62
+ $(ZUUL) \
63
+ --ui mocha-bdd \
64
+ --browser-name $(BROWSER_NAME) \
65
+ --browser-version $(BROWSER_VERSION) \
66
+ test/*.js; \
67
+ else \
68
+ $(ZUUL) \
69
+ --ui mocha-bdd \
70
+ --browser-name $(BROWSER_NAME) \
71
+ --browser-version $(BROWSER_VERSION) \
72
+ --browser-platform "$(BROWSER_PLATFORM)" \
73
+ test/*.js; \
74
+ fi
75
+
76
+ .PHONY: all install clean test test-node test-zuul
package/README.md CHANGED
@@ -1,62 +1,113 @@
1
- # node-plist
1
+ plist.js
2
+ ========
3
+ ### Mac OS X Plist parser/builder for Node.js and browsers
2
4
 
3
- Provides facilities for reading and writing Mac OS X Plist (property list) files. These are often used in programming OS X and iOS applications, as well as the iTunes
4
- configuration XML file.
5
+ [![Sauce Test Status](https://saucelabs.com/browser-matrix/plistjs.svg)](https://saucelabs.com/u/plistjs)
6
+
7
+ [![Build Status](https://travis-ci.org/TooTallNate/plist.js.svg?branch=master)](https://travis-ci.org/TooTallNate/plist.js)
8
+
9
+ Provides facilities for reading and writing Mac OS X Plist (property list)
10
+ files. These are often used in programming OS X and iOS applications, as
11
+ well as the iTunes configuration XML file.
5
12
 
6
13
  Plist files represent stored programming "object"s. They are very similar
7
- to JSON. A valid Plist file is representable as a native JavaScript Object and vice-versa.
14
+ to JSON. A valid Plist file is representable as a native JavaScript Object
15
+ and vice-versa.
8
16
 
9
- ## Tests
10
- `npm test`
11
17
 
12
18
  ## Usage
13
- Parsing a plist from filename
14
- ``` javascript
15
- var plist = require('plist');
16
19
 
17
- var obj = plist.parseFileSync('myPlist.plist');
18
- console.log(JSON.stringify(obj));
20
+ ### Node.js
21
+
22
+ Install using `npm`:
23
+
24
+ ``` bash
25
+ $ npm install --save plist
19
26
  ```
20
27
 
21
- Parsing a plist from string payload
22
- ``` javascript
28
+ Then `require()` the _plist_ module in your file:
29
+
30
+ ``` js
23
31
  var plist = require('plist');
24
32
 
25
- var obj = plist.parseStringSync('<plist><string>Hello World!</string></plist>');
26
- console.log(obj); // Hello World!
33
+ // now use the `parse()` and `build()` functions
34
+ var val = plist.parse('<plist><string>Hello World!</string></plist>');
35
+ console.log(val); // "Hello World!"
27
36
  ```
28
37
 
29
- Given an existing JavaScript Object, you can turn it into an XML document that complies with the plist DTD
30
38
 
31
- ``` javascript
32
- var plist = require('plist');
39
+ ### Browser
33
40
 
34
- console.log(plist.build({'foo' : 'bar'}).toString());
41
+ Include the `dist/plist.js` in a `<script>` tag in your HTML file:
42
+
43
+ ``` html
44
+ <script src="plist.js"></script>
45
+ <script>
46
+ // now use the `parse()` and `build()` functions
47
+ var val = plist.parse('<plist><string>Hello World!</string></plist>');
48
+ console.log(val); // "Hello World!"
49
+ </script>
35
50
  ```
36
51
 
37
52
 
53
+ ## API
54
+
55
+ ### Parsing
38
56
 
39
- ### Deprecated methods
40
- These functions work, but may be removed in a future release. version 0.4.x added Sync versions of these functions.
57
+ Parsing a plist from filename:
41
58
 
42
- Parsing a plist from filename
43
59
  ``` javascript
60
+ var fs = require('fs');
44
61
  var plist = require('plist');
45
62
 
46
- plist.parseFile('myPlist.plist', function(err, obj) {
47
- if (err) throw err;
48
-
49
- console.log(JSON.stringify(obj));
50
- });
63
+ var obj = plist.parse(fs.readFileSync('myPlist.plist', 'utf8'));
64
+ console.log(JSON.stringify(obj));
51
65
  ```
52
66
 
53
- Parsing a plist from string payload
67
+ Parsing a plist from string payload:
68
+
54
69
  ``` javascript
55
70
  var plist = require('plist');
56
71
 
57
- plist.parseString('<plist><string>Hello World!</string></plist>', function(err, obj) {
58
- if (err) throw err;
72
+ var obj = plist.parse('<plist><string>Hello World!</string></plist>');
73
+ console.log(obj); // Hello World!
74
+ ```
75
+
76
+ ### Building
77
+
78
+ Given an existing JavaScript Object, you can turn it into an XML document
79
+ that complies with the plist DTD:
80
+
81
+ ``` javascript
82
+ var plist = require('plist');
59
83
 
60
- console.log(obj[0]); // Hello World!
61
- });
84
+ console.log(plist.build({ foo: 'bar' }));
62
85
  ```
86
+
87
+
88
+ ## License
89
+
90
+ (The MIT License)
91
+
92
+ Copyright (c) 2010-2014 Nathan Rajlich <nathan@tootallnate.net>
93
+
94
+ Permission is hereby granted, free of charge, to any person
95
+ obtaining a copy of this software and associated documentation
96
+ files (the "Software"), to deal in the Software without
97
+ restriction, including without limitation the rights to use,
98
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
99
+ copies of the Software, and to permit persons to whom the
100
+ Software is furnished to do so, subject to the following
101
+ conditions:
102
+
103
+ The above copyright notice and this permission notice shall be
104
+ included in all copies or substantial portions of the Software.
105
+
106
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
107
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
108
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
109
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
110
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
111
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
112
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
113
+ OTHER DEALINGS IN THE SOFTWARE.