originator 3.0
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.
- checksums.yaml +7 -0
- data/CHANGELOG +31 -0
- data/Gemfile +8 -0
- data/LICENSE +20 -0
- data/Rakefile +30 -0
- data/Readme.rdoc +162 -0
- data/VERSION +1 -0
- data/lib/migration_helper.rb +19 -0
- data/lib/stampable.rb +152 -0
- data/lib/stamper.rb +43 -0
- data/lib/userstamp.rb +52 -0
- data/originator.gemspec +84 -0
- data/rdoc/classes/Ddb/Controller.html +111 -0
- data/rdoc/classes/Ddb/Controller/Userstamp.html +125 -0
- data/rdoc/classes/Ddb/Controller/Userstamp/InstanceMethods.html +105 -0
- data/rdoc/classes/Ddb/Userstamp.html +121 -0
- data/rdoc/classes/Ddb/Userstamp/MigrationHelper.html +111 -0
- data/rdoc/classes/Ddb/Userstamp/MigrationHelper/InstanceMethods.html +142 -0
- data/rdoc/classes/Ddb/Userstamp/Stampable.html +128 -0
- data/rdoc/classes/Ddb/Userstamp/Stampable/ClassMethods.html +225 -0
- data/rdoc/classes/Ddb/Userstamp/Stamper.html +112 -0
- data/rdoc/classes/Ddb/Userstamp/Stamper/ClassMethods.html +142 -0
- data/rdoc/classes/Ddb/Userstamp/Stamper/InstanceMethods.html +207 -0
- data/rdoc/classes/Userstamp.html +118 -0
- data/rdoc/created.rid +1 -0
- data/rdoc/files/CHANGELOG.html +137 -0
- data/rdoc/files/LICENSE.html +129 -0
- data/rdoc/files/Readme_rdoc.html +301 -0
- data/rdoc/files/lib/migration_helper_rb.html +101 -0
- data/rdoc/files/lib/stampable_rb.html +101 -0
- data/rdoc/files/lib/stamper_rb.html +101 -0
- data/rdoc/files/lib/userstamp_rb.html +110 -0
- data/rdoc/fr_class_index.html +38 -0
- data/rdoc/fr_file_index.html +33 -0
- data/rdoc/fr_method_index.html +33 -0
- data/rdoc/index.html +24 -0
- data/rdoc/rdoc-style.css +208 -0
- data/test/compatibility_stamping_test.rb +69 -0
- data/test/controllers/posts_controller.rb +26 -0
- data/test/controllers/users_controller.rb +12 -0
- data/test/controllers/userstamp_controller.rb +9 -0
- data/test/helper.rb +61 -0
- data/test/models/comment.rb +5 -0
- data/test/models/foo.rb +3 -0
- data/test/models/person.rb +3 -0
- data/test/models/post.rb +13 -0
- data/test/models/user.rb +3 -0
- data/test/schema.rb +54 -0
- data/test/stamping_test.rb +138 -0
- data/test/userstamp_controller_test.rb +103 -0
- data/test/userstamp_test.rb +7 -0
- metadata +138 -0
data/rdoc/rdoc-style.css
ADDED
@@ -0,0 +1,208 @@
|
|
1
|
+
|
2
|
+
body {
|
3
|
+
font-family: Verdana,Arial,Helvetica,sans-serif;
|
4
|
+
font-size: 90%;
|
5
|
+
margin: 0;
|
6
|
+
margin-left: 40px;
|
7
|
+
padding: 0;
|
8
|
+
background: white;
|
9
|
+
}
|
10
|
+
|
11
|
+
h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
|
12
|
+
h1 { font-size: 150%; }
|
13
|
+
h2,h3,h4 { margin-top: 1em; }
|
14
|
+
|
15
|
+
a { background: #eef; color: #039; text-decoration: none; }
|
16
|
+
a:hover { background: #039; color: #eef; }
|
17
|
+
|
18
|
+
/* Override the base stylesheet's Anchor inside a table cell */
|
19
|
+
td > a {
|
20
|
+
background: transparent;
|
21
|
+
color: #039;
|
22
|
+
text-decoration: none;
|
23
|
+
}
|
24
|
+
|
25
|
+
/* and inside a section title */
|
26
|
+
.section-title > a {
|
27
|
+
background: transparent;
|
28
|
+
color: #eee;
|
29
|
+
text-decoration: none;
|
30
|
+
}
|
31
|
+
|
32
|
+
/* === Structural elements =================================== */
|
33
|
+
|
34
|
+
div#index {
|
35
|
+
margin: 0;
|
36
|
+
margin-left: -40px;
|
37
|
+
padding: 0;
|
38
|
+
font-size: 90%;
|
39
|
+
}
|
40
|
+
|
41
|
+
|
42
|
+
div#index a {
|
43
|
+
margin-left: 0.7em;
|
44
|
+
}
|
45
|
+
|
46
|
+
div#index .section-bar {
|
47
|
+
margin-left: 0px;
|
48
|
+
padding-left: 0.7em;
|
49
|
+
background: #ccc;
|
50
|
+
font-size: small;
|
51
|
+
}
|
52
|
+
|
53
|
+
|
54
|
+
div#classHeader, div#fileHeader {
|
55
|
+
width: auto;
|
56
|
+
color: white;
|
57
|
+
padding: 0.5em 1.5em 0.5em 1.5em;
|
58
|
+
margin: 0;
|
59
|
+
margin-left: -40px;
|
60
|
+
border-bottom: 3px solid #006;
|
61
|
+
}
|
62
|
+
|
63
|
+
div#classHeader a, div#fileHeader a {
|
64
|
+
background: inherit;
|
65
|
+
color: white;
|
66
|
+
}
|
67
|
+
|
68
|
+
div#classHeader td, div#fileHeader td {
|
69
|
+
background: inherit;
|
70
|
+
color: white;
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
div#fileHeader {
|
75
|
+
background: #057;
|
76
|
+
}
|
77
|
+
|
78
|
+
div#classHeader {
|
79
|
+
background: #048;
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
.class-name-in-header {
|
84
|
+
font-size: 180%;
|
85
|
+
font-weight: bold;
|
86
|
+
}
|
87
|
+
|
88
|
+
|
89
|
+
div#bodyContent {
|
90
|
+
padding: 0 1.5em 0 1.5em;
|
91
|
+
}
|
92
|
+
|
93
|
+
div#description {
|
94
|
+
padding: 0.5em 1.5em;
|
95
|
+
background: #efefef;
|
96
|
+
border: 1px dotted #999;
|
97
|
+
}
|
98
|
+
|
99
|
+
div#description h1,h2,h3,h4,h5,h6 {
|
100
|
+
color: #125;;
|
101
|
+
background: transparent;
|
102
|
+
}
|
103
|
+
|
104
|
+
div#validator-badges {
|
105
|
+
text-align: center;
|
106
|
+
}
|
107
|
+
div#validator-badges img { border: 0; }
|
108
|
+
|
109
|
+
div#copyright {
|
110
|
+
color: #333;
|
111
|
+
background: #efefef;
|
112
|
+
font: 0.75em sans-serif;
|
113
|
+
margin-top: 5em;
|
114
|
+
margin-bottom: 0;
|
115
|
+
padding: 0.5em 2em;
|
116
|
+
}
|
117
|
+
|
118
|
+
|
119
|
+
/* === Classes =================================== */
|
120
|
+
|
121
|
+
table.header-table {
|
122
|
+
color: white;
|
123
|
+
font-size: small;
|
124
|
+
}
|
125
|
+
|
126
|
+
.type-note {
|
127
|
+
font-size: small;
|
128
|
+
color: #DEDEDE;
|
129
|
+
}
|
130
|
+
|
131
|
+
.xxsection-bar {
|
132
|
+
background: #eee;
|
133
|
+
color: #333;
|
134
|
+
padding: 3px;
|
135
|
+
}
|
136
|
+
|
137
|
+
.section-bar {
|
138
|
+
color: #333;
|
139
|
+
border-bottom: 1px solid #999;
|
140
|
+
margin-left: -20px;
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
.section-title {
|
145
|
+
background: #79a;
|
146
|
+
color: #eee;
|
147
|
+
padding: 3px;
|
148
|
+
margin-top: 2em;
|
149
|
+
margin-left: -30px;
|
150
|
+
border: 1px solid #999;
|
151
|
+
}
|
152
|
+
|
153
|
+
.top-aligned-row { vertical-align: top }
|
154
|
+
.bottom-aligned-row { vertical-align: bottom }
|
155
|
+
|
156
|
+
/* --- Context section classes ----------------------- */
|
157
|
+
|
158
|
+
.context-row { }
|
159
|
+
.context-item-name { font-family: monospace; font-weight: bold; color: black; }
|
160
|
+
.context-item-value { font-size: small; color: #448; }
|
161
|
+
.context-item-desc { color: #333; padding-left: 2em; }
|
162
|
+
|
163
|
+
/* --- Method classes -------------------------- */
|
164
|
+
.method-detail {
|
165
|
+
background: #efefef;
|
166
|
+
padding: 0;
|
167
|
+
margin-top: 0.5em;
|
168
|
+
margin-bottom: 1em;
|
169
|
+
border: 1px dotted #ccc;
|
170
|
+
}
|
171
|
+
.method-heading {
|
172
|
+
color: black;
|
173
|
+
background: #ccc;
|
174
|
+
border-bottom: 1px solid #666;
|
175
|
+
padding: 0.2em 0.5em 0 0.5em;
|
176
|
+
}
|
177
|
+
.method-signature { color: black; background: inherit; }
|
178
|
+
.method-name { font-weight: bold; }
|
179
|
+
.method-args { font-style: italic; }
|
180
|
+
.method-description { padding: 0 0.5em 0 0.5em; }
|
181
|
+
|
182
|
+
/* --- Source code sections -------------------- */
|
183
|
+
|
184
|
+
a.source-toggle { font-size: 90%; }
|
185
|
+
div.method-source-code {
|
186
|
+
background: #262626;
|
187
|
+
color: #ffdead;
|
188
|
+
margin: 1em;
|
189
|
+
padding: 0.5em;
|
190
|
+
border: 1px dashed #999;
|
191
|
+
overflow: hidden;
|
192
|
+
}
|
193
|
+
|
194
|
+
div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
195
|
+
|
196
|
+
/* --- Ruby keyword styles --------------------- */
|
197
|
+
|
198
|
+
.standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
|
199
|
+
|
200
|
+
.ruby-constant { color: #7fffd4; background: transparent; }
|
201
|
+
.ruby-keyword { color: #00ffff; background: transparent; }
|
202
|
+
.ruby-ivar { color: #eedd82; background: transparent; }
|
203
|
+
.ruby-operator { color: #00ffee; background: transparent; }
|
204
|
+
.ruby-identifier { color: #ffdead; background: transparent; }
|
205
|
+
.ruby-node { color: #ffa07a; background: transparent; }
|
206
|
+
.ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
|
207
|
+
.ruby-regexp { color: #ffa07a; background: transparent; }
|
208
|
+
.ruby-value { color: #7fffd4; background: transparent; }
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'test/helper'
|
2
|
+
|
3
|
+
class CompatibilityStampingTests < Test::Unit::TestCase # :nodoc:
|
4
|
+
def setup
|
5
|
+
create_test_models
|
6
|
+
Ddb::Userstamp.compatibility_mode = true
|
7
|
+
require 'test/models/comment'
|
8
|
+
Comment.delete_all
|
9
|
+
@first_comment = Comment.create!(:comment => 'a comment', :post => @first_post)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_comment_creation_with_stamped_integer
|
13
|
+
Person.stamper = @nicole.id
|
14
|
+
assert_equal @nicole.id, Person.stamper
|
15
|
+
|
16
|
+
comment = Comment.create(:comment => "Test Comment - 2")
|
17
|
+
assert_equal @nicole.id, comment.created_by
|
18
|
+
assert_equal @nicole.id, comment.updated_by
|
19
|
+
assert_equal @nicole, comment.creator
|
20
|
+
assert_equal @nicole, comment.updater
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_comment_creation_with_stamped_integer
|
24
|
+
Person.stamper = @nicole.id
|
25
|
+
assert_equal @nicole.id, Person.stamper
|
26
|
+
|
27
|
+
comment = Comment.create(:comment => "Test Comment - 2")
|
28
|
+
assert_equal @nicole.id, comment.created_by
|
29
|
+
assert_equal @nicole.id, comment.updated_by
|
30
|
+
assert_equal @nicole, comment.creator
|
31
|
+
assert_equal @nicole, comment.updater
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_comment_creation_with_stamped_object
|
35
|
+
assert_equal @delynn.id, Person.stamper
|
36
|
+
|
37
|
+
comment = Comment.create(:comment => "Test Comment")
|
38
|
+
assert_equal @delynn.id, comment.created_by
|
39
|
+
assert_equal @delynn.id, comment.updated_by
|
40
|
+
assert_equal @delynn, comment.creator
|
41
|
+
assert_equal @delynn, comment.updater
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_comment_updating_with_stamped_object
|
45
|
+
Person.stamper = @nicole
|
46
|
+
assert_equal @nicole.id, Person.stamper
|
47
|
+
|
48
|
+
@first_comment.comment << " - Updated"
|
49
|
+
@first_comment.save
|
50
|
+
@first_comment.reload
|
51
|
+
assert_equal @delynn.id, @first_comment.created_by
|
52
|
+
assert_equal @nicole.id, @first_comment.updated_by
|
53
|
+
assert_equal @delynn, @first_comment.creator
|
54
|
+
assert_equal @nicole, @first_comment.updater
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_comment_updating_with_stamped_integer
|
58
|
+
Person.stamper = @nicole.id
|
59
|
+
assert_equal @nicole.id, Person.stamper
|
60
|
+
|
61
|
+
@first_comment.comment << " - Updated"
|
62
|
+
@first_comment.save
|
63
|
+
@first_comment.reload
|
64
|
+
assert_equal @delynn.id, @first_comment.created_by
|
65
|
+
assert_equal @nicole.id, @first_comment.updated_by
|
66
|
+
assert_equal @delynn, @first_comment.creator
|
67
|
+
assert_equal @nicole, @first_comment.updater
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class PostsController < UserstampController
|
2
|
+
def edit
|
3
|
+
@post = Post.find(params[:id])
|
4
|
+
render(:inline => "<%= @post.title %>")
|
5
|
+
end
|
6
|
+
|
7
|
+
def update
|
8
|
+
@post = Post.find(params[:id])
|
9
|
+
@post.update_attributes(params[:post])
|
10
|
+
render(:inline => "<%= @post.title %>")
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
def current_user
|
15
|
+
Person.find(session[:person_id])
|
16
|
+
end
|
17
|
+
|
18
|
+
def set_stamper
|
19
|
+
Person.stamper = self.current_user
|
20
|
+
end
|
21
|
+
|
22
|
+
def reset_stamper
|
23
|
+
Person.reset_stamper
|
24
|
+
end
|
25
|
+
#end
|
26
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class UsersController < UserstampController
|
2
|
+
def edit
|
3
|
+
@user = User.find(params[:id])
|
4
|
+
render(:inline => "<%= @user.name %>")
|
5
|
+
end
|
6
|
+
|
7
|
+
def update
|
8
|
+
@user = User.find(params[:id])
|
9
|
+
@user.update_attributes(params[:user])
|
10
|
+
render(:inline => "<%= @user.name %>")
|
11
|
+
end
|
12
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift('lib')
|
4
|
+
|
5
|
+
# load normal stuff
|
6
|
+
require 'active_support'
|
7
|
+
require 'active_record'
|
8
|
+
require 'action_controller'
|
9
|
+
require 'init'
|
10
|
+
|
11
|
+
# connect to db
|
12
|
+
ActiveRecord::Base.establish_connection({
|
13
|
+
:adapter => "sqlite3",
|
14
|
+
:database => ":memory:",
|
15
|
+
})
|
16
|
+
require 'test/schema'
|
17
|
+
|
18
|
+
# load test framework
|
19
|
+
require 'test/unit'
|
20
|
+
begin
|
21
|
+
require 'redgreen'
|
22
|
+
rescue LoadError
|
23
|
+
end
|
24
|
+
require 'active_support/test_case'
|
25
|
+
require 'action_controller/test_case'
|
26
|
+
require 'action_controller/test_process'
|
27
|
+
require 'action_controller/integration'
|
28
|
+
|
29
|
+
# load test models/controllers
|
30
|
+
require 'test/controllers/userstamp_controller'
|
31
|
+
require 'test/controllers/users_controller'
|
32
|
+
require 'test/controllers/posts_controller'
|
33
|
+
require 'test/models/user'
|
34
|
+
require 'test/models/person'
|
35
|
+
require 'test/models/post'
|
36
|
+
require 'test/models/foo'
|
37
|
+
|
38
|
+
ActionController::Routing::Routes.draw do |map|
|
39
|
+
map.connect ':controller/:action/:id'
|
40
|
+
end
|
41
|
+
|
42
|
+
def reset_to_defaults
|
43
|
+
Ddb::Userstamp.compatibility_mode = false
|
44
|
+
create_test_models
|
45
|
+
end
|
46
|
+
|
47
|
+
def create_test_models
|
48
|
+
User.delete_all
|
49
|
+
Person.delete_all
|
50
|
+
Post.delete_all
|
51
|
+
|
52
|
+
@zeus = User.create!(:name => 'Zeus')
|
53
|
+
@hera = User.create!(:name => 'Hera')
|
54
|
+
User.stamper = @zeus.id
|
55
|
+
|
56
|
+
@delynn = Person.create!(:name => 'Delynn')
|
57
|
+
@nicole = Person.create!(:name => 'Nicole')
|
58
|
+
Person.stamper = @delynn.id
|
59
|
+
|
60
|
+
@first_post = Post.create!(:title => 'a title')
|
61
|
+
end
|
data/test/models/foo.rb
ADDED
data/test/models/post.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
class Post < ActiveRecord::Base
|
2
|
+
stampable :stamper_class_name => :person, :deleter => true
|
3
|
+
has_many :comments
|
4
|
+
|
5
|
+
# override destroy to get soft delete like acts_as_paranoid style delete
|
6
|
+
# Note: delete_all (used in helper) bypasses this and deletes all rows.
|
7
|
+
def destroy
|
8
|
+
return false if callback(:before_destroy) == false
|
9
|
+
self.deleted_at = DateTime.now
|
10
|
+
callback(:after_destroy)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
data/test/models/user.rb
ADDED
data/test/schema.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
ActiveRecord::Schema.define(:version => 0) do
|
2
|
+
# Users are created and updated by other Users
|
3
|
+
create_table :users, :force => true do |t|
|
4
|
+
t.column :name, :string
|
5
|
+
t.column :creator_id, :integer
|
6
|
+
t.column :created_on, :datetime
|
7
|
+
t.column :updater_id, :integer
|
8
|
+
t.column :updated_at, :datetime
|
9
|
+
end
|
10
|
+
|
11
|
+
# People are created and updated by Users
|
12
|
+
create_table :people, :force => true do |t|
|
13
|
+
t.column :name, :string
|
14
|
+
t.column :creator_id, :integer
|
15
|
+
t.column :created_on, :datetime
|
16
|
+
t.column :updater_id, :integer
|
17
|
+
t.column :updated_at, :datetime
|
18
|
+
end
|
19
|
+
|
20
|
+
# Posts are created and updated by People
|
21
|
+
create_table :posts, :force => true do |t|
|
22
|
+
t.column :title, :string
|
23
|
+
t.column :creator_id, :integer
|
24
|
+
t.column :created_on, :datetime
|
25
|
+
t.column :updater_id, :integer
|
26
|
+
t.column :updated_at, :datetime
|
27
|
+
t.column :deleter_id, :integer
|
28
|
+
t.column :deleted_at, :datetime
|
29
|
+
end
|
30
|
+
|
31
|
+
# Comments are created and updated by People
|
32
|
+
# and also use non-standard foreign keys.
|
33
|
+
create_table :comments, :force => true do |t|
|
34
|
+
t.column :post_id, :integer
|
35
|
+
t.column :comment, :string
|
36
|
+
t.column :created_by, :integer
|
37
|
+
t.column :created_at, :datetime
|
38
|
+
t.column :updated_by, :integer
|
39
|
+
t.column :updated_at, :datetime
|
40
|
+
t.column :deleted_by, :integer
|
41
|
+
t.column :deleted_at, :datetime
|
42
|
+
end
|
43
|
+
|
44
|
+
# only used to test :stampable args
|
45
|
+
create_table :foos, :force => true do |t|
|
46
|
+
t.column :created_by, :integer
|
47
|
+
t.column :created_at, :datetime
|
48
|
+
t.column :updated_by, :integer
|
49
|
+
t.column :updated_at, :datetime
|
50
|
+
t.column :deleted_by, :integer
|
51
|
+
t.column :deleted_at, :datetime
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|