You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ripple.apache.org by gt...@apache.org on 2013/03/22 21:52:00 UTC

[1/2] git commit: Update path arg to handle multiple paths

Updated Branches:
  refs/heads/next ab68639ad -> 24cae3151


Update path arg to handle multiple paths

- added map to parser to make rules to map values from the commandline
- fixed problem in regex for enableripple (ignore case)
- added rule to always have path an array value
- updated jshint to get rid of onevar (we have grown)
- allow static server to take multiple paths and merge into one


Project: http://git-wip-us.apache.org/repos/asf/incubator-ripple/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ripple/commit/2e483836
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ripple/tree/2e483836
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ripple/diff/2e483836

Branch: refs/heads/next
Commit: 2e483836bc5a24397ed002556f4209fac9508438
Parents: ab68639
Author: Gord Tanner <gt...@gmail.com>
Authored: Fri Mar 22 16:44:00 2013 -0400
Committer: Gord Tanner <gt...@gmail.com>
Committed: Fri Mar 22 16:44:00 2013 -0400

----------------------------------------------------------------------
 .jshintrc                         |    2 +-
 lib/cli/index.js                  |    4 +++
 lib/cli/parser.js                 |   14 ++++++++++-
 lib/client/ui/plugins/platform.js |    4 ++-
 lib/server/emulate.js             |    4 ++-
 lib/server/emulate/hosted.js      |   38 ++++++++++++++++++-------------
 lib/server/index.js               |    1 -
 test/unit/cli/parser.js           |   17 ++++++++++++++
 8 files changed, 62 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/2e483836/.jshintrc
----------------------------------------------------------------------
diff --git a/.jshintrc b/.jshintrc
index 4b39f35..e9db285 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -109,7 +109,7 @@
     "noarg": true,
     "noempty": false,
     "nonew": false,
