modified_acts_as_versioned 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/.gitignore +1 -0
  2. data/CHANGELOG +82 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README +28 -0
  5. data/RUNNING_UNIT_TESTS +41 -0
  6. data/Rakefile +50 -0
  7. data/VERSION.yml +4 -0
  8. data/acts_as_versioned.gemspec +29 -0
  9. data/init.rb +1 -0
  10. data/lib/acts_as_versioned.rb +488 -0
  11. data/rdoc/classes/ActiveRecord/Acts/Versioned/ActMethods/ClassMethods.html +336 -0
  12. data/rdoc/classes/ActiveRecord/Acts/Versioned/ActMethods.html +581 -0
  13. data/rdoc/classes/ActiveRecord/Acts/Versioned/ClassMethods.html +506 -0
  14. data/rdoc/classes/ActiveRecord/Acts/Versioned.html +187 -0
  15. data/rdoc/created.rid +1 -0
  16. data/rdoc/files/CHANGELOG.html +288 -0
  17. data/rdoc/files/README.html +158 -0
  18. data/rdoc/files/RUNNING_UNIT_TESTS.html +158 -0
  19. data/rdoc/files/lib/acts_as_versioned_rb.html +129 -0
  20. data/rdoc/fr_class_index.html +30 -0
  21. data/rdoc/fr_file_index.html +30 -0
  22. data/rdoc/fr_method_index.html +54 -0
  23. data/rdoc/index.html +24 -0
  24. data/rdoc/rdoc-style.css +208 -0
  25. data/test/abstract_unit.rb +60 -0
  26. data/test/database.yml +18 -0
  27. data/test/fixtures/authors.yml +6 -0
  28. data/test/fixtures/landmark.rb +3 -0
  29. data/test/fixtures/landmark_versions.yml +7 -0
  30. data/test/fixtures/landmarks.yml +7 -0
  31. data/test/fixtures/locked_pages.yml +10 -0
  32. data/test/fixtures/locked_pages_revisions.yml +27 -0
  33. data/test/fixtures/migrations/1_add_versioned_tables.rb +15 -0
  34. data/test/fixtures/page.rb +48 -0
  35. data/test/fixtures/page_versions.yml +16 -0
  36. data/test/fixtures/pages.yml +8 -0
  37. data/test/fixtures/widget.rb +6 -0
  38. data/test/migration_test.rb +47 -0
  39. data/test/schema.rb +82 -0
  40. data/test/versioned_test.rb +379 -0
  41. metadata +114 -0
