Skip to content

Instantly share code, notes, and snippets.

@fuba
Created January 16, 2014 16:54
Show Gist options
  • Save fuba/8458617 to your computer and use it in GitHub Desktop.
Save fuba/8458617 to your computer and use it in GitHub Desktop.
diff --git lib/atig/stream.rb lib/atig/stream.rb
index 069c0df..5f93731 100644
--- lib/atig/stream.rb
+++ lib/atig/stream.rb
@@ -46,12 +46,12 @@ module Atig
next if chunk.chomp.empty?
buffer << chunk.to_s
- if buffer =~ /\A(.*)\n/ then
- text = $1
- unless text.strip.empty?
- f.call TwitterStruct.make(JSON.parse(text))
+ buffer.split("\r\n").each do |line|
+ if line =~ /\A\{.*\}\Z/ then
+ f.call TwitterStruct.make(JSON.parse(line))
+ else
+ buffer = line
end
- buffer = ''
end
end
rescue => e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment