dbf 1.6.0 → 1.6.1
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.
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +17 -2
- data/README.md +15 -5
- data/lib/dbf.rb +1 -0
- data/lib/dbf/table.rb +3 -13
- data/lib/dbf/version.rb +1 -1
- metadata +20 -6
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 1.6.1
|
2
|
+
- fix YAML issue when using MRI version > 1.9.1
|
3
|
+
- remove Table#seek_to_index and Table#current_record private methods
|
4
|
+
|
5
|
+
## 1.6.0
|
6
|
+
- remove activesupport gem dependency
|
7
|
+
|
1
8
|
## 1.5.0
|
2
9
|
|
3
10
|
- Significant internal restructuring and performance improvements. Initial
|
data/Gemfile.lock
CHANGED
@@ -2,13 +2,17 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
dbf (1.6.0)
|
5
|
-
fastercsv (
|
5
|
+
fastercsv (~> 1.5.4)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
+
archive-tar-minitar (0.5.2)
|
11
|
+
columnize (0.3.4)
|
10
12
|
diff-lcs (1.1.3)
|
11
13
|
fastercsv (1.5.4)
|
14
|
+
linecache19 (0.5.12)
|
15
|
+
ruby_core_source (>= 0.1.4)
|
12
16
|
rspec (2.6.0)
|
13
17
|
rspec-core (~> 2.6.0)
|
14
18
|
rspec-expectations (~> 2.6.0)
|
@@ -17,10 +21,21 @@ GEM
|
|
17
21
|
rspec-expectations (2.6.0)
|
18
22
|
diff-lcs (~> 1.1.2)
|
19
23
|
rspec-mocks (2.6.0)
|
24
|
+
ruby-debug-base19 (0.11.25)
|
25
|
+
columnize (>= 0.3.1)
|
26
|
+
linecache19 (>= 0.5.11)
|
27
|
+
ruby_core_source (>= 0.1.4)
|
28
|
+
ruby-debug19 (0.11.6)
|
29
|
+
columnize (>= 0.3.1)
|
30
|
+
linecache19 (>= 0.5.11)
|
31
|
+
ruby-debug-base19 (>= 0.11.19)
|
32
|
+
ruby_core_source (0.1.5)
|
33
|
+
archive-tar-minitar (>= 0.5.2)
|
20
34
|
|
21
35
|
PLATFORMS
|
22
36
|
ruby
|
23
37
|
|
24
38
|
DEPENDENCIES
|
25
39
|
dbf!
|
26
|
-
rspec (
|
40
|
+
rspec (~> 2.6.0)
|
41
|
+
ruby-debug19
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ database files
|
|
11
11
|
|
12
12
|
## Compatibility
|
13
13
|
|
14
|
-
DBF
|
14
|
+
DBF is tested to work with MRI Ruby 1.8.6, 1.8.7, 1.9.2 and Jruby 1.6.2
|
15
15
|
|
16
16
|
## Installation
|
17
17
|
|
@@ -19,7 +19,7 @@ DBF works with Ruby 1.8.6, 1.8.7, and 1.9.2
|
|
19
19
|
|
20
20
|
## Basic Usage
|
21
21
|
|
22
|
-
|
22
|
+
Open a DBF file:
|
23
23
|
|
24
24
|
require 'dbf'
|
25
25
|
|
@@ -32,7 +32,7 @@ Enumerate all records
|
|
32
32
|
puts record.email
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
Find a single record
|
36
36
|
|
37
37
|
widget.find(6)
|
38
38
|
|
@@ -69,11 +69,14 @@ An example of migrating a DBF book table to ActiveRecord using a migration:
|
|
69
69
|
|
70
70
|
require 'dbf'
|
71
71
|
|
72
|
+
class Book < ActiveRecord::Base; end
|
73
|
+
|
72
74
|
class CreateBooks < ActiveRecord::Migration
|
73
75
|
def self.up
|
74
76
|
table = DBF::Table.new('db/dbf/books.dbf')
|
75
77
|
eval(table.schema)
|
76
|
-
|
78
|
+
|
79
|
+
Book.reset_column_information
|
77
80
|
table.each do |record|
|
78
81
|
Book.create(record.attributes)
|
79
82
|
end
|
@@ -95,6 +98,14 @@ A small command-line utility called dbf is installed along with the gem.
|
|
95
98
|
-a = create an ActiveRecord::Schema
|
96
99
|
-c = create a csv file
|
97
100
|
|
101
|
+
Create an executable ActiveRecord schema:
|
102
|
+
|
103
|
+
dbf -a books.dbf > books_schema.rb
|
104
|
+
|
105
|
+
Dump all records to a CSV file:
|
106
|
+
|
107
|
+
dbf -c books.dbf
|
108
|
+
|
98
109
|
## dBase version support
|
99
110
|
|
100
111
|
The basic dBase data types are generally supported well. Support for the
|
@@ -111,7 +122,6 @@ for a full list of supported column types.
|
|
111
122
|
|
112
123
|
* DBF is read-only
|
113
124
|
* Index files are not utilized
|
114
|
-
* No character set conversions from the code page defined in the dBase file
|
115
125
|
|
116
126
|
## License
|
117
127
|
|
data/lib/dbf.rb
CHANGED
data/lib/dbf/table.rb
CHANGED
@@ -2,8 +2,6 @@ module DBF
|
|
2
2
|
|
3
3
|
# DBF::Table is the primary interface to a single DBF file and provides
|
4
4
|
# methods for enumerating and searching the records.
|
5
|
-
|
6
|
-
# TODO set record_length to length of actual used column lengths
|
7
5
|
class Table
|
8
6
|
include Enumerable
|
9
7
|
|
@@ -60,8 +58,8 @@ module DBF
|
|
60
58
|
# @param [Fixnum] index
|
61
59
|
# @return [DBF::Record, NilClass]
|
62
60
|
def record(index)
|
63
|
-
|
64
|
-
|
61
|
+
seek(index * @record_length)
|
62
|
+
deleted_record? ? nil : DBF::Record.new(@data.read(@record_length), columns, version, @memo)
|
65
63
|
end
|
66
64
|
|
67
65
|
alias_method :row, :record
|
@@ -196,10 +194,6 @@ module DBF
|
|
196
194
|
@data.read(1).unpack('a') == ['*']
|
197
195
|
end
|
198
196
|
|
199
|
-
def current_record #nodoc
|
200
|
-
deleted_record? ? nil : DBF::Record.new(@data.read(@record_length), columns, version, @memo)
|
201
|
-
end
|
202
|
-
|
203
197
|
def get_header_info #nodoc
|
204
198
|
@data.rewind
|
205
199
|
@version, @record_count, @header_length, @record_length, encoding_key =
|
@@ -211,10 +205,6 @@ module DBF
|
|
211
205
|
@data.seek @header_length + offset
|
212
206
|
end
|
213
207
|
|
214
|
-
def seek_to_record(index) #nodoc
|
215
|
-
seek index * @record_length
|
216
|
-
end
|
217
|
-
|
218
208
|
def csv_class #nodoc
|
219
209
|
CSV.const_defined?(:Reader) ? FCSV : CSV
|
220
210
|
end
|
@@ -224,7 +214,7 @@ module DBF
|
|
224
214
|
end
|
225
215
|
|
226
216
|
def self.encodings
|
227
|
-
@encodings ||= YAML.
|
217
|
+
@encodings ||= YAML.load File.read(File.expand_path("../encodings.yml", __FILE__))
|
228
218
|
end
|
229
219
|
end
|
230
220
|
|
data/lib/dbf/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 1.6.
|
9
|
+
- 1
|
10
|
+
version: 1.6.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Keith Morrison
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-09-
|
18
|
+
date: 2011-09-28 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: fastercsv
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - ~>
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
hash: 11
|
29
29
|
segments:
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
|
-
- -
|
42
|
+
- - ~>
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
hash: 23
|
45
45
|
segments:
|
@@ -49,6 +49,20 @@ dependencies:
|
|
49
49
|
version: 2.6.0
|
50
50
|
type: :development
|
51
51
|
version_requirements: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: ruby-debug
|
54
|
+
prerelease: false
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
version: "0"
|
64
|
+
type: :development
|
65
|
+
version_requirements: *id003
|
52
66
|
description: A small fast library for reading dBase, xBase, Clipper and FoxPro database files.
|
53
67
|
email: keithm@infused.org
|
54
68
|
executables:
|