warning_cleaner 0.0.1
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 +7 -0
- data/.gitignore +1 -0
- data/README.md +11 -0
- data/lib/warning_cleaner.rb +2 -0
- data/lib/warning_cleaner/config.rb +24 -0
- data/lib/warning_cleaner/rule.rb +62 -0
- data/warning_cleaner.gemspec +13 -0
- metadata +50 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d6dffe6484e7376e37d5aca9773034dcbccf7bcf64abb6a720df80b1c2e13381
|
4
|
+
data.tar.gz: 95a8f9176b4fbab62fb17b032b8dcdbf41e064a74190aaa3b71500d672bc3459
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0b7d84e5a1002291c57b5e246e8ea676c684ac633c611835bafa26270040084e8382a200757c88e9ccf66cf2fb0e0a326961ac4a50c487c039e5d672cccdea27
|
7
|
+
data.tar.gz: 60f1385095617080fa00da98635760d95f1bf433893d9f537947c37828012bd47d001db84879fc62fc80f2e761359accd21b1ce0abdf8aa1784757a37eebcb72
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
/*.gem
|
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require "warning_cleaner/rule"
|
3
|
+
module WarningCleaner
|
4
|
+
def self.configure(&block)
|
5
|
+
yield @config ||= WarningCleaner::Config.new(Rule.new("4.2.11.1"))
|
6
|
+
end
|
7
|
+
|
8
|
+
class Config
|
9
|
+
|
10
|
+
attr_accessor :rule, :is_open
|
11
|
+
|
12
|
+
def initialize(rule, is_open = true)
|
13
|
+
@rule = rule
|
14
|
+
@is_open = is_open
|
15
|
+
clean_warning! if is_open
|
16
|
+
end
|
17
|
+
|
18
|
+
def clean_warning!
|
19
|
+
rule.run!
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module WarningCleaner
|
3
|
+
|
4
|
+
if RUBY_VERSION >= '2.4'
|
5
|
+
require 'bigdecimal'
|
6
|
+
|
7
|
+
def BigDecimal.new(*args, **kwargs)
|
8
|
+
BigDecimal(*args, **kwargs)
|
9
|
+
end
|
10
|
+
|
11
|
+
unless defined?(Fixnum)
|
12
|
+
Fixnum = Class.new(Integer)
|
13
|
+
end
|
14
|
+
|
15
|
+
unless defined?(Bignum)
|
16
|
+
Bignum = Class.new(Integer)
|
17
|
+
end
|
18
|
+
|
19
|
+
else
|
20
|
+
# future features
|
21
|
+
end
|
22
|
+
|
23
|
+
class Rule
|
24
|
+
|
25
|
+
WHITE_KEYS = %i(
|
26
|
+
rails_version
|
27
|
+
skip_line_contain
|
28
|
+
)
|
29
|
+
|
30
|
+
DEFAULT_SKIP_WORDS = [
|
31
|
+
"already initialized constant",
|
32
|
+
"previous definition of",
|
33
|
+
"Fixnum is deprecated",
|
34
|
+
"Bignum is deprecated",
|
35
|
+
"defined at the refinement"
|
36
|
+
].freeze
|
37
|
+
|
38
|
+
attr_accessor *WHITE_KEYS
|
39
|
+
def initialize(rails_version, skip_line_contain = [])
|
40
|
+
@rails_version = rails_version
|
41
|
+
@skip_line_contain = DEFAULT_SKIP_WORDS + skip_line_contain
|
42
|
+
end
|
43
|
+
|
44
|
+
def run!
|
45
|
+
rule = self
|
46
|
+
if defined?(::Warning)
|
47
|
+
::Warning.instance_eval do
|
48
|
+
alias_method :warn2, :warn
|
49
|
+
remove_method :warn
|
50
|
+
|
51
|
+
define_method(:warn) do |str|
|
52
|
+
unless str =~ /#{rule.instance_variable_get("@skip_line_contain").join("|")}/
|
53
|
+
warn2 str
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'warning_cleaner'
|
5
|
+
s.version = '0.0.1'
|
6
|
+
s.authors = ['Zhimeng Sun']
|
7
|
+
s.email = ['zhimengSun@gmail.com']
|
8
|
+
s.homepage = 'https://github.com/zhimengSun/warning_cleaner'
|
9
|
+
s.summary = 'simple tools to hide fucking warnings which you want'
|
10
|
+
s.description = 'simple tools to hide fucking warnings which you want, It\'s dead easy to config'
|
11
|
+
|
12
|
+
s.files = `git ls-files`.split("\n")
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: warning_cleaner
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zhimeng Sun
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-03-27 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: simple tools to hide fucking warnings which you want, It's dead easy
|
14
|
+
to config
|
15
|
+
email:
|
16
|
+
- zhimengSun@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".gitignore"
|
22
|
+
- README.md
|
23
|
+
- lib/warning_cleaner.rb
|
24
|
+
- lib/warning_cleaner/config.rb
|
25
|
+
- lib/warning_cleaner/rule.rb
|
26
|
+
- warning_cleaner.gemspec
|
27
|
+
homepage: https://github.com/zhimengSun/warning_cleaner
|
28
|
+
licenses: []
|
29
|
+
metadata: {}
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
requirements: []
|
45
|
+
rubyforge_project:
|
46
|
+
rubygems_version: 2.7.7
|
47
|
+
signing_key:
|
48
|
+
specification_version: 4
|
49
|
+
summary: simple tools to hide fucking warnings which you want
|
50
|
+
test_files: []
|