simply_versioned 0.9.3.2

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.
@@ -0,0 +1,47 @@
1
+ # SimplyVersioned 0.9.3
2
+ #
3
+ # Simple ActiveRecord versioning
4
+ # Copyright (c) 2007,2008 Matt Mower <self@mattmower.com>
5
+ # Released under the MIT license (see accompany MIT-LICENSE file)
6
+ #
7
+
8
+ # A Version represents a numbered revision of an ActiveRecord model.
9
+ #
10
+ # The version has two attributes +number+ and +yaml+ where the yaml attribute
11
+ # holds the representation of the ActiveRecord model attributes. To access
12
+ # these call +model+ which will return an instantiated model of the original
13
+ # class with those attributes.
14
+ #
15
+ class Version < ActiveRecord::Base #:nodoc:
16
+ belongs_to :versionable, :polymorphic => true
17
+
18
+ # Return an instance of the versioned ActiveRecord model with the attribute
19
+ # values of this version.
20
+ def model
21
+ obj = versionable.class.new
22
+ YAML::load( self.yaml ).each do |var_name,var_value|
23
+ obj.__send__( "#{var_name}=", var_value )
24
+ end
25
+ obj
26
+ end
27
+
28
+ # Return the next higher numbered version, or nil if this is the last version
29
+ def next
30
+ versionable.versions.next_version( self.number )
31
+ end
32
+
33
+ # Return the next lower numbered version, or nil if this is the first version
34
+ def previous
35
+ versionable.versions.previous_version( self.number )
36
+ end
37
+
38
+ protected
39
+ def before_create
40
+ if versionable.unversioned?
41
+ self.number = 1
42
+ else
43
+ self.number = versionable.versions.maximum( :number ) + 1
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,122 @@
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: SoftwareHeretics</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">SoftwareHeretics</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/simply_versioned_rb.html">
59
+ lib/simply_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
+ SimplyVersioned 0.1
78
+ </p>
79
+ <p>
80
+ Simple <a href="SoftwareHeretics/ActiveRecord.html">ActiveRecord</a>
81
+ versioning Copyright (c) 2007 Matt Mower &lt;self@mattmower.com&gt;
82
+ Released under the MIT license (see accompany MIT-LICENSE file)
83
+ </p>
84
+
85
+ </div>
86
+
87
+
88
+ </div>
89
+
90
+
91
+ </div>
92
+
93
+
94
+ <!-- if includes -->
95
+
96
+ <div id="section">
97
+
98
+ <div id="class-list">
99
+ <h3 class="section-bar">Classes and Modules</h3>
100
+
101
+ Module <a href="SoftwareHeretics/ActiveRecord.html" class="link">SoftwareHeretics::ActiveRecord</a><br />
102
+
103
+ </div>
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+ <!-- if method_list -->
112
+
113
+
114
+ </div>
115
+
116
+
117
+ <div id="validator-badges">
118
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
119
+ </div>
120
+
121
+ </body>
122
+ </html>
@@ -0,0 +1,111 @@
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: SoftwareHeretics::ActiveRecord</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">SoftwareHeretics::ActiveRecord</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/simply_versioned_rb.html">
59
+ lib/simply_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
+
76
+
77
+ </div>
78
+
79
+
80
+ </div>
81
+
82
+
83
+ <!-- if includes -->
84
+
85
+ <div id="section">
86
+
87
+ <div id="class-list">
88
+ <h3 class="section-bar">Classes and Modules</h3>
89
+
90
+ Module <a href="ActiveRecord/SimplyVersioned.html" class="link">SoftwareHeretics::ActiveRecord::SimplyVersioned</a><br />
91
+
92
+ </div>
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+ <!-- if method_list -->
101
+
102
+
103
+ </div>
104
+
105
+
106
+ <div id="validator-badges">
107
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
108
+ </div>
109
+
110
+ </body>
111
+ </html>
@@ -0,0 +1,149 @@
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: SoftwareHeretics::ActiveRecord::SimplyVersioned</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">SoftwareHeretics::ActiveRecord::SimplyVersioned</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../../files/lib/simply_versioned_rb.html">
59
+ lib/simply_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
+
76
+
77
+ </div>
78
+
79
+ <div id="method-list">
80
+ <h3 class="section-bar">Methods</h3>
81
+
82
+ <div class="name-list">
83
+ <a href="#M000001">included</a>&nbsp;&nbsp;
84
+ </div>
85
+ </div>
86
+
87
+ </div>
88
+
89
+
90
+ <!-- if includes -->
91
+
92
+ <div id="section">
93
+
94
+ <div id="class-list">
95
+ <h3 class="section-bar">Classes and Modules</h3>
96
+
97
+ Module <a href="SimplyVersioned/ClassMethods.html" class="link">SoftwareHeretics::ActiveRecord::SimplyVersioned::ClassMethods</a><br />
98
+ Module <a href="SimplyVersioned/InstanceMethods.html" class="link">SoftwareHeretics::ActiveRecord::SimplyVersioned::InstanceMethods</a><br />
99
+ Module <a href="SimplyVersioned/VersionsProxyMethods.html" class="link">SoftwareHeretics::ActiveRecord::SimplyVersioned::VersionsProxyMethods</a><br />
100
+
101
+ </div>
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+ <!-- if method_list -->
110
+ <div id="methods">
111
+ <h3 class="section-bar">Public Class methods</h3>
112
+
113
+ <div id="method-M000001" class="method-detail">
114
+ <a name="M000001"></a>
115
+
116
+ <div class="method-heading">
117
+ <a href="#M000001" class="method-signature">
118
+ <span class="method-name">included</span><span class="method-args">( receiver )</span>
119
+ </a>
120
+ </div>
121
+
122
+ <div class="method-description">
123
+ <p><a class="source-toggle" href="#"
124
+ onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
125
+ <div class="method-source-code" id="M000001-source">
126
+ <pre>
127
+ <span class="ruby-comment cmt"># File lib/simply_versioned.rb, line 96</span>
128
+ 96: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">included</span>( <span class="ruby-identifier">receiver</span> )
129
+ 97: <span class="ruby-identifier">receiver</span>.<span class="ruby-identifier">extend</span> <span class="ruby-constant">ClassMethods</span>
130
+ 98: <span class="ruby-identifier">receiver</span>.<span class="ruby-identifier">send</span> <span class="ruby-identifier">:include</span>, <span class="ruby-constant">InstanceMethods</span>
131
+ 99: <span class="ruby-keyword kw">end</span>
132
+ </pre>
133
+ </div>
134
+ </div>
135
+ </div>
136
+
137
+
138
+ </div>
139
+
140
+
141
+ </div>
142
+
143
+
144
+ <div id="validator-badges">
145
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
146
+ </div>
147
+
148
+ </body>
149
+ </html>
@@ -0,0 +1,159 @@
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: SoftwareHeretics::ActiveRecord::SimplyVersioned::ClassMethods</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">SoftwareHeretics::ActiveRecord::SimplyVersioned::ClassMethods</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../../../files/lib/simply_versioned_rb.html">
59
+ lib/simply_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
+
76
+
77
+ </div>
78
+
79
+ <div id="method-list">
80
+ <h3 class="section-bar">Methods</h3>
81
+
82
+ <div class="name-list">
83
+ <a href="#M000008">simply_versioned</a>&nbsp;&nbsp;
84
+ </div>
85
+ </div>
86
+
87
+ </div>
88
+
89
+
90
+ <!-- if includes -->
91
+
92
+ <div id="section">
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+ <!-- if method_list -->
102
+ <div id="methods">
103
+ <h3 class="section-bar">Public Instance methods</h3>
104
+
105
+ <div id="method-M000008" class="method-detail">
106
+ <a name="M000008"></a>
107
+
108
+ <div class="method-heading">
109
+ <a href="#M000008" class="method-signature">
110
+ <span class="method-name">simply_versioned</span><span class="method-args">( options = {} )</span>
111
+ </a>
112
+ </div>
113
+
114
+ <div class="method-description">
115
+ <p>
116
+ Marks this <a href="../../ActiveRecord.html">ActiveRecord</a> model as
117
+ being versioned. Calls to <tt>create</tt> or <tt>save</tt> will, in future,
118
+ create a series of associated Version instances that can be accessed via
119
+ the <tt>versions</tt> association.
120
+ </p>
121
+ <p>
122
+ Options: <tt>limit</tt> - specifies the number of old versions to keep
123
+ (default = 99)
124
+ </p>
125
+ <p><a class="source-toggle" href="#"
126
+ onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
127
+ <div class="method-source-code" id="M000008-source">
128
+ <pre>
129
+ <span class="ruby-comment cmt"># File lib/simply_versioned.rb, line 23</span>
130
+ 23: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">simply_versioned</span>( <span class="ruby-identifier">options</span> = {} )
131
+ 24: <span class="ruby-identifier">options</span>.<span class="ruby-identifier">reverse_merge!</span>( {
132
+ 25: <span class="ruby-identifier">:keep</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">99</span>
133
+ 26: })
134
+ 27:
135
+ 28: <span class="ruby-identifier">has_many</span> <span class="ruby-identifier">:versions</span>, <span class="ruby-identifier">:order</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'number DESC'</span>, <span class="ruby-identifier">:as</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:versionable</span>, <span class="ruby-identifier">:dependent</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:destroy</span>, <span class="ruby-identifier">:extend</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">VersionsProxyMethods</span>
136
+ 29:
137
+ 30: <span class="ruby-identifier">after_save</span> <span class="ruby-identifier">:simply_versioned_create_version</span>
138
+ 31:
139
+ 32: <span class="ruby-identifier">cattr_accessor</span> <span class="ruby-identifier">:simply_versioned_keep_limit</span>
140
+ 33: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">simply_versioned_keep_limit</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:keep</span>]
141
+ 34: <span class="ruby-keyword kw">end</span>
142
+ </pre>
143
+ </div>
144
+ </div>
145
+ </div>
146
+
147
+
148
+ </div>
149
+
150
+
151
+ </div>
152
+
153
+
154
+ <div id="validator-badges">
155
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
156
+ </div>
157
+
158
+ </body>
159
+ </html>