dbf 5.1.0 → 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.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/README.md +4 -2
  4. data/dbf.gemspec +6 -9
  5. data/lib/dbf/column.rb +19 -15
  6. data/lib/dbf/column_builder.rb +31 -0
  7. data/lib/dbf/column_type.rb +61 -15
  8. data/lib/dbf/database/foxpro.rb +21 -32
  9. data/lib/dbf/encodings.rb +2 -0
  10. data/lib/dbf/file_handler.rb +36 -0
  11. data/lib/dbf/find.rb +54 -0
  12. data/lib/dbf/header.rb +7 -8
  13. data/lib/dbf/memo/base.rb +4 -0
  14. data/lib/dbf/memo/dbase3.rb +5 -3
  15. data/lib/dbf/memo/dbase4.rb +4 -2
  16. data/lib/dbf/memo/foxpro.rb +16 -7
  17. data/lib/dbf/record.rb +62 -34
  18. data/lib/dbf/record_context.rb +5 -0
  19. data/lib/dbf/record_iterator.rb +35 -0
  20. data/lib/dbf/schema.rb +23 -21
  21. data/lib/dbf/table.rb +44 -178
  22. data/lib/dbf/version.rb +3 -1
  23. data/lib/dbf/version_config.rb +79 -0
  24. data/lib/dbf.rb +8 -0
  25. metadata +15 -64
  26. data/spec/dbf/column_spec.rb +0 -286
  27. data/spec/dbf/database/foxpro_spec.rb +0 -51
  28. data/spec/dbf/encoding_spec.rb +0 -47
  29. data/spec/dbf/file_formats_spec.rb +0 -219
  30. data/spec/dbf/record_spec.rb +0 -114
  31. data/spec/dbf/table_spec.rb +0 -375
  32. data/spec/fixtures/cp1251.dbf +0 -0
  33. data/spec/fixtures/cp1251_summary.txt +0 -12
  34. data/spec/fixtures/dbase_02.dbf +0 -0
  35. data/spec/fixtures/dbase_02_summary.txt +0 -23
  36. data/spec/fixtures/dbase_03.dbf +0 -0
  37. data/spec/fixtures/dbase_03_cyrillic.dbf +0 -0
  38. data/spec/fixtures/dbase_03_cyrillic_summary.txt +0 -11
  39. data/spec/fixtures/dbase_03_summary.txt +0 -40
  40. data/spec/fixtures/dbase_30.dbf +0 -0
  41. data/spec/fixtures/dbase_30.fpt +0 -0
  42. data/spec/fixtures/dbase_30_summary.txt +0 -154
  43. data/spec/fixtures/dbase_31.dbf +0 -0
  44. data/spec/fixtures/dbase_31_summary.txt +0 -20
  45. data/spec/fixtures/dbase_32.dbf +0 -0
  46. data/spec/fixtures/dbase_32_summary.txt +0 -11
  47. data/spec/fixtures/dbase_83.dbf +0 -0
  48. data/spec/fixtures/dbase_83.dbt +0 -0
  49. data/spec/fixtures/dbase_83_missing_memo.dbf +0 -0
  50. data/spec/fixtures/dbase_83_missing_memo_record_0.yml +0 -16
  51. data/spec/fixtures/dbase_83_record_0.yml +0 -16
  52. data/spec/fixtures/dbase_83_record_9.yml +0 -23
  53. data/spec/fixtures/dbase_83_schema_ar.txt +0 -19
  54. data/spec/fixtures/dbase_83_schema_sq.txt +0 -21
  55. data/spec/fixtures/dbase_83_schema_sq_lim.txt +0 -21
  56. data/spec/fixtures/dbase_83_summary.txt +0 -24
  57. data/spec/fixtures/dbase_8b.dbf +0 -0
  58. data/spec/fixtures/dbase_8b.dbt +0 -0
  59. data/spec/fixtures/dbase_8b_summary.txt +0 -15
  60. data/spec/fixtures/dbase_8c.dbf +0 -0
  61. data/spec/fixtures/dbase_f5.dbf +0 -0
  62. data/spec/fixtures/dbase_f5.fpt +0 -0
  63. data/spec/fixtures/dbase_f5_summary.txt +0 -68
  64. data/spec/fixtures/foxprodb/FOXPRO-DB-TEST.DBC +0 -0
  65. data/spec/fixtures/foxprodb/FOXPRO-DB-TEST.DCT +0 -0
  66. data/spec/fixtures/foxprodb/FOXPRO-DB-TEST.DCX +0 -0
  67. data/spec/fixtures/foxprodb/calls.CDX +0 -0
  68. data/spec/fixtures/foxprodb/calls.FPT +0 -0
  69. data/spec/fixtures/foxprodb/calls.dbf +0 -0
  70. data/spec/fixtures/foxprodb/contacts.CDX +0 -0
  71. data/spec/fixtures/foxprodb/contacts.FPT +0 -0
  72. data/spec/fixtures/foxprodb/contacts.dbf +0 -0
  73. data/spec/fixtures/foxprodb/setup.CDX +0 -0
  74. data/spec/fixtures/foxprodb/setup.dbf +0 -0
  75. data/spec/fixtures/foxprodb/types.CDX +0 -0
  76. data/spec/fixtures/foxprodb/types.dbf +0 -0
  77. data/spec/fixtures/polygon.dbf +0 -0
  78. data/spec/spec_helper.rb +0 -33
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbf
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keith Morrison
@@ -29,10 +29,7 @@ email: keithm@infused.org
29
29
  executables:
