dbf 3.0.2 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/bin/dbf +2 -4
- data/lib/dbf/column.rb +4 -6
- data/lib/dbf/column_type.rb +2 -1
- data/lib/dbf/version.rb +1 -1
- data/spec/dbf/column_spec.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fcab794d4aecd4f5e77cfd92906d883668cf7dd
|
4
|
+
data.tar.gz: d5ccc39ccfd37f5b6c539b4185f52769c0b6382e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3cddf7e897fa59cb4560b452eddd89f196f574e827383d8470d79a9e5448356acc59764de27a6257f4f6efd5b3334f69e6a2c263b24c5ba27472e2d30baf71b
|
7
|
+
data.tar.gz: 3577e03cd8f8327dd60aadcb8c124e102d26f755c82588d5020df09fa3e1bc666c3b59e88069d70309753d42c250ad60a279f114a9bf8fcf5973d618e39817c8
|
data/CHANGELOG.md
CHANGED
data/bin/dbf
CHANGED
@@ -12,7 +12,6 @@ if params['h'] then
|
|
12
12
|
puts " -a = create an ActiveRecord::Schema"
|
13
13
|
puts " -c = create a csv file"
|
14
14
|
else
|
15
|
-
|
16
15
|
filename = ARGV.shift
|
17
16
|
abort "You must supply a filename on the command line" unless filename
|
18
17
|
|
@@ -39,8 +38,7 @@ else
|
|
39
38
|
end
|
40
39
|
|
41
40
|
if params['c']
|
42
|
-
|
43
|
-
|
41
|
+
table = DBF::Table.new filename
|
42
|
+
table.to_csv
|
44
43
|
end
|
45
|
-
|
46
44
|
end
|
data/lib/dbf/column.rb
CHANGED
@@ -88,12 +88,10 @@ module DBF
|
|
88
88
|
private
|
89
89
|
|
90
90
|
def type_cast_class # nodoc
|
91
|
-
@type_cast_class ||=
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
TYPE_CAST_CLASS[type.to_sym]
|
96
|
-
end.new(@decimal, @encoding)
|
91
|
+
@type_cast_class ||= begin
|
92
|
+
klass = @length == 0 ? ColumnType::Nil : TYPE_CAST_CLASS[type.to_sym]
|
93
|
+
klass.new(@decimal, @encoding)
|
94
|
+
end
|
97
95
|
end
|
98
96
|
|
99
97
|
def encode(value, strip_output = false) # nodoc
|
data/lib/dbf/column_type.rb
CHANGED
@@ -22,6 +22,7 @@ module DBF
|
|
22
22
|
|
23
23
|
class Number < Base
|
24
24
|
def type_cast(value)
|
25
|
+
return nil if value.strip.empty?
|
25
26
|
@decimal.zero? ? value.to_i : value.to_f
|
26
27
|
end
|
27
28
|
end
|
@@ -77,7 +78,7 @@ module DBF
|
|
77
78
|
|
78
79
|
class Memo < Base
|
79
80
|
def type_cast(value)
|
80
|
-
if encoding
|
81
|
+
if encoding && !value.nil?
|
81
82
|
value.force_encoding(@encoding).encode(*ENCODING_ARGS)
|
82
83
|
else
|
83
84
|
value
|
data/lib/dbf/version.rb
CHANGED
data/spec/dbf/column_spec.rb
CHANGED
@@ -44,6 +44,14 @@ RSpec.describe DBF::Column do
|
|
44
44
|
|
45
45
|
context '#type_cast' do
|
46
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
|
+
|
47
55
|
context 'and 0 length' do
|
48
56
|
it 'returns nil' do
|
49
57
|
column = DBF::Column.new table, 'ColumnName', 'N', 0, 0
|
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: 3.0.
|
4
|
+
version: 3.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-18 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.
|