dbf 5.1.1 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +4 -2
- data/dbf.gemspec +6 -9
- data/lib/dbf/column.rb +17 -15
- data/lib/dbf/column_builder.rb +31 -0
- data/lib/dbf/column_type.rb +58 -14
- data/lib/dbf/database/foxpro.rb +19 -32
- data/lib/dbf/file_handler.rb +36 -0
- data/lib/dbf/find.rb +54 -0
- data/lib/dbf/header.rb +5 -8
- data/lib/dbf/memo/base.rb +2 -0
- data/lib/dbf/memo/dbase3.rb +2 -2
- data/lib/dbf/memo/dbase4.rb +2 -2
- data/lib/dbf/memo/foxpro.rb +14 -7
- data/lib/dbf/record.rb +60 -34
- data/lib/dbf/record_context.rb +5 -0
- data/lib/dbf/record_iterator.rb +35 -0
- data/lib/dbf/schema.rb +21 -21
- data/lib/dbf/table.rb +42 -178
- data/lib/dbf/version.rb +1 -1
- data/lib/dbf/version_config.rb +79 -0
- data/lib/dbf.rb +6 -0
- metadata +15 -64
- data/spec/dbf/column_spec.rb +0 -287
- data/spec/dbf/database/foxpro_spec.rb +0 -53
- data/spec/dbf/encoding_spec.rb +0 -49
- data/spec/dbf/file_formats_spec.rb +0 -221
- data/spec/dbf/record_spec.rb +0 -116
- data/spec/dbf/table_spec.rb +0 -377
- data/spec/fixtures/cp1251.dbf +0 -0
- data/spec/fixtures/cp1251_summary.txt +0 -12
- data/spec/fixtures/dbase_02.dbf +0 -0
- data/spec/fixtures/dbase_02_summary.txt +0 -23
- data/spec/fixtures/dbase_03.dbf +0 -0
- data/spec/fixtures/dbase_03_cyrillic.dbf +0 -0
- data/spec/fixtures/dbase_03_cyrillic_summary.txt +0 -11
- data/spec/fixtures/dbase_03_summary.txt +0 -40
- data/spec/fixtures/dbase_30.dbf +0 -0
- data/spec/fixtures/dbase_30.fpt +0 -0
- data/spec/fixtures/dbase_30_summary.txt +0 -154
- data/spec/fixtures/dbase_31.dbf +0 -0
- data/spec/fixtures/dbase_31_summary.txt +0 -20
- data/spec/fixtures/dbase_32.dbf +0 -0
- data/spec/fixtures/dbase_32_summary.txt +0 -11
- data/spec/fixtures/dbase_83.dbf +0 -0
- data/spec/fixtures/dbase_83.dbt +0 -0
- data/spec/fixtures/dbase_83_missing_memo.dbf +0 -0
- data/spec/fixtures/dbase_83_missing_memo_record_0.yml +0 -16
- data/spec/fixtures/dbase_83_record_0.yml +0 -16
- data/spec/fixtures/dbase_83_record_9.yml +0 -23
- data/spec/fixtures/dbase_83_schema_ar.txt +0 -19
- data/spec/fixtures/dbase_83_schema_sq.txt +0 -21
- data/spec/fixtures/dbase_83_schema_sq_lim.txt +0 -21
- data/spec/fixtures/dbase_83_summary.txt +0 -24
- data/spec/fixtures/dbase_8b.dbf +0 -0
- data/spec/fixtures/dbase_8b.dbt +0 -0
- data/spec/fixtures/dbase_8b_summary.txt +0 -15
- data/spec/fixtures/dbase_8c.dbf +0 -0
- data/spec/fixtures/dbase_f5.dbf +0 -0
- data/spec/fixtures/dbase_f5.fpt +0 -0
- data/spec/fixtures/dbase_f5_summary.txt +0 -68
- data/spec/fixtures/foxprodb/FOXPRO-DB-TEST.DBC +0 -0
- data/spec/fixtures/foxprodb/FOXPRO-DB-TEST.DCT +0 -0
- data/spec/fixtures/foxprodb/FOXPRO-DB-TEST.DCX +0 -0
- data/spec/fixtures/foxprodb/calls.CDX +0 -0
- data/spec/fixtures/foxprodb/calls.FPT +0 -0
- data/spec/fixtures/foxprodb/calls.dbf +0 -0
- data/spec/fixtures/foxprodb/contacts.CDX +0 -0
- data/spec/fixtures/foxprodb/contacts.FPT +0 -0
- data/spec/fixtures/foxprodb/contacts.dbf +0 -0
- data/spec/fixtures/foxprodb/setup.CDX +0 -0
- data/spec/fixtures/foxprodb/setup.dbf +0 -0
- data/spec/fixtures/foxprodb/types.CDX +0 -0
- data/spec/fixtures/foxprodb/types.dbf +0 -0
- data/spec/fixtures/polygon.dbf +0 -0
- data/spec/spec_helper.rb +0 -35
data/spec/dbf/table_spec.rb
DELETED
|
@@ -1,377 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
RSpec.describe DBF::Table do
|
|
6
|
-
let(:dbf_path) { fixture('dbase_83.dbf') }
|
|
7
|
-
let(:memo_path) { fixture('dbase_83.dbt') }
|
|
8
|
-
let(:table) { DBF::Table.new dbf_path }
|
|
9
|
-
|
|
10
|
-
specify 'foxpro versions' do
|
|
11
|
-
expect(DBF::Table::FOXPRO_VERSIONS.keys.sort).to eq %w[30 31 f5 fb].sort
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
specify 'row is an alias of record' do
|
|
15
|
-
expect(table.record(1)).to eq table.row(1)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
describe '#initialize' do
|
|
19
|
-
let(:data) { StringIO.new File.read(dbf_path) }
|
|
20
|
-
let(:memo) { StringIO.new File.read(memo_path) }
|
|
21
|
-
|
|
22
|
-
describe 'when given a path to an existing dbf file' do
|
|
23
|
-
it 'does not raise an error' do
|
|
24
|
-
expect { DBF::Table.new dbf_path }.to_not raise_error
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
describe 'when given a path to a non-existent dbf file' do
|
|
29
|
-
it 'raises a DBF::FileNotFound error' do
|
|
30
|
-
expect { DBF::Table.new 'x' }.to raise_error(DBF::FileNotFoundError, 'file not found: x')
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
describe 'when data is nil' do
|
|
35
|
-
it 'raises ArgumentError' do
|
|
36
|
-
expect { DBF::Table.new nil }.to raise_error(ArgumentError, 'data must be a file path or StringIO object')
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
describe 'when given paths to existing dbf and memo files' do
|
|
41
|
-
it 'does not raise an error' do
|
|
42
|
-
expect { DBF::Table.new dbf_path, memo_path }.to_not raise_error
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it 'accepts an io-like data object' do
|
|
47
|
-
expect { DBF::Table.new data }.to_not raise_error
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it 'accepts an io-like data and memo object' do
|
|
51
|
-
expect { DBF::Table.new data, memo }.to_not raise_error
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
describe '#close' do
|
|
56
|
-
before { table.close }
|
|
57
|
-
|
|
58
|
-
it 'closes the io' do
|
|
59
|
-
expect { table.record(1) }.to raise_error(IOError)
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
describe '#schema' do
|
|
64
|
-
describe 'when data is IO' do
|
|
65
|
-
let(:control_schema) { File.read(fixture('dbase_83_schema_ar.txt')) }
|
|
66
|
-
|
|
67
|
-
it 'matches the test schema fixture' do
|
|
68
|
-
expect(table.schema).to eq control_schema
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it 'raises ArgumentError if there is no matching schema' do
|
|
72
|
-
expect { table.schema(:invalid) }.to raise_error(
|
|
73
|
-
ArgumentError,
|
|
74
|
-
':invalid is not a valid schema. Valid schemas are: activerecord, json, sequel.'
|
|
75
|
-
)
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
describe 'when data is StringIO' do
|
|
80
|
-
let(:data) { StringIO.new File.read(dbf_path) }
|
|
81
|
-
let(:table) { DBF::Table.new data }
|
|
82
|
-
|
|
83
|
-
let(:control_schema) { File.read(fixture('dbase_83_schema_ar.txt')) }
|
|
84
|
-
|
|
85
|
-
it 'matches the test schema fixture' do
|
|
86
|
-
table.name = 'dbase_83'
|
|
87
|
-
expect(table.schema).to eq control_schema
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
describe '#sequel_schema' do
|
|
93
|
-
it 'returns a valid Sequel migration by default' do
|
|
94
|
-
control_schema = File.read(fixture('dbase_83_schema_sq.txt'))
|
|
95
|
-
expect(table.sequel_schema).to eq control_schema
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
it 'returns a limited Sequel migration when passed true' do
|
|
99
|
-
control_schema = File.read(fixture('dbase_83_schema_sq_lim.txt'))
|
|
100
|
-
expect(table.sequel_schema).to eq control_schema
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
describe '#json_schema' do
|
|
106
|
-
it 'is valid JSON' do
|
|
107
|
-
expect { JSON.parse(table.json_schema) }.to_not raise_error
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
it 'matches the test fixture' do
|
|
111
|
-
data = JSON.parse(table.json_schema)
|
|
112
|
-
expect(data).to eq [
|
|
113
|
-
{'name' => 'ID', 'type' => 'N', 'length' => 19, 'decimal' => 0},
|
|
114
|
-
{'name' => 'CATCOUNT', 'type' => 'N', 'length' => 19, 'decimal' => 0},
|
|
115
|
-
{'name' => 'AGRPCOUNT', 'type' => 'N', 'length' => 19, 'decimal' => 0},
|
|
116
|
-
{'name' => 'PGRPCOUNT', 'type' => 'N', 'length' => 19, 'decimal' => 0},
|
|
117
|
-
{'name' => 'ORDER', 'type' => 'N', 'length' => 19, 'decimal' => 0},
|
|
118
|
-
{'name' => 'CODE', 'type' => 'C', 'length' => 50, 'decimal' => 0},
|
|
119
|
-
{'name' => 'NAME', 'type' => 'C', 'length' => 100, 'decimal' => 0},
|
|
120
|
-
{'name' => 'THUMBNAIL', 'type' => 'C', 'length' => 254, 'decimal' => 0},
|
|
121
|
-
{'name' => 'IMAGE', 'type' => 'C', 'length' => 254, 'decimal' => 0},
|
|
122
|
-
{'name' => 'PRICE', 'type' => 'N', 'length' => 13, 'decimal' => 2},
|
|
123
|
-
{'name' => 'COST', 'type' => 'N', 'length' => 13, 'decimal' => 2},
|
|
124
|
-
{'name' => 'DESC', 'type' => 'M', 'length' => 10, 'decimal' => 0},
|
|
125
|
-
{'name' => 'WEIGHT', 'type' => 'N', 'length' => 13, 'decimal' => 2},
|
|
126
|
-
{'name' => 'TAXABLE', 'type' => 'L', 'length' => 1, 'decimal' => 0},
|
|
127
|
-
{'name' => 'ACTIVE', 'type' => 'L', 'length' => 1, 'decimal' => 0}
|
|
128
|
-
]
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
describe '#to_csv' do
|
|
133
|
-
after do
|
|
134
|
-
FileUtils.rm_f 'test.csv'
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
describe 'when no path param passed' do
|
|
138
|
-
it 'writes to STDOUT' do
|
|
139
|
-
expect { table.to_csv }.to output.to_stdout
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
describe 'when path param passed' do
|
|
144
|
-
before { table.to_csv('test.csv') }
|
|
145
|
-
|
|
146
|
-
it 'creates a custom csv file' do
|
|
147
|
-
expect(File).to exist('test.csv')
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
describe '#record' do
|
|
153
|
-
it 'return nil for deleted records' do
|
|
154
|
-
allow(table).to receive(:deleted_record?).and_return(true)
|
|
155
|
-
expect(table.record(5)).to be_nil
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
describe 'when dbf has no column definitions' do
|
|
159
|
-
let(:dbf_path) { fixture('polygon.dbf') }
|
|
160
|
-
|
|
161
|
-
it 'raises a DBF::NoColumnsDefined error' do
|
|
162
|
-
expect { DBF::Table.new(dbf_path).record(1) }.to raise_error(DBF::NoColumnsDefined, 'The DBF file has no columns defined')
|
|
163
|
-
end
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
describe '#current_record' do
|
|
168
|
-
it 'returns nil for deleted records' do
|
|
169
|
-
allow(table).to receive(:deleted_record?).and_return(true)
|
|
170
|
-
expect(table.record(0)).to be_nil
|
|
171
|
-
end
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
describe '#find' do
|
|
175
|
-
describe 'with index' do
|
|
176
|
-
it 'returns the correct record' do
|
|
177
|
-
expect(table.find(5)).to eq table.record(5)
|
|
178
|
-
end
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
describe 'with array of indexes' do
|
|
182
|
-
it 'returns the correct records' do
|
|
183
|
-
expect(table.find([1, 5, 10])).to eq [table.record(1), table.record(5), table.record(10)]
|
|
184
|
-
end
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
describe 'with :all' do
|
|
188
|
-
let(:records) do
|
|
189
|
-
table.find(:all, weight: 0.0)
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
it 'retrieves only matching records' do
|
|
193
|
-
expect(records.size).to eq 66
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
it 'yields to a block if given' do
|
|
197
|
-
record_count = 0
|
|
198
|
-
table.find(:all, weight: 0.0) do |record|
|
|
199
|
-
record_count += 1
|
|
200
|
-
expect(record).to be_a DBF::Record
|
|
201
|
-
end
|
|
202
|
-
expect(record_count).to eq 66
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
it 'returns all records if options are empty' do
|
|
206
|
-
expect(table.find(:all)).to eq table.to_a
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
it 'returns matching records when used with options' do
|
|
210
|
-
expect(table.find(:all, 'WEIGHT' => 0.0)).to eq(table.select { |r| r['weight'] == 0.0 })
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
it 'ANDS multiple search terms' do
|
|
214
|
-
expect(table.find(:all, 'ID' => 30, :IMAGE => 'graphics/00000001/TBC01.jpg')).to be_empty
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
it 'matches original column names' do
|
|
218
|
-
expect(table.find(:all, 'WEIGHT' => 0.0)).to_not be_empty
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
it 'matches symbolized column names' do
|
|
222
|
-
expect(table.find(:all, WEIGHT: 0.0)).to_not be_empty
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
it 'matches downcased column names' do
|
|
226
|
-
expect(table.find(:all, 'weight' => 0.0)).to_not be_empty
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
it 'matches symbolized downcased column names' do
|
|
230
|
-
expect(table.find(:all, weight: 0.0)).to_not be_empty
|
|
231
|
-
end
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
describe 'with :first' do
|
|
235
|
-
it 'returns the first record if options are empty' do
|
|
236
|
-
expect(table.find(:first)).to eq table.record(0)
|
|
237
|
-
end
|
|
238
|
-
|
|
239
|
-
it 'returns the first matching record when used with options' do
|
|
240
|
-
expect(table.find(:first, 'CODE' => 'C')).to eq table.record(5)
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
it 'ANDs multiple search terms' do
|
|
244
|
-
expect(table.find(:first, 'ID' => 30, 'IMAGE' => 'graphics/00000001/TBC01.jpg')).to be_nil
|
|
245
|
-
end
|
|
246
|
-
end
|
|
247
|
-
end
|
|
248
|
-
|
|
249
|
-
describe '#filename' do
|
|
250
|
-
it 'returns the filename as a string' do
|
|
251
|
-
expect(table.filename).to eq 'dbase_83.dbf'
|
|
252
|
-
end
|
|
253
|
-
end
|
|
254
|
-
|
|
255
|
-
describe '#name' do
|
|
256
|
-
describe 'when data is an IO' do
|
|
257
|
-
it 'defaults to the filename less extension' do
|
|
258
|
-
expect(table.name).to eq 'dbase_83'
|
|
259
|
-
end
|
|
260
|
-
|
|
261
|
-
it 'is mutable' do
|
|
262
|
-
table.name = 'database_83'
|
|
263
|
-
expect(table.name).to eq 'database_83'
|
|
264
|
-
end
|
|
265
|
-
end
|
|
266
|
-
|
|
267
|
-
describe 'when data is a StringIO' do
|
|
268
|
-
let(:data) { StringIO.new File.read(dbf_path) }
|
|
269
|
-
let(:memo) { StringIO.new File.read(memo_path) }
|
|
270
|
-
let(:table) { DBF::Table.new data }
|
|
271
|
-
|
|
272
|
-
it 'is nil' do
|
|
273
|
-
expect(table.name).to be_nil
|
|
274
|
-
end
|
|
275
|
-
|
|
276
|
-
it 'is mutable' do
|
|
277
|
-
table.name = 'database_83'
|
|
278
|
-
expect(table.name).to eq 'database_83'
|
|
279
|
-
end
|
|
280
|
-
end
|
|
281
|
-
end
|
|
282
|
-
|
|
283
|
-
describe '#has_memo_file?' do
|
|
284
|
-
describe 'without a memo file' do
|
|
285
|
-
let(:table) { DBF::Table.new fixture('dbase_03.dbf') }
|
|
286
|
-
|
|
287
|
-
it 'is false' do
|
|
288
|
-
expect(table).to_not have_memo_file
|
|
289
|
-
end
|
|
290
|
-
end
|
|
291
|
-
|
|
292
|
-
describe 'with a memo file' do
|
|
293
|
-
it 'is true' do
|
|
294
|
-
expect(table).to have_memo_file
|
|
295
|
-
end
|
|
296
|
-
end
|
|
297
|
-
end
|
|
298
|
-
|
|
299
|
-
describe '#columns' do
|
|
300
|
-
let(:columns) { table.columns }
|
|
301
|
-
|
|
302
|
-
it 'is an array of Columns' do
|
|
303
|
-
expect(columns).to be_an(Array)
|
|
304
|
-
expect(columns).to_not be_empty
|
|
305
|
-
expect(columns).to(be_all { |c| c.is_a? DBF::Column })
|
|
306
|
-
end
|
|
307
|
-
end
|
|
308
|
-
|
|
309
|
-
describe '#column_names' do
|
|
310
|
-
let(:column_names) do
|
|
311
|
-
%w[ID CATCOUNT AGRPCOUNT PGRPCOUNT ORDER CODE NAME THUMBNAIL IMAGE PRICE COST DESC WEIGHT TAXABLE ACTIVE]
|
|
312
|
-
end
|
|
313
|
-
|
|
314
|
-
describe 'when data is an IO' do
|
|
315
|
-
it 'is an array of all column names' do
|
|
316
|
-
expect(table.column_names).to eq column_names
|
|
317
|
-
end
|
|
318
|
-
end
|
|
319
|
-
|
|
320
|
-
describe 'when data is a StringIO' do
|
|
321
|
-
let(:data) { StringIO.new File.read(dbf_path) }
|
|
322
|
-
let(:table) { DBF::Table.new data, nil, Encoding::US_ASCII }
|
|
323
|
-
|
|
324
|
-
it 'is an array of all column names' do
|
|
325
|
-
expect(table.column_names).to eq column_names
|
|
326
|
-
end
|
|
327
|
-
end
|
|
328
|
-
end
|
|
329
|
-
|
|
330
|
-
describe '#activerecord_schema_definition' do
|
|
331
|
-
context 'with type N (number)' do
|
|
332
|
-
it 'outputs an integer column' do
|
|
333
|
-
column = DBF::Column.new table, 'ColumnName', 'N', 1, 0
|
|
334
|
-
expect(table.activerecord_schema_definition(column)).to eq "\"column_name\", :integer\n"
|
|
335
|
-
end
|
|
336
|
-
end
|
|
337
|
-
|
|
338
|
-
describe 'with type B (binary)' do
|
|
339
|
-
context 'with Foxpro dbf' do
|
|
340
|
-
it 'outputs a float column' do
|
|
341
|
-
column = DBF::Column.new table, 'ColumnName', 'B', 1, 2
|
|
342
|
-
expect(table.activerecord_schema_definition(column)).to eq "\"column_name\", :binary\n"
|
|
343
|
-
end
|
|
344
|
-
end
|
|
345
|
-
end
|
|
346
|
-
|
|
347
|
-
it 'defines a float colmn if type is (N)umber with more than 0 decimals' do
|
|
348
|
-
column = DBF::Column.new table, 'ColumnName', 'N', 1, 2
|
|
349
|
-
expect(table.activerecord_schema_definition(column)).to eq "\"column_name\", :float\n"
|
|
350
|
-
end
|
|
351
|
-
|
|
352
|
-
it 'defines a date column if type is (D)ate' do
|
|
353
|
-
column = DBF::Column.new table, 'ColumnName', 'D', 8, 0
|
|
354
|
-
expect(table.activerecord_schema_definition(column)).to eq "\"column_name\", :date\n"
|
|
355
|
-
end
|
|
356
|
-
|
|
357
|
-
it 'defines a datetime column if type is (D)ate' do
|
|
358
|
-
column = DBF::Column.new table, 'ColumnName', 'T', 16, 0
|
|
359
|
-
expect(table.activerecord_schema_definition(column)).to eq "\"column_name\", :datetime\n"
|
|
360
|
-
end
|
|
361
|
-
|
|
362
|
-
it 'defines a boolean column if type is (L)ogical' do
|
|
363
|
-
column = DBF::Column.new table, 'ColumnName', 'L', 1, 0
|
|
364
|
-
expect(table.activerecord_schema_definition(column)).to eq "\"column_name\", :boolean\n"
|
|
365
|
-
end
|
|
366
|
-
|
|
367
|
-
it 'defines a text column if type is (M)emo' do
|
|
368
|
-
column = DBF::Column.new table, 'ColumnName', 'M', 1, 0
|
|
369
|
-
expect(table.activerecord_schema_definition(column)).to eq "\"column_name\", :text\n"
|
|
370
|
-
end
|
|
371
|
-
|
|
372
|
-
it 'defines a string column with length for any other data types' do
|
|
373
|
-
column = DBF::Column.new table, 'ColumnName', 'X', 20, 0
|
|
374
|
-
expect(table.activerecord_schema_definition(column)).to eq "\"column_name\", :string, :limit => 20\n"
|
|
375
|
-
end
|
|
376
|
-
end
|
|
377
|
-
end
|
data/spec/fixtures/cp1251.dbf
DELETED
|
Binary file
|
data/spec/fixtures/dbase_02.dbf
DELETED
|
Binary file
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
Database: dbase_02.dbf
|
|
3
|
-
Type: (02) FoxBase
|
|
4
|
-
Memo File: false
|
|
5
|
-
Records: 9
|
|
6
|
-
|
|
7
|
-
Fields:
|
|
8
|
-
Name Type Length Decimal
|
|
9
|
-
------------------------------------------------------------------------------
|
|
10
|
-
EMP:NMBR N 3 0
|
|
11
|
-
LAST C 10 0
|
|
12
|
-
FIRST C 10 0
|
|
13
|
-
ADDR C 20 0
|
|
14
|
-
CITY C 15 0
|
|
15
|
-
ZIP:CODE C 10 0
|
|
16
|
-
PHONE C 9 0
|
|
17
|
-
SSN C 11 0
|
|
18
|
-
HIREDATE C 8 0
|
|
19
|
-
TERMDATE C 8 0
|
|
20
|
-
CLASS C 3 0
|
|
21
|
-
DEPT C 3 0
|
|
22
|
-
PAYRATE N 8 0
|
|
23
|
-
START:PAY N 8 0
|
data/spec/fixtures/dbase_03.dbf
DELETED
|
Binary file
|
|
Binary file
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
Database: dbase_03.dbf
|
|
3
|
-
Type: (03) dBase III without memo file
|
|
4
|
-
Memo File: false
|
|
5
|
-
Records: 14
|
|
6
|
-
|
|
7
|
-
Fields:
|
|
8
|
-
Name Type Length Decimal
|
|
9
|
-
------------------------------------------------------------------------------
|
|
10
|
-
Point_ID C 12 0
|
|
11
|
-
Type C 20 0
|
|
12
|
-
Shape C 20 0
|
|
13
|
-
Circular_D C 20 0
|
|
14
|
-
Non_circul C 60 0
|
|
15
|
-
Flow_prese C 20 0
|
|
16
|
-
Condition C 20 0
|
|
17
|
-
Comments C 60 0
|
|
18
|
-
Date_Visit D 8 0
|
|
19
|
-
Time C 10 0
|
|
20
|
-
Max_PDOP N 5 1
|
|
21
|
-
Max_HDOP N 5 1
|
|
22
|
-
Corr_Type C 36 0
|
|
23
|
-
Rcvr_Type C 36 0
|
|
24
|
-
GPS_Date D 8 0
|
|
25
|
-
GPS_Time C 10 0
|
|
26
|
-
Update_Sta C 36 0
|
|
27
|
-
Feat_Name C 20 0
|
|
28
|
-
Datafile C 20 0
|
|
29
|
-
Unfilt_Pos N 10 0
|
|
30
|
-
Filt_Pos N 10 0
|
|
31
|
-
Data_Dicti C 20 0
|
|
32
|
-
GPS_Week N 6 0
|
|
33
|
-
GPS_Second N 12 3
|
|
34
|
-
GPS_Height N 16 3
|
|
35
|
-
Vert_Prec N 16 1
|
|
36
|
-
Horz_Prec N 16 1
|
|
37
|
-
Std_Dev N 16 6
|
|
38
|
-
Northing N 16 3
|
|
39
|
-
Easting N 16 3
|
|
40
|
-
Point_ID N 9 0
|
data/spec/fixtures/dbase_30.dbf
DELETED
|
Binary file
|
data/spec/fixtures/dbase_30.fpt
DELETED
|
Binary file
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
Database: dbase_30.dbf
|
|
3
|
-
Type: (30) Visual FoxPro
|
|
4
|
-
Memo File: true
|
|
5
|
-
Records: 34
|
|
6
|
-
|
|
7
|
-
Fields:
|
|
8
|
-
Name Type Length Decimal
|
|
9
|
-
------------------------------------------------------------------------------
|
|
10
|
-
ACCESSNO C 15 0
|
|
11
|
-
ACQVALUE N 12 2
|
|
12
|
-
APPNOTES M 4 0
|
|
13
|
-
APPRAISOR C 75 0
|
|
14
|
-
CABINET C 25 0
|
|
15
|
-
CAPTION C 30 0
|
|
16
|
-
CAT C 1 0
|
|
17
|
-
CATBY C 25 0
|
|
18
|
-
CATDATE D 8 0
|
|
19
|
-
CATTYPE C 15 0
|
|
20
|
-
CLASSES M 4 0
|
|
21
|
-
COLLECTION C 75 0
|
|
22
|
-
CONDDATE D 8 0
|
|
23
|
-
CONDEXAM C 25 0
|
|
24
|
-
CONDITION C 35 0
|
|
25
|
-
CONDNOTES M 4 0
|
|
26
|
-
CONTAINER C 40 0
|
|
27
|
-
COPYRIGHT M 4 0
|
|
28
|
-
CREATOR C 80 0
|
|
29
|
-
CREDIT M 4 0
|
|
30
|
-
CURVALMAX N 12 2
|
|
31
|
-
CURVALUE N 12 2
|
|
32
|
-
DATASET C 15 0
|
|
33
|
-
DATE C 50 0
|
|
34
|
-
DESCRIP M 4 0
|
|
35
|
-
DIMNOTES M 4 0
|
|
36
|
-
DISPVALUE C 10 0
|
|
37
|
-
DRAWER C 20 0
|
|
38
|
-
EARLYDATE N 4 0
|
|
39
|
-
EVENT C 80 0
|
|
40
|
-
EXHIBITID C 36 0
|
|
41
|
-
EXHIBITNO N 7 0
|
|
42
|
-
EXHLABEL1 M 4 0
|
|
43
|
-
EXHLABEL2 M 4 0
|
|
44
|
-
EXHLABEL3 M 4 0
|
|
45
|
-
EXHLABEL4 M 4 0
|
|
46
|
-
EXHSTART D 8 0
|
|
47
|
-
FILMSIZE C 35 0
|
|
48
|
-
FLAGDATE T 8 0
|
|
49
|
-
FLAGNOTES M 4 0
|
|
50
|
-
FLAGREASON C 20 0
|
|
51
|
-
FRAME C 75 0
|
|
52
|
-
FRAMENO C 25 0
|
|
53
|
-
GPARENT C 45 0
|
|
54
|
-
HOMELOC C 60 0
|
|
55
|
-
IMAGEFILE C 60 0
|
|
56
|
-
IMAGENO N 3 0
|
|
57
|
-
INSCOMP C 30 0
|
|
58
|
-
INSDATE D 8 0
|
|
59
|
-
INSPHONE C 25 0
|
|
60
|
-
INSPREMIUM C 20 0
|
|
61
|
-
INSREP C 30 0
|
|
62
|
-
INSVALUE N 10 2
|
|
63
|
-
INVNBY C 25 0
|
|
64
|
-
INVNDATE D 8 0
|
|
65
|
-
LATEDATE N 4 0
|
|
66
|
-
LEGAL M 4 0
|
|
67
|
-
LOANCOND M 4 0
|
|
68
|
-
LOANDATE D 8 0
|
|
69
|
-
LOANDUE D 8 0
|
|
70
|
-
LOANID C 36 0
|
|
71
|
-
LOANINNO C 15 0
|
|
72
|
-
MAINTCYCLE C 10 0
|
|
73
|
-
MAINTDATE D 8 0
|
|
74
|
-
MAINTNOTE M 4 0
|
|
75
|
-
MEDIUM C 75 0
|
|
76
|
-
NEGLOC C 60 0
|
|
77
|
-
NEGNO C 25 0
|
|
78
|
-
NOTES M 4 0
|
|
79
|
-
OBJECTID C 25 0
|
|
80
|
-
OBJNAME C 40 0
|
|
81
|
-
OLDNO C 25 0
|
|
82
|
-
ORIGCOPY C 15 0
|
|
83
|
-
OTHERNO C 25 0
|
|
84
|
-
OUTDATE D 8 0
|
|
85
|
-
PARENT C 40 0
|
|
86
|
-
PEOPLE M 4 0
|
|
87
|
-
PLACE C 100 0
|
|
88
|
-
POLICYNO C 20 0
|
|
89
|
-
PRINTSIZE C 35 0
|
|
90
|
-
PROCESS C 75 0
|
|
91
|
-
PROVENANCE M 4 0
|
|
92
|
-
PUBNOTES M 4 0
|
|
93
|
-
RECAS C 20 0
|
|
94
|
-
RECDATE C 10 0
|
|
95
|
-
RECFROM C 120 0
|
|
96
|
-
RELATION C 36 0
|
|
97
|
-
RELNOTES M 4 0
|
|
98
|
-
ROOM C 25 0
|
|
99
|
-
SGFLAG C 1 0
|
|
100
|
-
SHELF C 20 0
|
|
101
|
-
SITE C 40 0
|
|
102
|
-
SITENO C 12 0
|
|
103
|
-
SLIDENO C 25 0
|
|
104
|
-
STATUS C 20 0
|
|
105
|
-
STATUSBY C 25 0
|
|
106
|
-
STATUSDATE D 8 0
|
|
107
|
-
STERMS M 4 0
|
|
108
|
-
STUDIO C 60 0
|
|
109
|
-
SUBJECTS M 4 0
|
|
110
|
-
TCABINET C 25 0
|
|
111
|
-
TCONTAINER C 40 0
|
|
112
|
-
TDRAWER C 20 0
|
|
113
|
-
TEMPAUTHOR C 25 0
|
|
114
|
-
TEMPBY C 25 0
|
|
115
|
-
TEMPDATE D 8 0
|
|
116
|
-
TEMPLOC C 60 0
|
|
117
|
-
TEMPNOTES M 4 0
|
|
118
|
-
TEMPREASON C 50 0
|
|
119
|
-
TEMPUNTIL C 10 0
|
|
120
|
-
TITLE M 4 0
|
|
121
|
-
TITLESORT C 100 0
|
|
122
|
-
TROOM C 25 0
|
|
123
|
-
TSHELF C 20 0
|
|
124
|
-
TWALL C 20 0
|
|
125
|
-
UDF1 C 75 0
|
|
126
|
-
UDF10 C 75 0
|
|
127
|
-
UDF11 C 20 0
|
|
128
|
-
UDF12 C 20 0
|
|
129
|
-
UDF13 N 12 0
|
|
130
|
-
UDF14 N 12 2
|
|
131
|
-
UDF15 N 12 2
|
|
132
|
-
UDF16 N 12 3
|
|
133
|
-
UDF17 N 12 3
|
|
134
|
-
UDF18 D 8 0
|
|
135
|
-
UDF19 D 8 0
|
|
136
|
-
UDF20 D 8 0
|
|
137
|
-
UDF21 M 4 0
|
|
138
|
-
UDF22 M 4 0
|
|
139
|
-
UDF2 C 75 0
|
|
140
|
-
UDF3 C 75 0
|
|
141
|
-
UDF4 C 75 0
|
|
142
|
-
UDF5 C 75 0
|
|
143
|
-
UDF6 C 75 0
|
|
144
|
-
UDF7 C 75 0
|
|
145
|
-
UDF8 C 75 0
|
|
146
|
-
UDF9 C 75 0
|
|
147
|
-
UPDATED T 8 0
|
|
148
|
-
UPDATEDBY C 25 0
|
|
149
|
-
VALUEDATE D 8 0
|
|
150
|
-
WALL C 20 0
|
|
151
|
-
WEBINCLUDE L 1 0
|
|
152
|
-
ZSORTER C 69 0
|
|
153
|
-
ZSORTERX C 44 0
|
|
154
|
-
PPID C 36 0
|
data/spec/fixtures/dbase_31.dbf
DELETED
|
Binary file
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
Database: dbase_31.dbf
|
|
3
|
-
Type: (31) Visual FoxPro with AutoIncrement field
|
|
4
|
-
Memo File: false
|
|
5
|
-
Records: 77
|
|
6
|
-
|
|
7
|
-
Fields:
|
|
8
|
-
Name Type Length Decimal
|
|
9
|
-
------------------------------------------------------------------------------
|
|
10
|
-
PRODUCTID I 4 0
|
|
11
|
-
PRODUCTNAM C 40 0
|
|
12
|
-
SUPPLIERID I 4 0
|
|
13
|
-
CATEGORYID I 4 0
|
|
14
|
-
QUANTITYPE C 20 0
|
|
15
|
-
UNITPRICE Y 8 4
|
|
16
|
-
UNITSINSTO I 4 0
|
|
17
|
-
UNITSONORD I 4 0
|
|
18
|
-
REORDERLEV I 4 0
|
|
19
|
-
DISCONTINU L 1 0
|
|
20
|
-
_NullFlags 0 1 0
|
data/spec/fixtures/dbase_32.dbf
DELETED
|
Binary file
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
Database: dbase_32.dbf
|
|
3
|
-
Type: (32) Visual FoxPro with field type Varchar or Varbinary
|
|
4
|
-
Memo File: false
|
|
5
|
-
Records: 1
|
|
6
|
-
|
|
7
|
-
Fields:
|
|
8
|
-
Name Type Length Decimal
|
|
9
|
-
------------------------------------------------------------------------------
|
|
10
|
-
NAME V 250 0
|
|
11
|
-
_NullFlags 0 1 0
|
data/spec/fixtures/dbase_83.dbf
DELETED
|
Binary file
|
data/spec/fixtures/dbase_83.dbt
DELETED
|
Binary file
|
|
Binary file
|