cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject git commit: 0.9.6. [CB-3182] Interpolate variables into <info> tags.
Date Fri, 12 Jul 2013 19:47:03 GMT
Updated Branches:
  refs/heads/master 50b1f5282 -> b340813f8


0.9.6. [CB-3182] Interpolate variables into <info> tags.


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

Branch: refs/heads/master
Commit: b340813f81ec21f0d713bf6090692591fd0f97c4
Parents: 50b1f52
Author: Fil Maj <maj.fil@gmail.com>
Authored: Fri Jul 12 12:47:00 2013 -0700
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Fri Jul 12 12:47:00 2013 -0700

----------------------------------------------------------------------
 package.json                           |  2 +-
 spec/install.spec.js                   | 10 ++++++++++
 spec/plugins/ChildBrowser/plugin.xml   |  4 +---
 spec/plugins/VariablePlugin/plugin.xml |  2 ++
 src/install.js                         | 12 ++++++++++--
 5 files changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/b340813f/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 36f6ac0..5e114fc 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
   "author": "Andrew Lunny <alunny@gmail.com>",
   "name": "plugman",
   "description": "install/uninstall Cordova plugins",
-  "version": "0.9.5",
+  "version": "0.9.6",
   "repository": {
     "type": "git",
     "url": "git://git-wip-us.apache.org/repos/asf/cordova-plugman.git"

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/b340813f/spec/install.spec.js
----------------------------------------------------------------------
diff --git a/spec/install.spec.js b/spec/install.spec.js
index 044266d..2895667 100644
--- a/spec/install.spec.js
+++ b/spec/install.spec.js
@@ -78,6 +78,16 @@ describe('install', function() {
             install('android', temp, childplugin, plugins_dir, {});
             expect(emit).toHaveBeenCalledWith('results', 'No matter what platform you are
installing to, this notice is very important.');
         });
+        it('should emit a results event with platform-specific <info>', function()
{
+            var emit = spyOn(plugman, 'emit');
+            install('android', temp, childplugin, plugins_dir, {});
+            expect(emit).toHaveBeenCalledWith('results', 'Please make sure you read this
because it is very important to complete the installation of your plugin.');
+        });
+        it('should interpolate variables into <info> tags', function() {
+            var emit = spyOn(plugman, 'emit');
+            install('android', temp, variableplugin, plugins_dir, {cli_variables:{API_KEY:'batman'}});
+            expect(emit).toHaveBeenCalledWith('results', 'Remember that your api key is batman!');
+        });
 
         describe('with dependencies', function() {
             it('should process all dependent plugins', function() {

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/b340813f/spec/plugins/ChildBrowser/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/ChildBrowser/plugin.xml b/spec/plugins/ChildBrowser/plugin.xml
index 218a838..512c02f 100644
--- a/spec/plugins/ChildBrowser/plugin.xml
+++ b/spec/plugins/ChildBrowser/plugin.xml
@@ -63,9 +63,7 @@
 
         <source-file src="src/android/ChildBrowser.java"
                 target-dir="src/com/phonegap/plugins/childBrowser" />
-        <info>
-          Please make sure you read this because it is very important to complete the installation
of your plugin
-        </info>
+        <info>Please make sure you read this because it is very important to complete
the installation of your plugin.</info>
     </platform>
 
     <!-- ios -->

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/b340813f/spec/plugins/VariablePlugin/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/VariablePlugin/plugin.xml b/spec/plugins/VariablePlugin/plugin.xml
index 67792f5..b713bed 100644
--- a/spec/plugins/VariablePlugin/plugin.xml
+++ b/spec/plugins/VariablePlugin/plugin.xml
@@ -26,6 +26,8 @@
     <name>Use Variables</name>
 
     <preference name="API_KEY" />
+
+    <info>Remember that your api key is $API_KEY!</info>
     <!-- android -->
     <platform name="android">
 		<config-file target="AndroidManifest.xml" parent="/manifest">

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/b340813f/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index 7aa0c0b..17343c8 100644
--- a/src/install.js
+++ b/src/install.js
@@ -291,13 +291,21 @@ function handleInstall(actions, plugin_id, plugin_et, platform, project_dir,
plu
             // Log out plugin INFO element contents in case additional install steps are
necessary
             var info = plugin_et.findall('./info');
             if(info.length) {
-                require('../plugman').emit('results', info[0].text);
+                require('../plugman').emit('results', interp_vars(filtered_variables, info[0].text));
             }
             info = (platformTag ? platformTag.findall('./info') : []);
             if(info.length) {
-                require('../plugman').emit('results', info[0].text);
+                require('../plugman').emit('results', interp_vars(filtered_variables, info[0].text));
             }
             if (callback) callback();
         }
     });
 }
+
+function interp_vars(vars, text) {
+    vars && Object.keys(vars).forEach(function(key) {
+        var regExp = new RegExp("\\$" + key, "g");
+        text = text.replace(regExp, vars[key]);
+    });
+    return text;
+}


Mime
View raw message