uncruft 0.2.1 → 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/Rakefile +10 -8
- data/lib/uncruft/deprecation_handler.rb +6 -8
- data/lib/uncruft/version.rb +1 -1
- data/lib/uncruft/warning.rb +3 -1
- data/lib/uncruft.rb +5 -2
- data/spec/spec_helper.rb +6 -2
- data/spec/uncruft/deprecatable_spec.rb +2 -2
- data/spec/uncruft/deprecation_handler_spec.rb +4 -4
- data/spec/uncruft/warning_spec.rb +3 -3
- data/spec/uncruft_spec.rb +1 -1
- metadata +19 -22
- data/spec/dummy/config/deprecations.ignore +0 -7
- data/spec/examples.txt +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c93c7cc504ba0e5d3bf93b8ffbbfadee05e66c8084f3580fc93855490ed4ec3
|
4
|
+
data.tar.gz: 6b1f3835bb69a640c757896730bb9cf284f212087f9f04339709e0186f921b92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6427a8d529e5b0f51f26c3fc8b88f06d3f9823a0d02eb0e3cfdf3c00419dab9c9f2c634adec618ba21c72f54cc9ddedd6b90c18aaad854ea7c0564c224dff52
|
7
|
+
data.tar.gz: 67fba4c3a6ba79098cc141f597e7965917804306b41d5299cb4795600f191a3c5c8589506e4073d7be9ec6f045b75abe635338a75077ebc28b35b4848773d446
|
data/Rakefile
CHANGED
@@ -6,8 +6,6 @@ end
|
|
6
6
|
|
7
7
|
Bundler::GemHelper.install_tasks
|
8
8
|
|
9
|
-
task(:default).clear
|
10
|
-
|
11
9
|
require 'rubocop/rake_task'
|
12
10
|
RuboCop::RakeTask.new
|
13
11
|
|
@@ -15,10 +13,14 @@ require 'rspec/core'
|
|
15
13
|
require 'rspec/core/rake_task'
|
16
14
|
RSpec::Core::RakeTask.new(:spec)
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
16
|
+
def default_task
|
17
|
+
if ENV['APPRAISAL_INITIALIZED'] || ENV['CI']
|
18
|
+
%i(rubocop spec)
|
19
|
+
else
|
20
|
+
require 'appraisal'
|
21
|
+
Appraisal::Task.new
|
22
|
+
%i(appraisal)
|
23
|
+
end
|
24
24
|
end
|
25
|
+
|
26
|
+
task(:default).clear.enhance(default_task)
|
@@ -95,14 +95,12 @@ module Uncruft
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def known_deprecations
|
98
|
-
@known_deprecations ||=
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
end
|
105
|
-
end
|
98
|
+
@known_deprecations ||= if known_deprecations_file_exists?
|
99
|
+
file = File.read(Uncruft.ignorefile_path)
|
100
|
+
JSON.parse(file)['ignored_warnings'].to_set
|
101
|
+
else
|
102
|
+
Set.new
|
103
|
+
end
|
106
104
|
end
|
107
105
|
|
108
106
|
def file_content(deprecations)
|
data/lib/uncruft/version.rb
CHANGED
data/lib/uncruft/warning.rb
CHANGED
@@ -2,10 +2,12 @@ module Uncruft
|
|
2
2
|
module Warning
|
3
3
|
DEPRECATION_PATTERN = /(deprecation|deprecated)/i.freeze
|
4
4
|
|
5
|
-
def warn(str, *args)
|
5
|
+
def warn(str, *args, **kwargs)
|
6
6
|
if str =~ DEPRECATION_PATTERN # rubocop:disable Performance/RegexpMatch
|
7
7
|
message = strip_caller_info(str, caller_locations(1..1).first).strip
|
8
8
|
ActiveSupport::Deprecation.warn(message)
|
9
|
+
elsif RUBY_VERSION < '2.7' && kwargs.empty?
|
10
|
+
super(str, *args)
|
9
11
|
else
|
10
12
|
super
|
11
13
|
end
|
data/lib/uncruft.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/time'
|
3
|
+
|
1
4
|
require 'uncruft/version'
|
2
5
|
require 'uncruft/railtie'
|
3
6
|
require 'uncruft/deprecation_handler'
|
@@ -10,11 +13,11 @@ module Uncruft
|
|
10
13
|
FALSE_VALUES = [false, 0, "0", "f", "F", "false", "FALSE", "off", "OFF"].to_set
|
11
14
|
|
12
15
|
def record_deprecations?
|
13
|
-
ENV['RECORD_DEPRECATIONS'].presence && !
|
16
|
+
ENV['RECORD_DEPRECATIONS'].presence && !ENV['RECORD_DEPRECATIONS'].in?(FALSE_VALUES)
|
14
17
|
end
|
15
18
|
|
16
19
|
def ignorefile_path
|
17
|
-
ENV['UNCRUFT_IGNOREFILE_PATH'] || Rails.root.join('config
|
20
|
+
ENV['UNCRUFT_IGNOREFILE_PATH'] || Rails.root.join('config/deprecations.ignore')
|
18
21
|
end
|
19
22
|
end
|
20
23
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,9 +5,13 @@ ENV["RAILS_ENV"] ||= 'test'
|
|
5
5
|
require File.expand_path('dummy/config/application', __dir__)
|
6
6
|
require 'support/rails_root'
|
7
7
|
|
8
|
-
Time.zone = ActiveSupport::TimeZone.all.first
|
9
|
-
|
10
8
|
RSpec.configure do |config|
|
11
9
|
config.run_all_when_everything_filtered = true
|
12
10
|
config.example_status_persistence_file_path = 'spec/examples.txt'
|
11
|
+
|
12
|
+
config.around(:all) do |example|
|
13
|
+
Time.use_zone(ActiveSupport::TimeZone.all.first) do
|
14
|
+
example.run
|
15
|
+
end
|
16
|
+
end
|
13
17
|
end
|
@@ -13,7 +13,7 @@ RSpec.describe Uncruft::Deprecatable do
|
|
13
13
|
attr_accessor :first_name
|
14
14
|
|
15
15
|
deprecate_attribute(:first_name,
|
16
|
-
|
16
|
+
message: "Please stop using this attribute!")
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -44,7 +44,7 @@ RSpec.describe Uncruft::Deprecatable do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
deprecate_method(:legacy_method,
|
47
|
-
|
47
|
+
message: "Please stop using this method!")
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe Uncruft::DeprecationHandler do
|
4
|
-
let(:ignorefile_path) { Rails.root.join('config
|
4
|
+
let(:ignorefile_path) { Rails.root.join('config/deprecations.ignore') }
|
5
5
|
|
6
6
|
before do
|
7
7
|
File.delete(ignorefile_path) if File.exist?(ignorefile_path)
|
@@ -10,7 +10,7 @@ RSpec.describe Uncruft::DeprecationHandler do
|
|
10
10
|
subject { described_class.new }
|
11
11
|
|
12
12
|
describe '#call' do
|
13
|
-
let(:absolute_path) { Rails.root.join('chicken
|
13
|
+
let(:absolute_path) { Rails.root.join('chicken/nuggets.rb') }
|
14
14
|
let(:line_number) { 123 }
|
15
15
|
let(:caller_label) { '<something>' }
|
16
16
|
let(:message) { "Warning: BAD called from #{caller_label} at #{absolute_path}:#{line_number}" }
|
@@ -104,14 +104,14 @@ RSpec.describe Uncruft::DeprecationHandler do
|
|
104
104
|
end
|
105
105
|
|
106
106
|
context 'when gem is vendored' do
|
107
|
-
let(:absolute_path) { Rails.root.join('vendor
|
107
|
+
let(:absolute_path) { Rails.root.join('vendor/cache/chicken/nuggets.rb') }
|
108
108
|
|
109
109
|
it 'sanitizes the message and raises an error' do
|
110
110
|
expect { subject.call(message, '') }.to raise_error(RuntimeError, expected_error_message)
|
111
111
|
end
|
112
112
|
|
113
113
|
context 'when gem is vendored elsewhere' do
|
114
|
-
let(:absolute_path) { Rails.root.join('
|
114
|
+
let(:absolute_path) { Rails.root.join('../../vendor/cache/chicken/nuggets.rb') }
|
115
115
|
|
116
116
|
it 'sanitizes the message and raises an error' do
|
117
117
|
expect { subject.call(message, '') }.to raise_error(RuntimeError, expected_error_message)
|
@@ -32,13 +32,13 @@ describe Uncruft::Warning do
|
|
32
32
|
it 'strips out the path so that ActiveSupport::Deprecation can append a new one' do
|
33
33
|
path = caller_locations(0..0).first.path
|
34
34
|
|
35
|
-
|
35
|
+
allow(ActiveSupport::Deprecation).to receive(:warn).with('foo is deprecated!').and_return('hurray')
|
36
36
|
expect(warn("#{path}: foo is deprecated!")).to eq('hurray')
|
37
37
|
|
38
|
-
|
38
|
+
allow(ActiveSupport::Deprecation).to receive(:warn).with('[DEPRECATION] bar is no more.').and_return('huzzah')
|
39
39
|
expect(Kernel.warn("[DEPRECATION] bar is no more. #{path}:#{caller_locations(0..0).first.lineno}")).to eq('huzzah')
|
40
40
|
|
41
|
-
|
41
|
+
allow(ActiveSupport::Deprecation).to receive(:warn).with('Deprecation detected: banana --').and_return('we do our best...')
|
42
42
|
expect(Warning.warn("Deprecation detected: banana -- #{caller(0..0).first}")).to eq('we do our best...')
|
43
43
|
end
|
44
44
|
end
|
data/spec/uncruft_spec.rb
CHANGED
@@ -30,7 +30,7 @@ RSpec.describe Uncruft do
|
|
30
30
|
|
31
31
|
describe '.ignorefile_path' do
|
32
32
|
it 'uses rails root' do
|
33
|
-
expect(described_class.ignorefile_path).to eq(Rails.root.join('config
|
33
|
+
expect(described_class.ignorefile_path).to eq(Rails.root.join('config/deprecations.ignore'))
|
34
34
|
end
|
35
35
|
|
36
36
|
context 'when env var is set' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uncruft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Griffith
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-01-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 5.2.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 5.2.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: appraisal
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: 2.2.0
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: betterlint
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
@@ -54,33 +54,33 @@ dependencies:
|
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: rails
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- - "
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
62
|
+
version: '0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- - "
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: '0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
71
|
+
name: rspec
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- - "
|
74
|
+
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: 3.7.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- - "
|
81
|
+
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
83
|
+
version: 3.7.0
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: timecop
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,8 +113,6 @@ files:
|
|
113
113
|
- lib/uncruft/version.rb
|
114
114
|
- lib/uncruft/warning.rb
|
115
115
|
- spec/dummy/config/application.rb
|
116
|
-
- spec/dummy/config/deprecations.ignore
|
117
|
-
- spec/examples.txt
|
118
116
|
- spec/spec_helper.rb
|
119
117
|
- spec/support/rails_root.rb
|
120
118
|
- spec/uncruft/deprecatable_spec.rb
|
@@ -125,7 +123,8 @@ files:
|
|
125
123
|
homepage: https://github.com/Betterment/uncruft
|
126
124
|
licenses:
|
127
125
|
- MIT
|
128
|
-
metadata:
|
126
|
+
metadata:
|
127
|
+
rubygems_mfa_required: 'true'
|
129
128
|
post_install_message:
|
130
129
|
rdoc_options: []
|
131
130
|
require_paths:
|
@@ -134,22 +133,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
134
133
|
requirements:
|
135
134
|
- - ">="
|
136
135
|
- !ruby/object:Gem::Version
|
137
|
-
version:
|
136
|
+
version: 2.6.0
|
138
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
138
|
requirements:
|
140
139
|
- - ">="
|
141
140
|
- !ruby/object:Gem::Version
|
142
141
|
version: '0'
|
143
142
|
requirements: []
|
144
|
-
rubygems_version: 3.
|
143
|
+
rubygems_version: 3.1.6
|
145
144
|
signing_key:
|
146
145
|
specification_version: 4
|
147
146
|
summary: A library to assist with Rails upgrades
|
148
147
|
test_files:
|
149
148
|
- spec/spec_helper.rb
|
150
|
-
- spec/dummy/config/deprecations.ignore
|
151
149
|
- spec/dummy/config/application.rb
|
152
|
-
- spec/examples.txt
|
153
150
|
- spec/uncruft/railtie_spec.rb
|
154
151
|
- spec/uncruft/warning_spec.rb
|
155
152
|
- spec/uncruft/deprecatable_spec.rb
|
data/spec/examples.txt
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
example_id | status | run_time |
|
2
|
-
------------------------------------------------------- | ------ | --------------- |
|
3
|
-
./spec/uncruft/deprecatable_spec.rb[1:1:1] | passed | 0.00763 seconds |
|
4
|
-
./spec/uncruft/deprecatable_spec.rb[1:1:2] | passed | 0.00031 seconds |
|
5
|
-
./spec/uncruft/deprecatable_spec.rb[1:2:1] | passed | 0.00025 seconds |
|
6
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:1] | passed | 0.00536 seconds |
|
7
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:2:1] | passed | 0.00786 seconds |
|
8
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:2:2:1] | passed | 0.00347 seconds |
|
9
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:3:1] | passed | 0.00061 seconds |
|
10
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:4:1] | passed | 0.00039 seconds |
|
11
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:5:1] | passed | 0.00044 seconds |
|
12
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:6:1] | passed | 0.00054 seconds |
|
13
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:6:2:1] | passed | 0.00045 seconds |
|
14
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:6:3:1] | passed | 0.00058 seconds |
|
15
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:6:3:2:1] | passed | 0.00066 seconds |
|
16
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:7:1] | passed | 0.00047 seconds |
|
17
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:8:1] | passed | 0.00302 seconds |
|
18
|
-
./spec/uncruft/deprecation_handler_spec.rb[1:1:8:2:1] | passed | 0.00166 seconds |
|
19
|
-
./spec/uncruft/railtie_spec.rb[1:1] | passed | 0.04267 seconds |
|
20
|
-
./spec/uncruft/railtie_spec.rb[1:2:1] | passed | 0.00167 seconds |
|
21
|
-
./spec/uncruft/railtie_spec.rb[1:3:1] | passed | 0.00219 seconds |
|
22
|
-
./spec/uncruft/warning_spec.rb[1:1] | passed | 0.00031 seconds |
|
23
|
-
./spec/uncruft/warning_spec.rb[1:2] | passed | 0.00011 seconds |
|
24
|
-
./spec/uncruft/warning_spec.rb[1:3:1] | passed | 0.00054 seconds |
|
25
|
-
./spec/uncruft/warning_spec.rb[1:3:2:1] | passed | 0.00045 seconds |
|
26
|
-
./spec/uncruft_spec.rb[1:1:1] | passed | 0.00246 seconds |
|
27
|
-
./spec/uncruft_spec.rb[1:2:1] | passed | 0.00025 seconds |
|
28
|
-
./spec/uncruft_spec.rb[1:2:2:1] | passed | 0.00024 seconds |
|