data_sanity 0.1.8 → 0.1.9
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.
- data/lib/data_sanity/inspector.rb +16 -1
- data/lib/data_sanity/tasks.rb +11 -3
- data/lib/data_sanity/version.rb +1 -1
- data/spec/support/helper.rb +0 -1
- metadata +2 -2
@@ -17,15 +17,21 @@ module DataSanity
|
|
17
17
|
if @all
|
18
18
|
@models.each do |model_string|
|
19
19
|
model = model_string.constantize
|
20
|
-
|
20
|
+
log_start(model)
|
21
|
+
validate_all(model)
|
22
|
+
log_end(model)
|
21
23
|
end
|
22
24
|
elsif @criteria
|
23
25
|
@criteria.keys.each do |model|
|
26
|
+
log_start(model)
|
24
27
|
validate_criteria(model.constantize, @criteria[model])
|
28
|
+
log_end(model)
|
25
29
|
end
|
26
30
|
else
|
27
31
|
@models.each do |model_string|
|
32
|
+
log_start(model_string)
|
28
33
|
validate_random(model_string.constantize)
|
34
|
+
log_end(model_string)
|
29
35
|
end
|
30
36
|
end
|
31
37
|
end
|
@@ -82,5 +88,14 @@ module DataSanity
|
|
82
88
|
all_models
|
83
89
|
end
|
84
90
|
|
91
|
+
def log_start model
|
92
|
+
puts "==> Inspecting :: " + model.to_s
|
93
|
+
end
|
94
|
+
|
95
|
+
def log_end model
|
96
|
+
validation_count = DataInspector.where(:table_name => model.to_s).count
|
97
|
+
puts "==> Inspection completed and found #{validation_count} validation(s) defaulters"
|
98
|
+
end
|
99
|
+
|
85
100
|
end
|
86
101
|
end
|
data/lib/data_sanity/tasks.rb
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
namespace :data_sanity do
|
2
2
|
namespace :db do
|
3
|
-
desc 'Create data inspector model for data sanity results'
|
3
|
+
desc 'Create data inspector model for data sanity results (runs migration too)'
|
4
4
|
task :migrate => :environment do
|
5
5
|
Dir.chdir("#{Rails.root}") do
|
6
|
-
|
6
|
+
command = "rails generate model DataInspector table_name:string table_primary_key:string primary_key_value:string validation_errors:text"
|
7
|
+
log_command command
|
8
|
+
system "#{command}"
|
9
|
+
command = "rake db:migrate"
|
10
|
+
Rake::Task['db:migrate'].execute
|
7
11
|
end
|
8
12
|
end
|
9
13
|
|
10
|
-
desc 'Destroy data inspector model for data sanity results'
|
14
|
+
desc 'Destroy data inspector model for data sanity results (it doesnt rollbacks the migration)'
|
11
15
|
task :rollback => :environment do
|
12
16
|
Dir.chdir("#{Rails.root}") do
|
13
17
|
system "rails destroy model DataInspector"
|
@@ -27,3 +31,7 @@ namespace :data_sanity do
|
|
27
31
|
DataSanity::Inspector.new(args).investigate
|
28
32
|
end
|
29
33
|
end
|
34
|
+
|
35
|
+
def log_command command
|
36
|
+
puts "Running ==> " + command.to_s
|
37
|
+
end
|
data/lib/data_sanity/version.rb
CHANGED
data/spec/support/helper.rb
CHANGED