em-eventsource 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/em-eventsource.rb +7 -4
  2. metadata +12 -12
@@ -123,11 +123,12 @@ module EventMachine
123
123
  end
124
124
 
125
125
  def handle_stream(stream)
126
- event = []
126
+ data = ""
127
127
  name = nil
128
128
  stream.split("\n").each do |part|
129
129
  /^data:(.+)$/.match(part) do |m|
130
- event << m[1].strip
130
+ data += m[1].strip
131
+ data += "\n"
131
132
  end
132
133
  /^id:(.+)$/.match(part) do |m|
133
134
  @last_event_id = m[1].strip
@@ -141,10 +142,12 @@ module EventMachine
141
142
  end
142
143
  end
143
144
  end
145
+ return if data.empty?
146
+ data.chomp!("\n")
144
147
  if name.nil?
145
- @messages.each { |message| message.call(event.join("\n")) }
148
+ @messages.each { |message| message.call(data) }
146
149
  else
147
- @on[name].each { |message| message.call(event.join("\n")) } if not @on[name].nil?
150
+ @on[name].each { |message| message.call(data) } if not @on[name].nil?
148
151
  end
149
152
  end
150
153
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-eventsource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-29 00:00:00.000000000Z
12
+ date: 2011-09-01 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine
16
- requirement: &21231620 !ruby/object:Gem::Requirement
16
+ requirement: &8006620 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.0.0.beta3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *21231620
24
+ version_requirements: *8006620
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: em-http-request
27
- requirement: &21231140 !ruby/object:Gem::Requirement
27
+ requirement: &8006140 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *21231140
35
+ version_requirements: *8006140
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: minitest
38
- requirement: &21230680 !ruby/object:Gem::Requirement
38
+ requirement: &8005680 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '2.0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *21230680
46
+ version_requirements: *8005680
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &21230300 !ruby/object:Gem::Requirement
49
+ requirement: &8005300 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *21230300
57
+ version_requirements: *8005300
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &21229840 !ruby/object:Gem::Requirement
60
+ requirement: &8004840 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *21229840
68
+ version_requirements: *8004840
69
69
  description: ! " em-eventsource is an eventmachine library to consume Server-Sent
70
70
  Events streaming API.\n You can find the specification here: http://dev.w3.org/html5/eventsource/\n"
71
71
  email: francois.de.metz@af83.com