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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 96a42e8a2472368295efedd4e47ea2a96bcced01
4
- data.tar.gz: b5a4f4b6fcf91a0f100581293489b7e087d94b06
3
+ metadata.gz: 7fcab794d4aecd4f5e77cfd92906d883668cf7dd
4
+ data.tar.gz: d5ccc39ccfd37f5b6c539b4185f52769c0b6382e
5
5
  SHA512:
6
- metadata.gz: acaf78f1f98dc82f3feb05c2d70cda1bbdb64b6567de76a47723c2c440ddf00e16d54d358e12dac36139514b451487d1540e30b78ef510657d68554d97d08583
7
- data.tar.gz: b6a86b0a5fb95da3e830847e7d39021b13fff15b06a81485db125b60ef6e99c29f34769e34fae0f1b9f4e809563047ae8667907bf3507a4268fa324c58f5150e
6
+ metadata.gz: f3cddf7e897fa59cb4560b452eddd89f196f574e827383d8470d79a9e5448356acc59764de27a6257f4f6efd5b3334f69e6a2c263b24c5ba27472e2d30baf71b
7
+ data.tar.gz: 3577e03cd8f8327dd60aadcb8c124e102d26f755c82588d5020df09fa3e1bc666c3b59e88069d70309753d42c250ad60a279f114a9bf8fcf5973d618e39817c8
@@ -1,3 +1,6 @@
1
+ # 3.0.3
2
+ - Uninitialized (N)umbers should return nil
3
+
1
4
  # 3.0.2
2
5
  - Performance improvements for large files
3
6
 
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
- table = DBF::Table.new filename
43
- table.to_csv
41
+ table = DBF::Table.new filename
42
+ table.to_csv
44
43
  end
45
-
46
44
  end
@@ -88,12 +88,10 @@ module DBF
88
88
  private
89
89
 
90
90
  def type_cast_class # nodoc
91
- @type_cast_class ||=
92
- if @length == 0
93
- ColumnType::Nil
94
- else
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
@@ -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 and not value.nil?
81
+ if encoding && !value.nil?
81
82
  value.force_encoding(@encoding).encode(*ENCODING_ARGS)
82
83
  else
83
84
  value
@@ -1,3 +1,3 @@
1
1
  module DBF
2
- VERSION = '3.0.2'
2
+ VERSION = '3.0.3'
3
3
  end
@@ -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.2
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-02 00:00:00.000000000 Z
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.