t 0.8.3 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/t/stream.rb ADDED
@@ -0,0 +1,91 @@
1
+ require 't/printable'
2
+ require 't/rcfile'
3
+ require 'thor'
4
+ require 'tweetstream'
5
+
6
+ module T
7
+ class Stream < Thor
8
+ include T::Printable
9
+
10
+ def initialize(*)
11
+ super
12
+ @rcfile = RCFile.instance
13
+ end
14
+
15
+ desc "all", "Stream a random sample of all Tweets (Control-C to stop)"
16
+ def all
17
+ client.on_timeline_status do |status|
18
+ print_status(status)
19
+ end
20
+ Signal.trap("TERM") do
21
+ client.stop
22
+ shutdown
23
+ end
24
+ client.sample
25
+ end
26
+
27
+ desc "matrix", "Unfortunately, no one can be told what the Matrix is. You have to see it for yourself."
28
+ def matrix
29
+ client.on_timeline_status do |status|
30
+ print("#{Thor::Shell::Color::BOLD}#{Thor::Shell::Color::GREEN}#{Thor::Shell::Color::ON_BLACK}#{status.text.gsub("\n", '')}#{Thor::Shell::Color::CLEAR}")
31
+ end
32
+ Signal.trap("TERM") do
33
+ client.stop
34
+ shutdown
35
+ end
36
+ client.sample
37
+ end
38
+
39
+ desc "search KEYWORD [KEYWORD...]", "Stream Tweets that contain specified keywords, joined with logical ORs (Control-C to stop)"
40
+ def search(keyword, *keywords)
41
+ keywords.unshift(keyword)
42
+ client.on_timeline_status do |status|
43
+ print_status(status)
44
+ end
45
+ Signal.trap("TERM") do
46
+ client.stop
47
+ shutdown
48
+ end
49
+ client.track(keywords)
50
+ end
51
+
52
+ desc "timeline", "Stream your timeline (Control-C to stop)"
53
+ def timeline
54
+ client.on_timeline_status do |status|
55
+ print_status(status)
56
+ end
57
+ Signal.trap("TERM") do
58
+ client.stop
59
+ shutdown
60
+ end
61
+ client.userstream
62
+ end
63
+
64
+ desc "users SCREEN_NAME [SCREEN_NAME...]", "Stream Tweets either from or in reply to specified users (Control-C to stop)"
65
+ def users(screen_name, *screen_names)
66
+ screen_names.unshift(screen_name)
67
+ client.on_timeline_status do |status|
68
+ print_status(status)
69
+ end
70
+ Signal.trap("TERM") do
71
+ client.stop
72
+ shutdown
73
+ end
74
+ client.follow(screen_names)
75
+ end
76
+
77
+ private
78
+
79
+ def client
80
+ return @client if @client
81
+ @rcfile.path = options['profile'] if options['profile']
82
+ @client = TweetStream::Client.new(
83
+ :consumer_key => @rcfile.active_consumer_key,
84
+ :consumer_secret => @rcfile.active_consumer_secret,
85
+ :oauth_token => @rcfile.active_token,
86
+ :oauth_token_secret => @rcfile.active_secret
87
+ )
88
+ end
89
+
90
+ end
91
+ end
data/lib/t/version.rb CHANGED
@@ -8,12 +8,12 @@ module T
8
8
 
9
9
  # @return [Integer]
10
10
  def self.minor
11
- 8
11
+ 9
12
12
  end
13
13
 
14
14
  # @return [Integer]
15
15
  def self.patch
16
- 3
16
+ 0
17
17
  end
18
18
 
19
19
  # @return [String, NilClass]
data/spec/cli_spec.rb CHANGED
@@ -722,7 +722,6 @@ ID Since Tweets Favorites Listed Following Followers Scre...
722
722
  $stdout.string.should =~ /@natevillegas/
723
723
  $stdout.string.should =~ /RT @gelobautista #riordan RT @WilI_Smith: Yesterday is history\. Tomorrow is a /
724
724
  $stdout.string.should =~ /mystery\. Today is a gift\. That's why it's called the present\./
725
- $stdout.string.should =~ /7 months ago/
726
725
  end
727
726
  context "--csv" do
728
727
  before do
@@ -744,7 +743,7 @@ ID,Posted at,Screen name,Text
744
743
  194546876782092291,2011-04-23 22:02:44 +0000,skilldrick,@shinypb Well played :) @hoverbird
