dbf 5.0.1 → 5.1.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 +1 -1
- data/dbf.gemspec +3 -3
- data/lib/dbf/column.rb +1 -1
- data/lib/dbf/database/foxpro.rb +1 -3
- data/lib/dbf/record.rb +1 -1
- data/lib/dbf/table.rb +2 -3
- data/lib/dbf/version.rb +1 -1
- data/spec/dbf/encoding_spec.rb +43 -43
- data/spec/dbf/file_formats_spec.rb +3 -3
- data/spec/dbf/record_spec.rb +6 -10
- data/spec/dbf/table_spec.rb +1 -1
- metadata +6 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea8e27ddd0d6d12797336f59d245bc8b62245e59c8fad0ecbf12c97513ac244f
|
4
|
+
data.tar.gz: d3cc1955ebb54357b5c724ef1b8687a8f69a47f794c445a08840d5dc08fa5861
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87ec87d1e3a45f4ec1f787f4e56d64aad00779aebe5e391656fe457f278219ffa72de97cc4ae679d2b8a14c7f03035fb059397251a290bc21587513382207c82
|
7
|
+
data.tar.gz: a931c1aa3ab7a5128824cb43bd4ec03217a52d548a071209495dce1647f68f269c78f84c15534ecf35ed9badac227e96a46ab53e0f33a9271d440d832fd26959
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -14,7 +14,7 @@ DBF is a small, fast Ruby library for reading dBase, xBase, Clipper, and FoxPro
|
|
14
14
|
* Report bugs: <https://github.com/infused/dbf/issues>
|
15
15
|
* Questions: Email <mailto:keithm@infused.org> and put DBF somewhere in the
|
16
16
|
subject line
|
17
|
-
* Change log: <https://github.com/infused/dbf/blob/
|
17
|
+
* Change log: <https://github.com/infused/dbf/blob/main/CHANGELOG.md>
|
18
18
|
|
19
19
|
NOTE: Beginning with version 4.3 we have dropped support for Ruby 3.0 and earlier.
|
20
20
|
|
data/dbf.gemspec
CHANGED
@@ -17,8 +17,8 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.extra_rdoc_files = ['README.md', 'CHANGELOG.md', 'LICENSE']
|
18
18
|
s.files = Dir['README.md', 'CHANGELOG.md', 'LICENSE', '{bin,lib,spec}/**/*', 'dbf.gemspec']
|
19
19
|
s.require_paths = ['lib']
|
20
|
-
s.required_rubygems_version = Gem::Requirement.new('>=
|
21
|
-
s.required_ruby_version = Gem::Requirement.new('>= 3.
|
20
|
+
s.required_rubygems_version = Gem::Requirement.new('>= 3.2.3')
|
21
|
+
s.required_ruby_version = Gem::Requirement.new('>= 3.1.0')
|
22
22
|
s.metadata['rubygems_mfa_required'] = 'true'
|
23
|
-
s.
|
23
|
+
s.add_dependency 'csv'
|
24
24
|
end
|
data/lib/dbf/column.rb
CHANGED
data/lib/dbf/database/foxpro.rb
CHANGED
data/lib/dbf/record.rb
CHANGED
data/lib/dbf/table.rb
CHANGED
@@ -295,10 +295,9 @@ module DBF
|
|
295
295
|
def memo_class # :nodoc:
|
296
296
|
@memo_class ||= if foxpro?
|
297
297
|
Memo::Foxpro
|
298
|
-
|
299
|
-
|
298
|
+
else
|
299
|
+
version == '83' ? Memo::Dbase3 : Memo::Dbase4
|
300
300
|
end
|
301
|
-
|
302
301
|
end
|
303
302
|
|
304
303
|
def memo_search_path(io) # :nodoc:
|
data/lib/dbf/version.rb
CHANGED
data/spec/dbf/encoding_spec.rb
CHANGED
@@ -1,47 +1,47 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require 'spec_helper'
|
4
2
|
|
5
|
-
RSpec.describe '
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
column
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
column
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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
46
|
end
|
47
47
|
end
|
@@ -9,7 +9,7 @@ RSpec.shared_examples_for 'DBF' do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
specify 'records should be instances of DBF::Record' do
|
12
|
-
expect(table).to all
|
12
|
+
expect(table).to all be_a(DBF::Record)
|
13
13
|
end
|
14
14
|
|
15
15
|
specify 'record count should be the same as reported in the header' do
|
@@ -31,7 +31,7 @@ RSpec.shared_examples_for 'DBF' do
|
|
31
31
|
|
32
32
|
specify 'column lengths should be instances of Integer' do
|
33
33
|
table.columns.each do |column|
|
34
|
-
expect(column.length).to
|
34
|
+
expect(column.length).to be_a(Integer)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -43,7 +43,7 @@ RSpec.shared_examples_for 'DBF' do
|
|
43
43
|
|
44
44
|
specify 'column decimals should be instances of Integer' do
|
45
45
|
table.columns.each do |column|
|
46
|
-
expect(column.decimal).to
|
46
|
+
expect(column.decimal).to be_a(Integer)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
data/spec/dbf/record_spec.rb
CHANGED
@@ -3,25 +3,22 @@ require 'spec_helper'
|
|
3
3
|
RSpec.describe DBF::Record do
|
4
4
|
describe '#to_a' do
|
5
5
|
let(:table) { DBF::Table.new fixture('dbase_83.dbf') }
|
6
|
-
let(:record0) { YAML.load_file(fixture('dbase_83_record_0.yml')) }
|
7
|
-
let(:record9) { YAML.load_file(fixture('dbase_83_record_9.yml')) }
|
8
6
|
|
9
7
|
it 'returns an ordered array of attribute values' do
|
10
8
|
record = table.record(0)
|
11
|
-
expect(record.to_a).to eq
|
9
|
+
expect(record.to_a).to eq YAML.load_file(fixture('dbase_83_record_0.yml'))
|
12
10
|
|
13
11
|
record = table.record(9)
|
14
|
-
expect(record.to_a).to eq
|
12
|
+
expect(record.to_a).to eq YAML.load_file(fixture('dbase_83_record_9.yml'))
|
15
13
|
end
|
16
14
|
|
17
15
|
describe 'with missing memo file' do
|
18
16
|
describe 'when opening a path' do
|
19
17
|
let(:table) { DBF::Table.new fixture('dbase_83_missing_memo.dbf') }
|
20
|
-
let(:record0) { YAML.load_file(fixture('dbase_83_missing_memo_record_0.yml')) }
|
21
18
|
|
22
19
|
it 'returns nil values for memo fields' do
|
23
20
|
record = table.record(0)
|
24
|
-
expect(record.to_a).to eq
|
21
|
+
expect(record.to_a).to eq YAML.load_file(fixture('dbase_83_missing_memo_record_0.yml'))
|
25
22
|
end
|
26
23
|
end
|
27
24
|
end
|
@@ -29,11 +26,10 @@ RSpec.describe DBF::Record do
|
|
29
26
|
describe 'when opening StringIO' do
|
30
27
|
let(:data) { StringIO.new(File.read(fixture('dbase_83_missing_memo.dbf'))) }
|
31
28
|
let(:table) { DBF::Table.new(data) }
|
32
|
-
let(:record0) { YAML.load_file(fixture('dbase_83_missing_memo_record_0.yml')) }
|
33
29
|
|
34
30
|
it 'returns nil values for memo fields' do
|
35
31
|
record = table.record(0)
|
36
|
-
expect(record.to_a).to eq
|
32
|
+
expect(record.to_a).to eq YAML.load_file(fixture('dbase_83_missing_memo_record_0.yml'))
|
37
33
|
end
|
38
34
|
end
|
39
35
|
end
|
@@ -44,13 +40,13 @@ RSpec.describe DBF::Record do
|
|
44
40
|
|
45
41
|
describe 'when other does not have attributes' do
|
46
42
|
it 'returns false' do
|
47
|
-
expect(
|
43
|
+
expect(record == instance_double(DBF::Record)).to be_falsey
|
48
44
|
end
|
49
45
|
end
|
50
46
|
|
51
47
|
describe 'if other attributes match' do
|
52
48
|
let(:attributes) { {x: 1, y: 2} }
|
53
|
-
let(:other) { instance_double(
|
49
|
+
let(:other) { instance_double(DBF::Record, attributes: attributes) }
|
54
50
|
|
55
51
|
before do
|
56
52
|
allow(record).to receive(:attributes).and_return(attributes)
|
data/spec/dbf/table_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Morrison
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: csv
|
@@ -31,9 +30,9 @@ executables:
|
|
31
30
|
- dbf
|
32
31
|
extensions: []
|
33
32
|
extra_rdoc_files:
|
34
|
-
- README.md
|
35
33
|
- CHANGELOG.md
|
36
34
|
- LICENSE
|
35
|
+
- README.md
|
37
36
|
files:
|
38
37
|
- CHANGELOG.md
|
39
38
|
- LICENSE
|
@@ -112,7 +111,6 @@ licenses:
|
|
112
111
|
- MIT
|
113
112
|
metadata:
|
114
113
|
rubygems_mfa_required: 'true'
|
115
|
-
post_install_message:
|
116
114
|
rdoc_options:
|
117
115
|
- "--charset=UTF-8"
|
118
116
|
require_paths:
|
@@ -121,15 +119,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
119
|
requirements:
|
122
120
|
- - ">="
|
123
121
|
- !ruby/object:Gem::Version
|
124
|
-
version: 3.
|
122
|
+
version: 3.1.0
|
125
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
124
|
requirements:
|
127
125
|
- - ">="
|
128
126
|
- !ruby/object:Gem::Version
|
129
|
-
version:
|
127
|
+
version: 3.2.3
|
130
128
|
requirements: []
|
131
|
-
rubygems_version: 3.
|
132
|
-
signing_key:
|
129
|
+
rubygems_version: 3.6.7
|
133
130
|
specification_version: 4
|
134
131
|
summary: Read xBase files
|
135
132
|
test_files: []
|