dbf 2.0.8 → 2.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ae3ffdc41708236ad7e4f5b6e97ccb7d1f4103a9
4
+ data.tar.gz: 92ac525038db50bd6ee8860a22d4314a37c76b4c
5
+ SHA512:
6
+ metadata.gz: 1301756b1375c63e6508d32328b411577c39f38568396d0123c25d8e6a03de85a06765e3e9cdeddd86a3588d58961108778d4b795724f1b8323adc9f9a564968
7
+ data.tar.gz: 06dd9b432d1c2dab916e7aab441f268951325e6d36b7e125e7c8f0a04b8ece6ecc79c025e59d29e191438bb10978603564aa9357ec28c27c8945df1dd4149dad
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 2.0.9
2
+ - fix dBase IV attributes when memo file is missing
3
+
1
4
  # 2.0.8
2
5
  - fix FoxPro currency fields on some builds of Ruby 1.9.3 and 2.0.0
3
6
 
data/Gemfile.lock CHANGED
@@ -1,15 +1,20 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dbf (2.0.7)
4
+ dbf (2.0.8)
5
5
  fastercsv (~> 1.5.4)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ byebug (3.2.0)
11
+ columnize (~> 0.8)
12
+ debugger-linecache (~> 1.2)
10
13
  celluloid (0.15.2)
11
14
  timers (~> 1.1.0)
12
15
  coderay (1.1.0)
16
+ columnize (0.9.0)
17
+ debugger-linecache (1.2.0)
13
18
  diff-lcs (1.2.5)
14
19
  fastercsv (1.5.5)
15
20
  ffi (1.9.3)
@@ -259,6 +264,7 @@ PLATFORMS
259
264
  ruby
260
265
 
261
266
  DEPENDENCIES
267
+ byebug
262
268
  dbf!
263
269
  guard
264
270
  guard-rspec
data/dbf.gemspec CHANGED
@@ -20,5 +20,5 @@ Gem::Specification.new do |s|
20
20
  s.require_paths = ['lib']
21
21
 
22
22
  s.required_rubygems_version = '>= 1.3.0'
23
- s.add_dependency 'fastercsv', '~> 1.5.4'
23
+ s.add_dependency 'fastercsv', '~> 1.5'
24
24
  end
data/lib/dbf/record.rb CHANGED
@@ -82,12 +82,18 @@ module DBF
82
82
  end
83
83
 
84
84
  def init_attribute(column) #nodoc
85
- value = if column.memo?
86
- @memo && @memo.get(memo_start_block(column))
85
+ value = column.memo? ? memo(column) : unpack_data(column)
86
+ column.type_cast(value)
87
+ end
88
+
89
+ def memo(column) #nodoc
90
+ if @memo
91
+ @memo.get(memo_start_block(column))
87
92
  else
88
- unpack_data(column)
93
+ # the memo file is missing, so read ahead to next record and return nil
94
+ @data.read(column.length)
95
+ nil
89
96
  end
90
- column.type_cast(value)
91
97
  end
92
98
 
93
99
  def memo_start_block(column) #nodoc
data/lib/dbf/table.rb CHANGED
@@ -149,9 +149,10 @@ module DBF
149
149
  #
150
150
  # @param [optional String] path Defaults to STDOUT
151
151
  def to_csv(path = nil)
152
- csv = csv_class.new((path ? File.open(path, 'w') : $stdout), :force_quotes => true)
153
- csv << columns.map {|c| c.name}
154
- each {|record| csv << record.to_a}
152
+ out_io = path ? File.open(path, 'w') : $stdout
153
+ csv = csv_class.new(out_io, :force_quotes => true)
154
+ csv << column_names
155
+ each { |record| csv << record.to_a }
155
156
  end
156
157
 
157
158
  # Find records using a simple ActiveRecord-like syntax.
@@ -232,9 +233,7 @@ module DBF
232
233
  while !["\0", "\r"].include?(first_byte = @data.read(1))
233
234
  column_data = first_byte + @data.read(DBF_HEADER_SIZE - 1)
234
235
  name, type, length, decimal = column_data.unpack('a10 x a x4 C2')
235
- if length > 0
236
- columns << column_class.new(self, name, type, length, decimal)
237
- end
236
+ columns << column_class.new(self, name, type, length, decimal)
238
237
  end
239
238
  columns
240
239
  end
data/lib/dbf/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module DBF
2
- VERSION = '2.0.8'
2
+ VERSION = '2.0.9'
3
3
  end
@@ -14,11 +14,23 @@ describe DBF::Record do
14
14
  end
