Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Hi! I fixed some calls to "sys" for you! #1

Open
wants to merge 10 commits into from

3 participants

@node-migrator-bot

Hello Sutto!

I am migrationBot, an open-source bot, and I'm here to help you migrate your codebase to node v0.8!

Did you know that the "sys" module throws an error if your program tries to require it in node v0.8? To help keep your code running, I automatically replaced var sys = require('sys') with var util = require('util').

If you'd like to know more about these changes in node.js, take a look at joyent/node@1582cf#L1R51 and https://github.com/joyent/node/blob/1582cfebd6719b2d2373547994b3dca5c8c569c0/ChangeLog#L51 and http://blog.jit.su/introducing-blakmatrix-and-migratorbot .

As for myself, I was written by your friendly neighborhood node ninjas at Nodejitsu, and you can find them at #nodejitsu on irc.freenode.net or with http://webchat.jit.su .

Enjoy!

--migrationBot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 28, 2011
  1. Bump version

    authored
  2. Add missing dep

    authored
  3. Bump version

    authored
  4. Damn it

    authored
Commits on Jul 29, 2011
  1. Bump version

    authored
  2. Conditional logic: heck yeah

    authored
  3. Bump version

    authored
Commits on Jun 24, 2012
  1. @blakmatrix
This page is out of date. Refresh to see the latest.
View
20 lib/pebble.js
@@ -1,7 +1,7 @@
(function() {
var Pebble, broadcaster, fs, path, redis, sys, web;
path = require('path');
- sys = require('sys');
+ util = require('util');
fs = require('fs');
redis = require('./pebble/redis');
web = require('./pebble/web');
@@ -31,12 +31,12 @@
builtin = require("./pebble/" + name);
return this.add(builtin);
} catch (e) {
- return sys.puts("Unable to add builtin publisher: " + name + " - " + e);
+ return util.puts("Unable to add builtin publisher: " + name + " - " + e);
}
};
Pebble.prototype.run = function() {
var publisher, runningPublishers, _i, _len, _ref;
- sys.puts("Starting pebble...");
+ util.puts("Starting pebble...");
this.redis = new redis(this);
this.web = new web(this);
this.broadcast = new broadcaster(this);
@@ -55,9 +55,9 @@
runningPublishers.push('web');
}
if (runningPublishers.length) {
- return sys.puts("Running the following publishers: " + (runningPublishers.join(', ')));
+ return util.puts("Running the following publishers: " + (runningPublishers.join(', ')));
} else {
- return sys.puts('Not running any publishers.');
+ return util.puts('Not running any publishers.');
}
};
Pebble.prototype.visitableURL = function() {
@@ -150,11 +150,11 @@
return config;
};
Pebble.printOptions = function() {
- sys.puts("Known options:");
- sys.puts("--server, --client, --mode [server,client] - sets the mode of the current pebble-based application.");
- sys.puts("--direct, --pubsub, --broadcaster [direct,pubsub] - sets the broadcaster for the current pebble-based application.");
- sys.puts("--port [port] - sets the http port for the current application.");
- return sys.puts("--host [host] - sets the http host for the current application.");
+ util.puts("Known options:");
+ util.puts("--server, --client, --mode [server,client] - sets the mode of the current pebble-based application.");
+ util.puts("--direct, --pubsub, --broadcaster [direct,pubsub] - sets the broadcaster for the current pebble-based application.");
+ util.puts("--port [port] - sets the http port for the current application.");
+ return util.puts("--host [host] - sets the http host for the current application.");
};
return Pebble;
})();
View
4 lib/pebble/base.js
@@ -1,6 +1,6 @@
(function() {
var Base, sys, uuid;
- sys = require('sys');
+ util = require('util');
uuid = require('node-uuid');
Base = (function() {
Base.prototype.name = "unknown";
@@ -23,7 +23,7 @@
};
Base.prototype.run = function() {
if (this.isEnabled()) {
- sys.puts("Starting publisher: " + this.name);
+ util.puts("Starting publisher: " + this.name);
return this.setup();
}
};
View
12 lib/pebble/redis.js
@@ -2,7 +2,7 @@
var RedisWrapper, redis, sys;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
redis = require('redis');
- sys = require('sys');
+ util = require('util');
RedisWrapper = (function() {
function RedisWrapper(runner) {
this.runner = runner;
@@ -29,7 +29,7 @@
message = key;
key = this.namespace;
}
- sys.puts("Publishing to " + key);
+ util.puts("Publishing to " + key);
return this.redis.publish(key, message);
};
RedisWrapper.prototype.historyKeyFor = function(channel) {
@@ -63,7 +63,7 @@
key = this.historyKeyFor(channel);
return this.redis.lrange(key, 0, this.maxHistory - 1, __bind(function(err, result) {
if (err) {
- sys.puts("Had error getting history for " + key + ": " + err);
+ util.puts("Had error getting history for " + key + ": " + err);
return callback(err);
} else if (!result) {
return callback(true);
@@ -73,8 +73,8 @@
}, this));
};
RedisWrapper.prototype.debugResponse = function(err, result) {
- sys.puts("Error: " + (sys.inspect(err)));
- return sys.puts("Result: " + (sys.inspect(result)));
+ util.puts("Error: " + (util.inspect(err)));
+ return util.puts("Result: " + (util.inspect(result)));
};
RedisWrapper.prototype.publish = function(channel, message) {
var encoded;
@@ -88,7 +88,7 @@
var broadcaster;
broadcaster = this.runner.broadcast;
this.subredis = this.createConnection();
- sys.puts("Subscribing to " + this.pubsubChannel);
+ util.puts("Subscribing to " + this.pubsubChannel);
this.subredis.on("message", function(channel, message) {
var parsed;
parsed = JSON.parse(message);
View
20 lib/pebble/twitter.js
@@ -10,7 +10,7 @@
}, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
NTwitter = require('ntwitter');
Base = require('./base');
- sys = require('sys');
+ util = require('util');
Twitter = (function() {
__extends(Twitter, Base);
function Twitter() {
@@ -20,32 +20,37 @@
Twitter.prototype.setup = function() {
var config;
config = this.config();
- return this.twitter = new NTwitter({
+ this.trackingRegexp = this.buildTrackingRegexp(config.track);
+ this.twitter = new NTwitter({
consumer_key: config.consumer.key,
consumer_secret: config.consumer.secret,
access_token_key: config.access_token.key,
access_token_secret: config.access_token.secret
});
+ return this.startStream();
};
Twitter.prototype.startStream = function() {
- var outer;
+ var config, outer;
outer = this;
+ config = this.config();
return this.twitter.stream('statuses/filter', {
track: config.track
}, __bind(function(stream) {
stream.on('data', function(tweet) {
- return outer.emit('tweet', outer.filtered(tweet));
+ if (tweet.text.match(outer.trackingRegexp)) {
+ return outer.emit('tweet', outer.filtered(tweet));
+ }
});
stream.on('end', function(resp) {
var reconnect;
- sys.puts("Twitter Connection ended, Status code was " + resp.statusCode);
+ util.puts("Twitter Connection ended, Status code was " + resp.statusCode);
reconnect = function() {
return outer.startStream();
};
return setTimeout(reconnect, 10000);
});
return stream.on('error', function(error) {
- return sys.puts("Error in Twitter: " + error.message);
+ return util.puts("Error in Twitter: " + error.message);
});
}, this));
};
@@ -62,6 +67,9 @@
}
};
};
+ Twitter.prototype.buildTrackingRegexp = function(keywords) {
+ return new RegExp("(" + (keywords.join('|')) + ")", 'i');
+ };
return Twitter;
})();
module.exports = Twitter;
View
4 lib/pebble/web.js
@@ -9,7 +9,7 @@
return child;
}, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
express = require('express');
- sys = require('sys');
+ util = require('util');
EventEmitter = require('events').EventEmitter;
Web = (function() {
__extends(Web, EventEmitter);
@@ -72,7 +72,7 @@
}
};
Web.prototype.run = function() {
- sys.puts("Starting and running on port " + this.runner.port);
+ util.puts("Starting and running on port " + this.runner.port);
this.configure();
return this.app.listen(this.runner.port);
};
View
5 package.json
@@ -1,6 +1,6 @@
{
"name": "pebble",
- "version": "1.1.1",
+ "version": "1.1.7",
"description": "pebble is a series of tools for building real time event notifiers / streams.",
"keys": ["realtime", "events", "stream"],
"author": "Darcy Laycock <sutto@sutto.net> (http://blog.ninjahideout.com/)",
@@ -21,7 +21,8 @@
"redis": "~0.6.0",
"node-static": "~0.5.7",
"ejs": "~0.4.3",
- "optimist": "~0.2.6"
+ "optimist": "~0.2.6",
+ "node-uuid": "~1.2.0"
},
"devDependencies": {
"coffee-script": "~1.1.1"
View
9 src/pebble/twitter.coffee
@@ -8,18 +8,22 @@ class Twitter extends Base
setup: ->
config = @config()
+ @trackingRegexp = @buildTrackingRegexp config.track
@twitter = new NTwitter({
consumer_key: config.consumer.key
consumer_secret: config.consumer.secret
access_token_key: config.access_token.key
access_token_secret: config.access_token.secret
})
+ @startStream()
startStream: ->
outer = this
+ config = @config()
@twitter.stream 'statuses/filter', track: config.track, (stream) =>
stream.on 'data', (tweet) ->
- outer.emit 'tweet', outer.filtered tweet
+ if tweet.text.match outer.trackingRegexp
+ outer.emit 'tweet', outer.filtered tweet
stream.on 'end', (resp) ->
sys.puts "Twitter Connection ended, Status code was #{resp.statusCode}"
reconnect = -> outer.startStream()
@@ -37,5 +41,8 @@ class Twitter extends Base
name: tweet.user.name
profile_image_url: tweet.user.profile_image_url
screen_name: tweet.user.screen_name
+
+ buildTrackingRegexp: (keywords) ->
+ new RegExp "(#{keywords.join('|')})", 'i'
module.exports = Twitter
Something went wrong with that request. Please try again.