event_stream_parser 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -5
- data/lib/event_stream_parser/version.rb +1 -1
- data/lib/event_stream_parser.rb +0 -12
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49756d751627c15a8f085902ed658146505e48886f1dd00478303377cf306ef9
|
4
|
+
data.tar.gz: 02a1527fac3865d65041ae9f42c915da6f29af6db490dc18e021486571652fbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 644f4a6394f418ba3bb7ea34f0ec80cd52a1814c480fbdae7b9e15004c421c731ae273a7d68ca1976f2de471dfe898170658ccd625c5da3961712fda68c0b783
|
7
|
+
data.tar.gz: ba6cb519e0c839c65d0d4179d1ddee7ba66cd8cd7c92cac1b7c449cda497bdf71eef97912d950050ea0ec8629293556c43b173cc708e02257ce9ca50fbf1f601
|
data/README.md
CHANGED
@@ -11,6 +11,8 @@ from an HTTP client, for example) and emits events as it parses them. But it
|
|
11
11
|
remembers the last event id and reconnection time and keeps emitting them as
|
12
12
|
long as they are not overwritten by new ones.
|
13
13
|
|
14
|
+
BOM stripping is left as a responsibility of the chunk provider.
|
15
|
+
|
14
16
|
## Installation
|
15
17
|
|
16
18
|
Add this line to your application's Gemfile:
|
@@ -74,11 +76,7 @@ After checking out the repo:
|
|
74
76
|
2. Run `rake test` to run the tests.
|
75
77
|
3. Run `rubocop` to run Rubocop.
|
76
78
|
|
77
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
78
|
-
release a new version, update the version number in `version.rb`, and then run
|
79
|
-
`bundle exec rake release`, which will create a git tag for the version, push
|
80
|
-
git commits and tags, and push the `.gem` file to
|
81
|
-
[rubygems.org](https://rubygems.org).
|
79
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
82
80
|
|
83
81
|
## Contributing
|
84
82
|
|
data/lib/event_stream_parser.rb
CHANGED
@@ -12,8 +12,6 @@ module EventStreamParser
|
|
12
12
|
# Code comments are copied from the spec.
|
13
13
|
#
|
14
14
|
class Parser
|
15
|
-
UTF_8_BOM = [0xEF, 0xBB, 0xBF].pack("C*").force_encoding("UTF-8").freeze
|
16
|
-
|
17
15
|
def initialize
|
18
16
|
##
|
19
17
|
# When a stream is parsed, a data buffer, an event type buffer, and a last
|
@@ -26,20 +24,10 @@ module EventStreamParser
|
|
26
24
|
|
27
25
|
@reconnection_time = nil
|
28
26
|
@buffer = +""
|
29
|
-
@first_chunk = true
|
30
27
|
@last_delimiter = nil
|
31
28
|
end
|
32
29
|
|
33
30
|
def feed(chunk, &proc)
|
34
|
-
##
|
35
|
-
# The UTF-8 decode algorithm strips one leading UTF-8 Byte Order Mark (BOM),
|
36
|
-
# if any.
|
37
|
-
#
|
38
|
-
if @first_chunk
|
39
|
-
chunk = chunk.delete_prefix(UTF_8_BOM)
|
40
|
-
@first_chunk = false
|
41
|
-
end
|
42
|
-
|
43
31
|
@buffer << chunk
|
44
32
|
|
45
33
|
##
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ates Goral
|
@@ -54,6 +54,9 @@ homepage: https://github.com/Shopify/event_stream_parser
|
|
54
54
|
licenses:
|
55
55
|
- MIT
|
56
56
|
metadata:
|
57
|
+
bug_tracker_uri: https://github.com/Shopify/event_stream_parser/issues
|
58
|
+
changelog_uri: https://github.com/Shopify/event_stream_parser/blob/main/CHANGELOG.md
|
59
|
+
source_code_uri: https://github.com/Shopify/event_stream_parser
|
57
60
|
allowed_push_host: https://rubygems.org
|
58
61
|
post_install_message:
|
59
62
|
rdoc_options: []
|