silent 0.1.0 → 0.2.0
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/silent.rb +13 -10
- data/tests/tests.rb +15 -2
- metadata +36 -14
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e930cfee8ca64402d7d5127ad71feff05d418c86
|
4
|
+
data.tar.gz: f3461834cc86ded7f20e107049cced2b246bb5b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c369eb945367a6f7625e120b309cec42f8128cecef6a90d33440f28a18e91bc8fa8c9f775cd5850b5071c5d907cd2b7fef7dab72f42da69e30183209407ceb63
|
7
|
+
data.tar.gz: 91bec32e064078f3b744dbcc4d0d66264a6a5b5d61a0721d5c7a2a5b6cb72eb20dd26dcba99b57467d32c104cbbed75764fe91c1744c335c3151a34f1007da01
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
Binary file
|
data/lib/silent.rb
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
# -*- coding: UTF-8 -*-
|
2
2
|
|
3
|
-
# Silently execute a block.
|
4
|
-
#
|
3
|
+
# Silently execute a block.
|
4
|
+
# @param what [Symbol] output to silent. This must be either +:stdout+ or
|
5
|
+
# +:stderr:+. More than can be given.
|
6
|
+
# @yield []
|
7
|
+
# @return block's returned value
|
5
8
|
def silent(*what)
|
6
9
|
return unless block_given?
|
7
10
|
|
8
|
-
|
9
|
-
|
11
|
+
begin
|
12
|
+
_stdout, $stdout = $stdout, StringIO.new if what.include?(:stdout)
|
13
|
+
_stderr, $stderr = $stderr, StringIO.new if what.include?(:stderr)
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
res
|
15
|
+
yield
|
16
|
+
ensure
|
17
|
+
$stdout = _stdout if what.include?(:stdout)
|
18
|
+
$stderr = _stderr if what.include?(:stderr)
|
19
|
+
end
|
17
20
|
end
|
data/tests/tests.rb
CHANGED
@@ -7,13 +7,13 @@ Coveralls.wear!
|
|
7
7
|
require 'test/unit'
|
8
8
|
require 'simplecov'
|
9
9
|
|
10
|
-
test_dir = File.expand_path( File.dirname(__FILE__) )
|
11
|
-
|
12
10
|
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
13
11
|
SimpleCov.start { add_filter '/tests/' }
|
14
12
|
|
15
13
|
require 'silent'
|
16
14
|
|
15
|
+
class MyException < Exception; end
|
16
|
+
|
17
17
|
class SilentTests < Test::Unit::TestCase
|
18
18
|
def setup
|
19
19
|
@_stdout, $stdout = $stdout, StringIO.new
|
@@ -78,6 +78,19 @@ class SilentTests < Test::Unit::TestCase
|
|
78
78
|
assert_equal(s, $stderr.read)
|
79
79
|
assert_equal('', $stdout.read)
|
80
80
|
end
|
81
|
+
|
82
|
+
def test_silent_raise
|
83
|
+
assert_raise(MyException) do
|
84
|
+
silent(:stdout, :stderr) do
|
85
|
+
raise MyException.new
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
print "foo"
|
90
|
+
|
91
|
+
$stdout.seek(0)
|
92
|
+
assert_equal("foo", $stdout.read)
|
93
|
+
end
|
81
94
|
end
|
82
95
|
|
83
96
|
|
metadata
CHANGED
@@ -1,69 +1,91 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: silent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Baptiste Fontaine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
|
10
|
+
cert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5MW
|
27
|
+
WegqwIwRhIu6Rg7huqJ7TK50pVDF0yrZcsxvWjOfd3clblBHjKGQx5Mbu7LVNGKE
|
28
|
+
+QNdTAwYVTAA8wXHpxk200cHb9xz4e9ANpb4lonGuPz8jKmb/A7Z1M5QD6zStG8l
|
29
|
+
sTlVAhA/LZiC9gL9LtW8Iq7o7xRFhxNPKWHu6JVThH9i16eli+JignOJbGna7C40
|
30
|
+
QnOQb8zHyNL+gq2m/mnZGrSehx+6AujokjOfHbmivYMfDATOQQx0eIBI18IhacZm
|
31
|
+
42WxhhIV2bwDtd77
|
32
|
+
-----END CERTIFICATE-----
|
33
|
+
date: 2015-08-09 00:00:00.000000000 Z
|
12
34
|
dependencies:
|
13
35
|
- !ruby/object:Gem::Dependency
|
14
36
|
name: simplecov
|
15
37
|
requirement: !ruby/object:Gem::Requirement
|
16
38
|
requirements:
|
17
|
-
- - ~>
|
39
|
+
- - "~>"
|
18
40
|
- !ruby/object:Gem::Version
|
19
41
|
version: '0.8'
|
20
42
|
type: :development
|
21
43
|
prerelease: false
|
22
44
|
version_requirements: !ruby/object:Gem::Requirement
|
23
45
|
requirements:
|
24
|
-
- - ~>
|
46
|
+
- - "~>"
|
25
47
|
- !ruby/object:Gem::Version
|
26
48
|
version: '0.8'
|
27
49
|
- !ruby/object:Gem::Dependency
|
28
50
|
name: rake
|
29
51
|
requirement: !ruby/object:Gem::Requirement
|
30
52
|
requirements:
|
31
|
-
- - ~>
|
53
|
+
- - "~>"
|
32
54
|
- !ruby/object:Gem::Version
|
33
55
|
version: '10.3'
|
34
56
|
type: :development
|
35
57
|
prerelease: false
|
36
58
|
version_requirements: !ruby/object:Gem::Requirement
|
37
59
|
requirements:
|
38
|
-
- - ~>
|
60
|
+
- - "~>"
|
39
61
|
- !ruby/object:Gem::Version
|
40
62
|
version: '10.3'
|
41
63
|
- !ruby/object:Gem::Dependency
|
42
64
|
name: test-unit
|
43
65
|
requirement: !ruby/object:Gem::Requirement
|
44
66
|
requirements:
|
45
|
-
- - ~>
|
67
|
+
- - "~>"
|
46
68
|
- !ruby/object:Gem::Version
|
47
69
|
version: '2.5'
|
48
70
|
type: :development
|
49
71
|
prerelease: false
|
50
72
|
version_requirements: !ruby/object:Gem::Requirement
|
51
73
|
requirements:
|
52
|
-
- - ~>
|
74
|
+
- - "~>"
|
53
75
|
- !ruby/object:Gem::Version
|
54
76
|
version: '2.5'
|
55
77
|
- !ruby/object:Gem::Dependency
|
56
78
|
name: coveralls
|
57
79
|
requirement: !ruby/object:Gem::Requirement
|
58
80
|
requirements:
|
59
|
-
- - ~>
|
81
|
+
- - "~>"
|
60
82
|
- !ruby/object:Gem::Version
|
61
83
|
version: '0.7'
|
62
84
|
type: :development
|
63
85
|
prerelease: false
|
64
86
|
version_requirements: !ruby/object:Gem::Requirement
|
65
87
|
requirements:
|
66
|
-
- - ~>
|
88
|
+
- - "~>"
|
67
89
|
- !ruby/object:Gem::Version
|
68
90
|
version: '0.7'
|
69
91
|
description: |
|
@@ -85,17 +107,17 @@ require_paths:
|
|
85
107
|
- lib
|
86
108
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
109
|
requirements:
|
88
|
-
- -
|
110
|
+
- - ">="
|
89
111
|
- !ruby/object:Gem::Version
|
90
112
|
version: '0'
|
91
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
114
|
requirements:
|
93
|
-
- -
|
115
|
+
- - ">="
|
94
116
|
- !ruby/object:Gem::Version
|
95
117
|
version: '0'
|
96
118
|
requirements: []
|
97
119
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
120
|
+
rubygems_version: 2.4.6
|
99
121
|
signing_key:
|
100
122
|
specification_version: 4
|
101
123
|
summary: Silently execute a piece of code
|
metadata.gz.sig
ADDED
Binary file
|