dbf 4.0.0 → 4.0.1
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 +3 -0
- data/README.md +1 -1
- data/lib/dbf.rb +2 -2
- data/lib/dbf/column_type.rb +1 -1
- data/lib/dbf/table.rb +3 -1
- data/lib/dbf/version.rb +1 -1
- data/spec/dbf/column_spec.rb +4 -4
- data/spec/dbf/record_spec.rb +1 -1
- data/spec/dbf/table_spec.rb +5 -11
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 05e4dd29c786ddbbfe219160fdf25170ef1045ddfaaa581d4f3186343fb5617f
|
|
4
|
+
data.tar.gz: a97677ab9355e999d6de833fb171db446e5f03f076ddb65e28378e1cfde88840
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b39d4780cc6fc6c0b5793c765186176ed711568652c32ab36714a725e849cf236391a4aa681606d8fdcc25b6590cadfcb6bfe0e108ee4cab5077d881675b73c5
|
|
7
|
+
data.tar.gz: f041b858997396063d8a5bb51ada8c5616559ba98b160e78a860a8a7b939bdc254d3efa64e24e7d621ed829819697b4a881c80e8c94bc9a619d2a5e18f1ab669
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/lib/dbf.rb
CHANGED
data/lib/dbf/column_type.rb
CHANGED
|
@@ -70,7 +70,7 @@ module DBF
|
|
|
70
70
|
def type_cast(value)
|
|
71
71
|
days, msecs = value.unpack('l2')
|
|
72
72
|
secs = (msecs / 1000).to_i
|
|
73
|
-
::DateTime.jd(days, (secs / 3600).to_i, (secs / 60).to_i % 60, secs % 60)
|
|
73
|
+
::DateTime.jd(days, (secs / 3600).to_i, (secs / 60).to_i % 60, secs % 60).to_time
|
|
74
74
|
rescue StandardError
|
|
75
75
|
nil
|
|
76
76
|
end
|
data/lib/dbf/table.rb
CHANGED
|
@@ -115,7 +115,9 @@ module DBF
|
|
|
115
115
|
|
|
116
116
|
# @return [String]
|
|
117
117
|
def filename
|
|
118
|
-
|
|
118
|
+
return unless @data.respond_to?(:path)
|
|
119
|
+
|
|
120
|
+
File.basename(@data.path)
|
|
119
121
|
end
|
|
120
122
|
|
|
121
123
|
# Find records using a simple ActiveRecord-like syntax.
|
data/lib/dbf/version.rb
CHANGED
data/spec/dbf/column_spec.rb
CHANGED
|
@@ -42,7 +42,7 @@ RSpec.describe DBF::Column do
|
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
describe '#type_cast' do
|
|
46
46
|
context 'with type N (number)' do
|
|
47
47
|
context 'when value is empty' do
|
|
48
48
|
it 'returns nil' do
|
|
@@ -180,7 +180,7 @@ RSpec.describe DBF::Column do
|
|
|
180
180
|
|
|
181
181
|
context 'with valid datetime' do
|
|
182
182
|
it 'casts to DateTime' do
|
|
183
|
-
expect(column.type_cast("Nl%\000\300Z\252\003")).to eq
|
|
183
|
+
expect(column.type_cast("Nl%\000\300Z\252\003")).to eq Time.parse('2002-10-10T17:04:56+00:00')
|
|
184
184
|
end
|
|
185
185
|
end
|
|
186
186
|
|
|
@@ -190,7 +190,7 @@ RSpec.describe DBF::Column do
|
|
|
190
190
|
end
|
|
191
191
|
end
|
|
192
192
|
|
|
193
|
-
context '
|
|
193
|
+
context 'with 0 length' do
|
|
194
194
|
it 'returns nil' do
|
|
195
195
|
column = DBF::Column.new table, 'ColumnName', 'T', 0, 0
|
|
196
196
|
expect(column.type_cast('')).to be_nil
|
|
@@ -213,7 +213,7 @@ RSpec.describe DBF::Column do
|
|
|
213
213
|
end
|
|
214
214
|
end
|
|
215
215
|
|
|
216
|
-
context '
|
|
216
|
+
context 'with 0 length' do
|
|
217
217
|
it 'returns nil' do
|
|
218
218
|
column = DBF::Column.new table, 'ColumnName', 'D', 0, 0
|
|
219
219
|
expect(column.type_cast('')).to be_nil
|
data/spec/dbf/record_spec.rb
CHANGED
|
@@ -80,7 +80,7 @@ RSpec.describe DBF::Record do
|
|
|
80
80
|
let(:table) { DBF::Table.new fixture('cp1251.dbf') }
|
|
81
81
|
let(:record) { table.find(0) }
|
|
82
82
|
|
|
83
|
-
it '
|
|
83
|
+
it 'encodes to default system encoding' do
|
|
84
84
|
expect(record.name.encoding).to eq Encoding.default_external
|
|
85
85
|
|
|
86
86
|
# russian a
|
data/spec/dbf/table_spec.rb
CHANGED
|
@@ -44,7 +44,7 @@ RSpec.describe DBF::Table do
|
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
describe '#close' do
|
|
48
48
|
before { table.close }
|
|
49
49
|
|
|
50
50
|
it 'closes the io' do
|
|
@@ -129,13 +129,7 @@ RSpec.describe DBF::Table do
|
|
|
129
129
|
|
|
130
130
|
describe 'when no path param passed' do
|
|
131
131
|
it 'writes to STDOUT' do
|
|
132
|
-
|
|
133
|
-
$stdout = StringIO.new
|
|
134
|
-
table.to_csv
|
|
135
|
-
expect($stdout.string).to_not be_empty
|
|
136
|
-
ensure
|
|
137
|
-
$stdout = STDOUT
|
|
138
|
-
end
|
|
132
|
+
expect { table.to_csv }.to output.to_stdout
|
|
139
133
|
end
|
|
140
134
|
end
|
|
141
135
|
|
|
@@ -293,7 +287,7 @@ RSpec.describe DBF::Table do
|
|
|
293
287
|
it 'is an array of Columns' do
|
|
294
288
|
expect(columns).to be_an(Array)
|
|
295
289
|
expect(columns).to_not be_empty
|
|
296
|
-
expect(columns).to be_all { |c| c.
|
|
290
|
+
expect(columns).to be_all { |c| c.is_a? DBF::Column }
|
|
297
291
|
end
|
|
298
292
|
end
|
|
299
293
|
|
|
@@ -318,7 +312,7 @@ RSpec.describe DBF::Table do
|
|
|
318
312
|
end
|
|
319
313
|
end
|
|
320
314
|
|
|
321
|
-
|
|
315
|
+
describe '#activerecord_schema_definition' do
|
|
322
316
|
context 'with type N (number)' do
|
|
323
317
|
it 'outputs an integer column' do
|
|
324
318
|
column = DBF::Column.new table, 'ColumnName', 'N', 1, 0
|
|
@@ -326,7 +320,7 @@ RSpec.describe DBF::Table do
|
|
|
326
320
|
end
|
|
327
321
|
end
|
|
328
322
|
|
|
329
|
-
|
|
323
|
+
describe 'with type B (binary)' do
|
|
330
324
|
context 'with Foxpro dbf' do
|
|
331
325
|
it 'outputs a float column' do
|
|
332
326
|
column = DBF::Column.new table, 'ColumnName', 'B', 1, 2
|
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.0.
|
|
4
|
+
version: 4.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Keith Morrison
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-01-
|
|
11
|
+
date: 2019-01-06 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.
|