memories 0.3.4 → 0.3.5

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.
Files changed (3) hide show
  1. data/lib/memories/base.rb +2 -2
  2. metadata +8 -9
  3. data/README.markdown +0 -191
@@ -351,10 +351,10 @@ module Memories
351
351
  @logical_version_number || self.current_version
352
352
  end
353
353
 
354
- def save_with_destroying_logical_version_and_revision
354
+ def save_with_destroying_logical_version_and_revision(options={})
355
355
  @logical_version_number = nil
356
356
  @logical_revision = nil
357
- save_without_destroying_logical_version_and_revision
357
+ save_without_destroying_logical_version_and_revision(options)
358
358
  end
359
359
 
360
360
  def save_with_destroying_logical_version_and_revision!
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: 27
5
- prerelease: false
4
+ hash: 25
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 4
10
- version: 0.3.4
9
+ - 5
10
+ version: 0.3.5
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: 2011-01-25 00:00:00 -05:00
19
+ date: 2011-03-16 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -41,8 +41,8 @@ executables: []
41
41
 
42
42
  extensions: []
43
43
 
44
- extra_rdoc_files:
45
- - README.markdown
44
+ extra_rdoc_files: []
45
+
46
46
  files:
47
47
  - lib/memories.rb
48
48
  - lib/memories/annotation.rb
@@ -50,7 +50,6 @@ files:
50
50
  - lib/memories/base.rb
51
51
  - lib/memories/milestones_proxy.rb
52
52
  - lib/memories/versions_proxy.rb
53
- - README.markdown
54
53
  has_rdoc: true
55
54
  homepage: http://github.com/moonmaster9000/memories
56
55
  licenses: []
@@ -81,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
80
  requirements: []
82
81
 
83
82
  rubyforge_project:
84
- rubygems_version: 1.3.7
83
+ rubygems_version: 1.5.0
85
84
  signing_key:
86
85
  specification_version: 3
87
86
  summary: Versioning for your couchrest_model documents.
