Class: Madeleine::SanityCheck
- Inherits:
-
Object
- Object
- Madeleine::SanityCheck
- Includes:
- Singleton
- Defined in:
- lib/madeleine/sanity.rb
Instance Method Summary collapse
- #file_check ⇒ Object
-
#initialize ⇒ SanityCheck
constructor
A new instance of SanityCheck.
- #marshal_check ⇒ Object
- #run ⇒ Object
- #run_once ⇒ Object
Constructor Details
#initialize ⇒ SanityCheck
Returns a new instance of SanityCheck.
13 14 15 16 |
# File 'lib/madeleine/sanity.rb', line 13 def initialize @testdata = "\x85\x00\x0a\0x0d\x0a".freeze @was_run = false end |
Instance Method Details
#file_check ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/madeleine/sanity.rb', line 37 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 |
#marshal_check ⇒ Object
30 31 32 33 34 35 |
# File 'lib/madeleine/sanity.rb', line 30 def marshal_check result = Marshal.load(Marshal.dump(@testdata)) if result != @testdata raise "Sanity check failed for Marshal" end end |
#run ⇒ Object
24 25 26 27 28 |
# File 'lib/madeleine/sanity.rb', line 24 def run marshal_check file_check @was_run = true end |
#run_once ⇒ Object
18 19 20 21 22 |
# File 'lib/madeleine/sanity.rb', line 18 def run_once unless @was_run run end end |