dbf 3.1.2 → 3.1.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
  SHA256:
3
- metadata.gz: 2701f07f7f1de7cf433af7589ddab5e0d63d465735e1bf6e3856ab26246cb40b
4
- data.tar.gz: 788b16069d991e4a0d56fa776d8a52911d3acbc7c32c583e20651977d1189b63
3
+ metadata.gz: 05f4c5675dae61be9046beaf3dab5cf09d16752bdfa5b3841f7811fe4e08b981
4
+ data.tar.gz: 7dd76a7c629a0965557d2c4fae8043ac7e5811834e3e011ea55ab669678a238c
5
5
  SHA512:
6
- metadata.gz: 8df157ab067bd42bf9dc2b875630e2fcbaa378292cd480bc638c83a0b5aca4001d9fccbc1ab6604dd940d74837b512ea9f997c0f16c9aaf6d8837c1a5fd38eaa
7
- data.tar.gz: cd9f715b341ac1f696ba0f25183af91a64dda196ae6fbe48f81e595aacdffe677eca01826106b933d2c9abf067dfb570fa57c146f7da0695764e83f0fa3996f4
6
+ metadata.gz: eeb040f9f564e605a0fb107c43558d060c55ff868cadccfdfdd5b452040cc0ec30261ed0db0eb31ff8891efb6f1e57305743b6176f90ed3a7508186166e80752
7
+ data.tar.gz: 303215437b2339e83436e8999c9b2465ac69ee48a2be591c63e77a1c53968accfcb1c84a5160174d47665dd6af561721dcb255777db9861a442452a399342015
@@ -1,22 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dbf (3.1.2)
4
+ dbf (3.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- ast (2.3.0)
9
+ ast (2.4.0)
10
10
  awesome_print (1.8.0)
11
- byebug (9.1.0)
11
+ byebug (10.0.2)
12
12
  coderay (1.1.2)
13
13
  diff-lcs (1.3)
14
- ffi (1.9.18)
14
+ ffi (1.9.25)
15
15
  formatador (0.2.5)
16
- guard (2.14.1)
16
+ guard (2.14.2)
17
17
  formatador (>= 0.2.4)
18
18
  listen (>= 2.7, < 4.0)
19
- lumberjack (~> 1.0)
19
+ lumberjack (>= 1.0.12, < 2.0)
20
20
  nenv (~> 0.1)
21
21
  notiffany (~> 0.0)
22
22
  pry (>= 0.9.12)
@@ -27,54 +27,55 @@ GEM
27
27
  guard (~> 2.1)
28
28
  guard-compat (~> 1.1)
29
29
  rspec (>= 2.99.0, < 4.0)
30
+ jaro_winkler (1.5.1)
30
31
  listen (3.1.5)
31
32
  rb-fsevent (~> 0.9, >= 0.9.4)
32
33
  rb-inotify (~> 0.9, >= 0.9.7)
33
34
  ruby_dep (~> 1.2)
34
- lumberjack (1.0.12)
35
+ lumberjack (1.0.13)
35
36
  method_source (0.9.0)
36
37
  nenv (0.3.0)
37
38
  notiffany (0.1.1)
38
39
  nenv (~> 0.1)
39
40
  shellany (~> 0.0)
40
- parallel (1.12.0)
41
- parser (2.4.0.2)
42
- ast (~> 2.3)
43
- powerpack (0.1.1)
41
+ parallel (1.12.1)
42
+ parser (2.5.1.2)
43
+ ast (~> 2.4.0)
44
+ powerpack (0.1.2)
44
45
  pry (0.11.3)
45
46
  coderay (~> 1.1.0)
46
47
  method_source (~> 0.9.0)
47
- rainbow (2.2.2)
48
- rake
49
- rake (12.3.0)
50
- rb-fsevent (0.10.2)
48
+ rainbow (3.0.0)
49
+ rake (12.3.1)
50
+ rb-fsevent (0.10.3)
51
51
  rb-inotify (0.9.10)
52
52
  ffi (>= 0.5.0, < 2)
53
- rspec (3.7.0)
54
- rspec-core (~> 3.7.0)
55
- rspec-expectations (~> 3.7.0)
56
- rspec-mocks (~> 3.7.0)
57
- rspec-core (3.7.0)
58
- rspec-support (~> 3.7.0)
59
- rspec-expectations (3.7.0)
53
+ rspec (3.8.0)
54
+ rspec-core (~> 3.8.0)
55
+ rspec-expectations (~> 3.8.0)
56
+ rspec-mocks (~> 3.8.0)
57
+ rspec-core (3.8.0)
58
+ rspec-support (~> 3.8.0)
59
+ rspec-expectations (3.8.1)
60
60
  diff-lcs (>= 1.2.0, < 2.0)
61
- rspec-support (~> 3.7.0)
62
- rspec-mocks (3.7.0)
61
+ rspec-support (~> 3.8.0)
62
+ rspec-mocks (3.8.0)
63
63
  diff-lcs (>= 1.2.0, < 2.0)
64
- rspec-support (~> 3.7.0)
65
- rspec-support (3.7.0)
66
- rubocop (0.51.0)
64
+ rspec-support (~> 3.8.0)
65
+ rspec-support (3.8.0)
66
+ rubocop (0.59.2)
67
+ jaro_winkler (~> 1.5.1)
67
68
  parallel (~> 1.10)
68
- parser (>= 2.3.3.1, < 3.0)
69
+ parser (>= 2.5, != 2.5.1.1)
69
70
  powerpack (~> 0.1)
70
- rainbow (>= 2.2.2, < 3.0)
71
+ rainbow (>= 2.2.2, < 4.0)
71
72
  ruby-progressbar (~> 1.7)
72
73
  unicode-display_width (~> 1.0, >= 1.0.1)
73
- ruby-progressbar (1.9.0)
74
+ ruby-progressbar (1.10.0)
74
75
  ruby_dep (1.5.0)
75
76
  shellany (0.0.1)
76
77
  thor (0.20.0)
77
- unicode-display_width (1.3.0)
78
+ unicode-display_width (1.4.0)
78
79
 
79
80
  PLATFORMS
80
81
  ruby
@@ -90,4 +91,4 @@ DEPENDENCIES
90
91
  rubocop
91
92
 
92
93
  BUNDLED WITH
93
- 1.16.1
94
+ 1.16.5
data/README.md CHANGED
@@ -3,8 +3,8 @@
3
3
  [![Build Status](http://img.shields.io/travis/infused/dbf/master.svg?style=flat)](http://travis-ci.org/infused/dbf)
4
4
  [![Code Quality](http://img.shields.io/codeclimate/maintainability/infused/dbf.svg?style=flat)](https://codeclimate.com/github/infused/dbf)
5
5
  [![Code Coverage](http://img.shields.io/codeclimate/c/infused/dbf.svg?style=flat)](https://codeclimate.com/github/infused/dbf)
6
- [![Dependency Status](http://img.shields.io/gemnasium/infused/dbf.svg?style=flat)](https://gemnasium.com/infused/dbf)
7
6
  [![Total Downloads](https://img.shields.io/gem/dt/dbf.svg)](https://rubygems.org/gems/dbf/)
7
+ [![License](https://img.shields.io/github/license/infused/dbf.svg)](https://github.com/infused/dbf)
8
8
 
9
9
  DBF is a small fast library for reading dBase, xBase, Clipper and FoxPro
10
10
  database files
@@ -60,6 +60,8 @@ module DBF
60
60
  class Date < Base
61
61
  def type_cast(value)
62
62
  value =~ /\d{8}/ && ::Date.strptime(value, '%Y%m%d')
63
+ rescue
64
+ nil
63
65
  end
64
66
  end
65
67
 
@@ -211,13 +211,12 @@ module DBF
211
211
  def build_columns # :nodoc:
212
212
  safe_seek do
213
213
  @data.seek(DBF_HEADER_SIZE)
214
- columns = []
215
- until end_of_record?
216
- column_data = @data.read(DBF_HEADER_SIZE)
217
- name, type, length, decimal = column_data.unpack('a10 x a x4 C2')
218
- columns << Column.new(self, name, type, length, decimal)
214
+ [].tap do |columns|
215
+ until end_of_record?
216
+ column_data = @data.read(DBF_HEADER_SIZE)
217
+ columns << Column.new(self, *column_data.unpack('a10 x a x4 C2'))
218
+ end
219
219
  end
220
- columns
221
220
  end
222
221
  end
223
222
 
@@ -231,12 +230,11 @@ module DBF
231
230
  end
232
231
 
233
232
  def find_all(options) # :nodoc:
234
- map do |record|
235
- if record && record.match?(options)
236
- yield record if block_given?
237
- record
238
- end
239
- end.compact
233
+ select do |record|
234
+ next unless record && record.match?(options)
235
+ yield record if block_given?
236
+ record
237
+ end
240
238
  end
241
239
 
242
240
  def find_first(options) # :nodoc:
@@ -250,7 +248,7 @@ module DBF
250
248
  def header # :nodoc:
251
249
  @header ||= safe_seek do
252
250
  @data.seek(0)
253
- Header.new(@data.read DBF_HEADER_SIZE)
251
+ Header.new(@data.read(DBF_HEADER_SIZE))
254
252
  end
255
253
  end
256
254
 
@@ -1,3 +1,3 @@
1
1
  module DBF
2
- VERSION = '3.1.2'
2
+ VERSION = '3.1.3'
3
3
  end
@@ -209,7 +209,7 @@ RSpec.describe DBF::Column do
209
209
 
210
210
  context 'with invalid date' do
211
211
  it 'casts to nil' do
212
- expect(column.type_cast('0')).to be_nil
212
+ expect(column.type_cast('000000000')).to be_nil
213
213
  end
214
214
  end
215
215
 
@@ -177,13 +177,20 @@ RSpec.describe DBF::Table do
177
177
 
178
178
  describe 'with :all' do
179
179
  let(:records) do
180
- table.find(:all, weight: 0.0).inject([]) do |records, record|
181
- records << record
182
- end
180
+ table.find(:all, weight: 0.0)
181
+ end
182
+
183
+ it 'retrieves only matching records' do
184
+ expect(records.size).to eq 66
183
185
  end
184
186
 
185
- it 'accepts a block' do
186
- expect(records).to eq table.find(:all, weight: 0.0)
187
+ it 'yields to a block if given' do
188
+ record_count = 0
189
+ table.find(:all, weight: 0.0) do |record|
190
+ record_count += 1
191
+ expect(record).to be_a DBF::Record
192
+ end
193
+ expect(record_count).to eq 66
187
194
  end
188
195
 
189
196
  it 'returns all records if options are empty' do
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.1.2
4
+ version: 3.1.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: 2018-04-26 00:00:00.000000000 Z
11
+ date: 2018-10-02 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.
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  version: 1.3.0
113
113
  requirements: []
114
114
  rubyforge_project:
115
- rubygems_version: 2.7.3
115
+ rubygems_version: 2.7.6
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: Read xBase files