grosser-userstamp 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/CHANGELOG +26 -0
  2. data/LICENSE +20 -0
  3. data/README +179 -0
  4. data/Rakefile +36 -0
  5. data/init.rb +1 -0
  6. data/lib/ddb/userstamp.rb +44 -0
  7. data/lib/ddb/userstamp/migration_helper.rb +19 -0
  8. data/lib/ddb/userstamp/stampable.rb +151 -0
  9. data/lib/ddb/userstamp/stamper.rb +43 -0
  10. data/lib/userstamp.rb +8 -0
  11. data/rdoc/classes/Ddb/Controller.html +111 -0
  12. data/rdoc/classes/Ddb/Controller/Userstamp.html +125 -0
  13. data/rdoc/classes/Ddb/Controller/Userstamp/InstanceMethods.html +105 -0
  14. data/rdoc/classes/Ddb/Userstamp.html +121 -0
  15. data/rdoc/classes/Ddb/Userstamp/MigrationHelper.html +111 -0
  16. data/rdoc/classes/Ddb/Userstamp/MigrationHelper/InstanceMethods.html +142 -0
  17. data/rdoc/classes/Ddb/Userstamp/Stampable.html +128 -0
  18. data/rdoc/classes/Ddb/Userstamp/Stampable/ClassMethods.html +222 -0
  19. data/rdoc/classes/Ddb/Userstamp/Stamper.html +112 -0
  20. data/rdoc/classes/Ddb/Userstamp/Stamper/ClassMethods.html +142 -0
  21. data/rdoc/classes/Ddb/Userstamp/Stamper/InstanceMethods.html +207 -0
  22. data/rdoc/files/CHANGELOG.html +137 -0
  23. data/rdoc/files/LICENSE.html +129 -0
  24. data/rdoc/files/README.html +341 -0
  25. data/rdoc/files/lib/ddb/userstamp/migration_helper_rb.html +101 -0
  26. data/rdoc/files/lib/ddb/userstamp/stampable_rb.html +101 -0
  27. data/rdoc/files/lib/ddb/userstamp/stamper_rb.html +101 -0
  28. data/rdoc/files/lib/ddb/userstamp_rb.html +101 -0
  29. data/rdoc/files/lib/userstamp_rb.html +114 -0
  30. data/test/compatibility_stamping_test.rb +63 -0
  31. data/test/controllers/posts_controller.rb +26 -0
  32. data/test/controllers/users_controller.rb +12 -0
  33. data/test/controllers/userstamp_controller.rb +9 -0
  34. data/test/database.yml +4 -0
  35. data/test/fixtures/comments.yml +16 -0
  36. data/test/fixtures/people.yml +11 -0
  37. data/test/fixtures/posts.yml +9 -0
  38. data/test/fixtures/users.yml +7 -0
  39. data/test/helpers/functional_test_helper.rb +37 -0
  40. data/test/helpers/unit_test_helper.rb +29 -0
  41. data/test/models/comment.rb +4 -0
  42. data/test/models/person.rb +3 -0
  43. data/test/models/ping.rb +7 -0
  44. data/test/models/post.rb +4 -0
  45. data/test/models/user.rb +3 -0
  46. data/test/schema.rb +56 -0
  47. data/test/stamping_test.rb +110 -0
  48. data/test/userstamp_controller_test.rb +118 -0
  49. data/userstamp.gemspec +53 -0
  50. metadata +180 -0
