cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject git commit: minor refactor, added specs
Date Thu, 11 Jul 2013 20:08:35 GMT
Updated Branches:
  refs/heads/plugman-registry 7e8812fb5 -> bf9751330


minor refactor, added specs


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

Branch: refs/heads/plugman-registry
Commit: bf975133054c0b324fd55b361f456a7fee6bc44f
Parents: 7e8812f
Author: Anis Kadri <anis@apache.org>
Authored: Thu Jul 11 13:08:23 2013 -0700
Committer: Anis Kadri <anis@apache.org>
Committed: Thu Jul 11 13:08:23 2013 -0700

----------------------------------------------------------------------
 config.js              |  2 +-
 main.js                | 32 ++++----------------------------
 plugman.js             |  4 ++++
 spec/adduser.spec.js   | 13 +++++++++++++
 spec/publish.spec.js   | 13 +++++++++++++
 spec/search.spec.js    | 13 +++++++++++++
 spec/unpublish.spec.js | 13 +++++++++++++
 src/adduser.js         | 11 +++++++++++
 src/publish.js         | 11 +++++++++++
 src/search.js          | 13 +++++++++++++
 src/unpublish.js       | 11 +++++++++++
 11 files changed, 107 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/bf975133/config.js
----------------------------------------------------------------------
diff --git a/config.js b/config.js
index 7056d93..244bf55 100644
--- a/config.js
+++ b/config.js
@@ -1,3 +1,3 @@
 module.exports = {
-  registry: "http://localhost:5984/registry/_design/scratch/_rewrite"
+  registry: "http://plugins.cordova.io"
 }

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/bf975133/main.js
----------------------------------------------------------------------
diff --git a/main.js b/main.js
index 076b30d..a0cd602 100755
--- a/main.js
+++ b/main.js
@@ -24,8 +24,6 @@ var path = require('path')
     , package = require(path.join(__dirname, 'package'))
     , nopt = require('nopt')
     , plugins = require('./src/util/plugins')