745
744
  194546811480969217,2011-04-23 22:02:29 +0000,sam,"Can someone project the date that I'll get a 27"" retina display?"
746
745
  194546738810458112,2011-04-23 22:02:11 +0000,shinypb,"@skilldrick @hoverbird Wow, I didn't even know they *had* TV in Britain."
747
- 194546727670390784,2011-04-23 22:02:09 +0000,bartt,"@noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come."
746
+ 194546727670390784,2011-04-23 22:02:09 +0000,bartt,"@noahlt @gaarf Yup, now owning @twitter -> FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come."
748
747
  194546649203347456,2011-04-23 22:01:50 +0000,skilldrick,"@hoverbird @shinypb You guys must be soooo old, I don't remember the words to the duck tales intro at all."
749
748
  194546583608639488,2011-04-23 22:01:34 +0000,sean,@mep Thanks for coming by. Was great to have you.
750
749
  194546388707717120,2011-04-23 22:00:48 +0000,hoverbird,"@shinypb @trammell it's all suck a ""duck blur"" sometimes."
@@ -1703,7 +1702,6 @@ ID Created at Slug Members Subscribers Mode ...
1703
1702
  $stdout.string.should =~ /@natevillegas/
1704
1703
  $stdout.string.should =~ /RT @gelobautista #riordan RT @WilI_Smith: Yesterday is history\. Tomorrow is a /
1705
1704
  $stdout.string.should =~ /mystery\. Today is a gift\. That's why it's called the present\./
1706
- $stdout.string.should =~ /7 months ago/
1707
1705
  end
1708
1706
  context "--csv" do
1709
1707
  before do
@@ -1725,7 +1723,7 @@ ID,Posted at,Screen name,Text
1725
1723
  194546876782092291,2011-04-23 22:02:44 +0000,skilldrick,@shinypb Well played :) @hoverbird
1726
1724
  194546811480969217,2011-04-23 22:02:29 +0000,sam,"Can someone project the date that I'll get a 27"" retina display?"
1727
1725
  194546738810458112,2011-04-23 22:02:11 +0000,shinypb,"@skilldrick @hoverbird Wow, I didn't even know they *had* TV in Britain."
1728
- 194546727670390784,2011-04-23 22:02:09 +0000,bartt,"@noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come."
1726
+ 194546727670390784,2011-04-23 22:02:09 +0000,bartt,"@noahlt @gaarf Yup, now owning @twitter -> FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come."
1729
1727
  194546649203347456,2011-04-23 22:01:50 +0000,skilldrick,"@hoverbird @shinypb You guys must be soooo old, I don't remember the words to the duck tales intro at all."
1730
1728
  194546583608639488,2011-04-23 22:01:34 +0000,sean,@mep Thanks for coming by. Was great to have you.
1731
1729
  194546388707717120,2011-04-23 22:00:48 +0000,hoverbird,"@shinypb @trammell it's all suck a ""duck blur"" sometimes."
@@ -1972,7 +1970,6 @@ ID Posted at Screen name Text
1972
1970
  $stdout.string.should =~ /@natevillegas/
1973
1971
  $stdout.string.should =~ /RT @gelobautista #riordan RT @WilI_Smith: Yesterday is history\. Tomorrow is a /
1974
1972
  $stdout.string.should =~ /mystery\. Today is a gift\. That's why it's called the present\./
1975
- $stdout.string.should =~ /7 months ago/
1976
1973
  end
1977
1974
  end
1978
1975
  context "--csv" do
@@ -1995,7 +1992,7 @@ ID,Posted at,Screen name,Text
1995
1992
  194546876782092291,2011-04-23 22:02:44 +0000,skilldrick,@shinypb Well played :) @hoverbird
1996
1993
  194546811480969217,2011-04-23 22:02:29 +0000,sam,"Can someone project the date that I'll get a 27"" retina display?"
1997
1994
  194546738810458112,2011-04-23 22:02:11 +0000,shinypb,"@skilldrick @hoverbird Wow, I didn't even know they *had* TV in Britain."
1998
- 194546727670390784,2011-04-23 22:02:09 +0000,bartt,"@noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come."
1995
+ 194546727670390784,2011-04-23 22:02:09 +0000,bartt,"@noahlt @gaarf Yup, now owning @twitter -> FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come."
1999
1996
  194546649203347456,2011-04-23 22:01:50 +0000,skilldrick,"@hoverbird @shinypb You guys must be soooo old, I don't remember the words to the duck tales intro at all."
