suppress_output 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 37ac23b6b47f78daaaea82f2f0443d608497c21f
4
+ data.tar.gz: 372368b727e429d67bbe31ccdb0f4456fb865c0f
5
+ SHA512:
6
+ metadata.gz: 5cf5ca22f3fe682a55189a67b9053c6d534e4f797cdf99ab9777b91bff5a67c6970c50b294714cf5014e20962889521cbd87305289f10292ba227ad6363190d5
7
+ data.tar.gz: 8140f7ecf10bd8e5bc37487d983edeecf98ef803f24826c9e18c10eb29c8198d5927f675c42021b3cdfd287528fa26ef1616bc80bbcbb166ab3ac3a33e59fe19
@@ -0,0 +1,27 @@
1
+ # This code is taken from https://gist.github.com/moertel/11091573
2
+ #
3
+ #
4
+ # Temporarily redirects STDOUT and STDERR to /dev/null
5
+ # but does print exceptions should there occur any.
6
+ # Call as:
7
+ # suppress_output { puts 'never printed' }
8
+ #
9
+ class Object
10
+ def suppress_output
11
+ begin
12
+ original_stderr = $stderr.clone
13
+ original_stdout = $stdout.clone
14
+ $stderr.reopen(File.new('/dev/null', 'w'))
15
+ $stdout.reopen(File.new('/dev/null', 'w'))
16
+ retval = yield
17
+ rescue Exception => e
18
+ $stdout.reopen(original_stdout)
19
+ $stderr.reopen(original_stderr)
20
+ raise e
21
+ ensure
22
+ $stdout.reopen(original_stdout)
23
+ $stderr.reopen(original_stderr)
24
+ end
25
+ retval
26
+ end
27
+ end
@@ -0,0 +1,7 @@
1
+ Gem::Specification.new do |g|
2
+ g.name = 'suppress_output'
3
+ g.files = `git ls-files`.split($/)
4
+ g.version = '0.0.1'
5
+ g.summary = 'Extend Object with a method for temporarily redirecting STDOUT and STDERR to /dev/null'
6
+ g.authors = ['Stefanie Grunwald']
7
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: suppress_output
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Stefanie Grunwald
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/suppress_output.rb
20
+ - suppress_output.gemspec
21
+ homepage:
22
+ licenses: []
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.4.5
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Extend Object with a method for temporarily redirecting STDOUT and STDERR
44
+ to /dev/null
45
+ test_files: []
46
+ has_rdoc: