scriber 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1,6 +1,7 @@
1
1
 
2
- Record class changes and replay them.
3
- I plan to use this for Ruby class synchronisation on different clients.
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.4
1
+ 0.0.5
@@ -8,12 +8,8 @@ require "supermodel"
8
8
  module Scriber
9
9
  class ScriberError < StandardError; end
10
10
 
11
- def record(klass, type, data = nil)
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
- $: << File.dirname(__FILE__)
23
+ $:.unshift(File.dirname(__FILE__))
28
24
 
29
25
  require "scriber/scribe"
@@ -1,18 +1,19 @@
1
1
  module Scriber
2
2
  class Scribe < SuperModel::Base
3
3
  include SuperModel::RandomID
4
- include SuperModel::Persist::Model
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{scriber}
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alex MacCaw"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scriber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex MacCaw