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.
@@ -17,15 +17,21 @@ module DataSanity
17
17
  if @all
18
18
  @models.each do |model_string|
19
19
  model = model_string.constantize
20
- validate_all(model) if @all
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
@@ -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
- system "rails generate model DataInspector table_name:string table_primary_key:string primary_key_value:string validation_errors:text"
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
@@ -1,3 +1,3 @@
1
1
  module DataSanity
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -15,7 +15,6 @@ end
15
15
  def setup_data_inspector
16
16
  Dir.chdir("#{Rails.root}") do
17
17
  system "rake data_sanity:db:migrate"
18
- system "rake db:migrate"
19
18
  end
20
19
  end
21
20
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 8
9
- version: 0.1.8
8
+ - 9
9
+ version: 0.1.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Habibullah, Rahul, Jigyasa, Jyotsna, Hephzibah, Garima