lib/madeleine.rb in madeleine-0.7.1 vs lib/madeleine.rb in madeleine-0.7.2
- old
+ new
@@ -1,10 +1,10 @@
#
# Madeleine - Ruby Object Prevalence
#
# Author:: Anders Bengtsson <ndrsbngtssn@yahoo.se>
-# Copyright:: Copyright (c) 2003-2004
+# Copyright:: Copyright (c) 2003-2006
#
# Usage:
#
# require 'madeleine'
#
@@ -17,13 +17,15 @@
module Madeleine
require 'thread'
require 'sync'
+ require 'fileutils'
require 'madeleine/files'
+ require 'madeleine/sanity'
- MADELEINE_VERSION = "0.7.1"
+ MADELEINE_VERSION = "0.7.2"
class SnapshotMadeleine
# Builds a new Madeleine instance. If there is a snapshot available
# then the system will be created from that, otherwise
@@ -61,10 +63,12 @@
# The prevalent system
attr_reader :system
def initialize(system, logger, snapshotter, lock, executer)
+ SanityCheck.instance.run_once
+
@system = system
@logger = logger
@snapshotter = snapshotter
@lock = lock
@executer = executer
@@ -82,11 +86,11 @@
#
# * <tt>command</tt> - The command to execute on the system.
def execute_command(command)
verify_command_sane(command)
@lock.synchronize {
- raise "closed" if @closed
+ raise MadeleineClosedException if @closed
@logger.store(command)
@executer.execute(command)
}
end
@@ -147,10 +151,13 @@
end
class InvalidCommandException < Exception
end
+ class MadeleineClosedException < RuntimeError
+ end
+
#
# Internal classes below
#
FILE_COUNTER_SIZE = 21 #:nodoc:
@@ -307,10 +314,10 @@
ensure_directory_exists
end
def ensure_directory_exists
if ! File.exist?(@directory_name)
- Dir.mkdir(@directory_name)
+ FileUtils.mkpath(@directory_name)
end
end
def reset
close