Updated Branches: refs/heads/master 753214ca7 -> 83a042a75
[CB-4511] [BlackBerry10] Fix parser handling of config.xml - Removed logic to copy config.xml from tempalte. - Generalized the implementation of access element changes. Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/83a042a7 Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/83a042a7 Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/83a042a7 Branch: refs/heads/master Commit: 83a042a75ab83370b74a5413a2721cceb08e6399 Parents: 753214c Author: Jeffrey Heifetz <[email protected]> Authored: Tue Aug 6 12:04:48 2013 -0400 Committer: Bryan Higgins <[email protected]> Committed: Tue Aug 6 16:59:05 2013 -0400 ---------------------------------------------------------------------- spec/metadata/blackberry_parser.spec.js | 19 +++++++++++-------- src/config_parser.js | 6 +++++- src/metadata/blackberry10_parser.js | 19 ++----------------- 3 files changed, 18 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/83a042a7/spec/metadata/blackberry_parser.spec.js ---------------------------------------------------------------------- diff --git a/spec/metadata/blackberry_parser.spec.js b/spec/metadata/blackberry_parser.spec.js index 7a86f78..3ba22da 100644 --- a/spec/metadata/blackberry_parser.spec.js +++ b/spec/metadata/blackberry_parser.spec.js @@ -93,13 +93,15 @@ describe('blackberry10 project parser', function() { xml_pkg = jasmine.createSpy('xml pkg'); xml_version = jasmine.createSpy('xml version'); xml_access_rm = jasmine.createSpy('xml access rm'); + xml_access_add = jasmine.createSpy('xml access add'); xml_update = jasmine.createSpy('xml update'); xml_append = jasmine.createSpy('xml append'); p.xml.name = xml_name; p.xml.packageName = xml_pkg; p.xml.version = xml_version; p.xml.access = { - remove:xml_access_rm + remove:xml_access_rm, + add: xml_access_add }; p.xml.update = xml_update; p.xml.doc = { @@ -123,11 +125,11 @@ describe('blackberry10 project parser', function() { }); xml = spyOn(ET, 'XML'); cfg = new config_parser(); - cfg.name = function() { return 'testname' }; - cfg.packageName = function() { return 'testpkg' }; - cfg.version = function() { return 'one point oh' }; - cfg.access.get = function() { return [] }; - cfg.preference.get = function() { return [] }; + cfg.name = function() { return 'testname'; }; + cfg.packageName = function() { return 'testpkg'; }; + cfg.version = function() { return 'one point oh'; }; + cfg.access.getAttributes = function() { return []; }; + cfg.preference.get = function() { return []; }; }); it('should write out the app name to config.xml', function() { @@ -147,9 +149,10 @@ describe('blackberry10 project parser', function() { expect(xml_access_rm).toHaveBeenCalled(); }); it('should update the whitelist', function() { - cfg.access.get = function() { return ['one'] }; + cfg.access.getAttributes = function() { return [{origin: 'one'},{uri: "two", subdomains: "false"}]; }; p.update_from_config(cfg); - expect(xml_append.mostRecentCall.args[0].attrib.uri).toEqual('one'); + expect(xml_access_add).toHaveBeenCalledWith('one', undefined); + expect(xml_access_add).toHaveBeenCalledWith('two', 'false'); }); }); describe('www_dir method', function() { http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/83a042a7/src/config_parser.js ---------------------------------------------------------------------- diff --git a/src/config_parser.js b/src/config_parser.js index 33a1c38..5d1b8ed 100644 --- a/src/config_parser.js +++ b/src/config_parser.js @@ -55,9 +55,10 @@ function access(cfg) { }; access.prototype = { - add:function(uri) { + add:function(uri, subdomain) { var el = new et.Element('access'); el.attrib.origin = uri; + if (typeof subdomain !== "undefined") el.attrib.subdomains = subdomain; this.config.doc.getroot().append(el); this.config.update(); }, @@ -73,6 +74,9 @@ access.prototype = { }, get:function() { return this.config.doc.findall('access').map(function(a) { return a.attrib.origin || a.attrib.uri; }); + }, + getAttributes:function() { + return this.config.doc.findall('access').map(function(a) { return a.attrib; }); } }; http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/83a042a7/src/metadata/blackberry10_parser.js ---------------------------------------------------------------------- diff --git a/src/metadata/blackberry10_parser.js b/src/metadata/blackberry10_parser.js index dc0f632..79e303f 100644 --- a/src/metadata/blackberry10_parser.js +++ b/src/metadata/blackberry10_parser.js @@ -58,13 +58,9 @@ module.exports.prototype = { events.emit('log', 'Wrote out BlackBerry version to "' + config.version() + '"'); this.xml.access.remove(); var self = this; - config.access.get().forEach(function(uri) { - var el = new et.Element('access'); - el.attrib.uri = uri; - el.attrib.subdomains = 'true'; - self.xml.doc.getroot().append(el); + config.access.getAttributes().forEach(function(attribs) { + self.xml.access.add(attribs.uri || attribs.origin, attribs.subdomains); }); - this.xml.update(); }, update_project:function(cfg, callback) { var self = this; @@ -111,17 +107,6 @@ module.exports.prototype = { if (custom_path) lib_path = custom_path; // add cordova.js shell.cp('-f', path.join(lib_path, 'javascript', 'cordova.blackberry10.js'), path.join(this.www_dir(), 'cordova.js')); - - // add webworks ext directories - shell.cp('-rf', path.join(lib_path, 'framework', 'ext*'), this.www_dir()); - - // add config.xml - // @TODO should use project www/config.xml but it must use BBWP elements - shell.cp('-f', path.join(lib_path, 'bin', 'templates', 'project', 'www', 'config.xml'), this.www_dir()); - - // add res/ - // @TODO remove this when config.xml is generalized - shell.cp('-rf', path.join(lib_path, 'bin', 'templates', 'project', 'www', 'res'), this.www_dir()); }, // update the overrides folder into the www folder