2000
1997
  194546583608639488,2011-04-23 22:01:34 +0000,sean,@mep Thanks for coming by. Was great to have you.
2001
1998
  194546388707717120,2011-04-23 22:00:48 +0000,hoverbird,"@shinypb @trammell it's all suck a ""duck blur"" sometimes."
@@ -2332,7 +2329,6 @@ ID Since Tweets Favorites Listed Following Followers Scre...
2332
2329
  $stdout.string.should =~ /@natevillegas/
2333
2330
  $stdout.string.should =~ /RT @gelobautista #riordan RT @WilI_Smith: Yesterday is history\. Tomorrow is a /
2334
2331
  $stdout.string.should =~ /mystery\. Today is a gift\. That's why it's called the present\./
2335
- $stdout.string.should =~ /7 months ago/
2336
2332
  end
2337
2333
  end
2338
2334
  context "--csv" do
@@ -2355,7 +2351,7 @@ ID,Posted at,Screen name,Text
2355
2351
  194546876782092291,2011-04-23 22:02:44 +0000,skilldrick,@shinypb Well played :) @hoverbird
2356
2352
  194546811480969217,2011-04-23 22:02:29 +0000,sam,"Can someone project the date that I'll get a 27"" retina display?"
2357
2353
  194546738810458112,2011-04-23 22:02:11 +0000,shinypb,"@skilldrick @hoverbird Wow, I didn't even know they *had* TV in Britain."
2358
- 194546727670390784,2011-04-23 22:02:09 +0000,bartt,"@noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come."
2354
+ 194546727670390784,2011-04-23 22:02:09 +0000,bartt,"@noahlt @gaarf Yup, now owning @twitter -> FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come."
2359
2355
  194546649203347456,2011-04-23 22:01:50 +0000,skilldrick,"@hoverbird @shinypb You guys must be soooo old, I don't remember the words to the duck tales intro at all."
2360
2356
  194546583608639488,2011-04-23 22:01:34 +0000,sean,@mep Thanks for coming by. Was great to have you.
2361
2357
  194546388707717120,2011-04-23 22:00:48 +0000,hoverbird,"@shinypb @trammell it's all suck a ""duck blur"" sometimes."
@@ -2812,7 +2808,7 @@ Name Erik Michaels-Ober
2812
2808
  Bio A mind forever voyaging through strange seas of thought, alone.
2813
2809
  Location San Francisco
2814
2810
  Status Not following
2815
- Last update RT @tenderlove: [ANN] sqlite3-ruby =&gt; sqlite3 (10 months ago)
2811
+ Last update RT @tenderlove: [ANN] sqlite3-ruby => sqlite3 (10 months ago)
2816
2812
  Since Jul 16 2007
2817
2813
  Tweets 3,479
2818
2814
  Favorites 1,040
@@ -2830,7 +2826,7 @@ URL https://github.com/sferik
2830
2826
  @cli.whois("sferik")
2831
2827
  $stdout.string.should == <<-eos
2832
2828
  ID,Verified,Name,Screen name,Bio,Location,Following,Last update,Lasted updated at,Since,Tweets,Favorites,Listed,Following,Followers,URL
2833
- 7505382,false,Erik Michaels-Ober,sferik,"A mind forever voyaging through strange seas of thought, alone.",San Francisco,false,RT @tenderlove: [ANN] sqlite3-ruby =&gt; sqlite3,2011-01-16 21:38:25 +0000,2007-07-16 12:59:01 +0000,3479,1040,41,197,1048,https://github.com/sferik
2829
+ 7505382,false,Erik Michaels-Ober,sferik,"A mind forever voyaging through strange seas of thought, alone.",San Francisco,false,RT @tenderlove: [ANN] sqlite3-ruby => sqlite3,2011-01-16 21:38:25 +0000,2007-07-16 12:59:01 +0000,3479,1040,41,197,1048,https://github.com/sferik
2834
2830
  eos
2835
2831
  end
2836
2832
  end
data/spec/list_spec.rb CHANGED
@@ -365,7 +365,6 @@ ID Since Tweets Favorites Listed Following Followers Scre...
365
365
  $stdout.string.should =~ /@natevillegas/
366
366
  $stdout.string.should =~ /RT @gelobautista #riordan RT @WilI_Smith: Yesterday is history\. Tomorrow is a /
