versioned 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/version.rb +1 -1
- data/lib/versioned.rb +5 -7
- data/test/revert_test.rb +5 -2
- data/versioned.gemspec +8 -8
- metadata +7 -7
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/lib/version.rb
CHANGED
data/lib/versioned.rb
CHANGED
@@ -12,13 +12,9 @@ module Versioned
|
|
12
12
|
module LockingInstanceMethods
|
13
13
|
private
|
14
14
|
#new? isn't working
|
15
|
-
def is_new_document?
|
16
|
-
(read_attribute(self.version_lock_key).blank? && changes[self.version_lock_key.to_s].blank?) ||
|
17
|
-
(changes[self.version_lock_key.to_s] && changes[self.version_lock_key.to_s].first.blank?)
|
18
|
-
end
|
19
15
|
def prep_lock_version
|
20
16
|
old = read_attribute(self.version_lock_key)
|
21
|
-
if !
|
17
|
+
if !new? || old.blank?
|
22
18
|
v = (Time.now.to_f * 1000).ceil.to_s
|
23
19
|
write_attribute self.version_lock_key, v
|
24
20
|
end
|
@@ -28,7 +24,9 @@ module Versioned
|
|
28
24
|
|
29
25
|
def save_to_collection(options = {})
|
30
26
|
current_version = prep_lock_version
|
31
|
-
|
27
|
+
old_new = new?
|
28
|
+
@new = false
|
29
|
+
if old_new
|
32
30
|
collection.insert(to_mongo, :safe => true)
|
33
31
|
else
|
34
32
|
selector = { :_id => read_attribute(:_id), self.version_lock_key => current_version }
|
@@ -80,7 +78,7 @@ module Versioned
|
|
80
78
|
else
|
81
79
|
conditions = condition
|
82
80
|
end
|
83
|
-
|
81
|
+
all(
|
84
82
|
:number => conditions,
|
85
83
|
:order => "number #{(from_number > to_number) ? 'DESC' : 'ASC'}"
|
86
84
|
)
|
data/test/revert_test.rb
CHANGED
@@ -17,9 +17,12 @@ class RevertTest < Test::Unit::TestCase
|
|
17
17
|
end
|
18
18
|
|
19
19
|
should 'do nothing for a non-existent version' do
|
20
|
-
attributes = @user.attributes
|
20
|
+
attributes = @user.attributes.clone
|
21
21
|
@user.revert_to!(nil)
|
22
|
-
|
22
|
+
|
23
|
+
attributes.each do |k,v|
|
24
|
+
assert_equal @user[k].to_s, v.to_s #dates aren't comparing well
|
25
|
+
end
|
23
26
|
end
|
24
27
|
|
25
28
|
should 'return the new version number' do
|
data/versioned.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{versioned}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["twoism", "toastyapps", "jacqui", "mrkurt"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-02-17}
|
13
13
|
s.description = %q{Versioning for MongoMapper}
|
14
14
|
s.email = %q{signalstatic@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -41,16 +41,16 @@ Gem::Specification.new do |s|
|
|
41
41
|
s.rubygems_version = %q{1.3.5}
|
42
42
|
s.summary = %q{Versioning for MongoMapper}
|
43
43
|
s.test_files = [
|
44
|
-
"test/
|
45
|
-
"test/
|
44
|
+
"test/test_helper.rb",
|
45
|
+
"test/between_test.rb",
|
46
46
|
"test/comparable_test.rb",
|
47
|
+
"test/revert_test.rb",
|
47
48
|
"test/creation_test.rb",
|
48
49
|
"test/latest_changes_test.rb",
|
49
|
-
"test/lock_test.rb",
|
50
|
-
"test/revert_test.rb",
|
51
|
-
"test/schema.rb",
|
52
50
|
"test/specified_version_key_test.rb",
|
53
|
-
"test/
|
51
|
+
"test/schema.rb",
|
52
|
+
"test/lock_test.rb",
|
53
|
+
"test/changes_test.rb"
|
54
54
|
]
|
55
55
|
|
56
56
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: versioned
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- twoism
|
@@ -12,7 +12,7 @@ autorequire:
|
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
14
|
|
15
|
-
date: 2010-
|
15
|
+
date: 2010-02-17 00:00:00 -06:00
|
16
16
|
default_executable:
|
17
17
|
dependencies: []
|
18
18
|
|
@@ -72,13 +72,13 @@ signing_key:
|
|
72
72
|
specification_version: 3
|
73
73
|
summary: Versioning for MongoMapper
|
74
74
|
test_files:
|
75
|
+
- test/test_helper.rb
|
75
76
|
- test/between_test.rb
|
76
|
-
- test/changes_test.rb
|
77
77
|
- test/comparable_test.rb
|
78
|
+
- test/revert_test.rb
|
78
79
|
- test/creation_test.rb
|
79
80
|
- test/latest_changes_test.rb
|
80
|
-
- test/lock_test.rb
|
81
|
-
- test/revert_test.rb
|
82
|
-
- test/schema.rb
|
83
81
|
- test/specified_version_key_test.rb
|
84
|
-
- test/
|
82
|
+
- test/schema.rb
|
83
|
+
- test/lock_test.rb
|
84
|
+
- test/changes_test.rb
|