ruby_warning_filter 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Manifest.txt +1 -0
- data/Readme.md +3 -1
- data/lib/ruby_warning_filter.rb +10 -6
- data/ruby_warning_filter.gemspec +1 -1
- data/test/bench.rb +32 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c91d9f4a9c50812b5453fea598148a4671e1e3c0
|
4
|
+
data.tar.gz: f2e129ea8ece436be6c218072feef11a9c3a08de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73abc3ab4af12b573a56272af381b5cf1f6d7bd44473730978ada189914da8614522938cdcb3625019bbfc7e5bf04d2c7e658bd0a4fc2bd3de9fd6e793b97b53
|
7
|
+
data.tar.gz: 4080f1ce3435991cfac80045efc007552adb497445350ce01442ec7886d0f58a095727772a17917f66a8475ddfe2e44b46fa09b4e73c80471ab8be007cbf4a01
|
data/Gemfile
CHANGED
data/Manifest.txt
CHANGED
data/Readme.md
CHANGED
@@ -24,6 +24,8 @@ When running your app or tests you should see only relevant warnings. Now, go fi
|
|
24
24
|
|
25
25
|
## Feedback
|
26
26
|
|
27
|
+
The filter works by proxying all writes to stderr. It has been running for a while in many of my work projects with good results. However, it is probably not comprehensive. Please, report any warnings that it misses or swallows by error.
|
28
|
+
|
27
29
|
[![Build Status](https://travis-ci.org/semaperepelitsa/ruby_warning_filter.svg?branch=master)](https://travis-ci.org/semaperepelitsa/ruby_warning_filter)
|
28
30
|
|
29
|
-
The
|
31
|
+
The gem is tested against Ruby 2.0, 2.1, 2.2.
|
data/lib/ruby_warning_filter.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
require
|
1
|
+
require "delegate"
|
2
|
+
require "set"
|
2
3
|
|
3
4
|
# Filter IO from Ruby warnings that come out of external gems.
|
4
5
|
# There is no other way currently to filter out Ruby warnings other than hijacking stderr.
|
@@ -22,9 +23,16 @@ class RubyWarningFilter < DelegateClass(IO)
|
|
22
23
|
|
23
24
|
def initialize(io, ignore_path: Gem.path)
|
24
25
|
super(io)
|
26
|
+
|
25
27
|
@ruby_warnings = 0
|
26
28
|
@ignored = false
|
27
|
-
@ignore_path = ignore_path
|
29
|
+
@ignore_path = ignore_path.to_set
|
30
|
+
|
31
|
+
# Gem path can contain symlinks.
|
32
|
+
# Some warnings use real path instead of symlinks so we need to ignore both.
|
33
|
+
ignore_path.each do |a|
|
34
|
+
@ignore_path << File.realpath(a) if File.exist?(a)
|
35
|
+
end
|
28
36
|
end
|
29
37
|
|
30
38
|
def write(line)
|
@@ -72,10 +80,6 @@ class RubyWarningFilter < DelegateClass(IO)
|
|
72
80
|
line.start_with?("\tfrom")
|
73
81
|
end
|
74
82
|
|
75
|
-
def whitespace?(line)
|
76
|
-
line =~ /^\s*$/
|
77
|
-
end
|
78
|
-
|
79
83
|
def eval_redefined?(line)
|
80
84
|
line =~ /\(eval\):\d+: warning: previous definition of .+ was here/
|
81
85
|
end
|
data/ruby_warning_filter.gemspec
CHANGED
data/test/bench.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require_relative "../lib/ruby_warning_filter"
|
3
|
+
require "benchmark/ips"
|
4
|
+
|
5
|
+
file = File.new("/dev/null", "w")
|
6
|
+
filter = RubyWarningFilter.new(file, ignore_path: ["/path/to/gems"])
|
7
|
+
|
8
|
+
def write_errors(io)
|
9
|
+
10.times do
|
10
|
+
io.write("/path/to/gems/file.rb:297: warning: instance variable @object not initialized\n")
|
11
|
+
end
|
12
|
+
|
13
|
+
10.times do |i|
|
14
|
+
io.write("\tfrom /something/foo/bar:#{i}:in `<main>'")
|
15
|
+
end
|
16
|
+
|
17
|
+
10.times do
|
18
|
+
io.write("(eval):1: warning: previous definition of foo was here")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
Benchmark.ips do |x|
|
23
|
+
x.report "plain File" do
|
24
|
+
write_errors(file)
|
25
|
+
end
|
26
|
+
|
27
|
+
x.report "RubyWarningFilter" do
|
28
|
+
write_errors(filter)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_warning_filter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Semyon Perepelitsa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: sema@sema.in
|
@@ -22,6 +22,7 @@ files:
|
|
22
22
|
- Readme.md
|
23
23
|
- lib/ruby_warning_filter.rb
|
24
24
|
- ruby_warning_filter.gemspec
|
25
|
+
- test/bench.rb
|
25
26
|
- test/ruby_warnings_filter_test.rb
|
26
27
|
homepage: https://github.com/semaperepelitsa/ruby_warning_filter
|
27
28
|
licenses:
|
@@ -48,4 +49,5 @@ signing_key:
|
|
48
49
|
specification_version: 4
|
49
50
|
summary: Hassle-free Ruby warnings
|
50
51
|
test_files:
|
52
|
+
- test/bench.rb
|
51
53
|
- test/ruby_warnings_filter_test.rb
|