lib/picky/sources/csv.rb in picky-0.12.1 vs lib/picky/sources/csv.rb in picky-0.12.2

- old
+ new

@@ -5,16 +5,18 @@ # class NoCSVFileGiven < StandardError; end class CSV < Base - attr_reader :file_name, :category_names + attr_reader :file_name, :csv_options, :category_names def initialize *category_names, options require 'csv' @category_names = category_names - @file_name = Hash === options && options[:file] || raise_no_file_given(category_names) + + @csv_options = Hash === options && options || {} + @file_name = @csv_options.delete(:file) || raise_no_file_given(category_names) end # # def raise_no_file_given category_names @@ -22,11 +24,11 @@ end # Harvests the data to index. # def harvest _, category - index = category_names.index category.name + index = category_names.index category.from get_data do |ary| indexed_id = ary.shift.to_i # TODO is to_i necessary? text = ary[index] next unless text text.force_encoding 'utf-8' # TODO Still needed? @@ -35,10 +37,10 @@ end # # def get_data &block - ::CSV.foreach file_name, &block + ::CSV.foreach file_name, csv_options, &block end end end \ No newline at end of file