dbf 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 2.0.3
2
+ - set encoding if table encoding is nil
3
+
1
4
  # 2.0.2
2
5
  - Allow overriding the character encoding specified in the file
3
6
 
data/README.md CHANGED
@@ -14,8 +14,9 @@ database files
14
14
  DBF is tested to work with the following versions of ruby:
15
15
 
16
16
  * MRI Ruby 1.8.6, 1.8.7, 1.9.1, 1.9.2 and 1.9.3
17
- * JRuby 1.6.2, 1.6.3, 1.6.4, and 1.6.5
17
+ * JRuby 1.6.x, 1.7.x
18
18
  * REE 1.8.6, 1.8.7
19
+ * Rubinius (1.8 mode)
19
20
 
20
21
  ## Installation
21
22
 
data/dbf.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.required_rubygems_version = '>= 1.3.0'
22
22
  s.add_dependency 'fastercsv', '~> 1.5.4'
23
23
 
24
- s.add_development_dependency 'rspec', '~> 2.9.0'
24
+ s.add_development_dependency 'rspec', '~> 2.11.0'
25
25
  s.add_development_dependency 'rake', '~> 0.9.2'
26
26
 
27
27
  # if RUBY_VERSION.to_f >= 1.9
data/lib/dbf/table.rb CHANGED
@@ -59,7 +59,7 @@ module DBF
59
59
  def initialize(data, memo = nil, encoding = nil)
60
60
  @data = open_data(data)
61
61
  get_header_info
62
- @encoding = encoding if encoding && @encoding
62
+ @encoding = encoding || @encoding
63
63
  @memo = open_memo(data, memo)
64
64
  end
65
65
 
data/lib/dbf/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module DBF
2
- VERSION = '2.0.2'
2
+ VERSION = '2.0.3'
3
3
  end
@@ -106,10 +106,10 @@ describe DBF::Column::Dbase do
106
106
  if ruby_supports_mathn?
107
107
  context 'when requiring mathn' do
108
108
  it "casts to DateTime" do
109
- expect do
109
+ lambda {
110
110
  require 'mathn'
111
111
  column.type_cast("Nl%\000\300Z\252\003")
112
- end.call.should == DateTime.parse("2002-10-10T17:04:56+00:00")
112
+ }.call.should == DateTime.parse("2002-10-10T17:04:56+00:00")
113
113
  end
114
114
  end
115
115
  end
@@ -19,17 +19,22 @@ describe DBF::Record do
19
19
  table = DBF::Table.new "#{DB_PATH}/dbase_8b.dbf"
20
20
  table.record(9)
21
21
  end
22
-
23
- it 'should be false if other does not have attributes' do
24
- (record == mock('other')).should be_false
22
+
23
+ describe 'when other does not have attributes' do
24
+ it 'is false' do
25
+ (record == mock('other')).should be_false
26
+ end
25
27
  end
26
28
 
27
- it 'should be true if other attributes match' do
28
- attributes = {:x => 1, :y => 2}
29
- record.stub!(:attributes).and_return(attributes)
30
- other = mock('object', :attributes => attributes)
31
- (record == other).should be_true
29
+ describe 'if other attributes match' do
30
+ it 'is true' do
31
+ attributes = {:x => 1, :y => 2}
32
+ record.stub!(:attributes).and_return(attributes)
33
+ other = mock('object', :attributes => attributes)
34
+ (record == other).should be_true
35
+ end
32
36
  end
37
+
33
38
  end
34
39
 
35
40
  describe 'column accessors' do
@@ -41,7 +41,7 @@ describe DBF::Table do
41
41
  end
42
42
 
43
43
  describe "#schema" do
44
- it "should match the test schema fixture" do
44
+ it "matches the test schema fixture" do
45
45
  table = DBF::Table.new "#{DB_PATH}/dbase_83.dbf"
46
46
  control_schema = File.read("#{DB_PATH}/dbase_83_schema.txt")
47
47
  table.schema.should == control_schema
@@ -56,7 +56,7 @@ describe DBF::Table do
56
56
  end
57
57
 
58
58
  describe 'when no path param passed' do
59
- it 'should dump to STDOUT' do
59
+ it 'writes to STDOUT' do
60
60
  begin
61
61
  $stdout = StringIO.new
62
62
  table.to_csv
@@ -68,7 +68,7 @@ describe DBF::Table do
68
68
  end
69
69
 
70
70
  describe 'when path param passed' do
