intridea-tweetstream 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/tweetstream/client.rb +22 -9
- data/lib/tweetstream/daemon.rb +1 -2
- data/lib/tweetstream/hash.rb +2 -3
- data/spec/tweetstream/client_spec.rb +5 -0
- metadata +2 -3
- data/lib/tracker.rb +0 -12
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/lib/tweetstream/client.rb
CHANGED
@@ -65,9 +65,9 @@ module TweetStream
|
|
65
65
|
def track(*keywords, &block)
|
66
66
|
query_params = keywords.pop if keywords.last.is_a?(::Hash)
|
67
67
|
query_params ||= {}
|
68
|
-
|
68
|
+
filter(query_params.merge(:track => keywords), &block)
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
# Returns public statuses from or in reply to a set of users. Mentions
|
72
72
|
# ("Hello @user!") and implicit replies ("@user Hello!" created without
|
73
73
|
# pressing the reply "swoosh") are not matched. Requires integer user
|
@@ -75,11 +75,26 @@ module TweetStream
|
|
75
75
|
def follow(*user_ids, &block)
|
76
76
|
query_params = user_ids.pop if user_ids.last.is_a?(::Hash)
|
77
77
|
query_params ||= {}
|
78
|
-
|
78
|
+
filter(query_params.merge(:follow => user_ids), &block)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Make a call to the statuses/filter method of the Streaming API,
|
82
|
+
# you may provide <tt>:follow</tt>, <tt>:track</tt> or both as options
|
83
|
+
# to follow the tweets of specified users or track keywords. This
|
84
|
+
# method is provided separately for cases when it would conserve the
|
85
|
+
# number of HTTP connections to combine track and follow.
|
86
|
+
def filter(query_params = {}, &block)
|
87
|
+
[:follow, :track].each do |param|
|
88
|
+
if query_params[param].is_a?(Array)
|
89
|
+
query_params[param] = query_params[param].collect{|q| q.to_s}.join(',')
|
90
|
+
elsif query_params[param]
|
91
|
+
query_params[param] = query_params[param].to_s
|
92
|
+
end
|
93
|
+
end
|
94
|
+
start('statuses/filter', query_params, &block)
|
79
95
|
end
|
80
96
|
|
81
|
-
#:nodoc:
|
82
|
-
def start(path, query_parameters = {}, &block)
|
97
|
+
def start(path, query_parameters = {}, &block) #:nodoc:
|
83
98
|
uri = build_uri(path, query_parameters)
|
84
99
|
|
85
100
|
Yajl::HttpStream.get(uri, :symbolize_keys => true) do |hash|
|
@@ -89,13 +104,11 @@ module TweetStream
|
|
89
104
|
|
90
105
|
protected
|
91
106
|
|
92
|
-
#:nodoc:
|
93
|
-
def build_uri(path, query_parameters = {})
|
107
|
+
def build_uri(path, query_parameters = {}) #:nodoc:
|
94
108
|
URI.parse("http://#{self.username}:#{self.password}@stream.twitter.com/1/#{path}.json#{build_query_parameters(query_parameters)}")
|
95
109
|
end
|
96
110
|
|
97
|
-
#:nodoc:
|
98
|
-
def build_query_parameters(query)
|
111
|
+
def build_query_parameters(query) #:nodoc:
|
99
112
|
return '' unless query && query.is_a?(::Hash) && query.size > 0
|
100
113
|
pairs = []
|
101
114
|
|
data/lib/tweetstream/daemon.rb
CHANGED
@@ -31,8 +31,7 @@ class TweetStream::Daemon < TweetStream::Client
|
|
31
31
|
super(user, pass)
|
32
32
|
end
|
33
33
|
|
34
|
-
#:nodoc:
|
35
|
-
def start(path, query_parameters = {}, &block)
|
34
|
+
def start(path, query_parameters = {}, &block) #:nodoc:
|
36
35
|
Daemons.run_proc(@app_name || 'tweetstream', :multiple => true) do
|
37
36
|
super(path, query_parameters, &block)
|
38
37
|
end
|
data/lib/tweetstream/hash.rb
CHANGED
@@ -107,6 +107,11 @@ describe TweetStream::Client do
|
|
107
107
|
@client.should_receive(:start).once.with('statuses/filter', :follow => '123,456')
|
108
108
|
@client.follow(123, 456)
|
109
109
|
end
|
110
|
+
|
111
|
+
it '#filter should make a call to "statuses/filter" with the query params provided' do
|
112
|
+
@client.should_receive(:start).once.with('statuses/filter', :follow => '123')
|
113
|
+
@client.filter(:follow => 123)
|
114
|
+
end
|
110
115
|
end
|
111
116
|
|
112
117
|
describe '#track' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: intridea-tweetstream
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bleigh
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-23 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -56,7 +56,6 @@ files:
|
|
56
56
|
- README.rdoc
|
57
57
|
- Rakefile
|
58
58
|
- VERSION
|
59
|
-
- lib/tracker.rb
|
60
59
|
- lib/tweetstream.rb
|
61
60
|
- lib/tweetstream/client.rb
|
62
61
|
- lib/tweetstream/daemon.rb
|
data/lib/tracker.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'tweetstream'
|
3
|
-
require 'logger'
|
4
|
-
|
5
|
-
File.open('tracker.log', File::WRONLY | File::APPEND | File::CREAT) do |file|
|
6
|
-
log = Logger.new(file)
|
7
|
-
|
8
|
-
TweetStream::Daemon.new('mbleigh','hotmail', 'tracker').track('fail') do |status|
|
9
|
-
log.info "[#{status.user.screen_name}] #{status.text}"
|
10
|
-
puts "[#{status.user.screen_name}] #{status.text}"
|
11
|
-
end
|
12
|
-
end
|