30
30
  - dbf
31
31
  extensions: []
32
- extra_rdoc_files:
33
- - CHANGELOG.md
34
- - LICENSE
35
- - README.md
32
+ extra_rdoc_files: []
36
33
  files:
37
34
  - CHANGELOG.md
38
35
  - LICENSE
@@ -41,92 +38,46 @@ files:
41
38
  - dbf.gemspec
42
39
  - lib/dbf.rb
43
40
  - lib/dbf/column.rb
41
+ - lib/dbf/column_builder.rb
44
42
  - lib/dbf/column_type.rb
45
43
  - lib/dbf/database/foxpro.rb
46
44
  - lib/dbf/encodings.rb
45
+ - lib/dbf/file_handler.rb
46
+ - lib/dbf/find.rb
47
47
  - lib/dbf/header.rb
48
48
  - lib/dbf/memo/base.rb
49
49
  - lib/dbf/memo/dbase3.rb
50
50
  - lib/dbf/memo/dbase4.rb
51
51
  - lib/dbf/memo/foxpro.rb
52
52
  - lib/dbf/record.rb
53
+ - lib/dbf/record_context.rb
54
+ - lib/dbf/record_iterator.rb
53
55
  - lib/dbf/schema.rb
54
56
  - lib/dbf/table.rb
55
57
  - lib/dbf/version.rb
