plist 1.0.1 → 2.0.1

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/test/parse.js DELETED
@@ -1,448 +0,0 @@
1
-
2
- var assert = require('assert');
3
- var parse = require('../').parse;
4
- var multiline = require('multiline');
5
-
6
- describe('plist', function () {
7
-
8
- describe('parse()', function () {
9
-
10
- it('should parse a minimal <string> node into a String', function () {
11
- var parsed = parse('<plist><string>Hello World!</string></plist>');
12
- assert.strictEqual(parsed, 'Hello World!');
13
- });
14
-
15
- it('should parse a full XML <string> node into a String', function () {
16
- var xml = multiline(function () {/*
17
- <?xml version="1.0" encoding="UTF-8"?>
18
- <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
19
- <plist version="1.0">
20
- <string>gray</string>
21
- </plist>
22
- */});
23
- var parsed = parse(xml);
24
- assert.strictEqual(parsed, 'gray');
25
- });
26
-
27
- it('should parse an <integer> node into a Number', function () {
28
- var xml = multiline(function () {/*
29
- <?xml version="1.0" encoding="UTF-8"?>
30
- <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
31
- <plist version="1.0">
32
- <integer>14</integer>
33
- </plist>
34
- */});
35
- var parsed = parse(xml);
36
- assert.strictEqual(parsed, 14);
37
- });
38
-
39
- it('should parse a <real> node into a Number', function () {
40
- var xml = multiline(function () {/*
41
- <?xml version="1.0" encoding="UTF-8"?>
42
- <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
43
- <plist version="1.0">
44
- <real>3.14</real>
45
- </plist>
46
- */});
47
- var parsed = parse(xml);
48
- assert.strictEqual(parsed, 3.14);
49
- });
50
-
51
- it('should parse a <date> node into a Date', function () {
52
- var xml = multiline(function () {/*
53
- <?xml version="1.0" encoding="UTF-8"?>
54
- <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
55
- <plist version="1.0">
56
- <date>2010-02-08T21:41:23Z</date>
57
- </plist>
58
- */});
59
- var parsed = parse(xml);
60
- assert(parsed instanceof Date);
61
- assert.strictEqual(parsed.getTime(), 1265665283000);
62
- });
63
-
64
- it('should parse a <data> node into a Buffer', function () {
65
- var xml = multiline(function () {/*
66
- <?xml version="1.0" encoding="UTF-8"?>
67
- <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
68
- <plist version="1.0">
69
- <data>4pyTIMOgIGxhIG1vZGU=</data>
70
- </plist>
71
- */});
72
- var parsed = parse(xml);
73
- assert(Buffer.isBuffer(parsed));
74
- assert.strictEqual(parsed.toString('utf8'), '✓ à la mode');
75
- });
76
-
77
- it('should parse a <data> node with newlines into a Buffer', function () {
78
- var xml = multiline(function () {/*
79
- <?xml version="1.0" encoding="UTF-8"?>
80
- <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
81
- <plist version="1.0">
82
- <data>4pyTIMOgIGxhIG
83
-
84
-
85
- 1v
86
-
87
- ZG
88
- U=</data>
89
- </plist>
90
- */});
91
- var parsed = parse(xml);
92
- assert(Buffer.isBuffer(parsed));
93
- assert.strictEqual(parsed.toString('utf8'), '✓ à la mode');
94
- });
95
-
96
- it('should parse a <true> node into a Boolean `true` value', function () {
97
- var xml = multiline(function () {/*
98
- <?xml version="1.0" encoding="UTF-8"?>
99
- <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
100
- <plist version="1.0">
101
- <true/>
102
- </plist>
103
- */});
104
- var parsed = parse(xml);
105
- assert.strictEqual(parsed, true);
106
- });
107
-
108
- it('should parse a <false> node into a Boolean `false` value', function () {
109
- var xml = multiline(function () {/*
110
- <?xml version="1.0" encoding="UTF-8"?>
111
- <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
112
- <plist version="1.0">
113
- <false/>
114
- </plist>
115
- */});
116
- var parsed = parse(xml);
117
- assert.strictEqual(parsed, false);
118
- });
119
-
120
- it('should parse an <array> node into an Array', function () {
121
- var xml = multiline(function () {/*
122
- <?xml version="1.0" encoding="UTF-8"?>
123
- <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
124
- <plist version="1.0">
125
- <array>
126
- <dict>
127
- <key>duration</key>
128
- <real>5555.0495000000001</real>
129
- <key>start</key>
130
- <real>0.0</real>
131
- </dict>
132
- </array>
133
- </plist>
134
- */});
135
- var parsed = parse(xml);
136
- assert.deepEqual(parsed, [
137
- {
138
- duration: 5555.0495,
139
- start: 0
140
- }
141
- ]);
142
- });
143
-
144
- it('should parse a plist file with XML comments', function () {
145
- var xml = multiline(function () {/*
146
- <?xml version="1.0" encoding="UTF-8"?>
147
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
148
- <plist version="1.0">
149
- <dict>
150
- <key>CFBundleName</key>
151
- <string>Emacs</string>
152
-
153
- <key>CFBundlePackageType</key>
154
- <string>APPL</string>
155
-
156
- <!-- This should be the emacs version number. -->
157
-
158
- <key>CFBundleShortVersionString</key>
159
- <string>24.3</string>
160
-
161
- <key>CFBundleSignature</key>
162
- <string>EMAx</string>
163
-
164
- <!-- This SHOULD be a build number. -->
165
-
166
- <key>CFBundleVersion</key>
167
- <string>9.0</string>
168
- </dict>
169
- </plist>
170
- */});
171
- var parsed = parse(xml);
172
- assert.deepEqual(parsed, {
173
- CFBundleName: 'Emacs',
174
- CFBundlePackageType: 'APPL',
175
- CFBundleShortVersionString: '24.3',
176
- CFBundleSignature: 'EMAx',
177
- CFBundleVersion: '9.0'
178
- });
179
- });
180
-
181
- it('should parse a plist file with CDATA content', function () {
182
- var xml = multiline(function () {/*
183
- <?xml version="1.0" encoding="UTF-8"?>
184
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
185
- <plist version="1.0">
186
- <dict>
187
- <key>OptionsLabel</key>
188
- <string>Product</string>
189
- <key>PopupMenu</key>
190
- <array>
191
- <dict>
192
- <key>Key</key>
193
- <string>iPhone</string>
194
- <key>Title</key>
195
- <string>iPhone</string>
196
- </dict>
197
- <dict>
198
- <key>Key</key>
199
- <string>iPad</string>
200
- <key>Title</key>
201
- <string>iPad</string>
202
- </dict>
203
- <dict>
204
- <key>Key</key>
205
- <string>
206
- <![CDATA[
207
- #import &lt;Cocoa/Cocoa.h&gt;
208
-
209
- #import &lt;MacRuby/MacRuby.h&gt;
210
-
211
- int main(int argc, char *argv[])
212
- {
213
- return macruby_main("rb_main.rb", argc, argv);
214
- }
215
- ]]>
216
- </string>
217
- </dict>
218
- </array>
219
- <key>TemplateSelection</key>
220
- <dict>
221
- <key>iPhone</key>
222
- <string>Tab Bar iPhone Application</string>
223
- <key>iPad</key>
224
- <string>Tab Bar iPad Application</string>
225
- </dict>
226
- </dict>
227
- </plist>
228
- */});
229
- var parsed = parse(xml);
230
- assert.deepEqual(parsed, { OptionsLabel: 'Product',
231
- PopupMenu:
232
- [ { Key: 'iPhone', Title: 'iPhone' },
233
- { Key: 'iPad', Title: 'iPad' },
234
- { Key: '\n \n #import &lt;Cocoa/Cocoa.h&gt;\n\n#import &lt;MacRuby/MacRuby.h&gt;\n\nint main(int argc, char *argv[])\n{\n return macruby_main("rb_main.rb", argc, argv);\n}\n\n' } ],
235
- TemplateSelection:
236
- { iPhone: 'Tab Bar iPhone Application',
237
- iPad: 'Tab Bar iPad Application' }
238
- });
239
- });
240
-
241
- it('should parse an example "Cordova.plist" file', function () {
242
- var xml = multiline(function () {/*
243
- <?xml version="1.0" encoding="UTF-8"?>
244
- <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
245
- <!--
246
- #
247
- # Licensed to the Apache Software Foundation (ASF) under one
248
- # or more contributor license agreements. See the NOTICE file
249
- # distributed with this work for additional information
250
- # regarding copyright ownership. The ASF licenses this file
251
- # to you under the Apache License, Version 2.0 (the
252
- # "License"); you may not use this file except in compliance
253
- # with the License. You may obtain a copy of the License at
254
- #
255
- # http://www.apache.org/licenses/LICENSE-2.0
256
- #
257
- # Unless required by applicable law or agreed to in writing,
258
- # software distributed under the License is distributed on an
259
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
260
- # KIND, either express or implied. See the License for the
261
- # specific language governing permissions and limitations
262
- # under the License.
263
- #
264
- -->
265
- <plist version="1.0">
266
- <dict>
267
- <key>UIWebViewBounce</key>
268
- <true/>
269
- <key>TopActivityIndicator</key>
270
- <string>gray</string>
271
- <key>EnableLocation</key>
272
- <false/>
273
- <key>EnableViewportScale</key>
274
- <false/>
275
- <key>AutoHideSplashScreen</key>
276
- <true/>
277
- <key>ShowSplashScreenSpinner</key>
278
- <true/>
279
- <key>MediaPlaybackRequiresUserAction</key>
280
- <false/>
281
- <key>AllowInlineMediaPlayback</key>
282
- <false/>
283
- <key>OpenAllWhitelistURLsInWebView</key>
284
- <false/>
285
- <key>BackupWebStorage</key>
286
- <true/>
287
- <key>ExternalHosts</key>
288
- <array>
289
- <string>*</string>
290
- </array>
291
- <key>Plugins</key>
292
- <dict>
293
- <key>Device</key>
294
- <string>CDVDevice</string>
295
- <key>Logger</key>
296
- <string>CDVLogger</string>
297
- <key>Compass</key>
298
- <string>CDVLocation</string>
299
- <key>Accelerometer</key>
300
- <string>CDVAccelerometer</string>
301
- <key>Camera</key>
302
- <string>CDVCamera</string>
303
- <key>NetworkStatus</key>
304
- <string>CDVConnection</string>
305
- <key>Contacts</key>
306
- <string>CDVContacts</string>
307
- <key>Debug Console</key>
308
- <string>CDVDebugConsole</string>
309
- <key>Echo</key>
310
- <string>CDVEcho</string>
311
- <key>File</key>
312
- <string>CDVFile</string>
313
- <key>FileTransfer</key>
314
- <string>CDVFileTransfer</string>
315
- <key>Geolocation</key>
316
- <string>CDVLocation</string>
317
- <key>Notification</key>
318
- <string>CDVNotification</string>
319
- <key>Media</key>
320
- <string>CDVSound</string>
321
- <key>Capture</key>
322
- <string>CDVCapture</string>
323
- <key>SplashScreen</key>
324
- <string>CDVSplashScreen</string>
325
- <key>Battery</key>
326
- <string>CDVBattery</string>
327
- </dict>
328
- </dict>
329
- </plist>
330
- */});
331
- var parsed = parse(xml);
332
- assert.deepEqual(parsed, {
333
- UIWebViewBounce: true,
334
- TopActivityIndicator: 'gray',
335
- EnableLocation: false,
336
- EnableViewportScale: false,
337
- AutoHideSplashScreen: true,
338
- ShowSplashScreenSpinner: true,
339
- MediaPlaybackRequiresUserAction: false,
340
- AllowInlineMediaPlayback: false,
341
- OpenAllWhitelistURLsInWebView: false,
342
- BackupWebStorage: true,
343
- ExternalHosts: [ '*' ],
344
- Plugins: {
345
- Device: 'CDVDevice',
346
- Logger: 'CDVLogger',
347
- Compass: 'CDVLocation',
348
- Accelerometer: 'CDVAccelerometer',
349
- Camera: 'CDVCamera',
350
- NetworkStatus: 'CDVConnection',
351
- Contacts: 'CDVContacts',
352
- 'Debug Console': 'CDVDebugConsole',
353
- Echo: 'CDVEcho',
354
- File: 'CDVFile',
355
- FileTransfer: 'CDVFileTransfer',
356
- Geolocation: 'CDVLocation',
357
- Notification: 'CDVNotification',
358
- Media: 'CDVSound',
359
- Capture: 'CDVCapture',
360
- SplashScreen: 'CDVSplashScreen',
361
- Battery: 'CDVBattery'
362
- }
363
- });
364
- });
365
-
366
- it('should parse an example "Xcode-Info.plist" file', function () {
367
- var xml = multiline(function () {/*
368
- <?xml version="1.0" encoding="UTF-8"?>
369
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
370
- <plist version="1.0">
371
- <dict>
372
- <key>CFBundleDevelopmentRegion</key>
373
- <string>en</string>
374
- <key>CFBundleDisplayName</key>
375
- <string>${PRODUCT_NAME}</string>
376
- <key>CFBundleExecutable</key>
377
- <string>${EXECUTABLE_NAME}</string>
378
- <key>CFBundleIconFiles</key>
379
- <array/>
380
- <key>CFBundleIdentifier</key>
381
- <string>com.joshfire.ads</string>
382
- <key>CFBundleInfoDictionaryVersion</key>
383
- <string>6.0</string>
384
- <key>CFBundleName</key>
385
- <string>${PRODUCT_NAME}</string>
386
- <key>CFBundlePackageType</key>
387
- <string>APPL</string>
388
- <key>CFBundleShortVersionString</key>
389
- <string>1.0</string>
390
- <key>CFBundleSignature</key>
391
- <string>????</string>
392
- <key>CFBundleVersion</key>
393
- <string>1.0</string>
394
- <key>LSRequiresIPhoneOS</key>
395
- <true/>
396
- <key>UIRequiredDeviceCapabilities</key>
397
- <array>
398
- <string>armv7</string>
399
- </array>
400
- <key>UISupportedInterfaceOrientations</key>
401
- <array>
402
- <string>UIInterfaceOrientationPortrait</string>
403
- <string>UIInterfaceOrientationLandscapeLeft</string>
404
- <string>UIInterfaceOrientationLandscapeRight</string>
405
- </array>
406
- <key>UISupportedInterfaceOrientations~ipad</key>
407
- <array>
408
- <string>UIInterfaceOrientationPortrait</string>
409
- <string>UIInterfaceOrientationPortraitUpsideDown</string>
410
- <string>UIInterfaceOrientationLandscapeLeft</string>
411
- <string>UIInterfaceOrientationLandscapeRight</string>
412
- </array>
413
- <key>CFBundleAllowMixedLocalizations</key>
414
- <true/>
415
- </dict>
416
- </plist>
417
- */});
418
- var parsed = parse(xml);
419
- assert.deepEqual(parsed, {
420
- CFBundleDevelopmentRegion: 'en',
421
- CFBundleDisplayName: '${PRODUCT_NAME}',
422
- CFBundleExecutable: '${EXECUTABLE_NAME}',
423
- CFBundleIconFiles: [],
424
- CFBundleIdentifier: 'com.joshfire.ads',
425
- CFBundleInfoDictionaryVersion: '6.0',
426
- CFBundleName: '${PRODUCT_NAME}',
427
- CFBundlePackageType: 'APPL',
428
- CFBundleShortVersionString: '1.0',
429
- CFBundleSignature: '????',
430
- CFBundleVersion: '1.0',
431
- LSRequiresIPhoneOS: true,
432
- UIRequiredDeviceCapabilities: [ 'armv7' ],
433
- UISupportedInterfaceOrientations:
434
- [ 'UIInterfaceOrientationPortrait',
435
- 'UIInterfaceOrientationLandscapeLeft',
436
- 'UIInterfaceOrientationLandscapeRight' ],
437
- 'UISupportedInterfaceOrientations~ipad':
438
- [ 'UIInterfaceOrientationPortrait',
439
- 'UIInterfaceOrientationPortraitUpsideDown',
440
- 'UIInterfaceOrientationLandscapeLeft',
441
- 'UIInterfaceOrientationLandscapeRight' ],
442
- CFBundleAllowMixedLocalizations: true
443
- });
444
- });
445
-
446
- });
447
-
448
- });