memories 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/memories/base.rb +14 -1
- data/lib/memories/versions_proxy.rb +4 -4
- metadata +4 -4
data/lib/memories/base.rb
CHANGED
@@ -125,6 +125,17 @@ module Memories
|
|
125
125
|
}.inject(false) {|b, sum| sum || b})
|
126
126
|
end
|
127
127
|
end
|
128
|
+
|
129
|
+
# Returns a list of attachments it should not version
|
130
|
+
def attachments_to_forget
|
131
|
+
return [] unless self.class.remember_attachments?
|
132
|
+
(self.database.get(self.id)["_attachments"] || {}).keys.reject do |a|
|
133
|
+
a.match(VERSION_REGEX) ||
|
134
|
+
(self.class.remember_attachments.map { |attachment_name_pattern|
|
135
|
+
a.match attachment_name_pattern
|
136
|
+
}.inject(false) {|b, sum| sum || b})
|
137
|
+
end
|
138
|
+
end
|
128
139
|
|
129
140
|
# Revert the document to a specific version and save.
|
130
141
|
# You can provide either a complete revision number ("1-u54abz3948302sjjej3jej300rj", or "rev-1-u54abz3948302sjjej3jej300rj")
|
@@ -132,11 +143,13 @@ module Memories
|
|
132
143
|
# my_doc.revert_to! 3 # ==> would revert your document "my_doc" to version 3.
|
133
144
|
def revert_to!(version)
|
134
145
|
revert version, :hard
|
146
|
+
self
|
135
147
|
end
|
136
148
|
|
137
149
|
# Same as #revert_to!, except that it doesn't save.
|
138
150
|
def revert_to(version)
|
139
151
|
revert version
|
152
|
+
self
|
140
153
|
end
|
141
154
|
|
142
155
|
# Same as #rollback!, but doesn't save.
|
@@ -261,7 +274,7 @@ module Memories
|
|
261
274
|
end
|
262
275
|
|
263
276
|
self["_attachments"].keys.select {|a| !a.match(VERSION_REGEX)}.each do |attachment|
|
264
|
-
self.delete_attachment(attachment)
|
277
|
+
self.delete_attachment(attachment) if !versioned_attachments['known_attachments'].include?(attachment) and !attachments_to_forget.include?(attachment)
|
265
278
|
end
|
266
279
|
end
|
267
280
|
end
|
@@ -2,6 +2,7 @@ module Memories
|
|
2
2
|
class VersionsProxy
|
3
3
|
def initialize(doc)
|
4
4
|
@doc = doc
|
5
|
+
@versions = {}
|
5
6
|
end
|
6
7
|
|
7
8
|
def count
|
@@ -22,15 +23,14 @@ module Memories
|
|
22
23
|
return [] if range.first > @doc.current_version
|
23
24
|
current_version = range.last >= @doc.current_version ? @doc.dup : nil
|
24
25
|
last = range.last >= @doc.current_version ? @doc.current_version - 1 : range.last
|
25
|
-
versions = (range.first..last).to_a.map {|i|
|
26
|
+
versions = (range.first..last).to_a.map {|i| version_num i}
|
26
27
|
versions << current_version if current_version
|
27
28
|
versions
|
28
29
|
end
|
29
30
|
|
30
31
|
def version_num(num)
|
31
|
-
return nil if !num.kind_of?(Fixnum) or num
|
32
|
-
@doc.revert_to(num)
|
33
|
-
@doc.dup
|
32
|
+
return nil if !num.kind_of?(Fixnum) or num >= @doc.current_version or num < 1
|
33
|
+
@versions[num] ||= @doc.revert_to(num).dup
|
34
34
|
end
|
35
35
|
|
36
36
|
def version_id(id)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memories
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 7
|
10
|
+
version: 0.2.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Parker
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-12-
|
19
|
+
date: 2010-12-25 00:00:00 -05:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|