@@ -0,0 +1,112 @@
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: Ddb::Userstamp::Stamper</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">Ddb::Userstamp::Stamper</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../../files/lib/ddb/userstamp/stamper_rb.html">
59
+ lib/ddb/userstamp/stamper.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="Stamper/ClassMethods.html" class="link">Ddb::Userstamp::Stamper::ClassMethods</a><br />
91
+ Module <a href="Stamper/InstanceMethods.html" class="link">Ddb::Userstamp::Stamper::InstanceMethods</a><br />
92
+
93
+ </div>
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+ <!-- if method_list -->
102
+
103
+
104
+ </div>
105
+
106
+
107
+ <div id="validator-badges">
108
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
109
+ </div>
110
+
111
+ </body>
112
+ </html>
@@ -0,0 +1,142 @@
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: Ddb::Userstamp::Stamper::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">Ddb::Userstamp::Stamper::ClassMethods</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../../../files/lib/ddb/userstamp/stamper_rb.html">
59
+ lib/ddb/userstamp/stamper.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">model_stamper</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-M000001" class="method-detail">
106
+ <a name="M000001"></a>
107
+
108
+ <div class="method-heading">
109
+ <a href="#M000001" class="method-signature">
110
+ <span class="method-name">model_stamper</span><span class="method-args">()</span>
111
+ </a>
112
+ </div>
113
+
114
+ <div class="method-description">
115
+ <p><a class="source-toggle" href="#"
116
+ onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
117
+ <div class="method-source-code" id="M000001-source">
118
+ <pre>
119
+ <span class="ruby-comment cmt"># File lib/ddb/userstamp/stamper.rb, line 9</span>
120
+ 9: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">model_stamper</span>
121
+ 10: <span class="ruby-comment cmt"># don't allow multiple calls</span>
122
+ 11: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">included_modules</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-constant">Ddb</span><span class="ruby-operator">::</span><span class="ruby-constant">Userstamp</span><span class="ruby-operator">::</span><span class="ruby-constant">Stamper</span><span class="ruby-operator">::</span><span class="ruby-constant">InstanceMethods</span>)
123
+ 12: <span class="ruby-identifier">send</span>(<span class="ruby-identifier">:extend</span>, <span class="ruby-constant">Ddb</span><span class="ruby-operator">::</span><span class="ruby-constant">Userstamp</span><span class="ruby-operator">::</span><span class="ruby-constant">Stamper</span><span class="ruby-operator">::</span><span class="ruby-constant">InstanceMethods</span>)
124
+ 13: <span class="ruby-keyword kw">end</span>
125
+ </pre>
126
+ </div>
127
+ </div>
128
+ </div>
129
+
130
+
131
+ </div>
132
+
133
+
134
+ </div>
135
+
136
+
137
+ <div id="validator-badges">
138
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
139
+ </div>
140
+
141
+ </body>
142
+ </html>
@@ -0,0 +1,207 @@
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: Ddb::Userstamp::Stamper::InstanceMethods</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">Ddb::Userstamp::Stamper::InstanceMethods</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../../../files/lib/ddb/userstamp/stamper_rb.html">
59
+ lib/ddb/userstamp/stamper.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="#M000004">reset_stamper</a>&nbsp;&nbsp;
84
+ <a href="#M000003">stamper</a>&nbsp;&nbsp;
85
+ <a href="#M000002">stamper=</a>&nbsp;&nbsp;
86
+ </div>
87
+ </div>
88
+
89
+ </div>
90
+
91
+
92
+ <!-- if includes -->
93
+
94
+ <div id="section">
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+ <!-- if method_list -->
104
+ <div id="methods">
105
+ <h3 class="section-bar">Public Instance methods</h3>
106
+
107
+ <div id="method-M000004" class="method-detail">
108
+ <a name="M000004"></a>
109
+
110
+ <div class="method-heading">
111
+ <a href="#M000004" class="method-signature">
112
+ <span class="method-name">reset_stamper</span><span class="method-args">()</span>
113
+ </a>
114
+ </div>
115
+
116
+ <div class="method-description">
117
+ <p>
118
+ Sets the <a href="InstanceMethods.html#M000003">stamper</a> back to
119
+ <tt>nil</tt> to prepare for the next request.
120
+ </p>
121
+ <p><a class="source-toggle" href="#"
122
+ onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
123
+ <div class="method-source-code" id="M000004-source">
124
+ <pre>
125
+ <span class="ruby-comment cmt"># File lib/ddb/userstamp/stamper.rb, line 35</span>
126
+ 35: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reset_stamper</span>
127
+ 36: <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>[<span class="ruby-node">&quot;#{self.to_s.downcase}_#{self.object_id}_stamper&quot;</span>] = <span class="ruby-keyword kw">nil</span>
128
+ 37: <span class="ruby-keyword kw">end</span>
129
+ </pre>
130
+ </div>
131
+ </div>
132
+ </div>
133
+
134
+ <div id="method-M000003" class="method-detail">
135
+ <a name="M000003"></a>
136
+
137
+ <div class="method-heading">
138
+ <a href="#M000003" class="method-signature">
139
+ <span class="method-name">stamper</span><span class="method-args">()</span>
140
+ </a>
141
+ </div>
142
+
143
+ <div class="method-description">
144
+ <p>
145
+ Retrieves the existing <a href="InstanceMethods.html#M000003">stamper</a>
146
+ for the current request.
147
+ </p>
148
+ <p><a class="source-toggle" href="#"
149
+ onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
150
+ <div class="method-source-code" id="M000003-source">
151
+ <pre>
152
+ <span class="ruby-comment cmt"># File lib/ddb/userstamp/stamper.rb, line 30</span>
153
+ 30: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stamper</span>
154
+ 31: <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>[<span class="ruby-node">&quot;#{self.to_s.downcase}_#{self.object_id}_stamper&quot;</span>]
155
+ 32: <span class="ruby-keyword kw">end</span>
156
+ </pre>
157
+ </div>
158
+ </div>
159
+ </div>
160
+
161
+ <div id="method-M000002" class="method-detail">
162
+ <a name="M000002"></a>
163
+
164
+ <div class="method-heading">
165
+ <a href="#M000002" class="method-signature">
166
+ <span class="method-name">stamper=</span><span class="method-args">(object)</span>
167
+ </a>
168
+ </div>
169
+
170
+ <div class="method-description">
171
+ <p>
172
+ Used to set the <a href="InstanceMethods.html#M000003">stamper</a> for a
173
+ particular request. See the <a href="../../Userstamp.html">Userstamp</a>
174
+ module for more details on how to use this method.
175
+ </p>
176
+ <p><a class="source-toggle" href="#"
177
+ onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
178
+ <div class="method-source-code" id="M000002-source">
179
+ <pre>
180
+ <span class="ruby-comment cmt"># File lib/ddb/userstamp/stamper.rb, line 19</span>
181
+ 19: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stamper=</span>(<span class="ruby-identifier">object</span>)
182
+ 20: <span class="ruby-identifier">object_stamper</span> = <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">object</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>)
183
+ 21: <span class="ruby-identifier">object</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;#{object.class.primary_key}&quot;</span>.<span class="ruby-identifier">to_sym</span>)
184
+ 22: <span class="ruby-keyword kw">else</span>
185
+ 23: <span class="ruby-identifier">object</span>
186
+ 24: <span class="ruby-keyword kw">end</span>
187
+ 25:
188
+ 26: <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>[<span class="ruby-node">&quot;#{self.to_s.downcase}_#{self.object_id}_stamper&quot;</span>] = <span class="ruby-identifier">object_stamper</span>
189
+ 27: <span class="ruby-keyword kw">end</span>
190
+ </pre>
191
+ </div>
192
+ </div>
193
+ </div>
194
+
195
+
196
+ </div>
197
+
198
+
199
+ </div>
200
+
201
+
202
+ <div id="validator-badges">
203
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
204
+ </div>
205
+
206
+ </body>
207
+ </html>