Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

changes

  • Loading branch information...
commit db7bf9b1bf8b106249d4ba137e81612573580ccc 1 parent ae79178
Dan Zajdband authored
3  Makefile
View
@@ -8,5 +8,8 @@ run-tests:
test:
@$(MAKE) NODE_PATH=lib TESTS="$(ALL_TESTS)" run-tests
+test-streaming:
+ @$(MAKE) NODE_PATH=lib TESTS="test/streaming.test.js" run-tests
+
.PHONY: test
13 lib/request.js
View
@@ -11,6 +11,7 @@ var OAuth = require('oauth').OAuth
, config = require('./config.json');
require('superagent-oauth')(request);
+require('superagent-stream')(request);
/*
* Stream object constructor
@@ -72,16 +73,20 @@ exports.oauth = function(params){
*/
exports.request = function(method, url, params, is_stream, callback) {
- request(method, url)
+ var req = request(method, url);
+ if(is_stream) req.stream();
+ req
.sign(this.oa, this.oa.access_token_key, this.oa.access_token_secret)
- .buffer(is_stream)
.send(params)
.set('Accept', '*/*')
.set('User-Agent', 'Tuiter')
.set('Accept-Encoding', 'deflate, gzip')
.end(function(res){
- console.log('a');
- if(res.ok) callback(null, res.body);
+ if(res.ok && is_stream) {
+ callback(null, res);
+ } else if(res.ok) {
+ callback(null, res.body);
+ }
else callback(res.text, res.body);
});
};
2  lib/tuiter.js
View
@@ -24,7 +24,7 @@ function Tuiter(oauth_params){
* Version
*/
-Tuiter.version = '0.1.5';
+Tuiter.version = '0.2.0';
module.exports = function(oauth_params){
8 test/keys.json
View
@@ -1,6 +1,6 @@
{
- "consumer_key" : ""
- , "consumer_secret" : ""
- , "access_token_key" : ""
- , "access_token_secret" : ""
+ "consumer_key" : "LO0jO1z0MBd0RFFtjoojZA"
+ , "consumer_secret" : "KuBUnXMPQGO4pISCfToLMkATjywwlOKWX8ZcRSk8"
+ , "access_token_key" : "308711490-wfCB1pxPbI7DqYKIuvN26scHE6fE4bEoo22l2MK9"
+ , "access_token_secret" : "K8UtzLxLZQK2BPR0pwKMT5VEH5RtbXQHDT61EKjX7YY"
}
4 test/streaming.test.js
View
@@ -19,10 +19,10 @@ describe('streaming', function(){
describe('#filter()', function(){
it('should stream tweets about twitter', function(done){
var tweetsReceived = 0
- , timeout = 5000
+ , timeout = 3500
, stream;
setTimeout(function(){
- stream.destroy();
+ stream.emit('end');
var listeners = stream.listeners('tweet').length === 0;
listeners.should.be.ok;
done();
Please sign in to comment.
Something went wrong with that request. Please try again.