lib/csv2hash.rb in csv2hash-0.1.1 vs lib/csv2hash.rb in csv2hash-0.2.0
- old
+ new
@@ -1,10 +1,13 @@
require 'csv2hash/version'
require 'csv2hash/definition'
require 'csv2hash/validator'
require 'csv2hash/validator/mapping'
require 'csv2hash/validator/collection'
+require 'csv2hash/structure_validator'
+require 'csv2hash/structure_validator/max_columns'
+require 'csv2hash/structure_validator/min_columns'
require 'csv2hash/parser'
require 'csv2hash/parser/mapping'
require 'csv2hash/parser/collection'
require 'csv2hash/csv_array'
require 'csv2hash/data_wrapper'
@@ -13,10 +16,12 @@
require 'csv'
class Csv2hash
+ include Csv2hash::StructureValidator
+
attr_accessor :definition, :file_path, :data, :notifier, :exception_mode, :errors, :ignore_blank_line
def initialize definition, file_path, exception_mode=true, data_source=nil, ignore_blank_line=false
@data_source = data_source
self.definition, self.file_path = definition, file_path
@@ -24,10 +29,11 @@
self.exception_mode, self.errors = exception_mode, []
dynamic_lib_loading 'Validator'
self.notifier = Notifier.new
self.ignore_blank_line = ignore_blank_line
init_plugins
+
end
def init_plugins
begin
@plugins = []
@@ -40,9 +46,10 @@
def parse
load_data_source
definition.validate!
definition.default!
+ validate_structure!
validate_data!
Csv2hash::DataWrapper.new.tap do |response|
if valid?
fill!
\ No newline at end of file