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 +4 -4
- data/lib/syslogger/io.rb +8 -3
- data/spec/syslogger/io_spec.rb +24 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d21ce3b28a7fb37988462480ad7345c5c5efcf32
|
4
|
+
data.tar.gz: 84b739de4a75b432f9b3672dfb795f041b95c301
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 =
|
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
|
-
|
44
|
+
if !@file.nil?
|
45
|
+
@file.flush
|
46
|
+
end
|
45
47
|
end
|
46
48
|
|
47
49
|
def close
|
48
|
-
|
50
|
+
if !@file.nil?
|
51
|
+
@file.close
|
52
|
+
@file = nil
|
53
|
+
end
|
49
54
|
end
|
50
55
|
end
|
51
56
|
end
|
data/spec/syslogger/io_spec.rb
CHANGED
@@ -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
|