-    "onevar": true,
+    "onevar": false,
     "plusplus": false,
     "regexp": false,
     "undef": true,

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/2e483836/lib/cli/index.js
----------------------------------------------------------------------
diff --git a/lib/cli/index.js b/lib/cli/index.js
index c461d78..1faf7e3 100644
--- a/lib/cli/index.js
+++ b/lib/cli/index.js
@@ -45,6 +45,10 @@ function lookup(command, subcommand, options) {
 
 module.exports = {
     interpret: function (args) {
+
+        //convert path to always be an array.
+        parser.map("path", function (v) { return v.forEach ? v : [v]; });
+
         var parsed = parser.parse(args),
             subcommand;
 

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/2e483836/lib/cli/parser.js
----------------------------------------------------------------------
diff --git a/lib/cli/parser.js b/lib/cli/parser.js
index 0cd40c8..a6158d6 100644
--- a/lib/cli/parser.js
+++ b/lib/cli/parser.js
@@ -18,7 +18,8 @@
  * under the License.
  *
  */
-var FLAG_PREFIX = /^\-\-?/;
+var FLAG_PREFIX = /^\-\-?/,
+    maps = {};
 
 function parse(args) {
     var result = {
@@ -59,9 +60,18 @@ function parse(args) {
         }
     }
 
+    Object.keys(result.options).forEach(function (key) {
+        if (maps[key]) {
+            result.options[key] = maps[key](result.options[key]);
+        }
+    });
+
     return result;
 }
 
 module.exports = {
-    parse: parse
+    parse: parse,
+    map: function (key, func) {
+        maps[key] = func;
+    }
 };

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/2e483836/lib/client/ui/plugins/platform.js
----------------------------------------------------------------------
diff --git a/lib/client/ui/plugins/platform.js b/lib/client/ui/plugins/platform.js
index e1062bf..75770ec 100644
--- a/lib/client/ui/plugins/platform.js
+++ b/lib/client/ui/plugins/platform.js
@@ -69,7 +69,9 @@ function changePlatformOrDevice() {
         var original = utils.queryString().enableripple,
             updated = platformId + "-" + version + "-" + device;
 
-        if (original) { location.href = location.href.replace(original, updated); }
+        if (original) {
+            location.href = location.href.replace(new RegExp(original, "i"), updated);
+        }
         else { location.reload(); }
     });
 }

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/2e483836/lib/server/emulate.js
----------------------------------------------------------------------
diff --git a/lib/server/emulate.js b/lib/server/emulate.js
index e247e26..cec549e 100644
--- a/lib/server/emulate.js
+++ b/lib/server/emulate.js
@@ -58,7 +58,9 @@ module.exports = {
         app.use(hosted.inject(options));
 
         if (!options.remote) {
-            app.use(express.static(options.path));
+            options.path.forEach(function (path) {
+                app.use("/", express.static(path));
+            });
         }
 
 // TODO: This should just talk about how to enable ripple via query params

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/2e483836/lib/server/emulate/hosted.js
----------------------------------------------------------------------
diff --git a/lib/server/emulate/hosted.js b/lib/server/emulate/hosted.js
index 544f782..63e4527 100644
--- a/lib/server/emulate/hosted.js
+++ b/lib/server/emulate/hosted.js
@@ -123,27 +123,33 @@ function remoteInjection(opts) {
 }
 
 function localInjection(opts) {
-    return function (req, res, next) {
-        var file;
+    function inject(file, req, res) {
+        fs.readFile(file, "utf-8", function (err, data) {
+            if (err) { throw new Error(err); }
+
+            var doc = data.replace(HEAD_TAG,
+                      '<head>' +
+                        '<script>' +
+                            BOOTSTRAP_FROM_IFRAME +
+                        '</script>');
+
+            res.send(doc);
+        });
+    }
 
+    return function (req, res, next) {
         // TODO: DRY (see proxyRemote function)
         if (req.query.enableripple) {
             res.sendfile(path.join(HOSTED_PKG_DIR, "index.html"));
         } else if (req.path.match(/^\/$/) || req.path.match(/\.html/)) {
-            file = opts.path + (req.path.match(/\/$/) ?
-                            req.path + "/index.html" : req.path);
-
-            fs.readFile(file, "utf-8", function (err, data) {
-                if (err) { throw new Error(err); }
-
-                var doc = data.replace(HEAD_TAG,
-                          '<head>' +
-                            '<script>' +
-                                BOOTSTRAP_FROM_IFRAME +
-                            '</script>');
-
-                res.send(doc);
-            });
+            //first matching file
+            var fullPath = opts.path.reduce(function (match, curr) {
+                if (match) return match;
+                var file = curr + (req.path.match(/\/$/) ? req.path + "/index.html" : req.path);
+                return fs.existsSync(file) ? file : match;
+            }, null);
+
+            inject(fullPath, req, res);
         } else {
             next();
         }

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/2e483836/lib/server/index.js
----------------------------------------------------------------------
diff --git a/lib/server/index.js b/lib/server/index.js
index 95fa579..46b7663 100644
--- a/lib/server/index.js
+++ b/lib/server/index.js
@@ -37,4 +37,3 @@ module.exports = {
         return app;
     }
 };
-

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/2e483836/test/unit/cli/parser.js
----------------------------------------------------------------------
diff --git a/test/unit/cli/parser.js b/test/unit/cli/parser.js
index f67fe89..0cbfd41 100644
--- a/test/unit/cli/parser.js
+++ b/test/unit/cli/parser.js
@@ -62,4 +62,21 @@ describe("cli", function () {
             }
         });
     });
+
+    it("can use map to change the value of the option", function () {
+        var multipleFlagsWithMultipleArgs = [
+            "cmd", "--a", "b", "c"
+        ];
+
+        parser.map("a", function () { return 12; });
+        parsed = parser.parse(basicArgs.concat(multipleFlagsWithMultipleArgs));
+
+        expect(parsed).toEqual({
+            commands: ["cmd"],
+            options: {
+                "a": 12
+            }
+        });
+        parser.map("a", null);
+    });
 });


[2/2] git commit: update version and changelog

Posted by gt...@apache.org.
update version and changelog


Project: http://git-wip-us.apache.org/repos/asf/incubator-ripple/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ripple/commit/24cae315
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ripple/tree/24cae315
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ripple/diff/24cae315

Branch: refs/heads/next
Commit: 24cae31518e78a73090f49d72fd8debaa71c361b
Parents: 2e48383
Author: Gord Tanner <gt...@gmail.com>
Authored: Fri Mar 22 16:51:13 2013 -0400
Committer: Gord Tanner <gt...@gmail.com>
Committed: Fri Mar 22 16:51:13 2013 -0400

----------------------------------------------------------------------
 doc/CHANGELOG.md |    9 ++++++++-
 package.json     |    2 +-
 2 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/24cae315/doc/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 5596003..30ffdd2 100644
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,4 +1,11 @@
-## v0.9.1r54 - March 08, 2013
+## v0.9.16 - March 22, 2013
+
+* Added support for serve app from multiple folders
+* Fixed browser tests to run again
+* added device selection to enableRipple qs param
+* Skinned devices now have ther size devided by the css pixel ratio
+
+## v0.9.15 - March 08, 2013
 
 * Updated version to 0.9.15 due to republishing need on Chrome Store as per this issue: https://groups.google.com/a/chromium.org/forum/?fromgroups=#!topic/chromium-extensions/d56BP7CTU-M
 

http://git-wip-us.apache.org/repos/asf/incubator-ripple/blob/24cae315/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 7b54316..c5d5d18 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "ripple-emulator",
-  "version": "0.9.15",
+  "version": "0.9.16",
   "description": "A browser based html5 mobile application development and testing tool",
   "homepage": "http://ripple.incubator.apache.org/",
   "author": {