Sha256: 7267cb156f73876ec9bc0a7c4a781cc3752bc7389dea91094664f470028a2a82

Contents?: true

Size: 603 Bytes

Versions: 7

Compression:

Stored size: 603 Bytes

Contents

# encoding: UTF-8
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../../lib')

require 'rubygems'
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/spritzer.json")

trap('INT') {
  puts "\n\nCaptured #{captured} objects from the stream"
  puts "CTRL+C caught, later!"
  exit(0)
}

Yajl::HttpStream.get(uri) do |hash|
  STDOUT.putc '.'
  STDOUT.flush
  captured += 1
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
brianmario-yajl-ruby-0.5.2 examples/http/twitter_stream_api.rb
brianmario-yajl-ruby-0.5.3 examples/http/twitter_stream_api.rb
brianmario-yajl-ruby-0.5.4 examples/http/twitter_stream_api.rb
brianmario-yajl-ruby-0.5.5 examples/http/twitter_stream_api.rb
brianmario-yajl-ruby-0.5.6 examples/http/twitter_stream_api.rb
yajl-ruby-0.5.5 examples/http/twitter_stream_api.rb
yajl-ruby-0.5.6 examples/http/twitter_stream_api.rb