71
- it 'should create custom csv file' do
71
+ it 'creates a custom csv file' do
72
72
  table.to_csv('test.csv')
73
73
  File.exists?('test.csv').should be_true
74
74
  end
@@ -95,19 +95,19 @@ describe DBF::Table do
95
95
  let(:table) { DBF::Table.new "#{DB_PATH}/dbase_83.dbf" }
96
96
 
97
97
  describe "with index" do
98
- it "should return the correct record" do
98
+ it "returns the correct record" do
99
99
  table.find(5).should == table.record(5)
100
100
  end
101
101
  end
102
102
 
103
103
  describe 'with array of indexes' do
104
- it "should return the correct records" do
104
+ it "returns the correct records" do
105
105
  table.find([1, 5, 10]).should == [table.record(1), table.record(5), table.record(10)]
106
106
  end
107
107
  end
108
108
 
109
109
  describe "with :all" do
110
- it "should accept a block" do
110
+ it "accepts a block" do
111
111
  records = []
112
112
  table.find(:all, :weight => 0.0) do |record|
113
113
  records << record
@@ -115,11 +115,11 @@ describe DBF::Table do
115
115
  records.should == table.find(:all, :weight => 0.0)
116
116
  end
117
117
 
118
- it "should return all records if options are empty" do
118
+ it "returns all records if options are empty" do
119
119
  table.find(:all).should == table.to_a
120
120
  end
121
121
 
122
- it "should return matching records when used with options" do
122
+ it "returns matching records when used with options" do
123
123
  table.find(:all, "WEIGHT" => 0.0).should == table.select {|r| r["weight"] == 0.0}
124
124
  end
125
125
 
@@ -131,36 +131,36 @@ describe DBF::Table do
131
131
  table.find(:all, "WEIGHT" => 0.0).should_not be_empty
132
132
  end
133
133
 
134
- it "should match symbolized column names" do
134
+ it "matches symbolized column names" do
135
135
  table.find(:all, :WEIGHT => 0.0).should_not be_empty
136
136
  end
137
137
 
138
- it "should match downcased column names" do
138
+ it "matches downcased column names" do
139
139
  table.find(:all, "weight" => 0.0).should_not be_empty
140
140
  end
141
141
 
142
- it "should match symbolized downcased column names" do
142
+ it "matches symbolized downcased column names" do
143
143
  table.find(:all, :weight => 0.0).should_not be_empty
144
144
  end
145
145
  end
146
146
 
147
147
  describe "with :first" do
148
- it "should return the first record if options are empty" do
148
+ it "returns the first record if options are empty" do
149
149
  table.find(:first).should == table.record(0)
150
150
  end
151
151
 
152
- it "should return the first matching record when used with options" do
152
+ it "returns the first matching record when used with options" do
153
153
  table.find(:first, "CODE" => "C").should == table.record(5)
154
154
  end
155
155
 
156
- it "should AND multiple search terms" do
156
+ it "ANDs multiple search terms" do
157
157
  table.find(:first, "ID" => 30, "IMAGE" => "graphics/00000001/TBC01.jpg").should be_nil
158
158
  end
159
159
  end
160
160
  end
161
161
 
162
162
  describe "filename" do
163
- it 'should be dbase_03.dbf' do
163
+ it 'is dbase_03.dbf' do
164
164
  table = DBF::Table.new "#{DB_PATH}/dbase_03.dbf"
165
165
  table.filename.should == "dbase_03.dbf"
166
166
  end
@@ -168,14 +168,14 @@ describe DBF::Table do
168
168
 
169
169
  describe 'has_memo_file?' do
170
170
  describe 'without a memo file' do
171
- it 'returns false' do
171
+ it 'is false' do
172
172
  table = DBF::Table.new "#{DB_PATH}/dbase_03.dbf"
173
173
  table.has_memo_file?.should be_false
174
174
  end
175
175
  end
176
176
 
177
177
  describe 'with a memo file' do
178
- it 'returns true' do
178
+ it 'is true' do
179
179
  table = DBF::Table.new "#{DB_PATH}/dbase_30.dbf"
180
180
  table.has_memo_file?.should be_true
181
181
  end
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: 2.0.2
4
+ version: 2.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-02 00:00:00.000000000 Z
12
+ date: 2012-11-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fastercsv
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 2.9.0
37
+ version: 2.11.0
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 2.9.0
45
+ version: 2.11.0
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rake
48
48
  requirement: !ruby/object:Gem::Requirement