dbf 4.1.6 → 4.2.2

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +172 -108
  3. data/Gemfile.lock +41 -40
  4. data/README.md +1 -1
  5. data/Rakefile +1 -1
  6. data/ci_A.dbf +0 -0
  7. data/lib/dbf/column.rb +3 -3
  8. data/lib/dbf/column_type.rb +9 -12
  9. data/lib/dbf/record.rb +4 -4
  10. data/lib/dbf/table.rb +16 -8
  11. data/lib/dbf/version.rb +1 -1
  12. data/nBOOKS.DBF +0 -0
  13. data/spec/dbf/column_spec.rb +3 -3
  14. data/spec/dbf/file_formats_spec.rb +18 -0
  15. data/spec/fixtures/dbase_02_summary.txt +23 -0
  16. data/spec/fixtures/dbase_32_summary.txt +11 -0
  17. data/spec/fixtures/dbase_8c.dbf +0 -0
  18. metadata +8 -51
  19. data/Gemfile.travis +0 -8
  20. data/docs/CNAME +0 -1
  21. data/docs/DBF/Column/LengthError.html +0 -124
  22. data/docs/DBF/Column/NameError.html +0 -124
  23. data/docs/DBF/Column.html +0 -947
  24. data/docs/DBF/ColumnType/Base.html +0 -389
  25. data/docs/DBF/ColumnType/Boolean.html +0 -238
  26. data/docs/DBF/ColumnType/Currency.html +0 -238
  27. data/docs/DBF/ColumnType/Date.html +0 -242
  28. data/docs/DBF/ColumnType/DateTime.html +0 -246
  29. data/docs/DBF/ColumnType/Double.html +0 -238
  30. data/docs/DBF/ColumnType/Float.html +0 -238
  31. data/docs/DBF/ColumnType/General.html +0 -238
  32. data/docs/DBF/ColumnType/Memo.html +0 -246
  33. data/docs/DBF/ColumnType/Nil.html +0 -238
  34. data/docs/DBF/ColumnType/Number.html +0 -242
  35. data/docs/DBF/ColumnType/SignedLong.html +0 -238
  36. data/docs/DBF/ColumnType/String.html +0 -240
  37. data/docs/DBF/ColumnType.html +0 -115
  38. data/docs/DBF/Database/Foxpro.html +0 -653
  39. data/docs/DBF/Database/Table.html +0 -346
  40. data/docs/DBF/Database.html +0 -126
  41. data/docs/DBF/FileNotFoundError.html +0 -124
  42. data/docs/DBF/Header.html +0 -723
  43. data/docs/DBF/Memo/Base.html +0 -485
  44. data/docs/DBF/Memo/Dbase3.html +0 -242
  45. data/docs/DBF/Memo/Dbase4.html +0 -230
  46. data/docs/DBF/Memo/Foxpro.html +0 -268
  47. data/docs/DBF/Memo.html +0 -117
  48. data/docs/DBF/NoColumnsDefined.html +0 -124
  49. data/docs/DBF/Record.html +0 -773
  50. data/docs/DBF/Schema.html +0 -980
  51. data/docs/DBF/Table.html +0 -1571
  52. data/docs/DBF.html +0 -200
  53. data/docs/_index.html +0 -415
  54. data/docs/class_list.html +0 -51
  55. data/docs/css/common.css +0 -1
  56. data/docs/css/full_list.css +0 -58
  57. data/docs/css/style.css +0 -497
  58. data/docs/file.README.html +0 -359
  59. data/docs/file_list.html +0 -56
  60. data/docs/frames.html +0 -17
  61. data/docs/index.html +0 -359
  62. data/docs/js/app.js +0 -314
  63. data/docs/js/full_list.js +0 -216
  64. data/docs/js/jquery.js +0 -4
  65. data/docs/method_list.html +0 -675
  66. data/docs/top-level-namespace.html +0 -110
data/lib/dbf/table.rb CHANGED
@@ -14,6 +14,7 @@ module DBF
14
14
 
15
15
  DBASE2_HEADER_SIZE = 8
16
16
  DBASE3_HEADER_SIZE = 32
17
+ DBASE7_HEADER_SIZE = 68
17
18
 