367
367
  $stdout.string.should =~ /mystery\. Today is a gift\. That's why it's called the present\./
368
- $stdout.string.should =~ /7 months ago/
369
368
  end
370
369
  context "--csv" do
371
370
  before do
@@ -387,7 +386,7 @@ ID,Posted at,Screen name,Text
387
386
  194546876782092291,2011-04-23 22:02:44 +0000,skilldrick,@shinypb Well played :) @hoverbird
388
387
  194546811480969217,2011-04-23 22:02:29 +0000,sam,"Can someone project the date that I'll get a 27"" retina display?"
389
388
  194546738810458112,2011-04-23 22:02:11 +0000,shinypb,"@skilldrick @hoverbird Wow, I didn't even know they *had* TV in Britain."
390
- 194546727670390784,2011-04-23 22:02:09 +0000,bartt,"@noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come."
389
+ 194546727670390784,2011-04-23 22:02:09 +0000,bartt,"@noahlt @gaarf Yup, now owning @twitter -> FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come."
391
390
  194546649203347456,2011-04-23 22:01:50 +0000,skilldrick,"@hoverbird @shinypb You guys must be soooo old, I don't remember the words to the duck tales intro at all."
392
391
  194546583608639488,2011-04-23 22:01:34 +0000,sean,@mep Thanks for coming by. Was great to have you.
393
392
  194546388707717120,2011-04-23 22:00:48 +0000,hoverbird,"@shinypb @trammell it's all suck a ""duck blur"" sometimes."
data/spec/search_spec.rb CHANGED
@@ -34,23 +34,8 @@ describe T::Search do
34
34
  end
35
35
  it "should have the correct output" do
36
36
  @search.all("twitter")
37
- $stdout.string.should == <<-eos
38
- JessRoveel: Pondre lo mas importante de Hamlet en Twitter para recordarlo mejor :D (7 months ago)
39
- lauravgeest: Twitter doet het al 7 uur niet meer (7 months ago)
40
- Jenny_Bearx333: I keep thinking that twitter is @instagram , and therefore double tap all the pics I like... #NotWorking (7 months ago)
41
- misspoxtonX: RT @jordantaylorhi: twitter friends &gt; twats at school (7 months ago)
42
- PatrickBrickman: RT @zeus30hightower: Too all Bama fans and followers my cousin mark Barron doesn't have a twitter so please disregard any tweets from that user (7 months ago)
43
- KolonelX: Ik refresh twitter op me telefoon terwijl ik tweetdeck voor me open heb staan (7 months ago)
44
- VLGPRLG5: @mikeyway and you too RT @NimcyGD: @gerardway Get your ass back to twitter, okay? :3 (7 months ago)
45
- xRhiBabyx: Trying to persuade the boyf to get on twitter and failing. Help? @holly_haime @Ckwarburton @samwarburton_ @chrishaime @rowloboy (7 months ago)
46
- juliotrv: RT @lookinglassbr: Lançamentos outono-inverno 2012...CONFIRA em http://t.co/YAk8OXp7 http://t.co/fmmrVrbG (7 months ago)
47
- shanleyaustin27: RT @caaammmmi: @shanleyaustin27 .....and this hahahahaa http://t.co/wzCMx6ZU (7 months ago)
48
- Dame_Valuta: RT @Paiser10: Great @chelseafc training at Nou Camp! #cfc http://t.co/k00TnRyR (7 months ago)
49
- miss_indyiah: smh, @IndianaHustle done turned into a twitter addict..fuck goin on lol ? (7 months ago)
50
- CAROLINEWOLLER: RT @Mark_Ingram28: To all Bama fans and followers, please unfollow and pay no attention to any user posing to be Mark Barron. My bro doesn't have a twitter! (7 months ago)
51
- shelbytrenchdww: RT @The90sLife: Admit it, we all have a cabinet that looks like this. http://t.co/gQEkQw5G (7 months ago)
52
- kabos84: RT @JF_q8: بالله عليكم ،، مو عيب !!! .. http://t.co/e29GV7Ow (7 months ago)
53
- eos
37
+ $stdout.string.should =~ /@JessRoveel/
38
+ $stdout.string.should =~ /Pondre lo mas importante de Hamlet en Twitter para recordarlo mejor :D/
54
39
  end
55
40
  context "--csv" do
56
41
  before do
