scriber 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +14 -5
- data/VERSION +1 -1
- data/lib/scriber.rb +3 -7
- data/lib/scriber/scribe.rb +5 -4
- data/scriber.gemspec +1 -1
- metadata +1 -1
data/README
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
|
2
|
-
Record class changes and replay them.
|
3
|
-
|
2
|
+
Record class changes and replay them. This may not look particularly
|
3
|
+
useful at first, but combined with the Syncro gem (http://github.com/maccman/syncro), you can easily implement
|
4
|
+
Ruby class synchronisation between remote clients.
|
4
5
|
|
5
6
|
Example:
|
6
7
|
|
@@ -25,11 +26,19 @@ Example:
|
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
|
-
Scriber.backend = Scriber::Backends::Log.new("scribe.log")
|
29
|
-
|
30
29
|
Scriber.record(Test, :var=, 1)
|
31
30
|
Scriber.record(Test, :var=, 2)
|
32
31
|
Scriber.record(Test, :var=, 3)
|
33
32
|
|
34
33
|
Scriber.play
|
35
|
-
Test.var #=> 3
|
34
|
+
Test.var #=> 3
|
35
|
+
|
36
|
+
|
37
|
+
To persist Scriber recordings, setup SuperModel's marshalling:
|
38
|
+
|
39
|
+
SuperModel::Marshal.path = "dump.db"
|
40
|
+
SuperModel::Marshal.load
|
41
|
+
|
42
|
+
at_exit {
|
43
|
+
SuperModel::Marshal.dump
|
44
|
+
}
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/lib/scriber.rb
CHANGED
@@ -8,12 +8,8 @@ require "supermodel"
|
|
8
8
|
module Scriber
|
9
9
|
class ScriberError < StandardError; end
|
10
10
|
|
11
|
-
def record(
|
12
|
-
Scribe.create(
|
13
|
-
:klass => klass,
|
14
|
-
:type => type,
|
15
|
-
:data => data
|
16
|
-
})
|
11
|
+
def record(hash)
|
12
|
+
Scribe.create(hash)
|
17
13
|
end
|
18
14
|
|
19
15
|
def play
|
@@ -24,6 +20,6 @@ module Scriber
|
|
24
20
|
extend self
|
25
21
|
end
|
26
22
|
|
27
|
-
|
23
|
+
$:.unshift(File.dirname(__FILE__))
|
28
24
|
|
29
25
|
require "scriber/scribe"
|
data/lib/scriber/scribe.rb
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
module Scriber
|
2
2
|
class Scribe < SuperModel::Base
|
3
3
|
include SuperModel::RandomID
|
4
|
-
include SuperModel::
|
4
|
+
include SuperModel::Marshal::Model
|
5
5
|
|
6
6
|
class << self
|
7
7
|
def since(id)
|
8
8
|
record = find(id)
|
9
9
|
index = records.index(record)
|
10
|
-
records.slice(index, -1).dup
|
11
|
-
rescue UnknownRecord
|
10
|
+
records.slice(index + 1, -1).dup
|
11
|
+
rescue SuperModel::UnknownRecord
|
12
|
+
[]
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
15
|
-
attributes :klass, :type, :data
|
16
|
+
attributes :klass, :type, :data, :clients
|
16
17
|
validates_presence_of :klass, :type
|
17
18
|
|
18
19
|
def play
|
data/scriber.gemspec
CHANGED