Add general purpose ConfigParser.getAttribute API

 This closes #466


Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/ced64c43
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/ced64c43
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/ced64c43

Branch: refs/heads/common-1.4.x
Commit: ced64c43462ed70ec789308440d31fb8cad08610
Parents: a429358
Author: Darryl Pogue <dar...@ayogo.com>
Authored: Thu Jul 21 20:03:33 2016 -0700
Committer: Steve Gill <stevengil...@gmail.com>
Committed: Mon Aug 8 17:37:43 2016 -0700

----------------------------------------------------------------------
 cordova-common/src/ConfigParser/ConfigParser.js | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ced64c43/cordova-common/src/ConfigParser/ConfigParser.js
----------------------------------------------------------------------
diff --git a/cordova-common/src/ConfigParser/ConfigParser.js 
b/cordova-common/src/ConfigParser/ConfigParser.js
index aae59db..195164a 100644
--- a/cordova-common/src/ConfigParser/ConfigParser.js
+++ b/cordova-common/src/ConfigParser/ConfigParser.js
@@ -90,20 +90,24 @@ function findElementAttributeValue(attributeName, elems) {
 }
 
 ConfigParser.prototype = {
+    getAttribute: function(attr) {
+        return this.doc.getroot().attrib[attr];
+    },
+
     packageName: function(id) {
-        return this.doc.getroot().attrib['id'];
+        return this.getAttribute('id');
     },
     setPackageName: function(id) {
         this.doc.getroot().attrib['id'] = id;
     },
     android_packageName: function() {
-        return this.doc.getroot().attrib['android-packageName'];
+        return this.getAttribute('android-packageName');
     },
     android_activityName: function() {
-       return this.doc.getroot().attrib['android-activityName'];
+        return this.getAttribute('android-activityName');
     },
     ios_CFBundleIdentifier: function() {
-        return this.doc.getroot().attrib['ios-CFBundleIdentifier'];
+        return this.getAttribute('ios-CFBundleIdentifier');
     },
     name: function() {
         return getNodeTextSafe(this.doc.find('name'));
@@ -120,16 +124,16 @@ ConfigParser.prototype = {
         el.text = text;
     },
     version: function() {
-        return this.doc.getroot().attrib['version'];
+        return this.getAttribute('version');
     },
     windows_packageVersion: function() {
-        return this.doc.getroot().attrib('windows-packageVersion');
+        return this.getAttribute('windows-packageVersion');
     },
     android_versionCode: function() {
-        return this.doc.getroot().attrib['android-versionCode'];
+        return this.getAttribute('android-versionCode');
     },
     ios_CFBundleVersion: function() {
-        return this.doc.getroot().attrib['ios-CFBundleVersion'];
+        return this.getAttribute('ios-CFBundleVersion');
     },
     setVersion: function(value) {
         this.doc.getroot().attrib['version'] = value;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org
For additional commands, e-mail: commits-h...@cordova.apache.org

Reply via email to