ld-eventsource 2.2.3 → 2.2.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4aa95953d325a67b03f0e740b9d1f898e7de4f7738e0449a6e3aaf2f7abe187
4
- data.tar.gz: 0ae820e9665bd4c78bc801c09df14f6f6795057a7dc0048b698a4dd4b4d7106d
3
+ metadata.gz: 153403888d19914467bf5e7f0edb31296036d8ff1d9f3344bc769dca9fab3389
4
+ data.tar.gz: 847e44e08275f72abdcdcff81530bdadeab58b8e096d914302c33dc05f6736da
5
5
  SHA512:
6
- metadata.gz: ceed9644f1d46f06b9def2675961215051aaf4059c94f2dd54142c6a37007becd987b459dd0eb9d640d29da08bba3aed9d567593b8594477202eef1b7042386f
7
- data.tar.gz: e782c7a6baf52eba573aa2194c1f535b651bc2498dab036881a4b4226fcfe3f6830333d0a80dddfb32a6aeb5b4b85adf9fbc369c9638ec24dbcc78679804c7ea
6
+ metadata.gz: 7eea1dd29f293744af4f0e8265bf322ef1033d2d2afbd58fbed72983a9b782a6ecb90402443c38004c0d44ea10cb270b4709a92cc652d1e2569060a08ecef8aa
7
+ data.tar.gz: 71dc1328363a588c96c3dadb91a1fb7b7787365cf5f2f04405273161c411d8bdce9d3cfc41580cb1e431f1a88812a30df4f68a3d3f4d1d10a04e5d3e64e377e6
data/README.md CHANGED
@@ -11,7 +11,7 @@ Parts of this code are based on https://github.com/Tonkpils/celluloid-eventsourc
11
11
  Supported Ruby versions
12
12
  -----------------------
13
13
 
14
- This gem has a minimum Ruby version of 2.5, or 9.2 for JRuby.
14
+ This gem has a minimum Ruby version of 3.1.
15
15
 
16
16
  Quick setup
17
17
  -----------
@@ -120,14 +120,14 @@ module SSE
120
120
  if @proxy
121
121
  http_client_options["proxy"] = {
122
122
  :proxy_address => @proxy.host,
123
- :proxy_port => @proxy.port
123
+ :proxy_port => @proxy.port,
124
124
  }
125
125
  end
126
126
 
127
127
  @http_client = HTTP::Client.new(http_client_options)
128
128
  .timeout({
129
129
  read: read_timeout,
130
- connect: connect_timeout
130
+ connect: connect_timeout,
131
131
  })
132
132
  @cxn = nil
133
133
  @lock = Mutex.new
@@ -202,13 +202,13 @@ module SSE
202
202
  private
203
203
 
204
204
  def reset_http
205
- @http_client.close if !@http_client.nil?
205
+ @http_client.close unless @http_client.nil?
206
206
  close_connection
207
207
  end
208
208
 
209
209
  def close_connection
210
210
  @lock.synchronize do
211
- @cxn.connection.close if !@cxn.nil?
211
+ @cxn.connection.close unless @cxn.nil?
212
212
  @cxn = nil
213
213
  end
214
214
  end
@@ -216,12 +216,12 @@ module SSE
216
216
  def default_logger
217
217
  log = ::Logger.new($stdout)
218
218
  log.level = ::Logger::WARN
219
- log.progname = 'ld-eventsource'
219
+ log.progname = 'ld-eventsource'
220
220
  log
221
221
  end
222
222
 
223
223
  def run_stream
224
- while !@stopped.value
224
+ until @stopped.value
225
225
  close_connection
226
226
  begin
227
227
  resp = connect
@@ -231,7 +231,7 @@ module SSE
231
231
  # There's a potential race if close was called in the middle of the previous line, i.e. after we
232
232
  # connected but before @cxn was set. Checking the variable again is a bit clunky but avoids that.
233
233
  return if @stopped.value
234
- read_stream(resp) if !resp.nil?
234
+ read_stream(resp) unless resp.nil?
235
235
  rescue => e
236
236
  # When we deliberately close the connection, it will usually trigger an exception. The exact type
237
237
  # of exception depends on the specific Ruby runtime. But @stopped will always be set in this case.
@@ -263,7 +263,7 @@ module SSE
263
263
  begin
264
264
  @logger.info { "Connecting to event stream at #{@uri}" }
265
265
  cxn = @http_client.request("GET", @uri, {
266
- headers: build_headers
266
+ headers: build_headers,
267
267
  })
268
268
  if cxn.status.code == 200
269
269
  content_type = cxn.content_type.mime_type
@@ -332,7 +332,7 @@ module SSE
332
332
 
333
333
  def dispatch_event(event)
334
334
  @logger.debug { "Received event: #{event}" }
