thirtythirty 0.0.8 → 0.1.0

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/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  pkg/*
4
4
  spec/reports
5
+ Gemfile.lock
data/lib/thirtythirty.rb CHANGED
@@ -52,7 +52,13 @@ private
52
52
  data = Marshal.load(uncompressed)
53
53
  obj = new
54
54
  marshalled_attributes.each do |attr|
55
- obj.send(:"#{attr}=", Marshal.load(data[attr]))
55
+ setter = :"#{attr}="
56
+ value = Marshal.load(data[attr])
57
+ if obj.respond_to?(setter)
58
+ obj.send(setter, value)
59
+ else
60
+ obj.instance_variable_set(:"@#{attr}", value)
61
+ end
56
62
  end
57
63
  obj
58
64
  end
@@ -75,7 +81,11 @@ private
75
81
 
76
82
  def build_marshalled_attributes_hash(&block)
77
83
  self.class.marshalled_attributes.inject({}) do |hash, attr|
78
- value = self.send(attr)
84
+ value = if self.respond_to?(attr)
85
+ self.send(attr)
86
+ else
87
+ self.instance_variable_get(:"@#{attr}")
88
+ end
79
89
  hash[attr] = block.call(value)
80
90
  hash
81
91
  end
@@ -15,3 +15,21 @@ class Compressed < ThirtythirtyBase
15
15
  marshal_with_compression
16
16
  marshalled_accessor :persistent
17
17
  end
18
+
19
+ class WithoutGetterSetter < ThirtythirtyBase
20
+ marshal :ivar
21
+ end
22
+
23
+ class WithGetterOnly < ThirtythirtyBase
24
+ marshal :ivar
25
+ def ivar
26
+ @ivar.nil? ? nil : @ivar.upcase
27
+ end
28
+ end
29
+
30
+ class WithSetterOnly < ThirtythirtyBase
31
+ marshal :ivar
32
+ def ivar=(value)
33
+ @ivar = value.nil? ? nil : value.upcase
34
+ end
35
+ end
@@ -208,6 +208,49 @@ describe Thirtythirty do
208
208
  restored.transient.should be_nil
209
209
  end
210
210
 
211
+ context "with marshalled instance variable without getter/setter" do
212
+
213
+ subject { WithoutGetterSetter.new }
214
+
215
+ it "should dump/restore instance variable when nil" do
216
+ restored = Marshal.load(Marshal.dump(subject))
217
+ restored.instance_variable_get(:"@ivar").should be_nil
218
+ end
219
+
220
+ it "should dump/restore instance variable when set" do
221
+ subject.instance_variable_set(:"@ivar", "value")
222
+ restored = Marshal.load(Marshal.dump(subject))
223
+ restored.instance_variable_get(:"@ivar").should == "value"
224
+ end
225
+
226
+ end
227
+
228
+ context "with marshalled instance variable without setter" do
229
+
230
+ subject { WithGetterOnly.new }
231
+
232
+ it "should dump accessor value/restore instance variable" do
233
+ subject.instance_variable_set(:"@ivar", "value")
234
+ subject.ivar.should == "VALUE"
235
+ restored = Marshal.load(Marshal.dump(subject))
236
+ restored.instance_variable_get(:"@ivar").should == "VALUE"
237
+ restored.ivar.should == "VALUE"
238
+ end
239
+
240
+ end
241
+
242
+ context "with marshalled instance variable without getter" do
243
+
244
+ subject { WithSetterOnly.new }
245
+
246
+ it "should dump instance variable/restore accessor value" do
247
+ subject.instance_variable_set(:"@ivar", "value")
248
+ restored = Marshal.load(Marshal.dump(subject))
249
+ restored.instance_variable_get(:"@ivar").should == "VALUE"
250
+ end
251
+
252
+ end
253
+
211
254
  context "with a single relation" do
212
255
 
213
256
  before do
data/thirtythirty.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = "thirtythirty"
4
- s.version = "0.0.8"
4
+ s.version = "0.1.0"
5
5
  s.date = Time.now
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ["Benjamin Behr", "Thomas Jachmann"]
@@ -12,8 +12,8 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.rubyforge_project = "thirtythirty"
14
14
 
15
- s.add_development_dependency "ci_reporter", "~> 1.6.3"
16
- s.add_development_dependency "rspec", "~> 2.4.0"
15
+ s.add_development_dependency "ci_reporter", "~> 1.6.5"
16
+ s.add_development_dependency "rspec", "~> 2.6.0"
17
17
  s.add_development_dependency "rake", "0.8.7"
18
18
 
19
19
  s.files = `git ls-files`.split("\n")
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thirtythirty
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 8
10
- version: 0.0.8
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Benjamin Behr
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-06-28 00:00:00 +02:00
19
+ date: 2011-08-02 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -27,12 +27,12 @@ dependencies:
27
27
  requirements:
28
28
  - - ~>
29
29
  - !ruby/object:Gem::Version
30
- hash: 9
30
+ hash: 5
31
31
  segments:
32
32
  - 1
33
33
  - 6
34
- - 3
35
- version: 1.6.3
34
+ - 5
35
+ version: 1.6.5
36
36
  type: :development
37
37
  version_requirements: *id001
38
38
  - !ruby/object:Gem::Dependency
@@ -43,12 +43,12 @@ dependencies:
43
43
  requirements:
44
44
  - - ~>
45
45
  - !ruby/object:Gem::Version
46
- hash: 31
46
+ hash: 23
47
47
  segments:
48
48
  - 2
49
- - 4
49
+ - 6
50
50
  - 0
51
- version: 2.4.0
51
+ version: 2.6.0
52
52
  type: :development
53
53
  version_requirements: *id002
54
54
  - !ruby/object:Gem::Dependency
@@ -81,7 +81,6 @@ files:
81
81
  - .gitignore
82
82
  - .rspec
83
83
  - Gemfile
84
- - Gemfile.lock
85
84
  - README.rdoc
86
85
  - Rakefile
87
86
  - lib/thirtythirty.rb
data/Gemfile.lock DELETED
@@ -1,31 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- thirtythirty (0.0.7)
5
-
6
- GEM
7
- remote: http://rubygems.org/
8
- specs:
9
- builder (3.0.0)
10
- ci_reporter (1.6.4)
11
- builder (>= 2.1.2)
12
- diff-lcs (1.1.2)
13
- rake (0.8.7)
14
- rspec (2.4.0)
15
- rspec-core (~> 2.4.0)
16
- rspec-expectations (~> 2.4.0)
17
- rspec-mocks (~> 2.4.0)
18
- rspec-core (2.4.0)
19
- rspec-expectations (2.4.0)
20
- diff-lcs (~> 1.1.2)
21
- rspec-mocks (2.4.0)
22
-
23
- PLATFORMS
24
- java
25
- ruby
26
-
27
- DEPENDENCIES
28
- ci_reporter (~> 1.6.3)
29
- rake (= 0.8.7)
30
- rspec (~> 2.4.0)
31
- thirtythirty!