@@ -63,7 +48,7 @@ ID,Posted at,Screen name,Text
63
48
  194521262415032320,2011-04-23 20:20:57 +0000,JessRoveel,Pondre lo mas importante de Hamlet en Twitter para recordarlo mejor :D
64
49
  194521262326951936,2011-04-23 20:20:57 +0000,lauravgeest,Twitter doet het al 7 uur niet meer
65
50
  194521262234669056,2011-04-23 20:20:57 +0000,Jenny_Bearx333,"I keep thinking that twitter is @instagram , and therefore double tap all the pics I like... #NotWorking"
66
- 194521262138204160,2011-04-23 20:20:57 +0000,misspoxtonX,RT @jordantaylorhi: twitter friends &gt; twats at school
51
+ 194521262138204160,2011-04-23 20:20:57 +0000,misspoxtonX,RT @jordantaylorhi: twitter friends > twats at school
67
52
  194521262134001665,2011-04-23 20:20:57 +0000,PatrickBrickman,RT @zeus30hightower: Too all Bama fans and followers my cousin mark Barron doesn't have a twitter so please disregard any tweets from that user
68
53
  194521262129811456,2011-04-23 20:20:57 +0000,KolonelX,Ik refresh twitter op me telefoon terwijl ik tweetdeck voor me open heb staan
69
54
  194521261852995586,2011-04-23 20:20:57 +0000,VLGPRLG5,"@mikeyway and you too RT @NimcyGD: @gerardway Get your ass back to twitter, okay? :3"
@@ -145,9 +130,8 @@ ID Posted at Screen name Text
145
130
  it "should have the correct output" do
146
131
  @search.favorites("twitter")
147
132
  $stdout.string.should =~ /@bartt/
148
- $stdout.string.should =~ /@noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons\. Lot’s/
133
+ $stdout.string.should =~ /@noahlt @gaarf Yup, now owning @twitter -> FB from FE to daemons\. Lot’s/
149
134
  $stdout.string.should =~ /fun\. Expect improvements in the weeks to come\./
150
- $stdout.string.should =~ /7 months ago/
151
135
  end
152
136
  context "--csv" do
153
137
  before do
@@ -157,7 +141,7 @@ ID Posted at Screen name Text
157
141
  @search.favorites("twitter")
158
142
  $stdout.string.should == <<-eos
159
143
  ID,Posted at,Screen name,Text
160
- 194546727670390784,2011-04-23 22:02:09 +0000,bartt,"@noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come."
144
+ 194546727670390784,2011-04-23 22:02:09 +0000,bartt,"@noahlt @gaarf Yup, now owning @twitter -> FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come."
161
145
  eos
162
146
  end
163
147
  end
@@ -209,9 +193,8 @@ ID Posted at Screen name Text
209
193
  it "should have the correct output" do
210
194
  @search.mentions("twitter")
211
195
  $stdout.string.should =~ /@bartt/
212
- $stdout.string.should =~ /@noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons\. Lot’s/
196
+ $stdout.string.should =~ /@noahlt @gaarf Yup, now owning @twitter -> FB from FE to daemons\. Lot’s/
213
197
  $stdout.string.should =~ /fun\. Expect improvements in the weeks to come\./
214
- $stdout.string.should =~ /7 months ago/
215
198
  end
216
199
  context "--csv" do
217
200
  before do
@@ -221,7 +204,7 @@ ID Posted at Screen name Text
221
204
  @search.mentions("twitter")
222
205
  $stdout.string.should == <<-eos
223
206
  ID,Posted at,Screen name,Text
224
- 194546727670390784,2011-04-23 22:02:09 +0000,bartt,"@noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come."
207
+ 194546727670390784,2011-04-23 22:02:09 +0000,bartt,"@noahlt @gaarf Yup, now owning @twitter -> FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come."
225
208
  eos
226
209
  end
227
210
  end
@@ -252,6 +235,97 @@ ID Posted at Screen name Text
252
235
  end
253
236
  end
254
237
 