335
- @last_id = event.id if !event.id.nil?
335
+ @last_id = event.id unless event.id.nil?
336
336
 
337
337
  # Pass the event to the caller
338
338
  @on[:event].call(event)
@@ -353,7 +353,7 @@ module SSE
353
353
  h = {
354
354
  'Accept' => 'text/event-stream',
355
355
  'Cache-Control' => 'no-cache',
356
- 'User-Agent' => 'ruby-eventsource'
356
+ 'User-Agent' => 'ruby-eventsource',
357
357
  }
358
358
  h['Last-Event-Id'] = @last_id if !@last_id.nil? && @last_id != ""
359
359
  h.merge(@headers)
@@ -30,7 +30,7 @@ module SSE
30
30
  #
31
31
  class HTTPContentTypeError < StandardError
32
32
  def initialize(type)
33
- @content_type = type
33
+ @content_type = type
34
34
  super("invalid content type \"#{type}\"")
35
35
  end
36
36
 
@@ -34,12 +34,12 @@ module SSE
34
34
  # @return [Float] the next interval in seconds
35
35
  #
36
36
  def next_interval
37
- if !@last_good_time.nil?
37
+ unless @last_good_time.nil?
38
38
  good_duration = Time.now.to_f - @last_good_time
39
39
  @attempts = 0 if good_duration >= @reconnect_reset_interval
40
40
  end
41
41
  @last_good_time = nil
42
- target = ([@base_interval * (2 ** @attempts), @max_interval].min).to_f
42
+ target = [@base_interval * (2 ** @attempts), @max_interval].min.to_f
43
43
  @attempts += 1
44
44
  if target == 0
45
45
  0 # in some Ruby versions it's illegal to call rand(0)
@@ -1,4 +1,3 @@
1
-
2
1
  module SSE
3
2
  module Impl
4
3
  class BufferedLineReader
@@ -16,7 +15,7 @@ module SSE
16
15
  # @return [Enumerator] an enumerator that will yield one line at a time in UTF-8
17
16
  #
18
17
  def self.lines_from(chunks)
19
- buffer = "".b
18
+ buffer = +"".b
20
19
  position = 0
21
20
  line_start = 0
22
21
  last_char_was_cr = false
@@ -36,7 +36,7 @@ module SSE
36
36
  if line.empty?
37
37
  event = maybe_create_event
38
38
  reset_buffers
39
- gen.yield event if !event.nil?
39
+ gen.yield event unless event.nil?
40
40
  elsif (pos = line.index(':'))
41
41
  name = line.slice(0...pos)
42
42
 
@@ -45,7 +45,7 @@ module SSE
45
45
  line = line.slice(pos..-1)
46
46
 
47
47
  item = process_field(name, line)
48
- gen.yield item if !item.nil?
48
+ gen.yield item unless item.nil?
49
49
  end
50
50
  end
51
51
  end
@@ -72,7 +72,7 @@ module SSE
72
72
  end
73
73
  @have_data = true
74
74
  when "id"
75
- if !value.include?("\x00")
75
+ unless value.include?("\x00")
76
76
  @id = value
77
77
  @last_event_id = value
78
78
  end
@@ -85,7 +85,7 @@ module SSE
85
85
  end
86
86
 
87
87
  def maybe_create_event
88
- return nil if !@have_data
88
+ return nil unless @have_data
89
89
  StreamEvent.new(@type || :message, @data, @id, @last_event_id)
90
90
  end
91
91
  end
@@ -1,3 +1,3 @@
1
1
  module SSE
2
- VERSION = "2.2.3" # x-release-please-version
2
+ VERSION = "2.2.5" # x-release-please-version
3
3
  end
metadata CHANGED
@@ -1,57 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ld-eventsource
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 2.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - LaunchDarkly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-10 00:00:00.000000000 Z
11
+ date: 2025-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.2.10
19
+ version: '3.2'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.2.10
26
+ version: '3.2'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rspec
28
+ name: rspec_junit_formatter
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.2'
33
+ version: 0.3.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '3.2'
40
+ version: 0.3.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec_junit_formatter
42
+ name: rubocop
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.3.0
47
+ version: '1.37'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.3.0
54
+ version: '1.37'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop-performance
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.15'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.15'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: webrick
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -129,14 +143,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
129
143
  requirements:
130
144
  - - ">="
131
145
  - !ruby/object:Gem::Version
132
- version: '0'
146
+ version: '3.1'
133
147
  required_rubygems_version: !ruby/object:Gem::Requirement
134
148
  requirements:
135
149
  - - ">="
136
150
  - !ruby/object:Gem::Version
137
151
  version: '0'
138
152
  requirements: []
139
- rubygems_version: 3.2.33
153
+ rubygems_version: 3.4.19
140
154
  signing_key:
141
155
  specification_version: 4
142
156
  summary: LaunchDarkly SSE client