@@ -1,191 +0,0 @@
1
- #Introduction
2
-
3
- A simple gem for adding versioning to your CouchRest::Model::Base documents. When you update a document, the previous version gets
4
- stored as an attachment on the document. This versioning strategy was originally created here: http://blog.couch.io/post/632718824/simple-document-versioning-with-couchdb
5
-
6
- ##Installation
7
-
8
- $ gem install memories
9
-
10
- ## Documentation
11
-
12
- Browse the documentation on rubydoc.info: http://rubydoc.info/gems/memories/frames
13
-
14
- ##How does it work?
15
-
16
- Just "include Memories" in your "CouchRest::Model::Base" classes and let the auto-versioning begin.
17
-
18
- ###Basic Versioning
19
-
20
- Here's how basic versioning works. Every time you save your document, you get a new version. You have the ability to roll back to a previous version.
21
-
22
- class Book < CouchRest::Model::Base
23
- include Memories
24
- use_database SOME_DATABASE
25
-
26
- property :name
27
- view_by :name
28
- end
29
-
30
- b = Book.create :name => "2001"
31
- b.current_version #==> 1
32
- b.name = "2001: A Space Odyssey"
33
- b.save
34
- b.current_version #==> 2
35
- b.previous_version #==> 1
36
- b.name #==> "2001: A Space Odyssey"
37
- b.revert_to! 1
38
- b.name #==> "2001"
39
- b.current_version #==> 3
40
-
41
- If you'd like to exclude certain properties from versioning, use the #forget class method:
42
-
43
- class Book < CouchRest::Model::Base
44
- include Memories
45
- use_database SOME_DATABASE
46
-
47
- forget :notes
48
-
49
- property :name
50
- property :notes
51
- view_by :name
52
- end
53
-
54
- b = Book.create :name => "2001", :notes => "creating the book."
55
- b.current_version #==> 1
56
- b.name = "2001: A Space Odyssey"
57
- b.notes += "updating the title. might ship today. 9/2/2010. MKP"
58
- b.save
59
- b.current_version #==> 2
60
- b.previous_version #==> 1
61
- p b.name #==> "2001: A Space Odyssey"
62
- p b.notes # ==> "creating the book. updating the title. might ship today. 9/2/2010. MKP"
63
- b.revert_to! 1
64
- p b.name #==> "2001"
65
- p b.notes # ==> "creating the book. updating the title. might ship today. 9/2/2010. MKP"
66
- b.current_version #==> 3
67
-
68
- If you'd like to explicitly define which properties to version, use the #remember method. It works just like #forget, but in reverse. Duh.
69
-
70
- ###Milestones
71
-
72
- As of version 0.2.0, Memories also supports milestones. Milestones are special versions that you want to flag in some way.
73
- For example, suppose you were creating a content management system, and every time someone publishes an article to the website, you want to flag the version
74
- they published as a milestone.
75
-
76
- class Article < CouchRest::Model::Base
77
- include Memories
78
- use_database SOME_DATABASE
79
-
80
- property :title
81
- property :author
82
- property :body
83
-
84
- def publish!
85
- # .... publishing logic
86
- end
87
- end
88
-
89
- a = Article.create(
90
- :title => "Memories gem makes versioning simple",
91
- :author => "moonmaster9000",
92
- :body => <<-ARTICLE
93
- Check it out at http://github.com/moonmaster9000/memories
94
- ARTICLE
95
- )
96
- a.save
97
- a.publish!
98
- a.current_version #==> 1
99
- a.milestone! do
100
- name "First publish."
101
- notes "Passed all relevant editing. Signed off by moonmaster10000"
102
- end
103
-
104
- Notice that we annotated our milestone; we gave it a name, and some notes. You can annotate with whatever properties you desire. The annotation do block is entirely optional.
105
- Now that we've created a milestone, let's inspect it via the `milestones` array:
106
-
107
- a.milestones.count #==> 1
108
- a.milestones.last.version # ==> 'rev-1-893428ifldlfds9832'
109
- a.milestones.last.version_number # ==> 1
110
- a.milestones.last.annotations.name # ==> "First publish."
111
- a.milestones.last.annotations.notes # ==> "Passed all relevant editing. Signed off by moonmaster 10000"
112
- a.milestones.last.instance.title # ==> Memories gem makes versioning simple
113
-
114
- Now, let's imagine that we've made some more edits / saves to the document, but they don't get approved. Now we want to revert to the version the document was
115
- at at the first milestone. How do we do that? Simple!
116
-
117
- a.revert_to_milestone! 1
118
-
119
- And now our document properties are back to the where they were when we first published the document.
120
-
121
- If you want to access the version instance of a milestone, simply use the "data" method:
122
-
123
- a.milestones.first.data.title #==> returns the "title" attribute on the first milestone
124
- a.milestones.each do |m|
125
- puts "Version: " + m.version
126
- puts "Title: " + m.data.title
127
- end
128
-
129
- ## Attachments
130
-
131
- By default, memories doesn't version attachments. If you'd like to version attachments, simply call the `remember_attachments!` class method in your
132
- class definition:
133
-
134
- class MyDoc < CouchRest::Model::Base
135
- use_database MY_DB
136
- include Memories
137
-
138
- remember_attachments!
139
- end
140
-
141
- If you only want specific attachments versioned, pass
142
- strings and/or regular expressions to this macro. Any attachments
143
- with matching names will be versioned.
144
-
145
- class HtmlPage < CouchRest::Model::Base
146
- use_database MY_DB
147
- include Memories
148
-
149
- remember_attachments! "image.png", %r{stylesheets/.*}
150
- end
151
-
152
- ## Accessing Previous Versions
153
-
154
- You can access old versions of your document via the "versions" method; it will return a proxy with array-like and hash-like access to previous versions.
155
-
156
- @doc.versions[1].instance # ==> returns version 1 of your document
157
- @doc.versions[1].revision # ==> 'rev-1-jkfldsi32849032894032'
158
- @doc.versions[1].version_number # ==> 1
159
- @doc.versions['rev-1-kjfdsla3289430289432'].instance # ==> returns version 1 of your document
160
- @doc.versions[1..7] # ==> returns version proxies 1 through 7 of your document
161
- @doc.versions.count # ==> returns the number of versions of your document
162
- @doc.versions.last # ==> returns a proxy for the latest version of your document
163
- @doc.versions.first # ==> returns a proxy for the first version of your document
164
- @doc.versions.each do |v|
165
- puts v.instance.some_property
166
- end
167
-
168
- ## Logical Revision Numbers
169
-
170
- As of version 0.3.1, when you soft revert a document (#revert_to), you can access the logical revision and logical version numbers of that document.
171
-
172
- For example, suppose you soft revert a document with 10 versions to version 2.
173
-
174
- @doc.current_version # ==> 10
175
- @doc.revert_to 2
176
-
177
- When you ask the logical revision, you'll receive the revision number of version 2:
178
-
179
- @doc.logical_revision #==> 'rev-2-kfdlsa432890432890432'
180
-
181
- Similarly, the logical version number:
182
-
183
- @doc.logical_version_number #==> 2
184
-
185
- However, as soon as you save the document, the logical revision and logical version number will simply mirror those of the actual document
186
-
187
- @doc.save
188
- @doc.rev #==> '11-qwerty1234567890'
189
- @doc.logical_revision #==> 'rev-11-qwerty1234567890'
190
- @doc.logical_version_number #==> 11
191
-