data_sanity 0.2.3 → 0.2.4

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.
@@ -19,21 +19,21 @@ module DataSanity
19
19
  considered_models = @criteria ? @criteria.keys : @models
20
20
  considered_models.each do |model_string|
21
21
  model = model_string.constantize
22
- log_start(model)
22
+ @output.start_log model
23
23
  validate_all(model)
24
- log_end(model)
24
+ @output.end_log
25
25
  end
26
26
  elsif @criteria
27
27
  @criteria.keys.each do |model|
28
- log_start(model)
28
+ @output.start_log model
29
29
  validate_criteria(model.constantize, @criteria[model])
30
- log_end(model)
30
+ @output.end_log
31
31
  end
32
32
  else
33
33
  @models.each do |model_string|
34
- log_start(model_string)
34
+ @output.start_log model_string
35
35
  validate_random(model_string.constantize)
36
- log_end(model_string)
36
+ @output.end_log
37
37
  end
38
38
  end
39
39
  @output.close
@@ -85,14 +85,5 @@ module DataSanity
85
85
  all_models
86
86
  end
87
87
 
88
- def log_start model
89
- puts "==> Inspecting :: " + model.to_s
90
- end
91
-
92
- def log_end model
93
- validation_count = DataInspector.where(:table_name => model.to_s).count
94
- puts "==> Inspection completed and found #{validation_count} validation(s) defaulters"
95
- end
96
-
97
88
  end
98
89
  end
@@ -8,6 +8,7 @@ module DataSanity
8
8
  def initialize options = {}
9
9
  raise Exception.new("This options to output the result of inspector is not valid") unless OPTIONS.include?(options[:option])
10
10
  self.option = options[:option]
11
+ @count = 0
11
12
  if self.option == :csv
12
13
  self.csv_file = FasterCSV.open("#{Rails.root}/tmp/data_inspector.csv", 'w')
13
14
  self.csv_file.add_row ['table_name', 'table_primary_key', 'primary_key_value', 'validation_errors']
@@ -22,16 +23,26 @@ module DataSanity
22
23
  self.csv_file.close_write if self.csv_file
23
24
  end
24
25
 
26
+ def start_log model
27
+ puts "==> Inspecting :: " + model.to_s
28
+ end
29
+
30
+ def end_log
31
+ puts "==> Inspection completed and found #{@count} validation(s) defaulters"
32
+ end
33
+
25
34
  private
26
35
  def store_to_table model, instance, exception
27
36
  DataInspector.create(:table_name => model.to_s,
28
37
  :table_primary_key => model.primary_key,
29
38
  :primary_key_value => instance.send(model.primary_key),
30
39
  :validation_errors => (exception || instance.errors.full_messages.to_yaml))
40
+ @count += 1
31
41
  end
32
42
 
33
43
  def store_to_csv model, instance, exception
34
44
  self.csv_file.add_row [model.to_s, model.primary_key, instance.send(model.primary_key), ( exception || instance.errors.full_messages.to_sentence) ]
45
+ @count += 1
35
46
  end
36
47
  end
37
48
  end
@@ -1,3 +1,3 @@
1
1
  module DataSanity
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 3
9
- version: 0.2.3
8
+ - 4
9
+ version: 0.2.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Habibullah, Rahul, Jigyasa, Jyotsna, Hephzibah, Garima
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-06-15 00:00:00 +05:30
17
+ date: 2012-06-23 00:00:00 +05:30
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency