scriber 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -8,6 +8,7 @@ begin
8
8
  gemspec.description = "Record class changes to disk, then replay them."
9
9
  gemspec.authors = ["Alex MacCaw"]
10
10
  gemspec.add_dependency("activesupport", ">=2.3.5")
11
+ gemspec.add_dependency("activemodel")
11
12
  end
12
13
  rescue LoadError
13
14
  puts "Jeweler not available. Install it with: sudo gem install jeweler"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/lib/scriber.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  gem "activesupport"
2
+ gem "activemodel"
2
3
 
3
4
  require "active_support/inflector"
4
5
  require "active_support/core_ext/string/inflections"
6
+ require "active_model"
5
7
 
6
8
  module Scriber
7
9
  class ScriberError < StandardError; end
@@ -15,8 +17,7 @@ module Scriber
15
17
  end
16
18
 
17
19
  def record(klass, type, data)
18
- scribe = Scribe.new(klass, type, data)
19
- backend.record(scribe)
20
+ Scribe.create(klass, type, data)
20
21
  end
21
22
 
22
23
  def play
@@ -3,7 +3,7 @@ module Scriber
3
3
  class Base
4
4
  class UnimplementedError < ScriberError; end
5
5
 
6
- def record(scribe)
6
+ def save(scribe)
7
7
  raise UnimplementedError
8
8
  end
9
9
 
@@ -7,7 +7,7 @@ module Scriber
7
7
  @path = path
8
8
  end
9
9
 
10
- def record(scribe)
10
+ def save(scribe)
11
11
  File.open(path, "ab") {|file|
12
12
  file.write(Marshal.dump(scribe) + $/)
13
13
  }
@@ -1,5 +1,13 @@
1
1
  module Scriber
2
2
  class Scribe
3
+ include ActiveModel::Observing
4
+
5
+ class << self
6
+ def create(*args)
7
+ self.new(*args).save
8
+ end
9
+ end
10
+
3
11
  attr_reader :klass, :type, :data
4
12
 
5
13
  def initialize(klass, type, data)
@@ -12,6 +20,13 @@ module Scriber
12
20
  klass.scribe_play(type, data)
13
21
  end
14
22
 
23
+ def save
24
+ notify_observers(:before_save)
25
+ Scriber.backend.save(self)
26
+ notify_observers(:after_save)
27
+ true
28
+ end
29
+
15
30
  def marshal_dump
16
31
  [klass.name, type, data]
17
32
  end
data/scriber.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{scriber}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
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"]
@@ -38,11 +38,14 @@ Gem::Specification.new do |s|
38
38
 
39
39
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
40
40
  s.add_runtime_dependency(%q<activesupport>, [">= 2.3.5"])
41
+ s.add_runtime_dependency(%q<activemodel>, [">= 0"])
41
42
  else
42
43
  s.add_dependency(%q<activesupport>, [">= 2.3.5"])
44
+ s.add_dependency(%q<activemodel>, [">= 0"])
43
45
  end
44
46
  else
45
47
  s.add_dependency(%q<activesupport>, [">= 2.3.5"])
48
+ s.add_dependency(%q<activemodel>, [">= 0"])
46
49
  end
47
50
  end
48
51
 
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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex MacCaw
@@ -22,6 +22,16 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: 2.3.5
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: activemodel
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
25
35
  description: Record class changes to disk, then replay them.
26
36
  email: info@eribium.org
27
37
  executables: []