slack_log_device 2.0.0 → 2.0.1
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/VERSION +1 -1
- data/lib/slack_log_device.rb +3 -7
- data/spec/slack_log_device_spec.rb +9 -7
- 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: 32885688b1cd9ac6a722a1a6f33555c509eb165f
|
4
|
+
data.tar.gz: 74ccc8aaa57329d2290dee6601fd6d82f9e31663
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fbf9de73db847487a88e5dd455865c4d892ad47fa2bd95c687655165c7da7701970d4a785931c1eb7c32ce1733c10963e3654940aefc3ff1590ee266a08c882
|
7
|
+
data.tar.gz: 2345e2526588ca41890abbd5e9864311b2ac19fd58c108608766eda3f2547629cba76846ef1d20f2d0a06f55db689d4c1afcc00b62fe51aea96ce1405742c6d0
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.1
|
data/lib/slack_log_device.rb
CHANGED
@@ -88,14 +88,10 @@ class SlackLogDevice
|
|
88
88
|
@mutex.synchronize do
|
89
89
|
@buffer << message
|
90
90
|
end
|
91
|
-
if
|
91
|
+
@flush_thread.kill if @flush_thread
|
92
|
+
@flush_thread = Thread.new do
|
93
|
+
sleep(flush_delay) unless auto_flush?
|
92
94
|
flush
|
93
|
-
else
|
94
|
-
@flush_thread.kill if @flush_thread
|
95
|
-
@flush_thread = Thread.new do
|
96
|
-
sleep(flush_delay)
|
97
|
-
flush
|
98
|
-
end
|
99
95
|
end
|
100
96
|
nil
|
101
97
|
end
|
@@ -356,6 +356,7 @@ describe SlackLogDevice do
|
|
356
356
|
it 'does nothing if log level is lower than specified one' do
|
357
357
|
expect(HTTParty).not_to receive(:post)
|
358
358
|
logger.debug('BIM!')
|
359
|
+
device.flush
|
359
360
|
end
|
360
361
|
|
361
362
|
it 'strips message' do
|
@@ -363,9 +364,16 @@ describe SlackLogDevice do
|
|
363
364
|
expect(device.instance_variable_get(:@buffer)).to eq(['BAM !'])
|
364
365
|
end
|
365
366
|
|
367
|
+
it 'converts message to string' do
|
368
|
+
device.write(42)
|
369
|
+
expect(device.instance_variable_get(:@buffer)).to eq(['42'])
|
370
|
+
end
|
371
|
+
|
366
372
|
it 'does nothing if message is blank' do
|
367
373
|
expect(HTTParty).not_to receive(:post)
|
368
|
-
expect
|
374
|
+
expect {
|
375
|
+
expect(device.write(" \n")).to be_nil
|
376
|
+
}.not_to change { device.instance_variable_get(:@buffer) }
|
369
377
|
end
|
370
378
|
|
371
379
|
it 'does nothing if message is nil' do
|
@@ -386,12 +394,6 @@ describe SlackLogDevice do
|
|
386
394
|
device.flush
|
387
395
|
end
|
388
396
|
|
389
|
-
it 'flush if auto flush is true' do
|
390
|
-
options[:auto_flush] = true
|
391
|
-
expect(HTTParty).to receive(:post)
|
392
|
-
device.write('BAM!')
|
393
|
-
end
|
394
|
-
|
395
397
|
it 'does not post HTTP message if auto flush is false' do
|
396
398
|
expect(HTTParty).not_to receive(:post)
|
397
399
|
device.write('BAM!')
|