238
+ describe "#list" do
239
+ before do
240
+ stub_get("/1/lists/statuses.json").
241
+ with(:query => {:count => "200", :owner_screen_name => "testcli", :slug => "presidents"}).
242
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
243
+ stub_get("/1/lists/statuses.json").
244
+ with(:query => {:count => "200", :max_id => "194546264212385792", :owner_screen_name => "testcli", :slug => "presidents"}).
245
+ to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
246
+ end
247
+ it "should request the correct resource" do
248
+ @search.list("presidents", "twitter")
249
+ a_get("/1/lists/statuses.json").
250
+ with(:query => {:count => "200", :owner_screen_name => "testcli", :slug => "presidents"}).
251
+ should have_been_made
252
+ a_get("/1/lists/statuses.json").
253
+ with(:query => {:count => "200", :max_id => "194546264212385792", :owner_screen_name => "testcli", :slug => "presidents"}).
254
+ should have_been_made
255
+ end
256
+ it "should have the correct output" do
257
+ @search.list("presidents", "twitter")
258
+ $stdout.string.should =~ /@bartt/
259
+ $stdout.string.should =~ /@noahlt @gaarf Yup, now owning @twitter -> FB from FE to daemons\. Lot’s/
260
+ $stdout.string.should =~ /fun\. Expect improvements in the weeks to come\./
261
+ end
262
+ context "--csv" do
263
+ before do
264
+ @search.options = @search.options.merge("csv" => true)
265
+ end
266
+ it "should output in CSV format" do
267
+ @search.list("presidents", "twitter")
268
+ $stdout.string.should == <<-eos
269
+ ID,Posted at,Screen name,Text
270
+ 194546727670390784,2011-04-23 22:02:09 +0000,bartt,"@noahlt @gaarf Yup, now owning @twitter -> FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come."
271
+ eos
272
+ end
273
+ end
274
+ context "--long" do
275
+ before do
276
+ @search.options = @search.options.merge("long" => true)
277
+ end
278
+ it "should output in long format" do
279
+ @search.list("presidents", "twitter")
280
+ $stdout.string.should == <<-eos
281
+ ID Posted at Screen name Text
282
+ 194546727670390784 Apr 23 2011 @bartt @noahlt @gaarf Yup, now owning...
283
+ eos
284
+ end
285
+ end
286
+ context "with a user passed" do
287
+ it "should request the correct resource" do
288
+ @search.list("testcli/presidents", "twitter")
289
+ a_get("/1/lists/statuses.json").
290
+ with(:query => {:count => "200", :owner_screen_name => "testcli", :slug => "presidents"}).
291
+ should have_been_made
292
+ end
293
+ context "--id" do
294
+ before do
295
+ @search.options = @search.options.merge("id" => true)
296
+ stub_get("/1/lists/statuses.json").
297
+ with(:query => {:count => "200", :owner_id => "7505382", :slug => "presidents"}).
298
+ to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
299
+ stub_get("/1/lists/statuses.json").
300
+ with(:query => {:count => "200", :max_id => "194546264212385792", :owner_id => "7505382", :slug => "presidents"}).
301
+ to_return(:body => fixture("empty_array.json"), :headers => {:content_type => "application/json; charset=utf-8"})
302
+ end
303
+ it "should request the correct resource" do
304
+ @search.list("7505382/presidents", "twitter")
305
+ a_get("/1/lists/statuses.json").
306
+ with(:query => {:count => "200", :owner_id => "7505382", :slug => "presidents"}).
307
+ should have_been_made
308
+ a_get("/1/lists/statuses.json").
309
+ with(:query => {:count => "200", :max_id => "194546264212385792", :owner_id => "7505382", :slug => "presidents"}).
310
+ should have_been_made
311
+ end
312
+ end
313
+ end
314
+ context "Twitter is down" do
315
+ it "should retry 3 times and then raise an error" do
316
+ stub_get("/1/lists/statuses.json").
317
+ with(:query => {:count => "200", :owner_screen_name => "testcli", :slug => "presidents"}).
318
+ to_return(:status => 502)
319
+ lambda do
320
+ @search.list("presidents", "twitter")
321
+ end.should raise_error("Twitter is down or being upgraded.")
322
+ a_get("/1/lists/statuses.json").
323
+ with(:query => {:count => "200", :owner_screen_name => "testcli", :slug => "presidents"}).
324
+ should have_been_made.times(3)
325
+ end
326
+ end
327
+ end
328
+
255
329
  describe "#retweets" do
256
330
  before do
257
331
  stub_get("/1/statuses/retweeted_by_me.json").
@@ -273,9 +347,8 @@ ID Posted at Screen name Text
273
347
  it "should have the correct output" do
274
348
  @search.retweets("twitter")
275
349
  $stdout.string.should =~ /@bartt/
