structured_warnings 0.3.0 → 0.5.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 +5 -5
- data/README.md +4 -23
- data/lib/structured_warnings/kernel.rb +2 -2
- data/lib/structured_warnings/test/warner.rb +1 -1
- data/lib/structured_warnings/version.rb +1 -1
- data/lib/structured_warnings/warner.rb +6 -2
- data/lib/structured_warnings/warning.rb +8 -9
- data/lib/structured_warnings.rb +0 -3
- metadata +10 -15
- data/lib/warning.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a8774c997cadba9d8da089be20d8486231f1b3719cdd0aa3c316950d3e7b8000
|
4
|
+
data.tar.gz: 4fe13678cdbc0151442e8777822090d94204348efa25c479881b5796dff9d0d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51311c54bb3fe552f48d3b5def0c61708da3051a1b76c3888987085531ad9b260dec4d4d3f6d563d9cb7fcf0f81f15044e8c61023331b41fc9471c6bfe91deb7
|
7
|
+
data.tar.gz: 734fa0958d804c8e7ea308c2a0f35b4c9899761e6552f203e51ad5091e6463bcb52bc519e6f0f9e0a93e894d21b6565a96f42e2d6df4e0214eb125ab81f4b0f0
|
data/README.md
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
# StructuredWarnings
|
2
2
|
|
3
|
-
> **Disclaimer:** This is an experimental reimplementation of structured
|
4
|
-
> warnings, based on Ruby 2.4's new warning module. This is not yet ready for
|
5
|
-
> prime time.
|
6
|
-
|
7
3
|
This is an implementation of Daniel Berger's [proposal of structured warnings
|
8
4
|
for Ruby](https://web.archive.org/web/20140328021259/http://www.oreillynet.com/ruby/blog/2008/02/structured_warnings_now.html).
|
9
5
|
They provide dynamic suppression and activation, as well as, an inheritance
|
@@ -37,24 +33,9 @@ Or install it yourself as:
|
|
37
33
|
|
38
34
|
## Compatibility
|
39
35
|
|
40
|
-
`structured_warnings` aims to work with all Ruby
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
Versions of `structured_warnings` before `v0.3.0` are incompatible with Ruby
|
45
|
-
2.4+. Please upgrade accordingly, if you need Ruby 2.4 compatibility. Please
|
46
|
-
note on the otherhand, that many class names changed in an incompatible way
|
47
|
-
with `structured_warnings` `v0.3.0`. This was done to avoid future name clashes.
|
48
|
-
|
49
|
-
Here's a table which should ease upgrading.
|
50
|
-
|
51
|
-
| v0.2.0 and before | v0.3.0 and after |
|
52
|
-
|------------------------------|--------------------------------------------------|
|
53
|
-
| `Warning` | `StructuredWarnings::Base` |
|
54
|
-
| `StandardWarning` | `StructuredWarnings::StandardWarning` |
|
55
|
-
| `DeprecationWarning` | `StructuredWarnings::DeprecationWarning` |
|
56
|
-
| `DeprecatedMethodWarning` | `StructuredWarnings::DeprecatedMethodWarning` |
|
57
|
-
| `DeprecatedSignatureWarning` | `StructuredWarnings::DeprecatedSignatureWarning` |
|
36
|
+
`structured_warnings` aims to work with all stable, maintained Ruby versions. At
|
37
|
+
the time of this writing this is Ruby 3.2, 3.3, and 3.4. Please file a bug for
|
38
|
+
any incompatibilities.
|
58
39
|
|
59
40
|
|
60
41
|
### Test framework support
|
@@ -173,7 +154,7 @@ give as much feedback to your users as possible.
|
|
173
154
|
* [Implementation Highlights](http://www.nach-vorne.de/2008/2/22/structured_warnings-highlights)
|
174
155
|
* [Project's website](https://github.com/schmidt/structured_warnings/)
|
175
156
|
* [API doc](http://rdoc.info/projects/schmidt/structured_warnings)
|
176
|
-
* [Build status](https://
|
157
|
+
* [Build status](https://github.com/schmidt/structured_warnings/actions)
|
177
158
|
|
178
159
|
|
179
160
|
## Development
|
@@ -5,7 +5,7 @@ class StructuredWarnings::Test::Warner < StructuredWarnings::Warner
|
|
5
5
|
# Overrides the public interface of StructuredWarnings::Warner. This
|
6
6
|
# method always returns nil to avoid warnings on stdout during assert_warn
|
7
7
|
# and assert_no_warn blocks.
|
8
|
-
def format(warning, message, call_stack)
|
8
|
+
def format(warning, message, options, call_stack)
|
9
9
|
given_warnings << warning.new(message)
|
10
10
|
nil
|
11
11
|
end
|
@@ -5,11 +5,15 @@
|
|
5
5
|
class StructuredWarnings::Warner
|
6
6
|
# Warner.new.format(StructuredWarning::DeprecationWarning, "more info..", caller)
|
7
7
|
# # => "demo.rb:5 : more info.. (StructuredWarning::DeprecationWarning)"
|
8
|
-
def format(warning, message, stack)
|
8
|
+
def format(warning, message, options, stack)
|
9
9
|
frame = stack.shift
|
10
10
|
# This file contains the backwards compatibility code for Ruby 2.3 and
|
11
11
|
# lower, let's skip it
|
12
12
|
frame = stack.shift if frame.include? 'lib/structured_warnings/kernel.rb'
|
13
|
-
|
13
|
+
|
14
|
+
# Handle introduced uplevel introduced in Ruby 2.5
|
15
|
+
frame = stack.shift(options[:uplevel]).last if options[:uplevel]
|
16
|
+
|
17
|
+
"#{frame}: #{message} (#{warning})\n"
|
14
18
|
end
|
15
19
|
end
|
@@ -36,7 +36,7 @@ module StructuredWarnings::Warning
|
|
36
36
|
#
|
37
37
|
# warn StructuredWarnings::Base.new("The least specific warning you can get")
|
38
38
|
#
|
39
|
-
def warn(*args)
|
39
|
+
def warn(*args, **options)
|
40
40
|
first = args.shift
|
41
41
|
if first.is_a? Class and first <= StructuredWarnings::Base
|
42
42
|
warning = first
|
@@ -46,14 +46,13 @@ module StructuredWarnings::Warning
|
|
46
46
|
warning = first.class
|
47
47
|
message = first.message
|
48
48
|
|
49
|
-
|
50
|
-
warning =
|
51
|
-
if caller.shift.include? 'lib/structured_warnings/kernel.rb'
|
52
|
-
StructuredWarnings::StandardWarning
|
53
|
-
else
|
54
|
-
StructuredWarnings::BuiltInWarning
|
55
|
-
end
|
49
|
+
elsif caller.shift.include? 'lib/structured_warnings/kernel.rb'
|
50
|
+
warning = StructuredWarnings::StandardWarning
|
56
51
|
message = first.to_s
|
52
|
+
|
53
|
+
else
|
54
|
+
warning = StructuredWarnings::BuiltInWarning
|
55
|
+
message = first.to_s.split(':', 4).last.strip
|
57
56
|
end
|
58
57
|
|
59
58
|
# If args is not empty, user passed an incompatible set of arguments.
|
@@ -62,7 +61,7 @@ module StructuredWarnings::Warning
|
|
62
61
|
return super unless args.empty?
|
63
62
|
|
64
63
|
if warning.active?
|
65
|
-
output = StructuredWarnings.warner.format(warning, message, caller(1))
|
64
|
+
output = StructuredWarnings.warner.format(warning, message, options, caller(1))
|
66
65
|
super(output) unless output.nil? or output.to_s.empty?
|
67
66
|
end
|
68
67
|
end
|
data/lib/structured_warnings.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: structured_warnings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregor Schmidt
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-04-15 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: bundler
|
@@ -16,28 +15,28 @@ dependencies:
|
|
16
15
|
requirements:
|
17
16
|
- - "~>"
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1
|
18
|
+
version: '2.1'
|
20
19
|
type: :development
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
23
|
- - "~>"
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1
|
25
|
+
version: '2.1'
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: rake
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
30
29
|
requirements:
|
31
30
|
- - "~>"
|
32
31
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
32
|
+
version: '13.0'
|
34
33
|
type: :development
|
35
34
|
prerelease: false
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
37
36
|
requirements:
|
38
37
|
- - "~>"
|
39
38
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
39
|
+
version: '13.0'
|
41
40
|
- !ruby/object:Gem::Dependency
|
42
41
|
name: minitest
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +57,14 @@ dependencies:
|
|
58
57
|
requirements:
|
59
58
|
- - "~>"
|
60
59
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3.
|
60
|
+
version: '3.0'
|
62
61
|
type: :development
|
63
62
|
prerelease: false
|
64
63
|
version_requirements: !ruby/object:Gem::Requirement
|
65
64
|
requirements:
|
66
65
|
- - "~>"
|
67
66
|
- !ruby/object:Gem::Version
|
68
|
-
version: '3.
|
67
|
+
version: '3.0'
|
69
68
|
description: This is an implementation of Daniel Berger's proposal of structured warnings
|
70
69
|
for Ruby.
|
71
70
|
email:
|
@@ -87,12 +86,10 @@ files:
|
|
87
86
|
- lib/structured_warnings/version.rb
|
88
87
|
- lib/structured_warnings/warner.rb
|
89
88
|
- lib/structured_warnings/warning.rb
|
90
|
-
- lib/warning.rb
|
91
89
|
homepage: http://github.com/schmidt/structured_warnings
|
92
90
|
licenses:
|
93
91
|
- MIT
|
94
92
|
metadata: {}
|
95
|
-
post_install_message:
|
96
93
|
rdoc_options: []
|
97
94
|
require_paths:
|
98
95
|
- lib
|
@@ -100,16 +97,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
97
|
requirements:
|
101
98
|
- - ">="
|
102
99
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
100
|
+
version: 3.2.0
|
104
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
102
|
requirements:
|
106
103
|
- - ">="
|
107
104
|
- !ruby/object:Gem::Version
|
108
105
|
version: '0'
|
109
106
|
requirements: []
|
110
|
-
|
111
|
-
rubygems_version: 2.6.10
|
112
|
-
signing_key:
|
107
|
+
rubygems_version: 3.6.2
|
113
108
|
specification_version: 4
|
114
109
|
summary: Provides structured warnings for Ruby, using an exception-like interface
|
115
110
|
and hierarchy
|