daybreak 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/daybreak/db.rb CHANGED
@@ -124,7 +124,9 @@ module Daybreak
124
124
  # Reset and empty the database file.
125
125
  def empty!
126
126
  @writer.truncate!
127
+ close!
127
128
  reset!
129
+ read!
128
130
  end
129
131
  alias_method :clear, :empty!
130
132
 
@@ -10,7 +10,7 @@ module Daybreak
10
10
 
11
11
  # Close the Reader's file descriptor.
12
12
  def close!
13
- @fd.close unless @fd.nil?
13
+ @fd.close unless @fd.nil? || !@fd.closed?
14
14
  end
15
15
 
16
16
  # Read all values from the aof file.
@@ -19,19 +19,15 @@ module Daybreak
19
19
  # close and reread the whole db file, but since cross process
20
20
  # consistency is handled by the user, this should be fair warning.
21
21
  def read(&blk)
22
- reopen!
22
+ open!
23
23
  while !@fd.eof?
24
24
  blk.call(Record.read(@fd))
25
25
  end
26
+ close!
26
27
  end
27
28
 
28
29
  private
29
30
 
30
- def reopen!
31
- close!
32
- open!
33
- end
34
-
35
31
  def open!
36
32
  @fd = File.open @file_name, 'r'
37
33
  @fd.binmode
@@ -1,4 +1,4 @@
1
1
  module Daybreak
2
2
  # Updated using SemVer
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
@@ -34,9 +34,9 @@ module Daybreak
34
34
 
35
35
  # Truncate the file.
36
36
  def truncate!
37
- flush!
37
+ finish!
38
38
  @fd.truncate(0)
39
- open!
39
+ @fd.pos = 0
40
40
  end
41
41
 
42
42
  private
data/test/test.rb CHANGED
@@ -111,6 +111,14 @@ describe "database functions" do
111
111
  assert_equal db2['two'], nil
112
112
  end
113
113
 
114
+ it "should close and reopen the file when clearing the database" do
115
+ begin
116
+ 1000.times {@db.clear}
117
+ rescue
118
+ flunk
119
+ end
120
+ end
121
+
114
122
  after do
115
123
  @db.empty!
116
124
  @db.close!
metadata CHANGED
@@ -1,64 +1,64 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daybreak
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
4
  prerelease:
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jeff Larson
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-02 00:00:00.000000000 Z
12
+ date: 2013-01-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: minitest
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
15
+ version_requirements: !ruby/object:Gem::Requirement
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
20
+ none: false
21
+ name: minitest
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
24
+ requirement: !ruby/object:Gem::Requirement
26
25
  requirements:
27
26
  - - ! '>='
28
27
  - !ruby/object:Gem::Version
29
28
  version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: simplecov
32
- requirement: !ruby/object:Gem::Requirement
33
29
  none: false
30
+ - !ruby/object:Gem::Dependency
31
+ version_requirements: !ruby/object:Gem::Requirement
34
32
  requirements:
35
33
  - - ! '>='
36
34
  - !ruby/object:Gem::Version
37
35
  version: '0'
36
+ none: false
37
+ name: simplecov
38
38
  type: :development
39
39
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
40
+ requirement: !ruby/object:Gem::Requirement
42
41
  requirements:
43
42
  - - ! '>='
44
43
  - !ruby/object:Gem::Version
45
44
  version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: ruby-prof
48
- requirement: !ruby/object:Gem::Requirement
49
45
  none: false
46
+ - !ruby/object:Gem::Dependency
47
+ version_requirements: !ruby/object:Gem::Requirement
50
48
  requirements:
51
49
  - - ! '>='
52
50
  - !ruby/object:Gem::Version
53
51
  version: '0'
52
+ none: false
53
+ name: ruby-prof
54
54
  type: :development
55
55
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
56
+ requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
58
  - - ! '>='
60
59
  - !ruby/object:Gem::Version
61
60
  version: '0'
61
+ none: false
62
62
  description: A simple dimple key-value store for ruby.
63
63
  email:
64
64
  - thejefflarson@gmail.com
@@ -94,20 +94,20 @@ rdoc_options: []
94
94
  require_paths:
95
95
  - lib
96
96
  required_ruby_version: !ruby/object:Gem::Requirement
97
- none: false
98
97
  requirements:
99
98
  - - ! '>='
100
99
  - !ruby/object:Gem::Version
101
100
  version: '0'
102
- required_rubygems_version: !ruby/object:Gem::Requirement
103
101
  none: false
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
103
  requirements:
105
104
  - - ! '>='
106
105
  - !ruby/object:Gem::Version
107
106
  version: '0'
107
+ none: false
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 1.8.24
110
+ rubygems_version: 1.8.23
111
111
  signing_key:
112
112
  specification_version: 3
113
113
  summary: Daybreak provides an in memory key-value store that is easily enumerable