cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lorinb...@apache.org
Subject [09/50] [abbrv] webworks commit: Implement Logger plugin
Date Tue, 14 May 2013 04:15:16 GMT
Implement Logger plugin

Tested by Tracy Li <tli@blackberry.com>


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

Branch: refs/heads/master
Commit: 66e382216a58cf6e3da0e23d64d4d7d6d9a8c9f5
Parents: 042526c
Author: Bryan Higgins <bhiggins@blackberry.com>
Authored: Tue Apr 2 11:39:12 2013 -0400
Committer: Bryan Higgins <bhiggins@blackberry.com>
Committed: Fri May 3 10:13:29 2013 -0400

----------------------------------------------------------------------
 .../bin/templates/project/plugins/Logger/index.js  |   25 +++++++
 blackberry10/bin/test/plugins/Logger/index.js      |   51 ++++++++++++++
 blackberry10/javascript/cordova.blackberry10.js    |   52 +++++++++------
 3 files changed, 107 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/66e38221/blackberry10/bin/templates/project/plugins/Logger/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Logger/index.js b/blackberry10/bin/templates/project/plugins/Logger/index.js
new file mode 100644
index 0000000..497f477
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Logger/index.js
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2010-2011 Research In Motion Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+module.exports = {
+    logLevel: function (success, fail, args, env) {
+        var result = new PluginResult(args, env),
+            level = JSON.parse(decodeURIComponent(args[0])),
+            message = JSON.parse(decodeURIComponent(args[1]));
+        console.log(level + ": " + message);
+        result.noResult(false);
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/66e38221/blackberry10/bin/test/plugins/Logger/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Logger/index.js b/blackberry10/bin/test/plugins/Logger/index.js
new file mode 100644
index 0000000..e5dc9f9
--- /dev/null
+++ b/blackberry10/bin/test/plugins/Logger/index.js
@@ -0,0 +1,51 @@
+/*
+* Copyright 2013 Research In Motion Limited.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+describe("Logger", function () {
+
+    var _apiDir = __dirname + "./../../../templates/project/plugins/Logger/",
+        index,
+        result = {
+            noResult: jasmine.createSpy("noResult")
+        };
+    
+    beforeEach(function () {
+        index = require(_apiDir + "index");
+    });
+
+    afterEach(function () {
+        index = null;
+    });
+
+    describe("logLevel", function () {
+        beforeEach(function () {
+            spyOn(console, "log"); 
+            GLOBAL.PluginResult = function () {
+                return result;
+            };
+        });
+
+        afterEach(function () {
+            delete GLOBAL.PluginResult;
+        });
+
+        it("calls console.log", function () {
+            index.logLevel(function () {}, function () {}, ["%22ERROR%22", "%22message%22"]);
+            expect(console.log).toHaveBeenCalledWith("ERROR: message");
+            expect(result.noResult).toHaveBeenCalledWith(false);
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/66e38221/blackberry10/javascript/cordova.blackberry10.js
----------------------------------------------------------------------
diff --git a/blackberry10/javascript/cordova.blackberry10.js b/blackberry10/javascript/cordova.blackberry10.js
index 27c3c3a..8fd6292 100644
--- a/blackberry10/javascript/cordova.blackberry10.js
+++ b/blackberry10/javascript/cordova.blackberry10.js
@@ -1,8 +1,8 @@
 // Platform: blackberry10
 
-// commit 4c7d302ca09258a6ab9306e7647b1478b06c498a
+// commit 2a6ac9642dcc875318e348c64bf4e69d2e932cc1
 
-// File generated at :: Mon Apr 01 2013 10:04:19 GMT-0400 (EDT)
+// File generated at :: Mon Apr 08 2013 09:08:23 GMT-0400 (EDT)
 
 /*
  Licensed to the Apache Software Foundation (ASF) under one
@@ -952,7 +952,6 @@ var cordova = require('cordova'),
         'Accelerometer' : require('cordova/plugin/blackberry10/accelerometer'),
         'Compass' : require('cordova/plugin/blackberry10/magnetometer'),
         'Capture' : require('cordova/plugin/blackberry10/capture'),
-        'Logger' : require('cordova/plugin/blackberry10/logger'),
         'Notification' : require('cordova/plugin/blackberry10/notification'),
         'Media': require('cordova/plugin/blackberry10/media'),
         'FileTransfer': require('cordova/plugin/blackberry10/fileTransfer')
@@ -4665,21 +4664,6 @@ module.exports = {
 
 });
 
-// file: lib/blackberry10/plugin/blackberry10/logger.js
-define("cordova/plugin/blackberry10/logger", function(require, exports, module) {
-
-var cordova = require('cordova');
-
-module.exports = {
-    log: function (args, win, fail) {
-        console.log(args);
-        return {"status" : cordova.callbackStatus.OK,
-                "message" : 'Message logged to console: ' + args};
-    }
-};
-
-});
-
 // file: lib/blackberry10/plugin/blackberry10/magnetometer.js
 define("cordova/plugin/blackberry10/magnetometer", function(require, exports, module) {
 
@@ -4930,13 +4914,15 @@ module.exports = {
     id: "blackberry10",
     initialize: function () {
         document.addEventListener("deviceready", function () {
+            /*
+             TODO
             blackberry.event.addEventListener("pause", function () {
                 cordova.fireDocumentEvent("pause");
             });
             blackberry.event.addEventListener("resume", function () {
                 cordova.fireDocumentEvent("resume");
             });
-
+            */
             window.addEventListener("online", function () {
                 cordova.fireDocumentEvent("online");
             });
@@ -4947,8 +4933,8 @@ module.exports = {
         });
     },
     clobbers: {
-        open: {
-            path: "cordova/plugin/InAppBrowser"
+        requestFileSystem: {
+            path: "cordova/plugin/blackberry10/requestFileSystem"
         }
     },
     merges: {
@@ -5037,6 +5023,30 @@ module.exports = {
 
 });
 
+// file: lib/blackberry10/plugin/blackberry10/requestFileSystem.js
+define("cordova/plugin/blackberry10/requestFileSystem", function(require, exports, module)
{
+
+function getFileSystemName(fs) {
+    return (fs.name.indexOf("Persistent") != -1) ? "persistent" : "temporary";
+}
+
+function makeEntry(entry) {
+    if (entry.isDirectory) {
+        return new DirectoryEntry(entry.name, decodeURI(entry.toURL()).substring(11));
+    }
+    else {
+        return new FileEntry(entry.name, decodeURI(entry.toURL()).substring(11));
+    }
+}
+
+module.exports = function (type, size, success, fail) {
+    window.webkitRequestFileSystem(type, size, function (fs) {
+        success((new FileSystem(getFileSystemName(fs), makeEntry(fs.root))));
+    }, fail);
+};
+
+});
+
 // file: lib/blackberry10/plugin/blackberry10/utils.js
 define("cordova/plugin/blackberry10/utils", function(require, exports, module) {
 


Mime
View raw message