transaction-simple 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +13 -2
- data/Install +5 -1
- data/Rakefile +11 -17
- data/Readme +186 -103
- data/lib/transaction/simple.rb +295 -193
- data/lib/transaction/simple/group.rb +133 -0
- data/lib/transaction/simple/threadsafe.rb +52 -0
- data/lib/transaction/simple/threadsafe/group.rb +23 -0
- data/tests/{tests.rb → tc_transaction_simple.rb} +6 -131
- data/tests/tc_transaction_simple_group.rb +44 -0
- data/tests/tc_transaction_simple_threadsafe.rb +135 -0
- data/tests/testall.rb +20 -0
- metadata +24 -13
- data/ChangeLog +0 -20
- data/README +0 -110
data/tests/testall.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#--
|
3
|
+
# Ruwiki
|
4
|
+
# Copyright � 2002 - 2003, Digikata and HaloStatue
|
5
|
+
# Alan Chen (alan@digikata.com)
|
6
|
+
# Austin Ziegler (ruwiki@halostatue.ca)
|
7
|
+
#
|
8
|
+
# Licensed under the same terms as Ruby.
|
9
|
+
#
|
10
|
+
# $Id: testall.rb,v 1.1 2005/05/05 16:16:49 austin Exp $
|
11
|
+
#++
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib") if __FILE__ == $0
|
14
|
+
|
15
|
+
$stderr.puts "Checking for test cases:"
|
16
|
+
Dir['tc_*.rb'].each do |testcase|
|
17
|
+
$stderr.puts "\t#{testcase}"
|
18
|
+
load testcase
|
19
|
+
end
|
20
|
+
$stderr.puts " "
|
metadata
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.
|
2
|
+
rubygems_version: 0.8.10
|
3
3
|
specification_version: 1
|
4
4
|
name: transaction-simple
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.
|
7
|
-
date:
|
6
|
+
version: 1.3.0
|
7
|
+
date: 2005-05-05
|
8
8
|
summary: Simple object transaction support for Ruby.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
|
-
author: Austin Ziegler
|
12
11
|
email: transaction-simple@halostatue.ca
|
13
12
|
homepage: http://rubyforge.org/projects/trans-simple
|
14
13
|
rubyforge_project: trans-simple
|
15
|
-
description:
|
14
|
+
description: "Transaction::Simple provides a generic way to add active transaction support to
|
15
|
+
objects. The transaction methods added by this module will work with most
|
16
|
+
objects, excluding those that cannot be Marshal-ed (bindings, procedure objects,
|
17
|
+
IO instances, or singleton objects)."
|
16
18
|
autorequire: transaction/simple
|
17
19
|
default_executable:
|
18
20
|
bindir: bin
|
@@ -25,6 +27,8 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
25
27
|
version: 1.8.1
|
26
28
|
version:
|
27
29
|
platform: ruby
|
30
|
+
authors:
|
31
|
+
- Austin Ziegler
|
28
32
|
files:
|
29
33
|
- Changelog
|
30
34
|
- Install
|
@@ -33,22 +37,29 @@ files:
|
|
33
37
|
- Readme
|
34
38
|
- tests
|
35
39
|
- lib/transaction
|
40
|
+
- lib/transaction/simple
|
36
41
|
- lib/transaction/simple.rb
|
37
|
-
-
|
38
|
-
-
|
39
|
-
-
|
42
|
+
- lib/transaction/simple/group.rb
|
43
|
+
- lib/transaction/simple/threadsafe
|
44
|
+
- lib/transaction/simple/threadsafe.rb
|
45
|
+
- lib/transaction/simple/threadsafe/group.rb
|
46
|
+
- tests/tc_transaction_simple.rb
|
47
|
+
- tests/tc_transaction_simple_group.rb
|
48
|
+
- tests/tc_transaction_simple_threadsafe.rb
|
49
|
+
- tests/testall.rb
|
40
50
|
test_files:
|
41
|
-
- tests/
|
51
|
+
- tests/tc_transaction_simple.rb
|
52
|
+
- tests/tc_transaction_simple_group.rb
|
53
|
+
- tests/tc_transaction_simple_threadsafe.rb
|
42
54
|
rdoc_options:
|
43
55
|
- "--title"
|
44
|
-
- "Transaction::Simple --
|
56
|
+
- "Transaction::Simple -- Active Object Transaction Support for Ruby"
|
45
57
|
- "--main"
|
46
58
|
- Transaction::Simple
|
47
59
|
- "--line-numbers"
|
48
60
|
extra_rdoc_files:
|
49
|
-
-
|
50
|
-
-
|
51
|
-
- Install
|
61
|
+
- Readme
|
62
|
+
- Changelog
|
52
63
|
executables: []
|
53
64
|
extensions: []
|
54
65
|
requirements: []
|
data/ChangeLog
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
$Id: Changelog,v 1.2 2004/09/14 18:46:15 austin Exp $
|
2
|
-
|
3
|
-
== Transaction::Simple 1.2.0
|
4
|
-
* Added a RubyGem.
|
5
|
-
* Added a block form of Transaction::Simple.
|
6
|
-
|
7
|
-
== Transaction::Simple 1.1.1
|
8
|
-
* Cleaned up some documentation.
|
9
|
-
|
10
|
-
== Transaction::Simple 1.1
|
11
|
-
* Added Transaction::Simple::ThreadSafe for truly atomic and thread-safe
|
12
|
-
transactions.
|
13
|
-
* Fixed the description of Transaction::Simple to note that it is *not* atomic
|
14
|
-
because it is not necessarily thread-safe.
|
15
|
-
* Added support for named transactions. Named transactions can be used to make
|
16
|
-
checkpoints that can be committed, aborted, or rewound without explicitly
|
17
|
-
committing, aborting, or rewinding the intervening transactions.
|
18
|
-
|
19
|
-
== Transaction::Simple 1.0
|
20
|
-
* Created. Initial release.
|
data/README
DELETED
@@ -1,110 +0,0 @@
|
|
1
|
-
Transaction::Simple for Ruby
|
2
|
-
Simple object transaction support for Ruby
|
3
|
-
|
4
|
-
Introduction
|
5
|
-
------------
|
6
|
-
Transaction::Simple provides a generic way to add active transactional support
|
7
|
-
to objects. The transaction methods added by this module will work with most
|
8
|
-
objects, excluding those that cannot be Marshal-ed (bindings, procedure
|
9
|
-
objects, IO instances, or singleton objects).
|
10
|
-
|
11
|
-
The transactions supported by Transaction::Simple are not backend transaction;
|
12
|
-
that is, they have nothing to do with any sort of data store. They are "live"
|
13
|
-
transactions occurring in memory and in the object itself. This is to allow
|
14
|
-
"test" changes to be made to an object before making the changes permanent.
|
15
|
-
|
16
|
-
Transaction::Simple can handle an "infinite" number of transactional levels
|
17
|
-
(limited only by memory). If I open two transactions, commit the first, but
|
18
|
-
abort the second, the object will revert to the original version.
|
19
|
-
|
20
|
-
Transaction::Simple supports "named" transactions, so that multiple levels of
|
21
|
-
transactions can be committed, aborted, or rewound by referring to the
|
22
|
-
appropriate name of the transaction. Names may be any object except nil.
|
23
|
-
|
24
|
-
Copyright: Copyright � 2003 by Austin Ziegler
|
25
|
-
Version: 1.11
|
26
|
-
Licence: MIT-Style
|
27
|
-
|
28
|
-
Thanks to David Black and Mauricio Fern�ndez for their help with this library.
|
29
|
-
|
30
|
-
Usage
|
31
|
-
-----
|
32
|
-
include 'transaction/simple'
|
33
|
-
|
34
|
-
v = "Hello, you." # => "Hello, you."
|
35
|
-
v.extend(Transaction::Simple) # => "Hello, you."
|
36
|
-
|
37
|
-
v.start_transaction # => ... (a Marshal string)
|
38
|
-
v.transaction_open? # => true
|
39
|
-
v.gsub!(/you/, "world") # => "Hello, world."
|
40
|
-
|
41
|
-
v.rewind_transaction # => "Hello, you."
|
42
|
-
v.transaction_open? # => true
|
43
|
-
|
44
|
-
v.gsub!(/you/, "HAL") # => "Hello, HAL."
|
45
|
-
v.abort_transaction # => "Hello, you."
|
46
|
-
v.transaction_open? # => false
|
47
|
-
|
48
|
-
v.start_transaction # => ... (a Marshal string)
|
49
|
-
v.start_transaction # => ... (a Marshal string)
|
50
|
-
|
51
|
-
v.transaction_open? # => true
|
52
|
-
v.gsub!(/you/, "HAL") # => "Hello, HAL."
|
53
|
-
|
54
|
-
v.commit_transaction # => "Hello, HAL."
|
55
|
-
v.transaction_open? # => true
|
56
|
-
v.abort_transaction # => "Hello, you."
|
57
|
-
v.transaction_open? # => false
|
58
|
-
|
59
|
-
Named Transaction Usage
|
60
|
-
-----------------------
|
61
|
-
v = "Hello, you." # => "Hello, you."
|
62
|
-
v.extend(Transaction::Simple) # => "Hello, you."
|
63
|
-
|
64
|
-
v.start_transaction(:first) # => ... (a Marshal string)
|
65
|
-
v.transaction_open? # => true
|
66
|
-
v.transaction_open?(:first) # => true
|
67
|
-
v.transaction_open?(:second) # => false
|
68
|
-
v.gsub!(/you/, "world") # => "Hello, world."
|
69
|
-
|
70
|
-
v.start_transaction(:second) # => ... (a Marshal string)
|
71
|
-
v.gsub!(/world/, "HAL") # => "Hello, HAL."
|
72
|
-
v.rewind_transaction(:first) # => "Hello, you."
|
73
|
-
v.transaction_open? # => true
|
74
|
-
v.transaction_open?(:first) # => true
|
75
|
-
v.transaction_open?(:second) # => false
|
76
|
-
|
77
|
-
v.gsub!(/you/, "world") # => "Hello, world."
|
78
|
-
v.start_transaction(:second) # => ... (a Marshal string)
|
79
|
-
v.gsub!(/world/, "HAL") # => "Hello, HAL."
|
80
|
-
v.transaction_name # => :second
|
81
|
-
v.abort_transaction(:first) # => "Hello, you."
|
82
|
-
v.transaction_open? # => false
|
83
|
-
|
84
|
-
v.start_transaction(:first) # => ... (a Marshal string)
|
85
|
-
v.gsub!(/you/, "world") # => "Hello, world."
|
86
|
-
v.start_transaction(:second) # => ... (a Marshal string)
|
87
|
-
v.gsub!(/world/, "HAL") # => "Hello, HAL."
|
88
|
-
|
89
|
-
v.commit_transaction(:first) # => "Hello, HAL."
|
90
|
-
v.transaction_open? # => false
|
91
|
-
|
92
|
-
Contraindications
|
93
|
-
-----------------
|
94
|
-
While Transaction::Simple is very useful, it has some severe limitations that
|
95
|
-
must be understood. Transaction::Simple:
|
96
|
-
|
97
|
-
* uses Marshal. Thus, any object which cannot be Marshal-ed cannot use
|
98
|
-
Transaction::Simple.
|
99
|
-
* does not manage resources. Resources external to the object and its instance
|
100
|
-
variables are not managed at all. However, all instance variables and
|
101
|
-
objects "belonging" to those instance variables are managed. If there are
|
102
|
-
object reference counts to be handled, Transaction::Simple will probably
|
103
|
-
cause problems.
|
104
|
-
* is not thread-safe. In the ACID ("atomic, consistent, isolated, durable")
|
105
|
-
test, Transaction::Simple provides C and D, but it is up to the user of
|
106
|
-
Transaction::Simple to provide isolation. Transactions should be considered
|
107
|
-
"critical sections" in multi-threaded applications. Thread safety can be
|
108
|
-
ensured with Transaction::Simple::ThreadSafe.
|
109
|
-
* does not maintain Object#__id__ values on rewind or abort. This may change
|
110
|
-
for future versions that will be Ruby 1.8 or better only.
|