15
15
 
16
16
  describe 'with missing memo file' do
17
- let(:table) { DBF::Table.new fixture_path('dbase_83_missing_memo.dbf') }
17
+ describe 'when opening a path' do
18
+ let(:table) { DBF::Table.new fixture_path('dbase_83_missing_memo.dbf') }
19
+
20
+ it 'returns nil values for memo fields' do
21
+ record = table.record(0)
22
+ expect(record.to_a).to eq [87, 2, 0, 0, 87, "1", "Assorted Petits Fours", "graphics/00000001/t_1.jpg", "graphics/00000001/1.jpg", 0.0, 0.0, nil, 5.51, true, true]
23
+ end
24
+ end
25
+ end
26
+
27
+ describe 'when opening StringIO' do
28
+ let(:data) { StringIO.new(File.read(fixture_path('dbase_83_missing_memo.dbf'))) }
29
+ let(:table) { DBF::Table.new(data) }
18
30
 
19
31
  it 'returns nil values for memo fields' do
20
32
  record = table.record(0)
21
- expect(record.to_a).to eq [87, 2, 0, 0, 87, "1", "Assorted Petits Fours", "graphics/00000001/t_1.jpg", "graphics/00000001/1.jpg", 0.0, 0.0, nil, 1.0, false, false]
33
+ expect(record.to_a).to eq [87, 2, 0, 0, 87, "1", "Assorted Petits Fours", "graphics/00000001/t_1.jpg", "graphics/00000001/1.jpg", 0.0, 0.0, nil, 5.51, true, true]
22
34
  end
23
35
  end
24
36
  end
metadata CHANGED
@@ -1,32 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbf
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.8
5
- prerelease:
4
+ version: 2.0.9
6
5
  platform: ruby
7
6
  authors:
8
7
  - Keith Morrison
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-02-01 00:00:00.000000000 Z
11
+ date: 2015-03-05 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: fastercsv
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: 1.5.4
19
+ version: '1.5'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: 1.5.4
26
+ version: '1.5'
30
27
  description: A small fast library for reading dBase, xBase, Clipper and FoxPro database
31
28
  files.
32
29
  email: keithm@infused.org
@@ -45,11 +42,13 @@ files:
45
42
  - Gemfile.travis18
46
43
  - Guardfile
47
44
  - LICENSE
48
- - Rakefile
49
45
  - README.md
46
+ - Rakefile
50
47
  - bin/dbf
48
+ - dbf.gemspec
51
49
  - docs/supported_encodings.csv
52
50
  - docs/supported_types.markdown
51
+ - lib/dbf.rb
53
52
  - lib/dbf/column/base.rb
54
53
  - lib/dbf/column/dbase.rb
55
54
  - lib/dbf/column/foxpro.rb
@@ -63,7 +62,6 @@ files:
63
62
  - lib/dbf/schema.rb
64
63
  - lib/dbf/table.rb
65
64
  - lib/dbf/version.rb
66
- - lib/dbf.rb
67
65
  - spec/dbf/column_spec.rb
68
66
  - spec/dbf/file_formats_spec.rb
69
67
  - spec/dbf/record_spec.rb
@@ -82,32 +80,30 @@ files:
82
80
  - spec/fixtures/dbase_f5.dbf
83
81
  - spec/fixtures/dbase_f5.fpt
84
82
  - spec/spec_helper.rb
85
- - dbf.gemspec
86
83
  homepage: http://github.com/infused/dbf
87
84
  licenses:
88
85
  - MIT
86
+ metadata: {}
89
87
  post_install_message:
90
88
  rdoc_options:
91
- - --charset=UTF-8
89
+ - "--charset=UTF-8"
92
90
  require_paths:
93
91
  - lib
94
92
  required_ruby_version: !ruby/object:Gem::Requirement
95
- none: false
96
93
  requirements:
97
- - - ! '>='
94
+ - - ">="
98
95
  - !ruby/object:Gem::Version
99
96
  version: '0'
100
97
  required_rubygems_version: !ruby/object:Gem::Requirement
101
- none: false
102
98
  requirements:
103
- - - ! '>='
99
+ - - ">="
104
100
  - !ruby/object:Gem::Version
105
101
  version: 1.3.0
106
102
  requirements: []
107
103
  rubyforge_project:
108
- rubygems_version: 1.8.25
104
+ rubygems_version: 2.4.3
109
105
  signing_key:
110
- specification_version: 3
106
+ specification_version: 4
111
107
  summary: Read xBase files
112
108
  test_files:
113
109
  - spec/dbf/column_spec.rb