dbf 1.6.3 → 1.6.5

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.
@@ -1,3 +1,6 @@
1
+ # 1.6.5
2
+ - experimental support for visual foxpro double (b) data type
3
+
1
4
  # 1.6.3
2
5
  - Replace invalid chars with 'unicode replacement character' (U+FFFD)
3
6
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dbf (1.6.0)
4
+ dbf (1.6.3)
5
5
  fastercsv (~> 1.5.4)
6
6
 
7
7
  GEM
@@ -13,6 +13,8 @@ GEM
13
13
  fastercsv (1.5.4)
14
14
  linecache19 (0.5.12)
15
15
  ruby_core_source (>= 0.1.4)
16
+ rake (0.9.2)
17
+ rdoc (3.9.4)
16
18
  rspec (2.6.0)
17
19
  rspec-core (~> 2.6.0)
18
20
  rspec-expectations (~> 2.6.0)
@@ -37,5 +39,7 @@ PLATFORMS
37
39
 
38
40
  DEPENDENCIES
39
41
  dbf!
42
+ rake (~> 0.9.2)
43
+ rdoc (~> 3.9.0)
40
44
  rspec (~> 2.6.0)
41
45
  ruby-debug19
data/lib/dbf.rb CHANGED
@@ -10,5 +10,6 @@ require 'dbf/util'
10
10
  require 'dbf/attributes'
11
11
  require 'dbf/record'
12
12
  require 'dbf/column'
13
+ require 'dbf/foxpro_column'
13
14
  require 'dbf/memo'
14
15
  require 'dbf/table'
@@ -32,6 +32,7 @@ module DBF
32
32
  when 'D' then decode_date(value)
33
33
  when 'T' then decode_datetime(value)
34
34
  when 'L' then boolean(value)
35
+ when 'B' then unpack_binary(value)
35
36
  else encode_string(value.to_s).strip
36
37
  end
37
38
  end
@@ -73,6 +74,9 @@ module DBF
73
74
  def unpack_unsigned_long(value) #nodoc
74
75
  value.unpack('V')[0]
75
76
  end
77
+
78
+ def unpack_binary(value) #nodoc
79
+ end
76
80
 
77
81
  def boolean(value) #nodoc
78
82
  value.strip =~ /^(y|t)$/i ? true : false
@@ -0,0 +1,7 @@
1
+ module DBF
2
+ class FoxproColumn < Column
3
+ def unpack_binary(value) #nodoc
4
+ value.unpack('d')[0]
5
+ end
6
+ end
7
+ end
@@ -21,6 +21,10 @@ module DBF
21
21
  "f5" => "FoxPro with memo file",
22
22
  "fb" => "FoxPro without memo file"
23
23
  }
24
+
25
+ FOXPRO_VERSIONS = VERSION_DESCRIPTIONS.map do |version, description|
26
+ version if description =~ /FoxPro/
27
+ end.compact
24
28
 
25
29
  attr_reader :version # Internal dBase version number
26
30
  attr_reader :record_count # Total number of records
@@ -164,6 +168,8 @@ module DBF
164
168
 
165
169
  # Retrieves column information from the database
166
170
  def columns
171
+ column_class = FOXPRO_VERSIONS.include?(version) ? FoxproColumn : Column
172
+
167
173
  @columns ||= begin
168
174
  column_count = (@header_length - DBF_HEADER_SIZE + 1) / DBF_HEADER_SIZE
169
175
 
@@ -171,7 +177,9 @@ module DBF
171
177
  columns = []
172
178
  column_count.times do
173
179
  name, type, length, decimal = @data.read(32).unpack('a10 x a x4 C2')
174
- columns << Column.new(name.strip, type, length, decimal, @encoding) if length > 0
180
+ if length > 0
181
+ columns << column_class.new(name.strip, type, length, decimal, @encoding)
182
+ end
175
183
  end
176
184
  columns
177
185
  end
@@ -1,3 +1,3 @@
1
1
  module DBF
2
- VERSION = '1.6.3'
2
+ VERSION = '1.6.5'
3
3
  end
