Sha256: fabb61dc054b56164018cb02e31bc6be6fc28c039e464aa030665609de3447b9
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
#encoding:utf-8 # # Author:: Anders Bengtsson <ndrsbngtssn@yahoo.se> # Copyright:: Copyright (c) 2004-2006 # require 'tempfile' require 'singleton' module Madeleine class SanityCheck include Singleton def initialize @testdata = "\x85\x00\x0a\0x0d\x0a" if @testdata.respond_to?(:force_encoding) @testdata.force_encoding('ASCII-8BIT') end @testdata.freeze @was_run = false end def run_once unless @was_run run end end def run marshal_check file_check @was_run = true end def marshal_check result = Marshal.load(Marshal.dump(@testdata)) if result != @testdata raise "Sanity check failed for Marshal" end end def file_check Tempfile.open("madeleine_sanity") do |file| file.binmode # Needed for win32 file.write(@testdata) file.flush open(file.path, 'rb') do |read_file| result = read_file.read if result != @testdata raise "Sanity check failed for file IO" end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
madeleine-0.9.0 | lib/madeleine/sanity.rb |
madeleine-0.9.0.pre | lib/madeleine/sanity.rb |