Class: DataSanity::Output
- Inherits:
-
Object
- Object
- DataSanity::Output
- Defined in:
- lib/data_sanity/output.rb
Constant Summary collapse
- OPTIONS =
[:table, :csv]
Instance Attribute Summary collapse
-
#csv_file ⇒ Object
Returns the value of attribute csv_file.
-
#option ⇒ Object
Returns the value of attribute option.
Instance Method Summary collapse
- #close ⇒ Object
- #create_from(model, instance, exception = nil) ⇒ Object
- #end_log ⇒ Object
-
#initialize(options = {}) ⇒ Output
constructor
A new instance of Output.
- #start_log(model) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Output
Returns a new instance of Output.
8 9 10 11 12 13 14 15 16 |
# File 'lib/data_sanity/output.rb', line 8 def initialize = {} raise Exception.new("This options to output the result of inspector is not valid") unless OPTIONS.include?([:option]) self.option = [:option] @count = 0 if self.option == :csv self.csv_file = FasterCSV.open("#{Rails.root}/tmp/data_inspector.csv", 'w') self.csv_file.add_row ['table_name', 'table_primary_key', 'primary_key_value', 'validation_errors'] end end |
Instance Attribute Details
#csv_file ⇒ Object
Returns the value of attribute csv_file.
7 8 9 |
# File 'lib/data_sanity/output.rb', line 7 def csv_file @csv_file end |
#option ⇒ Object
Returns the value of attribute option.
7 8 9 |
# File 'lib/data_sanity/output.rb', line 7 def option @option end |
Instance Method Details
#close ⇒ Object
22 23 24 |
# File 'lib/data_sanity/output.rb', line 22 def close self.csv_file.close_write if self.csv_file end |
#create_from(model, instance, exception = nil) ⇒ Object
18 19 20 |
# File 'lib/data_sanity/output.rb', line 18 def create_from model, instance, exception = nil send("store_to_#{self.option}", model, instance, exception) end |
#end_log ⇒ Object
30 31 32 |
# File 'lib/data_sanity/output.rb', line 30 def end_log puts "==> Inspection completed and found #{@count} validation(s) defaulters" end |
#start_log(model) ⇒ Object
26 27 28 |
# File 'lib/data_sanity/output.rb', line 26 def start_log model puts "==> Inspecting :: " + model.to_s end |