56
- - spec/dbf/column_spec.rb
57
- - spec/dbf/database/foxpro_spec.rb
58
- - spec/dbf/encoding_spec.rb
59
- - spec/dbf/file_formats_spec.rb
60
- - spec/dbf/record_spec.rb
61
- - spec/dbf/table_spec.rb
62
- - spec/fixtures/cp1251.dbf
63
- - spec/fixtures/cp1251_summary.txt
64
- - spec/fixtures/dbase_02.dbf
65
- - spec/fixtures/dbase_02_summary.txt
66
- - spec/fixtures/dbase_03.dbf
67
- - spec/fixtures/dbase_03_cyrillic.dbf
68
- - spec/fixtures/dbase_03_cyrillic_summary.txt
69
- - spec/fixtures/dbase_03_summary.txt
70
- - spec/fixtures/dbase_30.dbf
71
- - spec/fixtures/dbase_30.fpt
72
- - spec/fixtures/dbase_30_summary.txt
73
- - spec/fixtures/dbase_31.dbf
74
- - spec/fixtures/dbase_31_summary.txt
75
- - spec/fixtures/dbase_32.dbf
76
- - spec/fixtures/dbase_32_summary.txt
77
- - spec/fixtures/dbase_83.dbf
78
- - spec/fixtures/dbase_83.dbt
79
- - spec/fixtures/dbase_83_missing_memo.dbf
80
- - spec/fixtures/dbase_83_missing_memo_record_0.yml
81
- - spec/fixtures/dbase_83_record_0.yml
82
- - spec/fixtures/dbase_83_record_9.yml
83
- - spec/fixtures/dbase_83_schema_ar.txt
84
- - spec/fixtures/dbase_83_schema_sq.txt
85
- - spec/fixtures/dbase_83_schema_sq_lim.txt
86
- - spec/fixtures/dbase_83_summary.txt
87
- - spec/fixtures/dbase_8b.dbf
88
- - spec/fixtures/dbase_8b.dbt
89
- - spec/fixtures/dbase_8b_summary.txt
90
- - spec/fixtures/dbase_8c.dbf
91
- - spec/fixtures/dbase_f5.dbf
92
- - spec/fixtures/dbase_f5.fpt
93
- - spec/fixtures/dbase_f5_summary.txt
94
- - spec/fixtures/foxprodb/FOXPRO-DB-TEST.DBC
95
- - spec/fixtures/foxprodb/FOXPRO-DB-TEST.DCT
96
- - spec/fixtures/foxprodb/FOXPRO-DB-TEST.DCX
97
- - spec/fixtures/foxprodb/calls.CDX
98
- - spec/fixtures/foxprodb/calls.FPT
99
- - spec/fixtures/foxprodb/calls.dbf
100
- - spec/fixtures/foxprodb/contacts.CDX
101
- - spec/fixtures/foxprodb/contacts.FPT
102
- - spec/fixtures/foxprodb/contacts.dbf
103
- - spec/fixtures/foxprodb/setup.CDX
104
- - spec/fixtures/foxprodb/setup.dbf
105
- - spec/fixtures/foxprodb/types.CDX
106
- - spec/fixtures/foxprodb/types.dbf
107
- - spec/fixtures/polygon.dbf
108
- - spec/spec_helper.rb
109
- homepage: http://github.com/infused/dbf
58
+ - lib/dbf/version_config.rb
59
+ homepage: https://github.com/infused/dbf
110
60
  licenses:
111
61
  - MIT
112
62
  metadata:
113
63
  rubygems_mfa_required: 'true'
114
- rdoc_options:
115
- - "--charset=UTF-8"
64
+ source_code_uri: https://github.com/infused/dbf
65
+ changelog_uri: https://github.com/infused/dbf/blob/main/CHANGELOG.md
66
+ rdoc_options: []
116
67
  require_paths:
117
68
  - lib
118
69
  required_ruby_version: !ruby/object:Gem::Requirement
119
70
  requirements:
120
71
  - - ">="
121
72
  - !ruby/object:Gem::Version
122
- version: 3.1.0
73
+ version: 3.3.0
123
74
  required_rubygems_version: !ruby/object:Gem::Requirement
124
75
  requirements:
125
76
  - - ">="
126
77
  - !ruby/object:Gem::Version
127
- version: 3.2.3
78
+ version: '0'
128
79
  requirements: []
129
- rubygems_version: 3.6.7
80
+ rubygems_version: 3.7.2
130
81
  specification_version: 4
131
82
  summary: Read xBase files
132
83
  test_files: []
