softcover 1.2.2 → 1.2.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: 64945447b208aa378a7f80ce6e4917f30157de65
4
- data.tar.gz: 83c6360aad31c986e10333cae4499b3feacdf903
3
+ metadata.gz: d37451336ae35f6232eb313e505cb8fbd4e046f3
4
+ data.tar.gz: afc5907905db330ed9b1f639c6ade75cc625785c
5
5
  SHA512:
6
- metadata.gz: d7a85506b488a3f35e03c5488b4bcf4b1b360943e007ea4139fe35d8948b6a914bbc9de8d242a909541fde2eaf732e8cd96b9e15ec78115da05b33ec5fd66334
7
- data.tar.gz: eb8263ccb8d85f962564f237ad98d0d87a22c5c5f5eed41decb28e7877c82ff81ef4fa5261ce85f410d148981f1303578fc8e9cea87fbe4297486ed083c0805c
6
+ metadata.gz: 871e39738c4ced74cbecd61d48c866341245d40a74fb8836fbacf9950c2a7c0ed08ad3f77bb656aa2e06d9afc1c167526e4f8550274cd6294652538d1e0eee99
7
+ data.tar.gz: 8a6960a5deb17b0cd41ad39e33edd07bca4af2a234eb494e3fb3e40c56786a98d96983de65b1bd375ef6757ee6bd785c8fc2815868f58039b53bba439aa51816
@@ -303,4 +303,18 @@ module Softcover::Utils
303
303
  def article?
304
304
  !!File.readlines(path('config/preamble.tex')).first.match(/extarticle/)
305
305
  end
306
+
307
+ # Silences a stream.
308
+ # This is taken directly from Rails Active Support `silence_stream`.
309
+ # The `silence_stream` method is deprecated because it's not thread-safe, but
310
+ # we don't care about that and the deprecation warnings are annoying.
311
+ def silence_stream(stream)
312
+ old_stream = stream.dup
313
+ stream.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')
314
+ stream.sync = true
315
+ yield
316
+ ensure
317
+ stream.reopen(old_stream)
318
+ old_stream.close
319
+ end
306
320
  end
@@ -1,3 +1,3 @@
1
1
  module Softcover
2
- VERSION = "1.2.2"
2
+ VERSION = "1.2.3"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -52,3 +52,23 @@ end
52
52
 
53
53
  TEST_API_KEY = 'asdfasdfasdfasdfasdf'
54
54
 
55
+ # Captures a stream.
56
+ # This is taken directly from Rails Active Support `capture`.
57
+ # The `capture` method is deprecated because it's not thread-safe, but
58
+ # we don't care about that and the deprecation warnings are annoying.
59
+ def capture(stream)
60
+ stream = stream.to_s
61
+ captured_stream = Tempfile.new(stream)
62
+ stream_io = eval("$#{stream}")
63
+ origin_stream = stream_io.dup
64
+ stream_io.reopen(captured_stream)
65
+
66
+ yield
67
+
68
+ stream_io.rewind
69
+ return captured_stream.read
70
+ ensure
71
+ captured_stream.close
72
+ captured_stream.unlink
73
+ stream_io.reopen(origin_stream)
74
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: softcover
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Hartl