Updated Branches:
  refs/heads/master a33b47d5a -> a018c4925

[all] Change builder functions to be normal instead of closures


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

Branch: refs/heads/master
Commit: a018c4925ed24140febe3bae3b31711b33e61d1a
Parents: 99fadd1
Author: Andrew Grieve <[email protected]>
Authored: Thu Nov 15 16:16:01 2012 -0500
Committer: Andrew Grieve <[email protected]>
Committed: Thu Nov 15 16:16:01 2012 -0500

----------------------------------------------------------------------
 lib/blackberry/platform.js       |    5 +++--
 lib/common/builder.js            |   26 ++++++++------------------
 lib/scripts/bootstrap.js         |   12 ++++++------
 test/blackberry/test.platform.js |   16 +++++-----------
 test/test.builder.js             |   10 +++++-----
 5 files changed, 27 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/a018c492/lib/blackberry/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/platform.js b/lib/blackberry/platform.js
index 0ff9dfe..b508bc6 100644
--- a/lib/blackberry/platform.js
+++ b/lib/blackberry/platform.js
@@ -40,8 +40,9 @@ module.exports = {
         var builder = require('cordova/builder'),
             platform = require('cordova/plugin/' + this.runtime() + 
'/platform');
 
-        builder.build(platform.objects).intoAndClobber(window);
-        builder.build(platform.merges).intoAndMerge(window);
+        builder.buildIntoButDoNotClobber(platform.defaults, window);
+        builder.buildIntoAndClobber(platform.clobbers, window);
+        builder.buildIntoAndMerge(platform.merges, window);
         platform.initialize();
     }
 };

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/a018c492/lib/common/builder.js
----------------------------------------------------------------------
diff --git a/lib/common/builder.js b/lib/common/builder.js
index 05d33c6..2eac76a 100644
--- a/lib/common/builder.js
+++ b/lib/common/builder.js
@@ -117,23 +117,13 @@ function recursiveMerge(target, src) {
 }
 
 module.exports = {
-    build: function (objects) {
-        return {
-            intoButDoNotClobber: function (target) {
-                if (objects) {
-                    include(target, objects, false, false);
-                }
-            },
-            intoAndClobber: function(target) {
-                if (objects) {
-                    include(target, objects, true, false);
-                }
-            },
-            intoAndMerge: function(target) {
-                if (objects) {
-                    include(target, objects, true, true);
-                }
-            }
-        };
+    buildIntoButDoNotClobber: function(objects, target) {
+        include(target, objects, false, false);
+    },
+    buildIntoAndClobber: function(objects, target) {
+        include(target, objects, true, false);
+    },
+    buildIntoAndMerge: function(objects, target) {
+        include(target, objects, true, true);
     }
 };

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/a018c492/lib/scripts/bootstrap.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap.js b/lib/scripts/bootstrap.js
index 4d727fb..239e4a4 100644
--- a/lib/scripts/bootstrap.js
+++ b/lib/scripts/bootstrap.js
@@ -40,13 +40,13 @@
                         platform = require('cordova/platform');
 
                     // Drop the common globals into the window object, but be 
nice and don't overwrite anything.
-                    builder.build(base.defaults).intoButDoNotClobber(context);
-                    builder.build(base.merges).intoAndMerge(context);
-                    builder.build(base.clobbers).intoAndClobber(context);
+                    builder.buildIntoButDoNotClobber(base.defaults, context);
+                    builder.buildIntoAndMerge(base.merges, context);
+                    builder.buildIntoAndClobber(base.clobbers, context);
 
-                    
builder.build(platform.defaults).intoButDoNotClobber(context);
-                    builder.build(platform.merges).intoAndMerge(context);
-                    builder.build(platform.clobbers).intoAndClobber(context);
+                    builder.buildIntoButDoNotClobber(platform.defaults, 
context);
+                    builder.buildIntoAndMerge(platform.merges, context);
+                    builder.buildIntoAndClobber(platform.clobbers, context);
 
                     // Call the platform-specific initialization
                     platform.initialize();

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/a018c492/test/blackberry/test.platform.js
----------------------------------------------------------------------
diff --git a/test/blackberry/test.platform.js b/test/blackberry/test.platform.js
index e379596..183e449 100644
--- a/test/blackberry/test.platform.js
+++ b/test/blackberry/test.platform.js
@@ -46,15 +46,11 @@ describe("blackberry platform", function () {
     });
 
     describe("when initializing", function () {
-        var builder = require('cordova/builder'),
-            clobber = jasmine.createSpy("intoAndClobber"),
-            merge = jasmine.createSpy("intoAndMerge");
+        var builder = require('cordova/builder');
 
         beforeEach(function () {
-            spyOn(builder, "build").andReturn({
-                intoAndClobber: clobber,
-                intoAndMerge: merge
-            });
+            spyOn(builder, "buildIntoAndClobber");
+            spyOn(builder, "buildIntoAndMerge");
         });
 
         it("calls initialize for the platform from the runtime", function () {
@@ -76,8 +72,7 @@ describe("blackberry platform", function () {
 
             platform.initialize();
 
-            expect(builder.build).toHaveBeenCalledWith(java.objects);
-            expect(clobber).toHaveBeenCalledWith(window);
+            
expect(builder.buildIntoAndClobber).toHaveBeenCalledWith(java.clobbers, window);
         });
 
         it("builds given platforms merges into window and merges them", 
function () {
@@ -88,8 +83,7 @@ describe("blackberry platform", function () {
 
             platform.initialize();
 
-            expect(builder.build).toHaveBeenCalledWith(qnx.merges);
-            expect(merge).toHaveBeenCalledWith(window);
+            expect(builder.buildIntoAndMerge).toHaveBeenCalledWith(qnx.merges, 
window);
         });
     });
 });

http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/a018c492/test/test.builder.js
----------------------------------------------------------------------
diff --git a/test/test.builder.js b/test/test.builder.js
index a33a1e4..e8921c1 100644
--- a/test/test.builder.js
+++ b/test/test.builder.js
@@ -32,8 +32,8 @@ describe("builder", function () {
                 }
             };
 
-        
-        builder.build(objects).intoAndClobber(target);
+
+        builder.buildIntoAndClobber(objects, target);
         expect(target.foo).toBeDefined();
         expect(target.foo).toBe(require("cordova/plugin/compass"));
     });
@@ -42,7 +42,7 @@ describe("builder", function () {
         var target = {},
             objects = {cat: {}};
 
-        builder.build(objects).intoButDoNotClobber(target);
+        builder.buildIntoButDoNotClobber(objects, target);
 
         expect(target.cat).toBeDefined();
     });
@@ -59,10 +59,10 @@ describe("builder", function () {
                            path: "cordova/plugin/compass"
                        }
                    }
-               } 
+               }
             };
 
-        builder.build(objects).intoButDoNotClobber(target);
+        builder.buildIntoButDoNotClobber(objects, target);
 
         expect(target.homer.bart).toBeDefined();
         expect(target.homer.maggie).toBe(require('cordova/plugin/compass'));

Reply via email to