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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 581f8331c54a02eb5c1f2d0dd6a88839e536a9edea6fb13f138e101ce24b2df9
4
- data.tar.gz: f81efd11329e60efef6d0f15d7c76045597ff6607ab5c88928e27e1398286b36
3
+ metadata.gz: a8973e45d20ed7c5dcbf2c5b2efc32b182cf7450b5ab380e615e25c7f5469cb3
4
+ data.tar.gz: 8e4031ed9fab5ca71011f42427e406abaeac5cb8926983394d2f41fb90da0ac5
5
5
  SHA512:
6
- metadata.gz: ba1b3f6cd0b8a360f30dde8e5e1a26cfa2a70fc645ac93710b548da4cd81437302d6bedd8b9991e0979f3ea9352b5e0851a05fb083b8acec9a7fe941d48641c4
7
- data.tar.gz: 9645c3f257de602d761aea9733ba96f67101e49ad900fb6280a62b7a98b62dad0d6ebb6b5e82a7adc6d7c4db1871a24d5db2c2699ae4c71d0687efc908c0fb3b
6
+ metadata.gz: 62d41a194185eb19b3b121c6d0a8b1ed85447d04babe386514c324b23959bea596f274fa97770579367ac76aa064c1477d210769ec6c8423c51c49bb7dce3c23
7
+ data.tar.gz: fd379c47ab834014b71609296e192364e79a0f74b8fbc6eade77bdd629fe5336012bbc68864f2a1027fc4c78ee8daf87c2f5b7d8573c0d1f7e3c557636dfe948
@@ -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(/mswin|mingw/.match?(RbConfig::CONFIG['host_os']) ? 'NUL:' : '/dev/null')
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SilentStream
4
- VERSION = '1.0.4'
4
+ VERSION = '1.0.5'
5
5
  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
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-06 00:00:00.000000000 Z
36
+ date: 2018-10-10 00:00:00.000000000 Z
37
37
  dependencies:
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: rake