dbf 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +3 -0
- data/lib/dbf/table.rb +7 -1
- data/lib/dbf/version.rb +1 -1
- data/spec/dbf/record_spec.rb +20 -6
- metadata +63 -70
data/CHANGELOG.md
CHANGED
data/lib/dbf/table.rb
CHANGED
@@ -49,11 +49,17 @@ module DBF
|
|
49
49
|
# # working with a dbf and memo in memory
|
50
50
|
# table = DBF::Table.new StringIO.new(dbf_data), StringIO.new(memo_data)
|
51
51
|
#
|
52
|
+
# # working with a dbf overriding specified in the dbf encoding
|
53
|
+
# table = DBF::Table.new 'data.dbf', nil, 'cp437'
|
54
|
+
# table = DBF::Table.new 'data.dbf', 'memo.dbt', Encoding::US_ASCII
|
55
|
+
#
|
52
56
|
# @param [String, StringIO] data Path to the dbf file or a StringIO object
|
53
57
|
# @param [optional String, StringIO] memo Path to the memo file or a StringIO object
|
54
|
-
|
58
|
+
# @param [optional String, Encoding] encoding Name of the encoding or an Encoding object
|
59
|
+
def initialize(data, memo = nil, encoding = nil)
|
55
60
|
@data = open_data(data)
|
56
61
|
get_header_info
|
62
|
+
@encoding = encoding if encoding && @encoding
|
57
63
|
@memo = open_memo(data, memo)
|
58
64
|
end
|
59
65
|
|
data/lib/dbf/version.rb
CHANGED
data/spec/dbf/record_spec.rb
CHANGED
@@ -52,13 +52,27 @@ describe DBF::Record do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
describe 'column data for table' do
|
55
|
-
|
55
|
+
describe 'using specified in dbf encoding' do
|
56
|
+
let(:table) { DBF::Table.new "#{DB_PATH}/cp1251.dbf"}
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
let(:record) { table.find(0) }
|
59
|
+
it 'should automatically encodes to default system encoding' do
|
60
|
+
if table.supports_encoding?
|
61
|
+
record.name.encoding.should == Encoding.default_external
|
62
|
+
record.name.encode("UTF-8").unpack("H4").should == ["d0b0"] # russian a
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe 'overriding specified in dbf encoding' do
|
68
|
+
let(:table) { DBF::Table.new "#{DB_PATH}/cp1251.dbf", nil, 'cp866'}
|
69
|
+
|
70
|
+
let(:record) { table.find(0) }
|
71
|
+
it 'should transcode from manually specified encoding to default system encoding' do
|
72
|
+
if table.supports_encoding?
|
73
|
+
record.name.encoding.should == Encoding.default_external
|
74
|
+
record.name.encode("UTF-8").unpack("H4").should == ["d180"] # russian а encoded in cp1251 and read as if it was encoded in cp866
|
75
|
+
end
|
62
76
|
end
|
63
77
|
end
|
64
78
|
end
|
metadata
CHANGED
@@ -1,75 +1,75 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbf
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 2
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
version: 2.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.2
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Keith Morrison
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-11-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: fastercsv
|
22
|
-
|
23
|
-
|
24
|
-
requirements:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
25
19
|
- - ~>
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 1
|
29
|
-
- 5
|
30
|
-
- 4
|
20
|
+
- !ruby/object:Gem::Version
|
31
21
|
version: 1.5.4
|
32
22
|
type: :runtime
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: rspec
|
36
23
|
prerelease: false
|
37
|
-
|
38
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
39
27
|
- - ~>
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.5.4
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
45
37
|
version: 2.9.0
|
46
38
|
type: :development
|
47
|
-
version_requirements: *id002
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: rake
|
50
39
|
prerelease: false
|
51
|
-
|
52
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
53
43
|
- - ~>
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.9.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
59
53
|
version: 0.9.2
|
60
54
|
type: :development
|
61
|
-
|
62
|
-
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.9.2
|
62
|
+
description: A small fast library for reading dBase, xBase, Clipper and FoxPro database
|
63
|
+
files.
|
63
64
|
email: keithm@infused.org
|
64
|
-
executables:
|
65
|
+
executables:
|
65
66
|
- dbf
|
66
67
|
extensions: []
|
67
|
-
|
68
|
-
extra_rdoc_files:
|
68
|
+
extra_rdoc_files:
|
69
69
|
- README.md
|
70
70
|
- CHANGELOG.md
|
71
71
|
- MIT-LICENSE
|
72
|
-
files:
|
72
|
+
files:
|
73
73
|
- CHANGELOG.md
|
74
74
|
- Gemfile
|
75
75
|
- Gemfile.lock
|
@@ -109,39 +109,32 @@ files:
|
|
109
109
|
- spec/rvm_ruby_runner.rb
|
110
110
|
- spec/spec_helper.rb
|
111
111
|
- dbf.gemspec
|
112
|
-
has_rdoc: true
|
113
112
|
homepage: http://github.com/infused/dbf
|
114
113
|
licenses: []
|
115
|
-
|
116
114
|
post_install_message:
|
117
|
-
rdoc_options:
|
115
|
+
rdoc_options:
|
118
116
|
- --charset=UTF-8
|
119
|
-
require_paths:
|
117
|
+
require_paths:
|
120
118
|
- lib
|
121
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
requirements:
|
130
|
-
- -
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
segments:
|
133
|
-
- 1
|
134
|
-
- 3
|
135
|
-
- 0
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
none: false
|
127
|
+
requirements:
|
128
|
+
- - ! '>='
|
129
|
+
- !ruby/object:Gem::Version
|
136
130
|
version: 1.3.0
|
137
131
|
requirements: []
|
138
|
-
|
139
132
|
rubyforge_project:
|
140
|
-
rubygems_version: 1.
|
133
|
+
rubygems_version: 1.8.24
|
141
134
|
signing_key:
|
142
135
|
specification_version: 3
|
143
136
|
summary: Read xBase files
|
144
|
-
test_files:
|
137
|
+
test_files:
|
145
138
|
- spec/dbf/column_spec.rb
|
146
139
|
- spec/dbf/file_formats_spec.rb
|
147
140
|
- spec/dbf/record_spec.rb
|