lib/dbf/table.rb in dbf-4.1.6 vs lib/dbf/table.rb in dbf-4.2.0
- old
+ new
@@ -12,10 +12,11 @@
include Enumerable
include ::DBF::Schema
DBASE2_HEADER_SIZE = 8
DBASE3_HEADER_SIZE = 32
+ DBASE7_HEADER_SIZE = 68
VERSIONS = {
'02' => 'FoxBase',
'03' => 'dBase III without memo file',
'04' => 'dBase IV without memo file',
@@ -28,10 +29,11 @@
'63' => 'dBASE IV SQL system files, no memo',
'7b' => 'dBase IV with memo file',
'83' => 'dBase III with memo file',
'87' => 'Visual Objects 1.x with memo file',
'8b' => 'dBase IV with memo file',
+ '8c' => 'dBase 7',
'8e' => 'dBase IV with SQL table',
'cb' => 'dBASE IV SQL table files, with memo',
'f5' => 'FoxPro with memo file',
'fb' => 'FoxPro without memo file'
}.freeze
@@ -214,26 +216,32 @@
def build_columns # :nodoc:
safe_seek do
@data.seek(header_size)
[].tap do |columns|
until end_of_record?
- case version
+ args = case version
when '02'
- column_data = @data.read(header_size * 2)
- columns << Column.new(self, *column_data.unpack('A11 a C'), 0)
+ [self, *@data.read(header_size * 2).unpack('A11 a C'), 0]
+ when '8c'
+ [self, *@data.read(48).unpack('A32 a C C x13')]
else
- column_data = @data.read(header_size)
- columns << Column.new(self, *column_data.unpack('A11 a x4 C2'))
+ [self, *@data.read(header_size).unpack('A11 a x4 C2')]
end
+
+ columns << Column.new(*args)
end
end
end
end
def header_size
- header_size = case version
- when '02' then DBASE2_HEADER_SIZE
- else DBASE3_HEADER_SIZE
+ case version
+ when '02'
+ DBASE2_HEADER_SIZE
+ when '8c'
+ DBASE7_HEADER_SIZE
+ else
+ DBASE3_HEADER_SIZE
end
end
def deleted_record? # :nodoc:
flag = @data.read(1)