@@ -0,0 +1,187 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Module: ActiveRecord::Acts::Versioned</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Module</strong></td>
53
+ <td class="class-name-in-header">ActiveRecord::Acts::Versioned</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../../files/lib/acts_as_versioned_rb.html">
59
+ lib/acts_as_versioned.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ </table>
66
+ </div>
67
+ <!-- banner header -->
68
+
69
+ <div id="bodyContent">
70
+
71
+
72
+
73
+ <div id="contextContent">
74
+
75
+ <div id="description">
76
+ <p>
77
+ Specify this act if you want to save a copy of the row in a versioned
78
+ table. This assumes there is a versioned table ready and that your model
79
+ has a version field. This works with optimistic locking if the lock_version
80
+ column is present as well.
81
+ </p>
82
+ <p>
83
+ The class for the versioned model is derived the first time it is seen.
84
+ Therefore, if you change your database schema you have to restart your
85
+ container for the changes to be reflected. In development mode this usually
86
+ means restarting WEBrick.
87
+ </p>
88
+ <pre>
89
+ class Page &lt; ActiveRecord::Base
90
+ # assumes pages_versions table
91
+ acts_as_versioned
92
+ end
93
+ </pre>
94
+ <p>
95
+ Example:
96
+ </p>
97
+ <pre>
98
+ page = Page.create(:title =&gt; 'hello world!')
99
+ page.version # =&gt; 1
100
+
101
+ page.title = 'hello world'
102
+ page.save
103
+ page.version # =&gt; 2
104
+ page.versions.size # =&gt; 2
105
+
106
+ page.revert_to(1) # using version number
107
+ page.title # =&gt; 'hello world!'
108
+
109
+ page.revert_to(page.versions.last) # using versioned instance
110
+ page.title # =&gt; 'hello world'
111
+
112
+ page.versions.earliest # efficient query to find the first version
113
+ page.versions.latest # efficient query to find the most recently created version
114
+ </pre>
115
+ <p>
116
+ Simple Queries to page between versions
117
+ </p>
118
+ <pre>
119
+ page.versions.before(version)
120
+ page.versions.after(version)
121
+ </pre>
122
+ <p>
123
+ Access the previous/next versions from the versioned model itself
124
+ </p>
125
+ <pre>
126
+ version = page.versions.latest
127
+ version.previous # go back one version
128
+ version.next # go forward one version
129
+ </pre>
130
+ <p>
131
+ See <a
132
+ href="Versioned/ClassMethods.html#M000022">ActiveRecord::Acts::Versioned::ClassMethods#acts_as_versioned</a>
133
+ for configuration options
134
+ </p>
135
+
136
+ </div>
137
+
138
+
139
+ </div>
140
+
141
+
142
+ </div>
143
+
144
+
145
+ <!-- if includes -->
146
+
147
+ <div id="section">
148
+
149
+ <div id="class-list">
150
+ <h3 class="section-bar">Classes and Modules</h3>
151
+
152
+ Module <a href="Versioned/ActMethods.html" class="link">ActiveRecord::Acts::Versioned::ActMethods</a><br />
153
+ Module <a href="Versioned/ClassMethods.html" class="link">ActiveRecord::Acts::Versioned::ClassMethods</a><br />
154
+
155
+ </div>
156
+
157
+ <div id="constants-list">
158
+ <h3 class="section-bar">Constants</h3>
159
+
160
+ <div class="name-list">
161
+ <table summary="Constants">
162
+ <tr class="top-aligned-row context-row">
163
+ <td class="context-item-name">CALLBACKS</td>
164
+ <td>=</td>
165
+ <td class="context-item-value">[:set_new_version, :save_version, :save_version?]</td>
166
+ </tr>
167
+ </table>
168
+ </div>
169
+ </div>
170
+
171
+
172
+
173
+
174
+
175
+
176
+ <!-- if method_list -->
177
+
178
+
179
+ </div>
180
+
181
+
182
+ <div id="validator-badges">
183
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
184
+ </div>
185
+
186
+ </body>
187
+ </html>
data/rdoc/created.rid ADDED
@@ -0,0 +1 @@
1
+ Wed, 29 Sep 2010 11:36:59 +0100
@@ -0,0 +1,288 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: CHANGELOG</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>CHANGELOG</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>CHANGELOG
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Wed Sep 29 11:16:43 +0100 2010</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+ <div id="description">
72
+ <p>
73
+ <b>GIT</b> (version numbers are overrated)
74
+ </p>
75
+ <ul>
76
+ <li>(16 Jun 2008) Backwards Compatibility is overrated (big updates for rails
77
+ 2.1)
78
+
79
+ <ul>
80
+ <li>Use ActiveRecord 2.1&#8216;s dirty attribute checking instead [Asa Calow]
81
+
82
+ </li>
83
+ <li>Remove last traces of non_versioned_fields
84
+
85
+ </li>
86
+ <li>Remove AR::Base.find_version and AR::Base.find_versions, rely on AR
87
+ association proxies and named_scope
88
+
89
+ </li>
90
+ <li>Remove versions_count, rely on AR association counter caching.
91
+
92
+ </li>
93
+ <li>Remove versioned_attributes, basically the same as
94
+ AR::Base.versioned_columns
95
+
96
+ </li>
97
+ </ul>
98
+ </li>
99
+ <li>(5 Oct 2006) Allow customization of versions association options [Dan
100
+ Peterson]
101
+
102
+ </li>
103
+ </ul>
104
+ <p>
105
+ *0.5.1*
106
+ </p>
107
+ <ul>
108
+ <li>(8 Aug 2006) Versioned models now belong to the unversioned model.
109
+ @article_version.article.class =&gt; Article [Aslak Hellesoy]
110
+
111
+ </li>
112
+ </ul>
113
+ <p>
114
+ *0.5* # do versions even matter for plugins?
115
+ </p>
116
+ <ul>
117
+ <li>(21 Apr 2006) Added without_locking and without_revision methods.
118
+
119
+ <p>
120
+ Foo.without_revision do
121
+ </p>
122
+ <pre>
123
+ @foo.update_attributes ...
124
+ </pre>
125
+ <p>
126
+ end
127
+ </p>
128
+ </li>
129
+ </ul>
130
+ <p>
131
+ *0.4*
132
+ </p>
133
+ <ul>
134
+ <li>(28 March 2006) Rename non_versioned_fields to non_versioned_columns (old
135
+ one is kept for compatibility).
136
+
137
+ </li>
138
+ <li>(28 March 2006) Made explicit documentation note that string column names
139
+ are required for non_versioned_columns.
140
+
141
+ </li>
142
+ </ul>
143
+ <p>
144
+ *0.3.1*
145
+ </p>
146
+ <ul>
147
+ <li>(7 Jan 2006) explicitly set :foreign_key option for the versioned
148
+ model&#8216;s belongs_to assocation for STI [Caged]
149
+
150
+ </li>
151
+ <li>(7 Jan 2006) added tests to prove has_many :through joins work
152
+
153
+ </li>
154
+ </ul>
155
+ <p>
156
+ *0.3*
157
+ </p>
158
+ <ul>
159
+ <li>(2 Jan 2006) added ability to share a mixin with versioned class
160
+
161
+ </li>
162
+ <li>(2 Jan 2006) changed the dynamic version model to MyModel::Version
163
+
164
+ </li>
165
+ </ul>
166
+ <p>
167
+ *0.2.4*
168
+ </p>
169
+ <ul>
170
+ <li>(27 Nov 2005) added note about possible destructive behavior of if_changed?
171
+ [Michael Schuerig]
172
+
173
+ </li>
174
+ </ul>
175
+ <p>
176
+ *0.2.3*
177
+ </p>
178
+ <ul>
179
+ <li>(12 Nov 2005) fixed bug with old behavior of blank? [Michael Schuerig]
180
+
181
+ </li>
182
+ <li>(12 Nov 2005) updated tests to use ActiveRecord Schema
183
+
184
+ </li>
185
+ </ul>
186
+ <p>
187
+ *0.2.2*
188
+ </p>
189
+ <ul>
190
+ <li>(3 Nov 2005) added documentation note to acts_as_versioned [Martin Jul]
191
+
192
+ </li>
193
+ </ul>
194
+ <p>
195
+ *0.2.1*
196
+ </p>
197
+ <ul>
198
+ <li>(6 Oct 2005) renamed dirty? to changed? to keep it uniform. it was aliased
199
+ to keep it backwards compatible.
200
+
201
+ </li>
202
+ </ul>
203
+ <p>
204
+ *0.2*
205
+ </p>
206
+ <ul>
207
+ <li>(6 Oct 2005) added find_versions and find_version class methods.
208
+
209
+ </li>
210
+ <li>(6 Oct 2005) removed transaction from create_versioned_table(). this way
211
+ you can specify your own transaction around a group of operations.
212
+
213
+ </li>
214
+ <li>(30 Sep 2005) fixed bug where find_versions() would order by
215
+ &#8216;version&#8217; twice. (found by Joe Clark)
216
+
217
+ </li>
218
+ <li>(26 Sep 2005) added :sequence_name option to acts_as_versioned to set the
219
+ sequence name on the versioned model
220
+
221
+ </li>
222
+ </ul>
223
+ <p>
224
+ *0.1.3* (18 Sep 2005)
225
+ </p>
226
+ <ul>
227
+ <li>First RubyForge release
228
+
229
+ </li>
230
+ </ul>
231
+ <p>
232
+ *0.1.2*
233
+ </p>
234
+ <ul>
235
+ <li>check if module is already included when acts_as_versioned is called
236
+
237
+ </li>
238
+ </ul>
239
+ <p>
240
+ *0.1.1*
241
+ </p>
242
+ <ul>
243
+ <li>Adding tests and rdocs
244
+
245
+ </li>
246
+ </ul>
247
+ <p>
248
+ *0.1*
249
+ </p>
250
+ <ul>
251
+ <li>Initial transfer from Rails ticket: <a
252
+ href="http://dev.rubyonrails.com/ticket/1974">dev.rubyonrails.com/ticket/1974</a>
253
+
254
+ </li>
255
+ </ul>
256
+
257
+ </div>
258
+
259
+
260
+ </div>
261
+
262
+
263
+ </div>
264
+
265
+
266
+ <!-- if includes -->
267
+
268
+ <div id="section">
269
+
270
+
271
+
272
+
273
+
274
+
275
+
276
+
277
+ <!-- if method_list -->
278
+
279
+
280
+ </div>
281
+
282
+
283
+ <div id="validator-badges">
284
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
285
+ </div>
286
+
287
+ </body>
288
+ </html>
@@ -0,0 +1,158 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: README</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>README</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>README
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Wed Sep 29 11:16:43 +0100 2010</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+ <div id="description">
72
+ <h1>acts_as_versioned</h1>
73
+ <p>
74
+ This library adds simple versioning to an ActiveRecord module. ActiveRecord
75
+ is required.
76
+ </p>
77
+ <h2>Resources</h2>
78
+ <p>
79
+ Install
80
+ </p>
81
+ <ul>
82
+ <li>gem install acts_as_versioned
83
+
84
+ </li>
85
+ </ul>
86
+ <p>
87
+ Rubyforge project
88
+ </p>
89
+ <ul>
90
+ <li><a
91
+ href="http://rubyforge.org/projects/ar-versioned">rubyforge.org/projects/ar-versioned</a>
92
+
93
+ </li>
94
+ </ul>
95
+ <p>
96
+ RDocs
97
+ </p>
98
+ <ul>
99
+ <li><a href="http://ar-versioned.rubyforge.org">ar-versioned.rubyforge.org</a>
100
+
101
+ </li>
102
+ </ul>
103
+ <p>
104
+ Subversion
105
+ </p>
106
+ <ul>
107
+ <li><a
108
+ href="http://techno-weenie.net/svn/projects/acts_as_versioned">techno-weenie.net/svn/projects/acts_as_versioned</a>
109
+
110
+ </li>
111
+ </ul>
112
+ <p>
113
+ Collaboa
114
+ </p>
115
+ <ul>
116
+ <li><a
117
+ href="http://collaboa.techno-weenie.net/repository/browse/acts_as_versioned">collaboa.techno-weenie.net/repository/browse/acts_as_versioned</a>
118
+
119
+ </li>
120
+ </ul>
121
+ <p>
122
+ Special thanks to Dreamer on #rubyonrails for help in early testing. His
123
+ ServerSideWiki (<a href="http://serversidewiki.com">serversidewiki.com</a>)
124
+ was the first project to use acts_as_versioned <em>in the wild</em>.
125
+ </p>
126
+
127
+ </div>
128
+
129
+
130
+ </div>
131
+
132
+
133
+ </div>
134
+
135
+
136
+ <!-- if includes -->
137
+
138
+ <div id="section">
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+ <!-- if method_list -->
148
+
149
+
150
+ </div>
151
+
152
+
153
+ <div id="validator-badges">
154
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
155
+ </div>
156
+
157
+ </body>
158
+ </html>