

var redis = require('redis'),
    haibu = require('../../haibu');

var pubsub = exports

pubsub.init = function (options, callback) {

  //
  // since Eventemitter2 is intended to be drop in compatible with EventEmitter,
  // it does not emit the event names, because EventEmitter doesn't

  var redisConf = (options && options.config && options.config.cache) || {host: 'localhost', port: 6379}

  var client = redis.createClient(redisConf.port,redisConf.host)

  var _emit = haibu.emit
  haibu.emit = function () {
    var args = new Array(arguments.length),
        i = arguments.length;
    while (i --) { args[i] = arguments[i]; }

    _emit.apply(haibu, args)
    client.publish(args[0], JSON.stringify(args.slice(1)))
  }

  if(redisConf.auth) {
    client.auth(redisConf.auth, callback)
  } else
    callback()

//  haibu.onAny(console.error)


}

pubsub.name = 'pubsub'
@@ -82,16 +82,17 @@
  exports
+;
 %0A%0Apubsub
@@ -284,16 +284,21 @@
  doesn't
+%0A  //
 %0A%0A  var 
@@ -395,16 +395,17 @@
 t: 6379%7D
+;
 %0A%0A  var 
@@ -462,16 +462,17 @@
 nf.host)
+;
 %0A%0A  var 
@@ -489,16 +489,18 @@
 ibu.emit
+;%0A
 %0A  haibu
@@ -669,16 +669,17 @@
 u, args)
+;
 %0A    cli
@@ -729,20 +729,22 @@
 ice(1)))
+;
 %0A  %7D
+;
 %0A%0A  if(r
@@ -801,16 +801,17 @@
 allback)
+;
 %0A  %7D els
@@ -811,16 +811,18 @@
   %7D else
+ %7B
 %0A    cal
@@ -832,42 +832,13 @@
 ck()
-%0A%0A//  haibu.onAny(console.error)%0A%0A
+;%0A  %7D
 %0A%7D%0A%0A
@@ -859,8 +859,9 @@
 'pubsub'
+;

fix ; for nodejitsu style