twail 0.0.8 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/twail.rb +10 -2
- data/twail.gemspec +1 -1
- metadata +1 -1
data/lib/twail.rb
CHANGED
@@ -76,17 +76,25 @@ if ARGV.first =~ /^s/ # search
|
|
76
76
|
$stderr.puts "Max pages: #{max_pages}"
|
77
77
|
end
|
78
78
|
|
79
|
+
total_width = `tput cols`.to_i
|
80
|
+
text_width = (total_width - 44)
|
81
|
+
|
79
82
|
while query
|
80
83
|
url = "http://search.twitter.com/search.json#{query}"
|
81
84
|
json = `curl -s '#{url}'`
|
82
85
|
res = JSON.parse(json)
|
83
86
|
res['results'].each do |x|
|
84
87
|
time = Time.parse(x['created_at']).localtime
|
85
|
-
|
88
|
+
text = x['text'].gsub(/\n/, ' ')
|
89
|
+
textlines = text.wrap(text_width).split(/\n/)
|
90
|
+
puts "%s | %s | %s" % [time.to_s.gsub(/\s\S+$/,''), x['from_user'].rjust(18), textlines.shift]
|
91
|
+
textlines.each do |line|
|
92
|
+
puts("%s | %s" % [''.rjust(40), line])
|
93
|
+
end
|
86
94
|
end
|
87
95
|
query = res['next_page']
|
88
96
|
if max_pages
|
89
|
-
if query[/page=(\d+)/, 1].to_i > max_pages.to_i
|
97
|
+
if query.nil? || query[/page=(\d+)/, 1].to_i > max_pages.to_i
|
90
98
|
exit
|
91
99
|
end
|
92
100
|
end
|
data/twail.gemspec
CHANGED