dbf 1.5.3 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +10 -14
- data/README.md +2 -2
- data/Rakefile +1 -1
- data/lib/dbf.rb +1 -8
- data/lib/dbf/attributes.rb +1 -1
- data/lib/dbf/column.rb +2 -2
- data/lib/dbf/memo.rb +4 -0
- data/lib/dbf/record.rb +2 -2
- data/lib/dbf/table.rb +3 -3
- data/lib/dbf/util.rb +9 -0
- data/lib/dbf/version.rb +1 -1
- data/spec/dbf/column_spec.rb +1 -1
- data/spec/dbf/file_formats_spec.rb +2 -2
- metadata +14 -47
data/Gemfile.lock
CHANGED
@@ -1,30 +1,26 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dbf (1.
|
5
|
-
activesupport (~> 3.0.0)
|
4
|
+
dbf (1.6.0)
|
6
5
|
fastercsv (= 1.5.4)
|
7
|
-
i18n (~> 0.5.0)
|
8
6
|
|
9
7
|
GEM
|
10
8
|
remote: http://rubygems.org/
|
11
9
|
specs:
|
12
|
-
|
13
|
-
diff-lcs (1.1.2)
|
10
|
+
diff-lcs (1.1.3)
|
14
11
|
fastercsv (1.5.4)
|
15
|
-
|
16
|
-
|
17
|
-
rspec-
|
18
|
-
rspec-
|
19
|
-
|
20
|
-
rspec-
|
21
|
-
rspec-expectations (2.5.0)
|
12
|
+
rspec (2.6.0)
|
13
|
+
rspec-core (~> 2.6.0)
|
14
|
+
rspec-expectations (~> 2.6.0)
|
15
|
+
rspec-mocks (~> 2.6.0)
|
16
|
+
rspec-core (2.6.4)
|
17
|
+
rspec-expectations (2.6.0)
|
22
18
|
diff-lcs (~> 1.1.2)
|
23
|
-
rspec-mocks (2.
|
19
|
+
rspec-mocks (2.6.0)
|
24
20
|
|
25
21
|
PLATFORMS
|
26
22
|
ruby
|
27
23
|
|
28
24
|
DEPENDENCIES
|
29
25
|
dbf!
|
30
|
-
rspec (= 2.
|
26
|
+
rspec (= 2.6.0)
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ RSpec::Core::RakeTask.new :spec do |t|
|
|
8
8
|
end
|
9
9
|
|
10
10
|
require 'rake'
|
11
|
-
require '
|
11
|
+
require 'rdoc/task'
|
12
12
|
Rake::RDocTask.new { |rdoc|
|
13
13
|
rdoc.rdoc_dir = 'doc'
|
14
14
|
rdoc.title = "DBF - A small fast library for reading dBase, xBase, Clipper and FoxPro database files."
|
data/lib/dbf.rb
CHANGED
@@ -1,18 +1,11 @@
|
|
1
1
|
require 'date'
|
2
|
-
gem 'activesupport'
|
3
|
-
require 'active_support/core_ext/object'
|
4
|
-
require 'active_support/core_ext/date/conversions'
|
5
|
-
require 'active_support/core_ext/time/conversions'
|
6
|
-
require 'active_support/core_ext/date_time/conversions'
|
7
|
-
require 'active_support/core_ext/string/conversions'
|
8
|
-
require 'active_support/core_ext/string/inflections'
|
9
|
-
require 'active_support/core_ext/enumerable'
|
10
2
|
|
11
3
|
require 'csv'
|
12
4
|
if CSV.const_defined? :Reader
|
13
5
|
require 'fastercsv'
|
14
6
|
end
|
15
7
|
|
8
|
+
require 'dbf/util'
|
16
9
|
require 'dbf/attributes'
|
17
10
|
require 'dbf/record'
|
18
11
|
require 'dbf/column'
|
data/lib/dbf/attributes.rb
CHANGED
data/lib/dbf/column.rb
CHANGED
@@ -48,14 +48,14 @@ module DBF
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def underscored_name
|
51
|
-
@underscored_name ||=
|
51
|
+
@underscored_name ||= Util.underscore(name)
|
52
52
|
end
|
53
53
|
|
54
54
|
private
|
55
55
|
|
56
56
|
def decode_date(value) #nodoc
|
57
57
|
value.gsub!(' ', '0')
|
58
|
-
value
|
58
|
+
value !~ /\S/ ? nil : Date.parse(value)
|
59
59
|
rescue
|
60
60
|
nil
|
61
61
|
end
|
data/lib/dbf/memo.rb
CHANGED
data/lib/dbf/record.rb
CHANGED
@@ -21,7 +21,7 @@ module DBF
|
|
21
21
|
#
|
22
22
|
# @return [Array]
|
23
23
|
def to_a
|
24
|
-
@columns.map { |column| attributes[column.name
|
24
|
+
@columns.map { |column| attributes[Util.underscore(column.name)] }
|
25
25
|
end
|
26
26
|
|
27
27
|
# Do all search parameters match?
|
@@ -29,7 +29,7 @@ module DBF
|
|
29
29
|
# @param [Hash] options
|
30
30
|
# @return [Boolean]
|
31
31
|
def match?(options)
|
32
|
-
options.all? {|key, value| attributes[key.to_s
|
32
|
+
options.all? {|key, value| attributes[Util.underscore(key.to_s)] == value}
|
33
33
|
end
|
34
34
|
|
35
35
|
def attributes
|
data/lib/dbf/table.rb
CHANGED
@@ -173,7 +173,7 @@ module DBF
|
|
173
173
|
%w(fpt FPT dbt DBT).each do |extname|
|
174
174
|
filename = path.sub(/#{File.extname(path)[1..-1]}$/, extname)
|
175
175
|
if File.exists?(filename)
|
176
|
-
return Memo.
|
176
|
+
return Memo.open(filename, version)
|
177
177
|
end
|
178
178
|
end
|
179
179
|
nil
|
@@ -181,7 +181,7 @@ module DBF
|
|
181
181
|
|
182
182
|
def find_all(options) #nodoc
|
183
183
|
map do |record|
|
184
|
-
if record.
|
184
|
+
if record.match? options
|
185
185
|
yield record if block_given?
|
186
186
|
record
|
187
187
|
end
|
@@ -189,7 +189,7 @@ module DBF
|
|
189
189
|
end
|
190
190
|
|
191
191
|
def find_first(options) #nodoc
|
192
|
-
detect {|record| record.
|
192
|
+
detect {|record| record.match? options}
|
193
193
|
end
|
194
194
|
|
195
195
|
def deleted_record? #nodoc
|
data/lib/dbf/util.rb
ADDED
data/lib/dbf/version.rb
CHANGED
data/spec/dbf/column_spec.rb
CHANGED
@@ -93,7 +93,7 @@ describe DBF::Column do
|
|
93
93
|
|
94
94
|
context 'with valid datetime' do
|
95
95
|
it "casts to DateTime" do
|
96
|
-
column.type_cast("Nl%\000\300Z\252\003").should == "2002-10-10T17:04:56+00:00"
|
96
|
+
column.type_cast("Nl%\000\300Z\252\003").should == DateTime.parse("2002-10-10T17:04:56+00:00")
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
shared_examples_for 'DBF' do
|
4
4
|
specify "sum of column lengths should equal record length specified in header plus one" do
|
5
5
|
header_record_length = @table.instance_eval {@record_length}
|
6
|
-
sum_of_column_lengths =
|
6
|
+
sum_of_column_lengths = @table.columns.inject(1) {|sum, column| sum += column.length}
|
7
7
|
|
8
8
|
header_record_length.should == sum_of_column_lengths
|
9
9
|
end
|
@@ -51,7 +51,7 @@ shared_examples_for 'DBF' do
|
|
51
51
|
specify "column attributes should be accessible in underscored form" do
|
52
52
|
@table.columns do |column|
|
53
53
|
record = @table.records.first
|
54
|
-
record.send(column_name).should == record.send(
|
54
|
+
record.send(column_name).should == record.send(Util.underscore(column_name))
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
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: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 6
|
9
|
+
- 0
|
10
|
+
version: 1.6.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Keith Morrison
|
@@ -15,45 +15,12 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable:
|
18
|
+
date: 2011-09-02 00:00:00 Z
|
20
19
|
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
22
|
-
name: activesupport
|
23
|
-
prerelease: false
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 7
|
30
|
-
segments:
|
31
|
-
- 3
|
32
|
-
- 0
|
33
|
-
- 0
|
34
|
-
version: 3.0.0
|
35
|
-
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: i18n
|
39
|
-
prerelease: false
|
40
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 11
|
46
|
-
segments:
|
47
|
-
- 0
|
48
|
-
- 5
|
49
|
-
- 0
|
50
|
-
version: 0.5.0
|
51
|
-
type: :runtime
|
52
|
-
version_requirements: *id002
|
53
20
|
- !ruby/object:Gem::Dependency
|
54
21
|
name: fastercsv
|
55
22
|
prerelease: false
|
56
|
-
requirement: &
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
57
24
|
none: false
|
58
25
|
requirements:
|
59
26
|
- - "="
|
@@ -65,23 +32,23 @@ dependencies:
|
|
65
32
|
- 4
|
66
33
|
version: 1.5.4
|
67
34
|
type: :runtime
|
68
|
-
version_requirements: *
|
35
|
+
version_requirements: *id001
|
69
36
|
- !ruby/object:Gem::Dependency
|
70
37
|
name: rspec
|
71
38
|
prerelease: false
|
72
|
-
requirement: &
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
73
40
|
none: false
|
74
41
|
requirements:
|
75
42
|
- - "="
|
76
43
|
- !ruby/object:Gem::Version
|
77
|
-
hash:
|
44
|
+
hash: 23
|
78
45
|
segments:
|
79
46
|
- 2
|
80
|
-
-
|
47
|
+
- 6
|
81
48
|
- 0
|
82
|
-
version: 2.
|
49
|
+
version: 2.6.0
|
83
50
|
type: :development
|
84
|
-
version_requirements: *
|
51
|
+
version_requirements: *id002
|
85
52
|
description: A small fast library for reading dBase, xBase, Clipper and FoxPro database files.
|
86
53
|
email: keithm@infused.org
|
87
54
|
executables:
|
@@ -107,6 +74,7 @@ files:
|
|
107
74
|
- lib/dbf/memo.rb
|
108
75
|
- lib/dbf/record.rb
|
109
76
|
- lib/dbf/table.rb
|
77
|
+
- lib/dbf/util.rb
|
110
78
|
- lib/dbf/version.rb
|
111
79
|
- lib/dbf.rb
|
112
80
|
- spec/dbf/column_spec.rb
|
@@ -126,7 +94,6 @@ files:
|
|
126
94
|
- spec/fixtures/dbase_f5.dbf
|
127
95
|
- spec/fixtures/dbase_f5.fpt
|
128
96
|
- spec/spec_helper.rb
|
129
|
-
has_rdoc: true
|
130
97
|
homepage: http://github.com/infused/dbf
|
131
98
|
licenses: []
|
132
99
|
|
@@ -158,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
125
|
requirements: []
|
159
126
|
|
160
127
|
rubyforge_project:
|
161
|
-
rubygems_version: 1.
|
128
|
+
rubygems_version: 1.8.10
|
162
129
|
signing_key:
|
163
130
|
specification_version: 3
|
164
131
|
summary: Read xBase files
|