@@ -1,286 +0,0 @@
1
- # encoding: ascii-8bit
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe DBF::Column do
6
- let(:table) { DBF::Table.new fixture('dbase_30.dbf') }
7
-
8
- context 'when initialized' do
9
- let(:column) { DBF::Column.new table, 'ColumnName', 'N', 1, 0 }
10
-
11
- it 'sets :name accessor' do
12
- expect(column.name).to eq 'ColumnName'
13
- end
14
-
15
- it 'sets :type accessor' do
16
- expect(column.type).to eq 'N'
17
- end
18
-
19
- it 'sets the #length accessor' do
20
- expect(column.length).to eq 1
21
- end
22
-
23
- it 'sets the #decimal accessor' do
24
- expect(column.decimal).to eq 0
25
- end
26
-
27
- it 'accepts length of 0' do
28
- column = DBF::Column.new table, 'ColumnName', 'N', 0, 0
29
- expect(column.length).to eq 0
30
- end
31
-
32
- describe 'with length less than 0' do
33
- it 'raises DBF::Column::LengthError' do
34
- expect { DBF::Column.new table, 'ColumnName', 'N', -1, 0 }.to raise_error(DBF::Column::LengthError)
35
- end
36
- end
37
-
38
- describe 'with empty column name' do
39
- it 'raises DBF::Column::NameError' do
40
- expect { DBF::Column.new table, '', 'N', 1, 0 }.to raise_error(DBF::Column::NameError)
41
- end
42
- end
43
- end
44
-
45
- describe '#type_cast' do
46
- context 'with type N (number)' do
47
- context 'when value is empty' do
48
- it 'returns nil' do
49
- value = ''
50
- column = DBF::Column.new table, 'ColumnName', 'N', 5, 2
51
- expect(column.type_cast(value)).to be_nil
52
- end
53
- end
54
-
55
- context 'with 0 length' do
56
- it 'returns nil' do
57
- column = DBF::Column.new table, 'ColumnName', 'N', 0, 0
58
- expect(column.type_cast('')).to be_nil
59
- end
60
- end
61
-
62
- context 'with 0 decimals' do
63
- it 'casts value to Integer' do
64
- value = '135'
65
- column = DBF::Column.new table, 'ColumnName', 'N', 3, 0
66
- expect(column.type_cast(value)).to eq 135
67
- end
68
-
69
- it 'supports negative Integer' do
70
- value = '-135'
71
- column = DBF::Column.new table, 'ColumnName', 'N', 3, 0
72
- expect(column.type_cast(value)).to eq(-135)
73
- end
74
- end
75
-
76
- context 'with more than 0 decimals' do
77
- it 'casts value to Float' do
78
- value = '13.5'
79
- column = DBF::Column.new table, 'ColumnName', 'N', 2, 1
80
- expect(column.type_cast(value)).to eq 13.5
81
- end
82
-
83
- it 'casts negative value to Float' do
84
- value = '-13.5'
85
- column = DBF::Column.new table, 'ColumnName', 'N', 2, 1
86
- expect(column.type_cast(value)).to eq(-13.5)
87
- end
88
- end
89
- end
90
-
91
- context 'with type F (float)' do
92
- context 'with 0 length' do
93
- it 'returns nil' do
94
- column = DBF::Column.new table, 'ColumnName', 'F', 0, 0
95
- expect(column.type_cast('')).to be_nil
96
- end
97
- end
98
-
99
- it 'casts value to Float' do
100
- value = '135'
101
- column = DBF::Column.new table, 'ColumnName', 'F', 3, 0
102
- expect(column.type_cast(value)).to eq 135.0
103
- end
104
-
105
- it 'casts negative value to Float' do
106
- value = '-135'
107
- column = DBF::Column.new table, 'ColumnName', 'F', 3, 0
108
- expect(column.type_cast(value)).to eq(-135.0)
109
- end
110
- end
111
-
112
- context 'with type B (binary)' do
113
- context 'with Foxpro dbf' do
114
- it 'casts to float' do
115
- column = DBF::Column.new table, 'ColumnName', 'B', 1, 2
116
- expect(column.type_cast("\xEC\x51\xB8\x1E\x85\x6B\x31\x40")).to be_a(Float)
117
- expect(column.type_cast("\xEC\x51\xB8\x1E\x85\x6B\x31\x40")).to eq 17.42
118
- end
119
-
120
- it 'stores original precision' do
121
- column = DBF::Column.new table, 'ColumnName', 'B', 1, 0
122
- expect(column.type_cast("\xEC\x51\xB8\x1E\x85\x6B\x31\x40")).to be_a(Float)
123
- expect(column.type_cast("\xEC\x51\xB8\x1E\x85\x6B\x31\x40")).to eq 17.42
124
- end
125
-
126
- it 'supports negative binary' do
127
- column = DBF::Column.new table, 'ColumnName', 'B', 1, 2
128
- expect(column.type_cast("\x00\x00\x00\x00\x00\xC0\x65\xC0")).to be_a(Float)
129
- expect(column.type_cast("\x00\x00\x00\x00\x00\xC0\x65\xC0")).to eq(-174.0)
130
- end
131
- end
132
- end
133
-
134
- context 'with type I (integer)' do
135
- context 'with 0 length' do
136
- it 'returns nil' do
137
- column = DBF::Column.new table, 'ColumnName', 'I', 0, 0
138
- expect(column.type_cast('')).to be_nil
139
- end
140
- end
141
-
142
- it 'casts value to Integer' do
143
- value = "\203\171\001\000"
144
- column = DBF::Column.new table, 'ColumnName', 'I', 3, 0
145
- expect(column.type_cast(value)).to eq 96_643
146
- end
147
-
148
- it 'supports negative Integer' do
149
- value = "\x24\xE1\xFF\xFF"
150
- column = DBF::Column.new table, 'ColumnName', 'I', 3, 0
151
- expect(column.type_cast(value)).to eq(-7900)
152
- end
153
- end
154
-
155
- context 'with type L (logical/boolean)' do
156
- let(:column) { DBF::Column.new table, 'ColumnName', 'L', 1, 0 }
157
-
158
- it "casts 'y' to true" do
159
- expect(column.type_cast('y')).to be true
160
- end
161
-
162
- it "casts 't' to true" do
163
- expect(column.type_cast('t')).to be true
164
- end
165
-
166
- it "casts value other than 't' or 'y' to false" do
167
- expect(column.type_cast('n')).to be false
168
- end
169
-
170
- context 'with 0 length' do
171
- it 'returns nil' do
172
- column = DBF::Column.new table, 'ColumnName', 'L', 0, 0
173
- expect(column.type_cast('')).to be_nil
174
- end
175
- end
176
- end
177
-
178
- context 'with type T (datetime)' do
179
- let(:column) { DBF::Column.new table, 'ColumnName', 'T', 16, 0 }
180
-
181
- context 'with valid datetime' do
182
- it 'casts to DateTime' do
183
- expect(column.type_cast("Nl%\000\300Z\252\003")).to eq Time.parse('2002-10-10T17:04:56+00:00')
184
- end
185
- end
186
-
187
- context 'with invalid datetime' do
188
- it 'casts to nil' do
189
- expect(column.type_cast("Nl%\000\000A\000\999")).to be_nil
190
- end
191
- end
192
-
193
- context 'with 0 length' do
194
- it 'returns nil' do
195
- column = DBF::Column.new table, 'ColumnName', 'T', 0, 0
196
- expect(column.type_cast('')).to be_nil
197
- end
198
- end
199
- end
200
-
201
- context 'with type D (date)' do
202
- let(:column) { DBF::Column.new table, 'ColumnName', 'D', 8, 0 }
203
-
204
- context 'with valid date' do
205
- it 'casts to Date' do
206
- expect(column.type_cast('20050712')).to eq Date.new(2005, 7, 12)
207
- end
208
- end
209
-
210
- context 'with invalid date' do
211
- it 'casts to nil' do
212
- expect(column.type_cast('000000000')).to be_nil
213
- end
214
- end
215
-
216
- context 'with 0 length' do
217
- it 'returns nil' do
218
- column = DBF::Column.new table, 'ColumnName', 'D', 0, 0
219
- expect(column.type_cast('')).to be_nil
220
- end
221
- end
222
- end
223
-
224
- context 'with type M (memo)' do
225
- it 'casts to string' do
226
- column = DBF::Column.new table, 'ColumnName', 'M', 3, 0
227
- expect(column.type_cast('abc')).to eq 'abc'
228
- end
229
-
230
- it 'casts nil to nil' do
231
- column = DBF::Column.new table, 'ColumnName', 'M', 3, 0
232
- expect(column.type_cast(nil)).to be_nil
233
- end
234
-
235
- context 'with 0 length' do
236
- it 'returns nil' do
237
- column = DBF::Column.new table, 'ColumnName', 'M', 0, 0
238
- expect(column.type_cast('')).to be_nil
239
- end
240
- end
241
- end
242
-
243
- context 'with type G (memo)' do
244
- it 'returns binary data' do
245
- column = DBF::Column.new table, 'ColumnName', 'G', 3, 0
246
- expect(column.type_cast("\000\013\120")).to eq "\000\013\120"
247
- expect(column.type_cast("\000\013\120").encoding).to eq Encoding::ASCII_8BIT
248
- end
249
-
250
- it 'casts nil to nil' do
251
- column = DBF::Column.new table, 'ColumnName', 'G', 3, 0
252
- expect(column.type_cast(nil)).to be_nil
253
- end
254
-
255
- context 'with 0 length' do
256
- it 'returns nil' do
257
- column = DBF::Column.new table, 'ColumnName', 'G', 0, 0
258
- expect(column.type_cast('')).to be_nil
259
- end
260
- end
261
- end
262
- end
263
-
264
- context 'with type Y (currency)' do
265
- let(:column) { DBF::Column.new table, 'ColumnName', 'Y', 8, 4 }
266
-
267
- it 'casts to float' do
268
- expect(column.type_cast(" \xBF\x02\x00\x00\x00\x00\x00")).to eq 18.0
269
- end
270
-
271
- it 'supports negative currency' do
272
- expect(column.type_cast("\xFC\xF0\xF0\xFE\xFF\xFF\xFF\xFF")).to eq(-1776.41)
273
- end
274
-
275
- it 'supports 64bit negative currency' do
276
- expect(column.type_cast("pN'9\xFF\xFF\xFF\xFF")).to eq(-333_609.0)
277
- end
278
-
279
- context 'with 0 length' do
280
- it 'returns nil' do
281
- column = DBF::Column.new table, 'ColumnName', 'Y', 0, 0
282
- expect(column.type_cast('')).to be_nil
283
- end
284
- end
285
- end
286
- end
@@ -1,51 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe DBF::Database::Foxpro do
4
- let(:dbf_path) { fixture('foxprodb/FOXPRO-DB-TEST.DBC') }
5
- let(:db) { DBF::Database::Foxpro.new(dbf_path) }
6
-
7
- describe '#initialize' do
8
- describe 'when given a path to an existing dbc file' do
9
- it 'does not raise an error' do
10
- expect { DBF::Database::Foxpro.new dbf_path }.to_not raise_error
11
- end
12
- end
13
-
14
- describe 'when given a path to a non-existent dbf file' do
15
- it 'raises a DBF::FileNotFound error' do
16
- expect { DBF::Database::Foxpro.new 'x' }.to raise_error(DBF::FileNotFoundError, 'file not found: x')
17
- end
18
- end
19
-
20
- describe 'it loads the example db correctly' do
21
- it 'shows a correct list of tables' do
22
- expect(db.table_names.sort).to eq(%w[contacts calls setup types].sort)
23
- end
24
- end
25
- end
26
-
27
- describe '#table' do
28
- describe 'when accessing related tables' do
29
- let(:db) { DBF::Database::Foxpro.new(dbf_path) }
30
-
31
- it 'loads an existing related table' do
32
- expect(db.contacts.record_count).to eq 5
33
- end
34
-
35
- it 'supports a long table field name' do
36
- expect(db.contacts.record(1).spouses_interests).to eq 'Tennis, golf'
37
- end
38
-
39
- it 'loads an existing related table with wrong filename casing' do
40
- expect(db.calls.record_count).to eq 16
41
- end
42
- end
43
- end
44
-
45
- describe '#table_path' do
46
- it 'returns an absolute path' do
47
- expect(db.table_path('contacts')).to eq File.expand_path('spec/fixtures/foxprodb/contacts.dbf')
48
- end
49
- end
50
-
51
- end
@@ -1,47 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe 'DBF::Table' do
4
- context 'with default encoding' do
5
- let(:dbf_path) { fixture('dbase_03_cyrillic.dbf') }
6
- let(:table) { DBF::Table.new dbf_path }
7
-
8
- it 'defaults to UTF-8 encoding' do
9
- expect(table.encoding).to eq Encoding::UTF_8
10
- end
11
-
12
- it 'uses the table encoding for column encoding' do
13
- column = table.columns.first
14
- expect(column.encoding).to eq table.encoding
15
- end
16
-
17
- it 'encodes column names' do
18
- expect(table.column_names).to eq %w[ШАР ПЛОЩА]
19
- end
20
-
21
- it 'encodes record values' do
22
- expect(table.record(0).attributes['ШАР']).to eq 'Номер'
23
- end
24
- end
25
-
26
- context 'with embedded encoding' do
27
- let(:dbf_path) { fixture('cp1251.dbf') }
28
- let(:table) { DBF::Table.new dbf_path }
29
-
30
- it 'defaults to UTF-8 encoding' do
31
- expect(table.encoding).to eq 'cp1251'
32
- end
33
-
34
- it 'uses the table encoding for column encoding' do
35
- column = table.columns.first
36
- expect(column.encoding).to eq table.encoding
37
- end
38
-
39
- it 'encodes column names' do
40
- expect(table.column_names).to eq %w[RN NAME]
41
- end
42
-
43
- it 'encodes record values' do
44
- expect(table.record(0).attributes['NAME']).to eq 'амбулаторно-поликлиническое'
45
- end
46
- end
47
- end