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 +4 -4
- data/lib/softcover/utils.rb +14 -0
- data/lib/softcover/version.rb +1 -1
- data/spec/spec_helper.rb +20 -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: d37451336ae35f6232eb313e505cb8fbd4e046f3
|
4
|
+
data.tar.gz: afc5907905db330ed9b1f639c6ade75cc625785c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 871e39738c4ced74cbecd61d48c866341245d40a74fb8836fbacf9950c2a7c0ed08ad3f77bb656aa2e06d9afc1c167526e4f8550274cd6294652538d1e0eee99
|
7
|
+
data.tar.gz: 8a6960a5deb17b0cd41ad39e33edd07bca4af2a234eb494e3fb3e40c56786a98d96983de65b1bd375ef6757ee6bd785c8fc2815868f58039b53bba439aa51816
|
data/lib/softcover/utils.rb
CHANGED
@@ -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
|
data/lib/softcover/version.rb
CHANGED
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
|