Sha256: 9ddb273fc99aa60665086d1d88d48846aaff99f413d4c8983bfb22281b07bd49

Contents?: true

Size: 671 Bytes

Versions: 26

Compression:

Stored size: 671 Bytes

Contents

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

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

Version data entries

26 entries across 26 versions & 5 rubygems

Version Path
brianmario-yajl-ruby-0.5.10 examples/http/twitter_stream_api.rb
brianmario-yajl-ruby-0.5.11 examples/http/twitter_stream_api.rb
brianmario-yajl-ruby-0.5.12 examples/http/twitter_stream_api.rb
brianmario-yajl-ruby-0.5.7 examples/http/twitter_stream_api.rb
brianmario-yajl-ruby-0.5.8 examples/http/twitter_stream_api.rb
brianmario-yajl-ruby-0.5.9 examples/http/twitter_stream_api.rb
brianmario-yajl-ruby-0.6.0 examples/http/twitter_stream_api.rb
brianmario-yajl-ruby-0.6.1 examples/http/twitter_stream_api.rb
brianmario-yajl-ruby-0.6.3 examples/http/twitter_stream_api.rb
jdg-yajl-ruby-0.5.12 examples/http/twitter_stream_api.rb
oortle-yajl-ruby-0.5.8 examples/http/twitter_stream_api.rb
yajl-ruby-0.6.7 examples/http/twitter_stream_api.rb
yajl-ruby-0.6.6 examples/http/twitter_stream_api.rb
yajl-ruby-0.6.5 examples/http/twitter_stream_api.rb
yajl-ruby-0.6.4 examples/http/twitter_stream_api.rb
filipegiusti-yajl-ruby-0.6.4 examples/http/twitter_stream_api.rb
yajl-ruby-0.6.3 examples/http/twitter_stream_api.rb
yajl-ruby-0.6.2 examples/http/twitter_stream_api.rb
yajl-ruby-0.6.0 examples/http/twitter_stream_api.rb
yajl-ruby-0.6.1 examples/http/twitter_stream_api.rb