dbf 2.0.11 → 2.0.12

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: 8aee45603d7f53ed73d7a1a6068f823330c1770a
4
- data.tar.gz: 1478ad383f4b9b568d27ea315f16ac73690e3962
3
+ metadata.gz: fadab12ca4c3e6f7b7be026f240c816f1905336e
4
+ data.tar.gz: 2a3ad835ee60fa8be62ecdf901fc16fdc22e7bb3
5
5
  SHA512:
6
- metadata.gz: 1d2bdc66cdfc536d6f0f1881dd0bf26f883521357b775ca847ffff09f1b8d7fa0f7e8a1fcc78cef4bb97067e57969f9730c9bb2de87b1c67d9e984184899f87b
7
- data.tar.gz: 055e8f333772efc02e22556a225094cb2e1368f77cffac249c6b660fd2304c0ca5b838c86cb2994a3408eb03313bb253e686610acabe15586e23fa304a4a83e4
6
+ metadata.gz: 7460b41c54bcfa6ad7bf1dff4cbd1070a1923b38cc41b87b65a5211fcc0c31e00b1fa1786d40a854f7c42d4b8d1989707ee8777307dda1324c58a14dbcde76b4
7
+ data.tar.gz: 5dfed269798a64d07509b3cfa6f86f7363b8f9e0b4990d7673d9b1795876c4def3cda1254c7054b5f013bf75c5f75efec7c7af6477c8159c418330620ac0e968
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 2.0.12
2
+ - Parse (I) values as signed
3
+ (see https://github.com/infused/dbf/pull/70)
4
+
1
5
  # 2.0.11
2
6
  - Foxpro doubles should always return the full stored precision
3
7
  (see https://github.com/infused/dbf/pull/69)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dbf (2.0.10)
4
+ dbf (2.0.11)
5
5
  fastercsv (~> 1.5)
6
6
 
7
7
  GEM
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2006-2014 Keith Morrison <keithm@infused.org>
1
+ Copyright (c) 2006-2015 Keith Morrison <keithm@infused.org>
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
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 fieldnames are supported and tables can be references without using names.
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
- mycontact = contacts.record(1).spouses_interests
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-2014 Keith Morrison <<keithm@infused.org>>
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
@@ -76,7 +76,7 @@ module DBF
76
76
  def type_cast_methods # nodoc
77
77
  {
78
78
  'N' => :unpack_number,
79
- 'I' => :unpack_unsigned_long,
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
- (unpack_unsigned_long(value) / 10_000.0).to_f
114
+ (unpack_signed_long(value) / 10_000.0).to_f
115
115
  end
116
116
 
117
- def unpack_unsigned_long(value) # nodoc
118
- value.unpack('V')[0]
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
@@ -1,3 +1,3 @@
1
1
  module DBF
2
- VERSION = '2.0.11'
2
+ VERSION = '2.0.12'
3
3
  end
@@ -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.11
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-01 00:00:00.000000000 Z
11
+ date: 2015-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fastercsv