1 |
|
2 | #
|
3 | # Licensed to the Apache Software Foundation (ASF) under one
|
4 | # or more contributor license agreements. See the NOTICE file
|
5 | # distributed with this work for additional information
|
6 | # regarding copyright ownership. The ASF licenses this file
|
7 | # to you under the Apache License, Version 2.0 (the
|
8 | # "License"); you may not use this file except in compliance
|
9 | # with the License. You may obtain a copy of the License at
|
10 | #
|
11 | # http://www.apache.org/licenses/LICENSE-2.0
|
12 | #
|
13 | # Unless required by applicable law or agreed to in writing,
|
14 | # software distributed under the License is distributed on an
|
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16 | # KIND, either express or implied. See the License for the
|
17 | # specific language governing permissions and limitations
|
18 | # under the License.
|
19 | #
|
20 | -->
|
21 |
|
22 | # Cordova-Lib
|
23 |
|
24 | ## ConfigParser
|
25 |
|
26 | wraps a valid cordova config.xml file
|
27 |
|
28 | ### Usage
|
29 |
|
30 | ### Include the ConfigParser module in a projet
|
31 |
|
32 | var ConfigParser = require('cordova-lib').configparser;
|
33 |
|
34 | ### Create a new ConfigParser
|
35 |
|
36 | var config = new ConfigParser('path/to/config/xml/');
|
37 |
|
38 | ### Utility Functions
|
39 |
|
40 | #### packageName(id)
|
41 | returns document root 'id' attribute value
|
42 | #### Usage
|
43 |
|
44 | config.packageName: function(id)
|
45 |
|
46 | /*
|
47 | * sets document root element 'id' attribute to @id
|
48 | *
|
49 | * @id - new id value
|
50 | *
|
51 | */
|
52 | #### setPackageName(id)
|
53 | set document root 'id' attribute to
|
54 | function(id) {
|
55 | this.doc.getroot().attrib['id'] = id;
|
56 | },
|
57 |
|
58 | ###
|
59 | name: function() {
|
60 | return getNodeTextSafe(this.doc.find('name'));
|
61 | },
|
62 | setName: function(name) {
|
63 | var el = findOrCreate(this.doc, 'name');
|
64 | el.text = name;
|
65 | },
|
66 |
|
67 | ### read the description element
|
68 |
|
69 | config.description()
|
70 |
|
71 | var text = "New and improved description of App"
|
72 | setDescription(text)
|
73 |
|
74 | ### version management
|
75 | version()
|
76 | android_versionCode()
|
77 | ios_CFBundleVersion()
|
78 | setVersion()
|
79 |
|
80 | ### read author element
|
81 |
|
82 | config.author();
|
83 |
|
84 | ### read preference
|
85 |
|
86 | config.getPreference(name);
|