Sha256: 186294180c2798faffbc8fe0dc1b59a7f0cbbadab1f299d8f24f295f528d57f6

Contents?: true

Size: 714 Bytes

Versions: 13

Compression:

Stored size: 714 Bytes

Contents

$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

Version data entries

13 entries across 13 versions & 4 rubygems

Version Path
yajl-ruby-1.2.3 examples/http/twitter_stream_api.rb
yajl-ruby-1.2.2 examples/http/twitter_stream_api.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/yajl-ruby-1.2.1/examples/http/twitter_stream_api.rb
yajl-ruby-1.2.1 examples/http/twitter_stream_api.rb
yajl-ruby-1.2.0 examples/http/twitter_stream_api.rb
yajl-ruby-zenjoy-1.1.0 examples/http/twitter_stream_api.rb
yajl-ruby-maglev--1.1.0 examples/http/twitter_stream_api.rb
yajl-ruby-1.1.0-x86-mswin32-60 examples/http/twitter_stream_api.rb
yajl-ruby-1.1.0-x86-mingw32 examples/http/twitter_stream_api.rb
yajl-ruby-1.1.0 examples/http/twitter_stream_api.rb
yajl-ruby-1.0.0-x86-mswin32-60 examples/http/twitter_stream_api.rb
yajl-ruby-1.0.0-x86-mingw32 examples/http/twitter_stream_api.rb
yajl-ruby-1.0.0 examples/http/twitter_stream_api.rb