silent_stream 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/silent_stream.rb +15 -1
- data/lib/silent_stream/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8973e45d20ed7c5dcbf2c5b2efc32b182cf7450b5ab380e615e25c7f5469cb3
|
4
|
+
data.tar.gz: 8e4031ed9fab5ca71011f42427e406abaeac5cb8926983394d2f41fb90da0ac5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62d41a194185eb19b3b121c6d0a8b1ed85447d04babe386514c324b23959bea596f274fa97770579367ac76aa064c1477d210769ec6c8423c51c49bb7dce3c23
|
7
|
+
data.tar.gz: fd379c47ab834014b71609296e192364e79a0f74b8fbc6eade77bdd629fe5336012bbc68864f2a1027fc4c78ee8daf87c2f5b7d8573c0d1f7e3c557636dfe948
|
data/lib/silent_stream.rb
CHANGED
@@ -59,7 +59,7 @@ module SilentStream
|
|
59
59
|
# This method is not thread-safe.
|
60
60
|
def silence_stream(stream)
|
61
61
|
old_stream = stream.dup
|
62
|
-
stream.reopen(
|
62
|
+
stream.reopen(windows_os_test ? 'NUL:' : '/dev/null')
|
63
63
|
stream.sync = true
|
64
64
|
yield
|
65
65
|
ensure
|
@@ -116,5 +116,19 @@ module SilentStream
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
end
|
119
|
+
|
120
|
+
private
|
121
|
+
|
122
|
+
WINDOWS_REGEXP = /mswin|mingw/
|
123
|
+
REGEXP_HAS_MATCH = Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.4')
|
124
|
+
def windows_os_test
|
125
|
+
# When available, in Ruby 2.4+, we use Regexp#match? which does not update
|
126
|
+
# the $~ global object and may be 3x faster than alternative match tests
|
127
|
+
if REGEXP_HAS_MATCH
|
128
|
+
WINDOWS_REGEXP.match?(RbConfig::CONFIG['host_os'])
|
129
|
+
else
|
130
|
+
WINDOWS_REGEXP =~ (RbConfig::CONFIG['host_os'])
|
131
|
+
end
|
132
|
+
end
|
119
133
|
end
|
120
134
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: silent_stream
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Daer
|
@@ -33,7 +33,7 @@ authors:
|
|
33
33
|
autorequire:
|
34
34
|
bindir: exe
|
35
35
|
cert_chain: []
|
36
|
-
date: 2018-10-
|
36
|
+
date: 2018-10-10 00:00:00.000000000 Z
|
37
37
|
dependencies:
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: rake
|