/usr/share/doc/ruby-yajl/examples/http/twitter_stream_api.rb is in ruby-yajl 1.2.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../..')
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../../lib')
require 'yajl/gzip'
require 'yajl/deflate'
require 'yajl/http_stream'
require 'uri'
unless (username = ARGV[0]) && (password = ARGV[1])
puts "\nUsage: ruby examples/http/twitter_stream_api.rb username password\n\n"
exit(0)
end
captured = 0
uri = URI.parse("http://#{username}:#{password}@stream.twitter.com/1/statuses/sample.json")
trap('INT') {
puts "\n\nCaptured #{captured} objects from the stream"
puts "CTRL+C caught, later!"
exit(0)
}
Yajl::HttpStream.get(uri, :symbolize_keys => true) do |hash|
STDOUT.putc '.'
STDOUT.flush
captured += 1
end
|