recheck-rails 0.0.1 → 0.4.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 +4 -4
- data/lib/recheck/railtie.rb +10 -0
- data/lib/recheck-rails/setup.rb +55 -0
- data/lib/recheck-rails.rb +4 -0
- metadata +25 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e24b5df25ed0b1160abc3ddcb3162453620100c3d9bee7ed16e5cc89e35012d
|
4
|
+
data.tar.gz: a7aae909ad05e6cefd2ff327c55f460ebfc1e3e7dbe3758fe8196dbb3c6fbe35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6501662dbf1b0231b5dfde87ade48a912bbf3078a762daaad50c56dd6d99683c1aa0137c92d56a3e515e395a6ebc422365d0dbbfaf3f0f34b64a94a5a54b6dab
|
7
|
+
data.tar.gz: 3f9aee836cf002feaba09a93765e19ee33d860ae467bb76ca323c0444661ba14ef3b43d16789f0a0aa173b7862d2755c5d92ee771c1b2d9111fd7b479a753570
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
require "erb"
|
4
|
+
|
5
|
+
module Recheck
|
6
|
+
module Command
|
7
|
+
class Setup
|
8
|
+
# override the base gem's method; with the Rails env booted we can
|
9
|
+
# introspect the models to create much better initial checks
|
10
|
+
def setup_model_checks
|
11
|
+
puts "Introspecting ApplicationRecord..."
|
12
|
+
|
13
|
+
# surely there's a better way to find the gem's root
|
14
|
+
template_dir = File.join(File.expand_path("../..", __dir__), "template")
|
15
|
+
model_template = File.read("#{template_dir}/application_record_check.rb.erb")
|
16
|
+
validation_template = File.read("#{template_dir}/validation_checker.rb.erb")
|
17
|
+
|
18
|
+
# Get all non-abstract ActiveRecord model classes
|
19
|
+
models = ApplicationRecord.descendants.each do |model|
|
20
|
+
puts model
|
21
|
+
puts " skipping abstract class" or next if model.abstract_class?
|
22
|
+
puts " skipping readonly model (probably a view)" or next if model.new.send(:readonly?)
|
23
|
+
|
24
|
+
source_location = Object.const_source_location(model.to_s)
|
25
|
+
model_root_filename = source_location[0].sub(%r{#{Rails.root}/}, "")
|
26
|
+
# kind of a bad variable name here, but support the default model path + others
|
27
|
+
model_filename = model_root_filename.sub(%r{^app/models/}, "")
|
28
|
+
|
29
|
+
if %r{/zeitwerk/}.match?(source_location.first)
|
30
|
+
puts " Warning: model class wasn't loaded; apparently saw a zeitwerk placeholder for its source_location: #{souce_location}"
|
31
|
+
puts "Your app boots/preloads in an unexpected way, if you can help debug please open an issue on recheck."
|
32
|
+
exit 1
|
33
|
+
end
|
34
|
+
|
35
|
+
model_check_filename = "recheck/model/#{model_filename}"
|
36
|
+
class_name = model.name.sub("::", "_") # to differentiate AccountName and Account::Name
|
37
|
+
depth = 1 + model_filename.count("/")
|
38
|
+
|
39
|
+
puts " #{model_check_filename}"
|
40
|
+
FileUtils.mkdir_p(File.dirname(model_check_filename))
|
41
|
+
rendered = ERB.new(model_template).result_with_hash({class_name:, depth:, model:, model_root_filename:})
|
42
|
+
File.write(model_check_filename, rendered)
|
43
|
+
|
44
|
+
validation_check_filename = "recheck/validation/#{model_filename}"
|
45
|
+
puts " #{validation_check_filename}"
|
46
|
+
FileUtils.mkdir_p(File.dirname(validation_check_filename))
|
47
|
+
rendered = ERB.new(validation_template).result_with_hash({class_name:, depth:, model:, model_root_filename:})
|
48
|
+
File.write(validation_check_filename, rendered)
|
49
|
+
|
50
|
+
FileUtils.mkdir_p("recheck/regression")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recheck-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Bhat Harkins
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
11
|
-
dependencies:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: recheck
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
12
26
|
description: Check on validations, background jobs, third-party integrations, state
|
13
27
|
machines, and business rules
|
14
28
|
email:
|
@@ -16,14 +30,17 @@ email:
|
|
16
30
|
executables: []
|
17
31
|
extensions: []
|
18
32
|
extra_rdoc_files: []
|
19
|
-
files:
|
33
|
+
files:
|
34
|
+
- lib/recheck-rails.rb
|
35
|
+
- lib/recheck-rails/setup.rb
|
36
|
+
- lib/recheck/railtie.rb
|
20
37
|
homepage: https://recheck.dev
|
21
38
|
licenses:
|
22
39
|
- LGPL-3.0
|
23
40
|
metadata:
|
24
41
|
homepage_uri: https://recheck.dev
|
25
|
-
source_code_uri: https://github.com/recheckdev/recheck/ruby/recheck
|
26
|
-
changelog_uri: https://github.com/recheckdev/recheck/ruby/
|
42
|
+
source_code_uri: https://github.com/recheckdev/recheck/ruby/recheck-rails
|
43
|
+
changelog_uri: https://github.com/recheckdev/recheck/ruby/recheck-rails/blob/main/CHANGELOG.md
|
27
44
|
rdoc_options: []
|
28
45
|
require_paths:
|
29
46
|
- lib
|
@@ -38,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
38
55
|
- !ruby/object:Gem::Version
|
39
56
|
version: '0'
|
40
57
|
requirements: []
|
41
|
-
rubygems_version: 3.6.
|
58
|
+
rubygems_version: 3.6.7
|
42
59
|
specification_version: 4
|
43
|
-
summary: Recheck your production data integrity
|
60
|
+
summary: Recheck your production data integrity (in Rails)
|
44
61
|
test_files: []
|