twail 0.0.8 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/twail.rb +10 -2
  2. data/twail.gemspec +1 -1
  3. 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
- puts "%s | %s | %s" % [time.to_s.gsub(/\s\S+$/,''), x['from_user'].rjust(18), x['text'].gsub(/\n/, ' ')]
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
@@ -2,7 +2,7 @@
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "twail"
5
- s.version = '0.0.8'
5
+ s.version = '0.1.0'
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.required_ruby_version = '>= 1.9.0'
8
8
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: twail
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.8
5
+ version: 0.1.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Daniel Choi