@@ -16,10 +16,6 @@ shared_examples_for 'DBF' do
16
16
  @table.count.should == @table.record_count
17
17
  end
18
18
 
19
- specify "columns should be instances of DBF::Column" do
20
- @table.columns.all? {|column| column.should be_an_instance_of(DBF::Column)}
21
- end
22
-
23
19
  specify "column names should not be blank" do
24
20
  @table.columns.all? {|column| column.name.should_not be_empty}
25
21
  end
@@ -54,7 +50,12 @@ shared_examples_for 'DBF' do
54
50
  record.send(column_name).should == record.send(Util.underscore(column_name))
55
51
  end
56
52
  end
57
-
53
+ end
54
+
55
+ shared_examples_for 'Foxpro DBF' do
56
+ specify "columns should be instances of DBF::FoxproColumn" do
57
+ @table.columns.all? {|column| column.should be_an_instance_of(DBF::FoxproColumn)}
58
+ end
58
59
  end
59
60
 
60
61
  describe DBF, "of type 03 (dBase III without memo file)" do
@@ -163,6 +164,7 @@ describe DBF, "of type f5 (FoxPro with memo file)" do
163
164
  end
164
165
 
165
166
  it_should_behave_like "DBF"
167
+ it_should_behave_like "Foxpro DBF"
166
168
 
167
169
  it "should report the correct version number" do
168
170
  @table.version.should == "f5"
@@ -1,6 +1,10 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe DBF::Table do
4
+ # specify do
5
+ # DBF::Table::FOXPRO_VERSIONS.should == %w(30 31 f5 fb)
6
+ # end
7
+
4
8
  context "when closed" do
5
9
  before do
6
10
  @table = DBF::Table.new "#{DB_PATH}/dbase_83.dbf"
Binary file
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.3
4
+ version: 1.6.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-25 00:00:00.000000000Z
12
+ date: 2011-10-28 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fastercsv
16
- requirement: &2164833540 !ruby/object:Gem::Requirement
16
+ requirement: &70356603269760 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.5.4
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2164833540
24
+ version_requirements: *70356603269760
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &2164833080 !ruby/object:Gem::Requirement
27
+ requirement: &70356603269300 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.6.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2164833080
35
+ version_requirements: *70356603269300
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &2164832620 !ruby/object:Gem::Requirement
38
+ requirement: &70356603268820 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.9.2
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2164832620
46
+ version_requirements: *70356603268820
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rdoc
49
- requirement: &2164819800 !ruby/object:Gem::Requirement
49
+ requirement: &70356603268320 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 3.9.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2164819800
57
+ version_requirements: *70356603268320
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: ruby-debug19
60
- requirement: &2164819340 !ruby/object:Gem::Requirement
60
+ requirement: &70356603267840 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2164819340
68
+ version_requirements: *70356603267840
69
69
  description: A small fast library for reading dBase, xBase, Clipper and FoxPro database
70
70
  files.
71
71
  email: keithm@infused.org
@@ -88,6 +88,7 @@ files:
88
88
  - lib/dbf/attributes.rb
89
89
  - lib/dbf/column.rb
90
90
  - lib/dbf/encodings.yml
91
+ - lib/dbf/foxpro_column.rb
91
92
  - lib/dbf/memo.rb
92
93
  - lib/dbf/record.rb
93
94
  - lib/dbf/table.rb
@@ -98,6 +99,8 @@ files:
98
99
  - spec/dbf/file_formats_spec.rb
99
100
  - spec/dbf/record_spec.rb
100
101
  - spec/dbf/table_spec.rb
102
+ - spec/fixtures/colores.DBF
103
+ - spec/fixtures/colores.FPT
101
104
  - spec/fixtures/cp1251.dbf
102
105
  - spec/fixtures/dbase_03.dbf
103
106
  - spec/fixtures/dbase_30.dbf
@@ -132,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
135
  version: 1.3.0
133
136
  requirements: []
134
137
  rubyforge_project:
135
- rubygems_version: 1.8.11
138
+ rubygems_version: 1.8.10
136
139
  signing_key:
137
140
  specification_version: 3
138
141
  summary: Read xBase files