dbf 4.0.0 → 4.0.1

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: c958b14933bbb6d5a9f1e4489b61603d68e43d5fc39331267aac586c324a9afb
4
- data.tar.gz: 43714e5ff6c6c67f5e0d77fd0c6f7485466545ace2e3d911937076bb74ff4a23
3
+ metadata.gz: 05e4dd29c786ddbbfe219160fdf25170ef1045ddfaaa581d4f3186343fb5617f
4
+ data.tar.gz: a97677ab9355e999d6de833fb171db446e5f03f076ddb65e28378e1cfde88840
5
5
  SHA512:
6
- metadata.gz: c1b0f3d7edf0b5ec26d748c1c1f67be7877c4f150cb9adb14d0eb2994c3515ba466d803e3bc94c3111608c574908b54d1fd69077591e676ca75ea24cb81db6be
7
- data.tar.gz: 28358a00908e6f8bdaec6e74731b9961380a87c67e43dab21971bd686b7aef6fa6ba554faedee3168082a62125fd4dda24d23b257b5f1fa536b3313a8e2ef7a8
6
+ metadata.gz: b39d4780cc6fc6c0b5793c765186176ed711568652c32ab36714a725e849cf236391a4aa681606d8fdcc25b6590cadfcb6bfe0e108ee4cab5077d881675b73c5
7
+ data.tar.gz: f041b858997396063d8a5bb51ada8c5616559ba98b160e78a860a8a7b939bdc254d3efa64e24e7d621ed829819697b4a881c80e8c94bc9a619d2a5e18f1ab669
@@ -1,3 +1,6 @@
1
+ # 4.1.0
2
+ - Return Time instead of DateTime
3
+
1
4
  # 4.0.0
2
5
  - Drop support for ruby-2.2 and earlier
3
6
 
data/README.md CHANGED
@@ -24,7 +24,7 @@ NOTE: Beginning with version 3 we have dropped support for Ruby 1.8 and 1.9. If
24
24
 
25
25
  DBF is tested to work with the following versions of Ruby:
26
26
 
27
- * Ruby 2.3.x, 2.4.x, 2.5.x, 2.6.x
27
+ * Ruby 2.4.x, 2.5.x, 2.6.x
28
28
 
29
29
  ## Installation
30
30
 
data/lib/dbf.rb CHANGED
@@ -1,8 +1,8 @@
1
- require 'date'
2
-
3
1
  require 'csv'
2
+ require 'date'
4
3
  require 'forwardable'
5
4
  require 'json'
5
+ require 'time'
6
6
 
7
7
  require 'dbf/version'
8
8
  require 'dbf/schema'
@@ -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
@@ -115,7 +115,9 @@ module DBF
115
115
 
116
116
  # @return [String]
117
117
  def filename
118
- File.basename(@data.path) if @data.respond_to?(:path)
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.
@@ -1,3 +1,3 @@
1
1
  module DBF
2
- VERSION = '4.0.0'.freeze
2
+ VERSION = '4.0.1'.freeze
3
3
  end
@@ -42,7 +42,7 @@ RSpec.describe DBF::Column do
42
42
  end
43
43
  end
44
44
 
45
- context '#type_cast' do
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 DateTime.parse('2002-10-10T17:04:56+00:00')
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 'and 0 length' do
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 'and 0 length' do
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
@@ -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 'automaticallies encodes to default system encoding' do
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
@@ -44,7 +44,7 @@ RSpec.describe DBF::Table do
44
44
  end
45
45
  end
46
46
 
47
- context '#close' do
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
- begin
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.class == DBF::Column }
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
- context '#activerecord_schema_definition' do
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
- context 'with type B (binary)' do
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.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-05 00:00:00.000000000 Z
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.