structured_warnings 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +200 -0
- data/lib/{structured_warnings/dynamic.rb → dynamic.rb} +0 -0
- data/lib/structured_warnings.rb +19 -9
- data/lib/structured_warnings/base.rb +132 -0
- data/lib/structured_warnings/kernel.rb +5 -65
- data/lib/structured_warnings/minitest.rb +5 -0
- data/lib/structured_warnings/test.rb +3 -5
- data/lib/structured_warnings/test/assertions.rb +93 -98
- data/lib/structured_warnings/test/warner.rb +32 -35
- data/lib/structured_warnings/test_unit.rb +5 -0
- data/lib/structured_warnings/version.rb +3 -0
- data/lib/structured_warnings/warner.rb +13 -11
- data/lib/structured_warnings/warning.rb +61 -119
- data/lib/warning.rb +9 -0
- metadata +53 -92
- data/Gemfile +0 -3
- data/Gemfile.lock +0 -21
- data/History.txt +0 -36
- data/License.txt +0 -20
- data/README.rdoc +0 -137
- data/Rakefile +0 -55
- data/doc/DeprecatedMethodWarning.html +0 -105
- data/doc/DeprecatedSignatureWarning.html +0 -106
- data/doc/DeprecationWarning.html +0 -106
- data/doc/Dynamic.html +0 -125
- data/doc/Object.html +0 -117
- data/doc/README_rdoc.html +0 -283
- data/doc/StandardWarning.html +0 -104
- data/doc/StructuredWarnings.html +0 -125
- data/doc/StructuredWarnings/ClassMethods.html +0 -192
- data/doc/StructuredWarnings/Kernel.html +0 -222
- data/doc/StructuredWarnings/Test.html +0 -97
- data/doc/StructuredWarnings/Test/Assertions.html +0 -272
- data/doc/StructuredWarnings/Test/Warner.html +0 -208
- data/doc/StructuredWarnings/Warner.html +0 -162
- data/doc/Test.html +0 -95
- data/doc/Test/Unit.html +0 -95
- data/doc/Warning.html +0 -398
- data/doc/Warning/ClassMethods.html +0 -278
- data/doc/created.rid +0 -10
- data/doc/css/fonts.css +0 -167
- data/doc/css/rdoc.css +0 -590
- data/doc/fonts/Lato-Light.ttf +0 -0
- data/doc/fonts/Lato-LightItalic.ttf +0 -0
- data/doc/fonts/Lato-Regular.ttf +0 -0
- data/doc/fonts/Lato-RegularItalic.ttf +0 -0
- data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +0 -121
- data/doc/js/darkfish.js +0 -161
- data/doc/js/jquery.js +0 -4
- data/doc/js/navigation.js +0 -142
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search.js +0 -109
- data/doc/js/search_index.js +0 -1
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js +0 -228
- data/doc/js/searcher.js.gz +0 -0
- data/doc/table_of_contents.html +0 -200
- data/structured_warnings.gemspec +0 -24
- data/test/structured_warnings_test.rb +0 -187
data/structured_warnings.gemspec
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = 'structured_warnings'
|
5
|
-
s.version = '0.2.0'
|
6
|
-
s.author = 'Gregor Schmidt'
|
7
|
-
s.email = 'ruby@schmidtwisser.de'
|
8
|
-
s.homepage = 'http://github.com/schmidt/structured_warnings'
|
9
|
-
s.summary = 'Provides structured warnings for Ruby, using an exception-like interface and hierarchy'
|
10
|
-
s.license = 'MIT'
|
11
|
-
s.files = Dir['**/*'].reject{ |f| f.include?('git') }
|
12
|
-
s.test_files = Dir['test/*.rb']
|
13
|
-
|
14
|
-
s.rdoc_options = ['--charset=UTF-8']
|
15
|
-
s.extra_rdoc_files = ['README.rdoc']
|
16
|
-
|
17
|
-
s.add_development_dependency "rake"
|
18
|
-
s.add_development_dependency "test-unit"
|
19
|
-
|
20
|
-
s.description = %Q{
|
21
|
-
This is an implementation of Daniel Berger's proposal of structured
|
22
|
-
warnings for Ruby.
|
23
|
-
}
|
24
|
-
end
|
@@ -1,187 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'structured_warnings'
|
3
|
-
|
4
|
-
class Foo
|
5
|
-
def method_using_structured_warning_style_api
|
6
|
-
warn DeprecatedMethodWarning,
|
7
|
-
'This method is deprecated. Use new_method instead'
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
class Bar
|
12
|
-
attr_reader :args
|
13
|
-
|
14
|
-
def warn(*args)
|
15
|
-
@args = args
|
16
|
-
end
|
17
|
-
|
18
|
-
def method_using_incompatible_warn_api
|
19
|
-
warn :deprecated, 'explanation'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class StructuredWarningsTest < Test::Unit::TestCase
|
24
|
-
def supports_fork
|
25
|
-
return false unless Process.respond_to? :fork
|
26
|
-
fork { Kernel.exit! }
|
27
|
-
Process.wait
|
28
|
-
|
29
|
-
true
|
30
|
-
rescue NotImplementedError
|
31
|
-
false
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_fork_in_thread
|
35
|
-
return unless supports_fork
|
36
|
-
|
37
|
-
Thread.new do
|
38
|
-
fork do
|
39
|
-
begin
|
40
|
-
DeprecatedMethodWarning.disable do
|
41
|
-
Foo.new.method_using_structured_warning_style_api
|
42
|
-
end
|
43
|
-
rescue
|
44
|
-
puts "\n#{$!.class.name}: #{$!.message}"
|
45
|
-
puts $!.backtrace.join("\n")
|
46
|
-
exit 1
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end.join
|
50
|
-
Process.wait
|
51
|
-
|
52
|
-
assert($?.success?, 'Forked subprocess failed')
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_warn_using_structured_warning_style_api
|
56
|
-
assert_warn(DeprecatedMethodWarning) do
|
57
|
-
Foo.new.method_using_structured_warning_style_api
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_warn_using_incompatible_warn_api
|
62
|
-
bar = Bar.new
|
63
|
-
|
64
|
-
assert_no_warn do
|
65
|
-
bar.method_using_incompatible_warn_api
|
66
|
-
end
|
67
|
-
|
68
|
-
assert_equal :deprecated, bar.args.first
|
69
|
-
assert_equal "explanation", bar.args.last
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_disable_warning_blockwise
|
73
|
-
assert_no_warn(DeprecatedMethodWarning) do
|
74
|
-
DeprecatedMethodWarning.disable do
|
75
|
-
Foo.new.method_using_structured_warning_style_api
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_disable_warning_globally
|
81
|
-
assert_no_warn(DeprecatedMethodWarning) do
|
82
|
-
DeprecatedMethodWarning.disable
|
83
|
-
Foo.new.method_using_structured_warning_style_api
|
84
|
-
DeprecatedMethodWarning.enable
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_last_but_not_least
|
89
|
-
assert_warn(DeprecatedMethodWarning) do
|
90
|
-
DeprecatedMethodWarning.disable do
|
91
|
-
DeprecatedMethodWarning.enable do
|
92
|
-
Foo.new.method_using_structured_warning_style_api
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_warnings_have_an_inheritance_relation
|
99
|
-
assert_no_warn(DeprecatedMethodWarning) do
|
100
|
-
DeprecationWarning.disable do
|
101
|
-
Foo.new.method_using_structured_warning_style_api
|
102
|
-
end
|
103
|
-
end
|
104
|
-
assert_warn(DeprecationWarning) do
|
105
|
-
Foo.new.method_using_structured_warning_style_api
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_warn_writes_to_stderr
|
110
|
-
require "stringio"
|
111
|
-
old_stderr = $stderr
|
112
|
-
$stderr = io = ::StringIO.new
|
113
|
-
Foo.new.method_using_structured_warning_style_api
|
114
|
-
$stderr = old_stderr
|
115
|
-
io.rewind
|
116
|
-
assert io.length > 0
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_warning_is_default_warning
|
120
|
-
assert_warn(Warning) do
|
121
|
-
warn "my warning"
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
def test_passing_a_warning_instance_works_as_well
|
126
|
-
assert_warn(Warning) do
|
127
|
-
warn Warning.new("my warning")
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
def test_passing_anything_but_a_subclass_or_instance_of_warning_will_work
|
132
|
-
assert_warn(Warning) do
|
133
|
-
warn nil
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
def test_passing_an_additional_message_to_assert_no_warn
|
138
|
-
assert_no_warn(Warning, "with message") do
|
139
|
-
warn Warning, "with another message"
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_passing_an_additional_message_to_assert_warn
|
144
|
-
assert_warn(Warning, "with message") do
|
145
|
-
warn Warning, "with message"
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def test_passing_a_warning_instance_to_assert_warn
|
150
|
-
assert_warn(Warning.new("with message")) do
|
151
|
-
warn Warning, "with message"
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
def test_passing_a_warning_instance_to_assert_no_warn
|
156
|
-
assert_no_warn(Warning.new("with message")) do
|
157
|
-
warn DeprecationWarning, "with another message"
|
158
|
-
end
|
159
|
-
assert_no_warn(Warning.new) do
|
160
|
-
warn Warning, "with message"
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
def test_passing_a_regexp_as_message_to_assert_warn
|
165
|
-
assert_warn(Warning, /message/) do
|
166
|
-
warn DeprecationWarning, "with another message"
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
def test_passing_a_regexp_as_message_to_no_assert_warn
|
171
|
-
assert_no_warn(Warning, /message/) do
|
172
|
-
warn DeprecationWarning
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
def test_passing_a_message_only_to_assert_warn
|
177
|
-
assert_warn("I told you so") do
|
178
|
-
warn "I told you so"
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
def test_warnings_may_not_be_disabled_twice
|
183
|
-
assert_equal [Warning], Warning.disable
|
184
|
-
assert_equal [Warning], Warning.disable
|
185
|
-
assert_equal [], Warning.enable
|
186
|
-
end
|
187
|
-
end
|