Module: DataResurrection::Adapters::DBF

Defined in:
lib/data_resurrection/adapters.rb

Defined Under Namespace

Classes: ARObject

Instance Method Summary collapse

Instance Method Details

#get_data(table, encodings = nil, reserved_words = []) ⇒ Object



20
21
22
23
24
# File 'lib/data_resurrection/adapters.rb', line 20

def get_data(table, encodings=nil, reserved_words=[])
  result = get_raw_data(table, reserved_words)
  result = handle_encodings(result, encodings) if encodings.present?
  result
end

#resurrect(origin_table, options) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/data_resurrection/adapters.rb', line 9

def resurrect(origin_table, options)
  target_table_name = options[:target]
  from, to = options[:from], options[:to]
  field_types = options[:field_types]
  table = ::DBF::Table.new(origin_table)
  encodings = from.present? ? {from: from, to: to} : nil
  data = get_data(table, encodings, reserved_words)
  create_table(table, target_table_name, data, field_types)
  copy_data(target_table_name, data)
end