276
- $stdout.string.should =~ /@noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons\. Lot’s/
350
+ $stdout.string.should =~ /@noahlt @gaarf Yup, now owning @twitter -> FB from FE to daemons\. Lot’s/
277
351
  $stdout.string.should =~ /fun\. Expect improvements in the weeks to come\./
278
- $stdout.string.should =~ /7 months ago/
279
352
  end
280
353
  context "--csv" do
281
354
  before do
@@ -285,7 +358,7 @@ ID Posted at Screen name Text
285
358
  @search.retweets("twitter")
286
359
  $stdout.string.should == <<-eos
287
360
  ID,Posted at,Screen name,Text
288
- 194546727670390784,2011-04-23 22:02:09 +0000,bartt,"@noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come."
361
+ 194546727670390784,2011-04-23 22:02:09 +0000,bartt,"@noahlt @gaarf Yup, now owning @twitter -> FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come."
289
362
  eos
290
363
  end
291
364
  end
@@ -337,9 +410,8 @@ ID Posted at Screen name Text
337
410
  it "should have the correct output" do
338
411
  @search.timeline("twitter")
339
412
  $stdout.string.should =~ /@bartt/
340
- $stdout.string.should =~ /@noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons\. Lot’s/
413
+ $stdout.string.should =~ /@noahlt @gaarf Yup, now owning @twitter -> FB from FE to daemons\. Lot’s/
341
414
  $stdout.string.should =~ /fun\. Expect improvements in the weeks to come\./
342
- $stdout.string.should =~ /7 months ago/
343
415
  end
344
416
  context "--csv" do
345
417
  before do
@@ -349,7 +421,7 @@ ID Posted at Screen name Text
349
421
  @search.timeline("twitter")
350
422
  $stdout.string.should == <<-eos
351
423
  ID,Posted at,Screen name,Text
352
- 194546727670390784,2011-04-23 22:02:09 +0000,bartt,"@noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come."
424
+ 194546727670390784,2011-04-23 22:02:09 +0000,bartt,"@noahlt @gaarf Yup, now owning @twitter -> FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come."
353
425
  eos
354
426
  end
355
427
  end
@@ -401,9 +473,8 @@ ID Posted at Screen name Text
401
473
  it "should have the correct output" do
402
474
  @search.user("sferik", "twitter")
403
475
  $stdout.string.should =~ /@bartt/
404
- $stdout.string.should =~ /@noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons\. Lot’s/
476
+ $stdout.string.should =~ /@noahlt @gaarf Yup, now owning @twitter -> FB from FE to daemons\. Lot’s/
405
477
  $stdout.string.should =~ /fun\. Expect improvements in the weeks to come\./
406
- $stdout.string.should =~ /7 months ago/
407
478
  end
408
479
  context "--csv" do
409
480
  before do
@@ -413,7 +484,7 @@ ID Posted at Screen name Text
413
484
  @search.user("sferik", "twitter")
414
485
  $stdout.string.should == <<-eos
415
486
  ID,Posted at,Screen name,Text
416
- 194546727670390784,2011-04-23 22:02:09 +0000,bartt,"@noahlt @gaarf Yup, now owning @twitter -&gt; FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come."
487
+ 194546727670390784,2011-04-23 22:02:09 +0000,bartt,"@noahlt @gaarf Yup, now owning @twitter -> FB from FE to daemons. Lot’s of fun. Expect improvements in the weeks to come."
417
488
  eos
418
489
  end
419
490
  end
data/t.gemspec CHANGED
@@ -8,10 +8,12 @@ Gem::Specification.new do |gem|
8
8
  gem.add_dependency 'fastercsv', '~> 1.5'
9
9
  gem.add_dependency 'geokit', '~> 1.6'
10
10
  gem.add_dependency 'highline', '~> 1.6'
11
+ gem.add_dependency 'htmlentities', '~> 4.3'
11
12
  gem.add_dependency 'json', '~> 1.6'
12
13
  gem.add_dependency 'oauth', '~> 0.4'
13
14
  gem.add_dependency 'retryable', '~> 1.2'
14
15
  gem.add_dependency 'thor', ['~> 0.15', '< 2']
16
+ gem.add_dependency 'tweetstream', '~> 1.1'
15
17
  gem.add_dependency 'twitter', ['~> 2.2', '>= 2.2.5']
16
18
  gem.add_dependency 'twitter-text', '~> 1.4'
17
19
  gem.add_development_dependency 'pry'