Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Hi! I fixed some code for you! #2

Open
wants to merge 10 commits into from

3 participants

@node-migrator-bot

Hi!

I am migrationBot

Did you know that path.{exists,existsSync} was moved to fs.{exists,existsSync}, and that tty.setRawMode(mode) was moved to tty.ReadStream#setRawMode() (i.e. process.stdin.setRawMode()) in node v0.8.0? Read more @API changes between v0.6 and v0.8

I automatically made some changes I think will help you migrate your codebase to node v0.8.0, please review these changes and merge them if you feel they are useful, If they are not you can ignore this Pull Request.

For backwards compatibility please use something like fs.existsSync || (fs.existsSync = path.existsSync);, fs.exists || (fs.exists = path.exists);, and tty.setRawMode || (tty.setRawMode = process.stdin.setRawMode); respectively.

Have a Nice Day!

--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 Jul 7, 2012
  1. @blakmatrix
This page is out of date. Refresh to see the latest.
View
2  Cakefile
@@ -11,7 +11,7 @@ run = (args, cb) ->
cb() if typeof cb is 'function'
isDirectory = (f) ->
- path.existsSync(f) and fs.statSync(f).isDirectory()
+ fs.existsSync(f) and fs.statSync(f).isDirectory()
buildUnder = (input, output) ->
files = fs.readdirSync input
View
14 lib/pebble/twitter.js
@@ -20,21 +20,26 @@
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;
@@ -62,6 +67,9 @@
}
};
};
+ Twitter.prototype.buildTrackingRegexp = function(keywords) {
+ return new RegExp("(" + (keywords.join('|')) + ")", 'i');
+ };
return Twitter;
})();
module.exports = Twitter;
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.