dbf 2.0.11 → 2.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/LICENSE +1 -1
- data/README.md +4 -3
- data/lib/dbf/column/base.rb +4 -4
- data/lib/dbf/version.rb +1 -1
- data/spec/dbf/column_spec.rb +39 -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: fadab12ca4c3e6f7b7be026f240c816f1905336e
|
4
|
+
data.tar.gz: 2a3ad835ee60fa8be62ecdf901fc16fdc22e7bb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7460b41c54bcfa6ad7bf1dff4cbd1070a1923b38cc41b87b65a5211fcc0c31e00b1fa1786d40a854f7c42d4b8d1989707ee8777307dda1324c58a14dbcde76b4
|
7
|
+
data.tar.gz: 5dfed269798a64d07509b3cfa6f86f7363b8f9e0b4990d7673d9b1795876c4def3cda1254c7054b5f013bf75c5f75efec7c7af6477c8159c418330620ac0e968
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -15,6 +15,7 @@ database files
|
|
15
15
|
* Report bugs: <http://github.com/infused/dbf/issues>
|
16
16
|
* Questions: Email <mailto:keithm@infused.org> and put DBF somewhere in the
|
17
17
|
subject line
|
18
|
+
* Change log: <https://github.com/infused/dbf/blob/master/CHANGELOG.md>
|
18
19
|
|
19
20
|
## Compatibility
|
20
21
|
|
@@ -180,13 +181,13 @@ Dump all records to a CSV file:
|
|
180
181
|
## Reading a Visual Foxpro database (v8, v9)
|
181
182
|
|
182
183
|
A special Database::Foxpro class is available to read Visual Foxpro container files (.dbc-files). When using this class,
|
183
|
-
long
|
184
|
+
long field names are supported and tables can be referenced without using names.
|
184
185
|
|
185
186
|
```ruby
|
186
187
|
require 'dbf'
|
187
188
|
|
188
189
|
contacts = DBF::Database::Foxpro.new('contactdatabase.dbc').contacts
|
189
|
-
|
190
|
+
my_contact = contacts.record(1).spouses_interests
|
190
191
|
```
|
191
192
|
|
192
193
|
|
@@ -209,7 +210,7 @@ for a full list of supported column types.
|
|
209
210
|
|
210
211
|
## License
|
211
212
|
|
212
|
-
Copyright (c) 2006-
|
213
|
+
Copyright (c) 2006-2015 Keith Morrison <<keithm@infused.org>>
|
213
214
|
|
214
215
|
Permission is hereby granted, free of charge, to any person
|
215
216
|
obtaining a copy of this software and associated documentation
|
data/lib/dbf/column/base.rb
CHANGED
@@ -76,7 +76,7 @@ module DBF
|
|
76
76
|
def type_cast_methods # nodoc
|
77
77
|
{
|
78
78
|
'N' => :unpack_number,
|
79
|
-
'I' => :
|
79
|
+
'I' => :unpack_signed_long,
|
80
80
|
'F' => :unpack_float,
|
81
81
|
'Y' => :unpack_currency,
|
82
82
|
'D' => :decode_date,
|
@@ -111,11 +111,11 @@ module DBF
|
|
111
111
|
end
|
112
112
|
|
113
113
|
def unpack_currency(value) # nodoc
|
114
|
-
(
|
114
|
+
(unpack_signed_long(value) / 10_000.0).to_f
|
115
115
|
end
|
116
116
|
|
117
|
-
def
|
118
|
-
value.unpack('
|
117
|
+
def unpack_signed_long(value) # nodoc
|
118
|
+
value.unpack('l<')[0]
|
119
119
|
end
|
120
120
|
|
121
121
|
def unpack_float(value) # nodoc
|
data/lib/dbf/version.rb
CHANGED
data/spec/dbf/column_spec.rb
CHANGED
@@ -58,6 +58,13 @@ describe DBF::Column::Dbase do
|
|
58
58
|
expect(column.type_cast(value)).to be_a(Fixnum)
|
59
59
|
expect(column.type_cast(value)).to eq 135
|
60
60
|
end
|
61
|
+
|
62
|
+
it 'supports negative Fixnum' do
|
63
|
+
value = '-135'
|
64
|
+
column = DBF::Column::Dbase.new table, "ColumnName", "N", 3, 0
|
65
|
+
expect(column.type_cast(value)).to be_a(Fixnum)
|
66
|
+
expect(column.type_cast(value)).to eq -135
|
67
|
+
end
|
61
68
|
end
|
62
69
|
|
63
70
|
context 'and more than 0 decimals' do
|
@@ -67,6 +74,13 @@ describe DBF::Column::Dbase do
|
|
67
74
|
expect(column.type_cast(value)).to be_a(Float)
|
68
75
|
expect(column.type_cast(value)).to eq 13.5
|
69
76
|
end
|
77
|
+
|
78
|
+
it 'supports negative Float' do
|
79
|
+
value = '-13.5'
|
80
|
+
column = DBF::Column::Dbase.new table, "ColumnName", "N", 2, 1
|
81
|
+
expect(column.type_cast(value)).to be_a(Float)
|
82
|
+
expect(column.type_cast(value)).to eq -13.5
|
83
|
+
end
|
70
84
|
end
|
71
85
|
end
|
72
86
|
|
@@ -84,6 +98,13 @@ describe DBF::Column::Dbase do
|
|
84
98
|
expect(column.type_cast(value)).to be_a(Float)
|
85
99
|
expect(column.type_cast(value)).to eq 135.0
|
86
100
|
end
|
101
|
+
|
102
|
+
it 'supports negative Float' do
|
103
|
+
value = '-135'
|
104
|
+
column = DBF::Column::Dbase.new table, "ColumnName", "F", 3, 0
|
105
|
+
expect(column.type_cast(value)).to be_a(Float)
|
106
|
+
expect(column.type_cast(value)).to eq -135.0
|
107
|
+
end
|
87
108
|
end
|
88
109
|
|
89
110
|
context "with type B (binary)" do
|
@@ -99,6 +120,12 @@ describe DBF::Column::Dbase do
|
|
99
120
|
expect(column.type_cast("\xEC\x51\xB8\x1E\x85\x6B\x31\x40")).to be_a(Float)
|
100
121
|
expect(column.type_cast("\xEC\x51\xB8\x1E\x85\x6B\x31\x40")).to eq 17.42
|
101
122
|
end
|
123
|
+
|
124
|
+
it 'supports negative binary' do
|
125
|
+
column = DBF::Column::Dbase.new table, "ColumnName", "B", 1, 2
|
126
|
+
expect(column.type_cast("\x00\x00\x00\x00\x00\xC0\x65\xC0")).to be_a(Float)
|
127
|
+
expect(column.type_cast("\x00\x00\x00\x00\x00\xC0\x65\xC0")).to eq -174.0
|
128
|
+
end
|
102
129
|
end
|
103
130
|
end
|
104
131
|
|
@@ -116,6 +143,13 @@ describe DBF::Column::Dbase do
|
|
116
143
|
expect(column.type_cast(value)).to be_a(Fixnum)
|
117
144
|
expect(column.type_cast(value)).to eq 96643
|
118
145
|
end
|
146
|
+
|
147
|
+
it "supports negative Fixnum" do
|
148
|
+
value = "\x24\xE1\xFF\xFF\xFF\xFF\xFF\xFF"
|
149
|
+
column = DBF::Column::Dbase.new table, "ColumnName", "I", 3, 0
|
150
|
+
expect(column.type_cast(value)).to be_a(Fixnum)
|
151
|
+
expect(column.type_cast(value)).to eq -7900
|
152
|
+
end
|
119
153
|
end
|
120
154
|
|
121
155
|
context 'with type L (logical/boolean)' do
|
@@ -234,6 +268,11 @@ describe DBF::Column::Dbase do
|
|
234
268
|
expect(column.type_cast(" \xBF\x02\x00\x00\x00\x00\x00")).to eq 18.0
|
235
269
|
end
|
236
270
|
|
271
|
+
it 'supports negative currency' do
|
272
|
+
expect(column.type_cast("\xFC\xF0\xF0\xFE\xFF\xFF\xFF\xFF")).to be_a(Float)
|
273
|
+
expect(column.type_cast("\xFC\xF0\xF0\xFE\xFF\xFF\xFF\xFF")).to eq -1776.41
|
274
|
+
end
|
275
|
+
|
237
276
|
context 'and 0 length' do
|
238
277
|
it 'returns nil' do
|
239
278
|
column = DBF::Column::Dbase.new table, "ColumnName", "Y", 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: 2.0.
|
4
|
+
version: 2.0.12
|
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-10-
|
11
|
+
date: 2015-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fastercsv
|