18
19
  VERSIONS = {
19
20
  '02' => 'FoxBase',
@@ -30,6 +31,7 @@ module DBF
30
31
  '83' => 'dBase III with memo file',
31
32
  '87' => 'Visual Objects 1.x with memo file',
32
33
  '8b' => 'dBase IV with memo file',
34
+ '8c' => 'dBase 7',
33
35
  '8e' => 'dBase IV with SQL table',
34
36
  'cb' => 'dBASE IV SQL table files, with memo',
35
37
  'f5' => 'FoxPro with memo file',
@@ -216,23 +218,29 @@ module DBF
216
218
  @data.seek(header_size)
217
219
  [].tap do |columns|
218
220
  until end_of_record?
219
- case version
221
+ args = case version
220
222
  when '02'
221
- column_data = @data.read(header_size * 2)
222
- columns << Column.new(self, *column_data.unpack('A11 a C'), 0)
223
+ [self, *@data.read(header_size * 2).unpack('A11 a C'), 0]
224
+ when '04', '8c'
225
+ [self, *@data.read(48).unpack('A32 a C C x13')]
223
226
  else
224
- column_data = @data.read(header_size)
225
- columns << Column.new(self, *column_data.unpack('A11 a x4 C2'))
227
+ [self, *@data.read(header_size).unpack('A11 a x4 C2')]
226
228
  end
229
+
230
+ columns << Column.new(*args)
227
231
  end
228
232
  end
229
233
  end
230
234
  end
231
235
 
232
236
  def header_size
233
- header_size = case version
234
- when '02' then DBASE2_HEADER_SIZE
235
- else DBASE3_HEADER_SIZE
237
+ case version
238
+ when '02'
239
+ DBASE2_HEADER_SIZE
240
+ when '04', '8c'
241
+ DBASE7_HEADER_SIZE
242
+ else
243
+ DBASE3_HEADER_SIZE
236
244
  end
237
245
  end
238
246
 
data/lib/dbf/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module DBF
2
- VERSION = '4.1.6'.freeze
2
+ VERSION = '4.2.2'.freeze
3
3
  end
data/nBOOKS.DBF ADDED
Binary file
@@ -286,13 +286,13 @@ RSpec.describe DBF::Column do
286
286
 
287
287
  describe '#name' do
288
288
  it 'contains only ASCII characters' do
289
- column = DBF::Column.new table, "--\x1F-\x68\x65\x6C\x6C\x6F world-\x80--", 'N', 1, 0
289
+ column = DBF::Column.new table, "--\x1F-\x68\x65\x6C\x6C\x6F \x00world-\x80--", 'N', 1, 0
290
290
  expect(column.name).to eq '---hello world---'
291
291
  end
292
292
 
293
293
  it 'is truncated at the null character' do
294
- column = DBF::Column.new table, "--\x1F-\x68\x65\x6C\x6C\x6F \x00 world-\x80--", 'N', 1, 0
295
- expect(column.name).to eq '---hello '
294
+ column = DBF::Column.new table, "--\x1F-\x68\x65\x6C\x6C\x6F \x00world-\x80--", 'N', 1, 0
295
+ expect(column.name).to eq '---hello world---'
296
296
  end
297
297
  end
298
298
  end
@@ -178,6 +178,24 @@ RSpec.describe DBF, 'of type 8b (dBase IV with memo file)' do
178
178
  end
179
179
  end
180
180
 
181
+ RSpec.describe DBF, 'of type 8c (unknown)' do
182
+ let(:table) { DBF::Table.new fixture('dbase_8c.dbf') }
183
+
184
+ it_behaves_like 'DBF'
185
+
186
+ it 'reports the correct version number' do
187
+ expect(table.version).to eq '8c'
188
+ end
189
+
190
+ it 'reports the correct version description' do
191
+ expect(table.version_description).to eq 'dBase 7'
192
+ end
193
+
194
+ it 'determines the number of records' do
195
+ expect(table.record_count).to eq 10
196
+ end
197
+ end
198
+
181
199
  RSpec.describe DBF, 'of type f5 (FoxPro with memo file)' do
182
200
  let(:table) { DBF::Table.new fixture('dbase_f5.dbf') }
183
201
 
@@ -0,0 +1,23 @@
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
@@ -0,0 +1,11 @@
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
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbf
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.6
4
+ version: 4.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keith Morrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-12 00:00:00.000000000 Z
11
+ date: 2022-08-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A small fast library for reading dBase, xBase, Clipper and FoxPro database
14
14
  files.
@@ -24,60 +24,13 @@ files:
24
24
  - CHANGELOG.md
25
25
  - Gemfile
26
26
  - Gemfile.lock
27
- - Gemfile.travis
28
27
  - Guardfile
29
28
  - LICENSE
30
29
  - README.md
31
30
  - Rakefile
32
31
  - bin/dbf
32
+ - ci_A.dbf
33
33
  - dbf.gemspec
34
- - docs/CNAME
35
- - docs/DBF.html
36
- - docs/DBF/Column.html
37
- - docs/DBF/Column/LengthError.html
38
- - docs/DBF/Column/NameError.html
39
- - docs/DBF/ColumnType.html
40
- - docs/DBF/ColumnType/Base.html
41
- - docs/DBF/ColumnType/Boolean.html
42
- - docs/DBF/ColumnType/Currency.html
43
- - docs/DBF/ColumnType/Date.html
44
- - docs/DBF/ColumnType/DateTime.html
45
- - docs/DBF/ColumnType/Double.html
46
- - docs/DBF/ColumnType/Float.html
47
- - docs/DBF/ColumnType/General.html
48
- - docs/DBF/ColumnType/Memo.html
49
- - docs/DBF/ColumnType/Nil.html
50
- - docs/DBF/ColumnType/Number.html
51
- - docs/DBF/ColumnType/SignedLong.html
52
- - docs/DBF/ColumnType/String.html
53
- - docs/DBF/Database.html
54
- - docs/DBF/Database/Foxpro.html
55
- - docs/DBF/Database/Table.html
56
- - docs/DBF/FileNotFoundError.html
57
- - docs/DBF/Header.html
58
- - docs/DBF/Memo.html
59
- - docs/DBF/Memo/Base.html
60
- - docs/DBF/Memo/Dbase3.html
61
- - docs/DBF/Memo/Dbase4.html
62
- - docs/DBF/Memo/Foxpro.html
63
- - docs/DBF/NoColumnsDefined.html
64
- - docs/DBF/Record.html
65
- - docs/DBF/Schema.html
66
- - docs/DBF/Table.html
67
- - docs/_index.html
68
- - docs/class_list.html
69
- - docs/css/common.css
70
- - docs/css/full_list.css
71
- - docs/css/style.css
72
- - docs/file.README.html
73
- - docs/file_list.html
74
- - docs/frames.html
75
- - docs/index.html
76
- - docs/js/app.js
77
- - docs/js/full_list.js
78
- - docs/js/jquery.js
79
- - docs/method_list.html
80
- - docs/top-level-namespace.html
81
34
  - lib/dbf.rb
82
35
  - lib/dbf/column.rb
83
36
  - lib/dbf/column_type.rb
@@ -92,6 +45,7 @@ files:
92
45
  - lib/dbf/schema.rb
93
46
  - lib/dbf/table.rb
94
47
  - lib/dbf/version.rb
48
+ - nBOOKS.DBF
95
49
  - spec/dbf/column_spec.rb
96
50
  - spec/dbf/database/foxpro_spec.rb
97
51
  - spec/dbf/file_formats_spec.rb
@@ -100,6 +54,7 @@ files:
100
54
  - spec/fixtures/cp1251.dbf
101
55
  - spec/fixtures/cp1251_summary.txt
102
56
  - spec/fixtures/dbase_02.dbf
57
+ - spec/fixtures/dbase_02_summary.txt
103
58
  - spec/fixtures/dbase_03.dbf
104
59
  - spec/fixtures/dbase_03_summary.txt
105
60
  - spec/fixtures/dbase_30.dbf
@@ -108,6 +63,7 @@ files:
108
63
  - spec/fixtures/dbase_31.dbf
109
64
  - spec/fixtures/dbase_31_summary.txt
110
65
  - spec/fixtures/dbase_32.dbf
66
+ - spec/fixtures/dbase_32_summary.txt
111
67
  - spec/fixtures/dbase_83.dbf
112
68
  - spec/fixtures/dbase_83.dbt
113
69
  - spec/fixtures/dbase_83_missing_memo.dbf
@@ -121,6 +77,7 @@ files:
121
77
  - spec/fixtures/dbase_8b.dbf
122
78
  - spec/fixtures/dbase_8b.dbt
123
79
  - spec/fixtures/dbase_8b_summary.txt
80
+ - spec/fixtures/dbase_8c.dbf
124
81
  - spec/fixtures/dbase_f5.dbf
125
82
  - spec/fixtures/dbase_f5.fpt
126
83
  - spec/fixtures/dbase_f5_summary.txt
@@ -159,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
116
  - !ruby/object:Gem::Version
160
117
  version: 1.3.0
161
118
  requirements: []
162
- rubygems_version: 3.2.15
119
+ rubygems_version: 3.3.7
163
120
  signing_key:
164
121
  specification_version: 4
165
122
  summary: Read xBase files
data/Gemfile.travis DELETED
@@ -1,8 +0,0 @@
1
- gemspec
2
- source 'https://rubygems.org'
3
-
4
- group :test do
5
- gem 'rspec'
6
- gem 'simplecov', platform: :ruby
7
- gem 'codeclimate-test-reporter'
8
- end
data/docs/CNAME DELETED
@@ -1 +0,0 @@
1
- dbf.infused.org
@@ -1,124 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>
7
- Exception: DBF::Column::LengthError
8
-
9
- &mdash; Documentation by YARD 0.9.26
10
-
11
- </title>
12
-
13
- <link rel="stylesheet" href="../../css/style.css" type="text/css" />
14
-
15
- <link rel="stylesheet" href="../../css/common.css" type="text/css" />
16
-
17
- <script type="text/javascript">
18
- pathId = "DBF::Column::LengthError";
19
- relpath = '../../';
20
- </script>
21
-
22
-
23
- <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
24
-
25
- <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
26
-
27
-
28
- </head>
29
- <body>
30
- <div class="nav_wrap">
31
- <iframe id="nav" src="../../class_list.html?1"></iframe>
32
- <div id="resizer"></div>
33
- </div>
34
-
35
- <div id="main" tabindex="-1">
36
- <div id="header">
37
- <div id="menu">
38
-
39
- <a href="../../_index.html">Index (L)</a> &raquo;
40
- <span class='title'><span class='object_link'><a href="../../DBF.html" title="DBF (module)">DBF</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Column.html" title="DBF::Column (class)">Column</a></span></span>
41
- &raquo;
42
- <span class="title">LengthError</span>
43
-
44
- </div>
45
-
46
- <div id="search">
47
-
48
- <a class="full_list_link" id="class_list_link"
49
- href="../../class_list.html">
50
-
51
- <svg width="24" height="24">
52
- <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
- <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
- <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
- </svg>
56
- </a>
57
-
58
- </div>
59
- <div class="clear"></div>
60
- </div>
61
-
62
- <div id="content"><h1>Exception: DBF::Column::LengthError
63
-
64
-
65
-
66
- </h1>
67
- <div class="box_info">
68
-
69
- <dl>
70
- <dt>Inherits:</dt>
71
- <dd>
72
- <span class="inheritName">StandardError</span>
73
-
74
- <ul class="fullTree">
75
- <li>Object</li>
76
-
77
- <li class="next">StandardError</li>
78
-
79
- <li class="next">DBF::Column::LengthError</li>
80
-
81
- </ul>
82
- <a href="#" class="inheritanceTree">show all</a>
83
-
84
- </dd>
85
- </dl>
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
- <dl>
98
- <dt>Defined in:</dt>
99
- <dd>lib/dbf/column.rb</dd>
100
- </dl>
101
-
102
- </div>
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
- </div>
115
-
116
- <div id="footer">
117
- Generated on Sun Aug 8 16:19:08 2021 by
118
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
119
- 0.9.26 (ruby-3.0.1).
120
- </div>
121
-
122
- </div>
123
- </body>
124
- </html>
@@ -1,124 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>
7
- Exception: DBF::Column::NameError
8
-
9
- &mdash; Documentation by YARD 0.9.26
10
-
11
- </title>
12
-
13
- <link rel="stylesheet" href="../../css/style.css" type="text/css" />
14
-
15
- <link rel="stylesheet" href="../../css/common.css" type="text/css" />
16
-
17
- <script type="text/javascript">
18
- pathId = "DBF::Column::NameError";
19
- relpath = '../../';
20
- </script>
21
-
22
-
23
- <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
24
-
25
- <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
26
-
27
-
28
- </head>
29
- <body>
30
- <div class="nav_wrap">
31
- <iframe id="nav" src="../../class_list.html?1"></iframe>
32
- <div id="resizer"></div>
33
- </div>
34
-
35
- <div id="main" tabindex="-1">
36
- <div id="header">
37
- <div id="menu">
38
-
39
- <a href="../../_index.html">Index (N)</a> &raquo;
40
- <span class='title'><span class='object_link'><a href="../../DBF.html" title="DBF (module)">DBF</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Column.html" title="DBF::Column (class)">Column</a></span></span>
41
- &raquo;
42
- <span class="title">NameError</span>
43
-
44
- </div>
45
-
46
- <div id="search">
47
-
48
- <a class="full_list_link" id="class_list_link"
49
- href="../../class_list.html">
50
-
51
- <svg width="24" height="24">
52
- <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
- <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
- <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
- </svg>
56
- </a>
57
-
58
- </div>
59
- <div class="clear"></div>
60
- </div>
61
-
62
- <div id="content"><h1>Exception: DBF::Column::NameError
63
-
64
-
65
-
66
- </h1>
67
- <div class="box_info">
68
-
69
- <dl>
70
- <dt>Inherits:</dt>
71
- <dd>
72
- <span class="inheritName">StandardError</span>
73
-
74
- <ul class="fullTree">
75
- <li>Object</li>
76
-
77
- <li class="next">StandardError</li>
78
-
79
- <li class="next">DBF::Column::NameError</li>
80
-
81
- </ul>
82
- <a href="#" class="inheritanceTree">show all</a>
83
-
84
- </dd>
85
- </dl>
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
- <dl>
98
- <dt>Defined in:</dt>
99
- <dd>lib/dbf/column.rb</dd>
100
- </dl>
101
-
102
- </div>
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
- </div>
115
-
116
- <div id="footer">
117
- Generated on Sun Aug 8 16:19:08 2021 by
118
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
119
- 0.9.26 (ruby-3.0.1).
120
- </div>
121
-
122
- </div>
123
- </body>
124
- </html>