syslogger5424 0.5.2 → 0.5.3

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
  SHA1:
3
- metadata.gz: 878d1d614d807540003e660138d901882aa27a69
4
- data.tar.gz: 7b65f0719eb122c49e420e39ce516ef00e0d7af8
3
+ metadata.gz: d21ce3b28a7fb37988462480ad7345c5c5efcf32
4
+ data.tar.gz: 84b739de4a75b432f9b3672dfb795f041b95c301
5
5
  SHA512:
6
- metadata.gz: eb08b6da75a380ebda9ca6dd8b9434f8deb7af27c4128b977ac65ae6dc232b628cc19b1241f6d7482d5a3273c1fb27ed55324dd8fdfd09b62ff863dac75e6c6d
7
- data.tar.gz: 0da12a8cf40adcab8586b435522c2521750dc6f65f32b861a7bc0361beba5a437e3b312e575637cbd01cbfdb02a5426ae85d7d905e0c166479e9d7bf75a7786c
6
+ metadata.gz: a5d789045cb23b6dd0908cc5b578164c96a090d65282f7314bae60dc1140dceb580f78fdfae501f0e2eb689bbcbd8a19d4053208656cc86016b37eac68f3cc20
7
+ data.tar.gz: bbea111ef484e1f25cb2342ab839f97ace120132feecba9c45bffcbdefe664e3fe3c9776243502d05c2273e556d86d949b1a4f839243d2784f9ae7814302dd4d
data/lib/syslogger/io.rb CHANGED
@@ -2,7 +2,7 @@ module SysLogger
2
2
  class IO
3
3
  def initialize(&file_creator)
4
4
  @file_creator = file_creator
5
- @file = @file_creator.call
5
+ @file = nil
6
6
  @connect_pid = Process.pid
7
7
  end
8
8
 
@@ -41,11 +41,16 @@ module SysLogger
41
41
  end
42
42
 
43
43
  def flush
44
- @file.flush
44
+ if !@file.nil?
45
+ @file.flush
46
+ end
45
47
  end
46
48
 
47
49
  def close
48
- @file.close
50
+ if !@file.nil?
51
+ @file.close
52
+ @file = nil
53
+ end
49
54
  end
50
55
  end
51
56
  end
@@ -15,11 +15,35 @@ describe SysLogger::IO do
15
15
  subject.write("foobar")
16
16
  expect(io.string).to eq "foobar"
17
17
  end
18
+ end
19
+
20
+ describe "#flush" do
21
+ it "works without writing first" do
22
+ subject.flush
23
+ end
18
24
 
19
25
  it "handles array messages" do
20
26
  subject.write(["foo", "bar"])
21
27
  expect(io.string).to eq "foobar"
22
28
  end
29
+
30
+ it "works after writing" do
31
+ subject.write('foobar')
32
+ subject.flush
33
+ expect(io.string).to eq "foobar"
34
+ end
35
+
36
+ it "works after an exception" do
37
+ count = 0
38
+ expect(io).to receive(:write).at_least(:once) do
39
+ count += 1
40
+ if count == 1
41
+ raise IOError
42
+ end
43
+ end
44
+ subject.write('foobar')
45
+ subject.flush
46
+ end
23
47
  end
24
48
 
25
49
  describe "unix_dgram_socket" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syslogger5424
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - EasyPost