-    , registry = require('plugman-registry')
-    , config = require('./config')
     , plugman = require('./plugman');
 
 var known_opts = { 'platform' : [ 'ios', 'android', 'blackberry10', 'wp7', 'wp8' ]
@@ -79,38 +77,16 @@ else if (cli_opts.uninstall) {
     plugman.uninstall(cli_opts.platform, cli_opts.project, cli_opts.plugin, plugins_dir,
{ www_dir: cli_opts.www });
 }
 else if (cli_opts.adduser) {
-  registry.use(config.registry, function(err) {
-    registry.adduser(null, function(err) {
-      if(err) return console.log(err);
-      console.log('user added');
-    });
-  });
+  plugman.adduser();
 }
 else if (cli_opts.publish && cli_opts.plugin) {
-  registry.use(config.registry, function(err) {
-    registry.publish([cli_opts.plugin], function(err, d) {
-      if(err) return console.log('Error publishing plugin', err); 
-      console.log('plugin published');
-    });
-  });
+  plugman.publish(new Array(cli_opts.plugin));
 }
 else if (cli_opts.unpublish && cli_opts.plugin) {
-  registry.use(config.registry, function(err) {
-    registry.unpublish([cli_opts.plugin], function(err, d) {
-      if(err) return console.log('Error unpublishing plugin'); 
-      console.log('plugin unpublished');
-    });
-  });
+  plugman.unpublish(new Array(cli_opts.plugin));
 }
 else if (cli_opts.search) {
-  registry.use(config.registry, function(err) {
-    registry.search(cli_opts.search.split(','), function(err, plugins) {
-      if(err) return console.log(err); 
-      for(var plugin in plugins) {
-        console.log(plugins[plugin].name, '-', plugins[plugin].description || 'no description
provided'); 
-      }
-    });
-  });
+  plugman.search(cli_opts.search.split(',');
 }
 else if(cli_opts.install) {
     var cli_variables = {}

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/bf975133/plugman.js
----------------------------------------------------------------------
diff --git a/plugman.js b/plugman.js
index 755204f..ac0ffec 100755
--- a/plugman.js
+++ b/plugman.js
@@ -23,5 +23,9 @@ module.exports = {
     uninstall:require('./src/uninstall'),
     fetch:    require('./src/fetch'),
     prepare:  require('./src/prepare'),
+    adduser:  require('./src/adduser'),
+    publish:  require('./src/publish'),
+    unpublish:require('./src/unpublish'),
+    search:   require('./src/search'),
     config_changes:require('./src/util/config-changes')
 };

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/bf975133/spec/adduser.spec.js
----------------------------------------------------------------------
diff --git a/spec/adduser.spec.js b/spec/adduser.spec.js
new file mode 100644
index 0000000..563592d
--- /dev/null
+++ b/spec/adduser.spec.js
@@ -0,0 +1,13 @@
+var adduser = require('../src/adduser'),
+    config = require('../config'),
+    registry = require('plugman-registry');
+
+describe('adduser', function() {
+    it('should add a user', function() {
+        var sUse = spyOn(registry, 'use').andCallThrough();
+        var sAddUser = spyOn(registry, 'adduser');
+        adduser();
+        expect(sUse).toHaveBeenCalledWith(config.registry, jasmine.any(Function));
+        expect(sAddUser).toHaveBeenCalled();
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/bf975133/spec/publish.spec.js
----------------------------------------------------------------------
diff --git a/spec/publish.spec.js b/spec/publish.spec.js
new file mode 100644
index 0000000..3a253e7
--- /dev/null
+++ b/spec/publish.spec.js
@@ -0,0 +1,13 @@
+var publish = require('../src/publish'),
+    config = require('../config'),
+    registry = require('plugman-registry');
+
+describe('publish', function() {
+    it('should publish a plugin', function() {
+        var sUse = spyOn(registry, 'use').andCallThrough(); 
+        var sPublish = spyOn(registry, 'publish');
+        publish(new Array('/path/to/myplugin'));
+        expect(sUse).toHaveBeenCalledWith(config.registry, jasmine.any(Function));
+        expect(sPublish).toHaveBeenCalledWith(['/path/to/myplugin'], jasmine.any(Function));
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/bf975133/spec/search.spec.js
----------------------------------------------------------------------
diff --git a/spec/search.spec.js b/spec/search.spec.js
new file mode 100644
index 0000000..f708854
--- /dev/null
+++ b/spec/search.spec.js
@@ -0,0 +1,13 @@
+var search = require('../src/search'),
+    config = require('../config'),
+    registry = require('plugman-registry');
+
+describe('search', function() {
+    it('should search a plugin', function() {
+        var sUse = spyOn(registry, 'use').andCallThrough();
+        var sSearch = spyOn(registry, 'search');
+        search(new Array('myplugin', 'keyword'));
+        expect(sUse).toHaveBeenCalledWith(config.registry, jasmine.any(Function));
+        expect(sSearch).toHaveBeenCalledWith(['myplugin', 'keyword'], jasmine.any(Function));
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/bf975133/spec/unpublish.spec.js
----------------------------------------------------------------------
diff --git a/spec/unpublish.spec.js b/spec/unpublish.spec.js
new file mode 100644
index 0000000..207804d
--- /dev/null
+++ b/spec/unpublish.spec.js
@@ -0,0 +1,13 @@
+var unpublish = require('../src/unpublish'),
+    config = require('../config'),
+    registry = require('plugman-registry');
+
+describe('unpublish', function() {
+    it('should unpublish a plugin', function() {
+        var sUse = spyOn(registry, 'use').andCallThrough();
+        var sUnpublish = spyOn(registry, 'unpublish');
+        unpublish(new Array('myplugin@0.0.1'));
+        expect(sUse).toHaveBeenCalledWith(config.registry, jasmine.any(Function));
+        expect(sUnpublish).toHaveBeenCalledWith(['myplugin@0.0.1'], jasmine.any(Function));
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/bf975133/src/adduser.js
----------------------------------------------------------------------
diff --git a/src/adduser.js b/src/adduser.js
new file mode 100644
index 0000000..da7cf4e
--- /dev/null
+++ b/src/adduser.js
@@ -0,0 +1,11 @@
+var registry = require('plugman-registry')
+  , config = require('../config');
+
+module.exports = function() {
+  registry.use(config.registry, function(err) {
+    registry.adduser(null, function(err) {
+      if(err) return console.log(err);
+      console.log('user added');
+    });
+  });
+}

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/bf975133/src/publish.js
----------------------------------------------------------------------
diff --git a/src/publish.js b/src/publish.js
new file mode 100644
index 0000000..234de15
--- /dev/null
+++ b/src/publish.js
@@ -0,0 +1,11 @@
+var registry = require('plugman-registry')
+  , config = require('../config');
+
+module.exports = function(plugin) {
+  registry.use(config.registry, function(err) {
+    registry.publish(plugin, function(err, d) {
+      if(err) return console.log('Error publishing plugin', err); 
+      console.log('plugin published');
+    });
+  });
+}

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/bf975133/src/search.js
----------------------------------------------------------------------
diff --git a/src/search.js b/src/search.js
new file mode 100644
index 0000000..2b244b3
--- /dev/null
+++ b/src/search.js
@@ -0,0 +1,13 @@
+var registry = require('plugman-registry')
+  , config = require('../config');
+
+module.exports = function(search_opts) {
+  registry.use(config.registry, function(err) {
+    registry.search(search_opts, function(err, plugins) {
+      if(err) return console.log(err); 
+      for(var plugin in plugins) {
+        console.log(plugins[plugin].name, '-', plugins[plugin].description || 'no description
provided'); 
+      }
+    });
+  });
+}

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/bf975133/src/unpublish.js
----------------------------------------------------------------------
diff --git a/src/unpublish.js b/src/unpublish.js
new file mode 100644
index 0000000..072d740
--- /dev/null
+++ b/src/unpublish.js
@@ -0,0 +1,11 @@
+var registry = require('plugman-registry')
+  , config = require('../config');
+
+module.exports = function(plugin) {
+  registry.use(config.registry, function(err) {
+    registry.unpublish(plugin, function(err, d) {
+      if(err) return console.log('Error unpublishing plugin'); 
+      console.log('plugin unpublished');
+    });
+  });
+}


Mime
View raw message