Skip to content

Commit

Permalink
reading number of times file changed
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Jun 19, 2010
1 parent a08eb29 commit 9ddc893
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/yehuda/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Yehuda
class Database
attr_accessor :page_size, :write_version, :read_version, :page_footer
attr_accessor :itp_fraction, :btp_fraction, :btl_fraction
attr_accessor :file_changes
attr_reader :fh

alias :to_io :fh
Expand All @@ -19,9 +20,10 @@ def initialize file
@write_version = @fh.read(1).unpack('C').first
@read_version = @fh.read(1).unpack('C').first
@page_footer = @fh.read(1).unpack('C').first
@itp_fraction = @fh.read(1).unpack('C').first
@btp_fraction = @fh.read(1).unpack('C').first
@btl_fraction = @fh.read(1).unpack('C').first
@itp_fraction = @fh.read(1).unpack('C').first
@btp_fraction = @fh.read(1).unpack('C').first
@btl_fraction = @fh.read(1).unpack('C').first
@file_changes = @fh.read(2).unpack('n').first
end

private
Expand Down
5 changes: 5 additions & 0 deletions test/yehuda/test_database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,10 @@ def test_btl_fraction
db = Yehuda::Database.new FILE
assert_equal 32, db.btl_fraction
end

def test_file_changes
db = Yehuda::Database.new FILE
assert_equal 0, db.file_changes
end
end
end

0 comments on commit 9ddc893

Please sign in to comment.