event_stream_parser 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49756d751627c15a8f085902ed658146505e48886f1dd00478303377cf306ef9
4
- data.tar.gz: 02a1527fac3865d65041ae9f42c915da6f29af6db490dc18e021486571652fbf
3
+ metadata.gz: 830b3472c8f361af6b3e3fe2b3d405be779a188dfad03689d742e1c7432c9d9a
4
+ data.tar.gz: 136a34302cc7b8ac6de60307960258fac2618035ad66394867417481f8c76437
5
5
  SHA512:
6
- metadata.gz: 644f4a6394f418ba3bb7ea34f0ec80cd52a1814c480fbdae7b9e15004c421c731ae273a7d68ca1976f2de471dfe898170658ccd625c5da3961712fda68c0b783
7
- data.tar.gz: ba6cb519e0c839c65d0d4179d1ddee7ba66cd8cd7c92cac1b7c449cda497bdf71eef97912d950050ea0ec8629293556c43b173cc708e02257ce9ca50fbf1f601
6
+ metadata.gz: 1834aa3df2243b44538415a4e05b4cc4cf2a86132a48ad32b70c12994205866fa3f80a530e75573b204d1d3cfc2719928f92fa13ddd9db868d6fbdee5f9d241e
7
+ data.tar.gz: 3b6b3bc90c9353988bc906b6fdec21e54d6bd3762f5f386d7cbfff4688fb7df0a626e5f3d8f054d8957f1c170d2bdb98295815887d278b84d0b82907b47ed96f
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # event_stream_parser
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/event_stream_parser.svg)](https://badge.fury.io/rb/event_stream_parser)
4
+ [![CI](https://github.com/Shopify/event_stream_parser/actions/workflows/ci.yml/badge.svg)](https://github.com/Shopify/event_stream_parser/actions/workflows/ci.yml)
5
+
3
6
  A lightweight, fully spec-compliant parser for the
4
7
  [event stream](https://www.w3.org/TR/eventsource/) format.
5
8
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EventStreamParser
4
- VERSION = "0.2.0"
4
+ VERSION = '0.3.0'
5
5
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "event_stream_parser/version"
3
+ require 'event_stream_parser/version'
4
4
 
5
5
  module EventStreamParser
6
6
  ##
@@ -18,12 +18,12 @@ module EventStreamParser
18
18
  # event ID buffer must be associated with it. They must be initialized to
19
19
  # the empty string.
20
20
  #
21
- @data_buffer = +""
22
- @event_type_buffer = +""
23
- @last_event_id_buffer = +""
21
+ @data_buffer = +''
22
+ @event_type_buffer = +''
23
+ @last_event_id_buffer = +''
24
24
 
25
25
  @reconnection_time = nil
26
- @buffer = +""
26
+ @buffer = +''
27
27
  @last_delimiter = nil
28
28
  end
29
29
 
@@ -38,9 +38,7 @@ module EventStreamParser
38
38
  # followed by a U+000A LINE FEED (LF) character being the ways in which a
39
39
  # line can end.
40
40
  #
41
- if @last_delimiter == "\r"
42
- @buffer.delete_prefix!("\n")
43
- end
41
+ @buffer.delete_prefix!("\n") if @last_delimiter == "\r"
44
42
 
45
43
  while (line = @buffer.slice!(/.*?(?<delim>\r\n|\r|\n)/))
46
44
  line.chomp!
@@ -68,7 +66,7 @@ module EventStreamParser
68
66
  ##
69
67
  # If the line is empty (a blank line)
70
68
  #
71
- when ""
69
+ when ''
72
70
  ##
73
71
  # Dispatch the event, as defined below.
74
72
  #
@@ -106,7 +104,7 @@ module EventStreamParser
106
104
  # Process the field using the steps described below, using the whole line
107
105
  # as the field name, and the empty string as the field value.
108
106
  #
109
- process_field(line, "")
107
+ process_field(line, '')
110
108
  end
111
109
  end
112
110
 
@@ -120,7 +118,7 @@ module EventStreamParser
120
118
  ##
121
119
  # If the field name is "event"
122
120
  #
123
- when "event"
121
+ when 'event'
124
122
  ##
125
123
  # Set the event type buffer to field value.
126
124
  #
@@ -128,7 +126,7 @@ module EventStreamParser
128
126
  ##
129
127
  # If the field name is "data"
130
128
  #
131
- when "data"
129
+ when 'data'
132
130
  ##
133
131
  # Append the field value to the data buffer, then append a single U+000A
134
132
  # LINE FEED (LF) character to the data buffer.
@@ -137,7 +135,7 @@ module EventStreamParser
137
135
  ##
138
136
  # If the field name is "id"
139
137
  #
140
- when "id"
138
+ when 'id'
141
139
  ##
142
140
  # If the field value does not contain U+0000 NULL, then set the last event
143
141
  # ID buffer to the field value. Otherwise, ignore the field.
@@ -146,7 +144,7 @@ module EventStreamParser
146
144
  ##
147
145
  # If the field name is "retry"
148
146
  #
149
- when "retry"
147
+ when 'retry'
150
148
  ##
151
149
  # If the field value consists of only ASCII digits, then interpret the
152
150
  # field value as an integer in base ten, and set the event stream's
@@ -188,8 +186,8 @@ module EventStreamParser
188
186
  # event type buffer to the empty string and return.
189
187
  #
190
188
  if @data_buffer.empty?
191
- @data_buffer = +""
192
- @event_type_buffer = +""
189
+ @data_buffer = +''
190
+ @event_type_buffer = +''
193
191
  return
194
192
  end
195
193
  ##
@@ -213,8 +211,8 @@ module EventStreamParser
213
211
  ##
214
212
  # 7. Set the data buffer and the event type buffer to the empty string.
215
213
  #
216
- @data_buffer = +""
217
- @event_type_buffer = +""
214
+ @data_buffer = +''
215
+ @event_type_buffer = +''
218
216
 
219
217
  yield type, data, id, @reconnection_time
220
218
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event_stream_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ates Goral
@@ -9,35 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2023-10-16 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: minitest
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '5.0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '5.0'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '13.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '13.0'
12
+ dependencies: []
41
13
  description:
42
14
  email:
43
15
  - ates.goral@shopify.com
@@ -58,6 +30,7 @@ metadata:
58
30
  changelog_uri: https://github.com/Shopify/event_stream_parser/blob/main/CHANGELOG.md
59
31
  source_code_uri: https://github.com/Shopify/event_stream_parser
60
32
  allowed_push_host: https://rubygems.org
33
+ rubygems_mfa_required: 'true'
61
34
  post_install_message:
62
35
  rdoc_options: []
63
36
  require_paths:
@@ -66,7 +39,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
66
39
  requirements:
67
40
  - - ">="
68
41
  - !ruby/object:Gem::Version
69
- version: 2.7.0
42
+ version: 2.6.0
70
43
  required_rubygems_version: !ruby/object:Gem::Requirement
71
44
  requirements:
72
45
  - - ">="