C0 code coverage information
Generated on Tue Oct 16 11:40:53 -0400 2007 with rcov 0.8.0
Code reported as executed by Ruby looks like this...
and this: this line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this,
and this: these lines were inferred by rcov (using simple heuristics).
Finally, here's a line marked as not executed.
1 # Copyright (C) 2004-2006 Laurent Sansonetti
2 #
3 # Alexandria is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License as
5 # published by the Free Software Foundation; either version 2 of the
6 # License, or (at your option) any later version.
7 #
8 # Alexandria is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public
14 # License along with Alexandria; see the file COPYING. If not,
15 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 # Boston, MA 02111-1307, USA.
17
18 module Alexandria
19 class UndoManager
20 include Singleton
21 include Observable
22
23 attr_reader :actions
24
25 def initialize
26 @undo_actions = []
27 @redo_actions = []
28 @within_undo = @withing_redo = false
29 end
30
31 def push(&block)
32 (@within_undo ? @redo_actions : @undo_actions) << block
33 notify
34 end
35
36 def can_undo?
37 @undo_actions.length > 0
38 end
39
40 def can_redo?
41 @redo_actions.length > 0
42 end
43
44 def undo!
45 @within_undo = true
46 begin
47 action(@undo_actions)
48 ensure
49 @within_undo = false
50 end
51 end
52
53 def redo!
54 @within_redo = true
55 begin
56 action(@redo_actions)
57 ensure
58 @within_redo = false
59 end
60 end
61
62 #######
63 private
64 #######
65
66 def action(array)
67 action = array.pop
68 raise if action.nil?
69 action.call
70 notify
71 end
72
73 def notify
74 changed
75 notify_observers(self)
76 end
77 end
78 end
Generated using the rcov code coverage analysis tool for Ruby version 0.8.0.