primer 0.1.0 → 0.2.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.
- data/History.txt +17 -0
- data/README.rdoc +74 -35
- data/example/README.rdoc +33 -23
- data/example/application.rb +2 -2
- data/example/console.rb +133 -0
- data/example/db/blog.sqlite3 +0 -0
- data/example/{models → db}/connection.rb +0 -0
- data/example/environment.rb +17 -4
- data/example/models/comment.rb +5 -0
- data/example/models/post.rb +5 -0
- data/example/script/setup_database.rb +8 -2
- data/example/views/comments.erb +6 -0
- data/example/views/layout.erb +1 -1
- data/example/views/show.erb +5 -1
- data/lib/primer/bus/amqp.rb +7 -5
- data/lib/primer/bus/amqp.rbc +1045 -0
- data/lib/primer/bus/memory.rbc +344 -0
- data/lib/primer/bus.rb +3 -2
- data/lib/primer/bus.rbc +872 -0
- data/lib/primer/cache/memory.rbc +1443 -0
- data/lib/primer/cache/redis.rb +2 -2
- data/lib/primer/cache/redis.rbc +1643 -0
- data/lib/primer/cache.rb +2 -16
- data/lib/primer/cache.rbc +1502 -0
- data/lib/primer/enabler.rbc +414 -0
- data/lib/primer/helpers.rbc +1438 -0
- data/lib/primer/lazyness.rb +63 -0
- data/lib/primer/lazyness.rbc +1442 -0
- data/lib/primer/real_time.rbc +1999 -0
- data/lib/primer/route_set.rb +1 -0
- data/lib/primer/route_set.rbc +1475 -0
- data/lib/primer/watcher/active_record_macros.rb +13 -3
- data/lib/primer/watcher/active_record_macros.rbc +1796 -0
- data/lib/primer/watcher/macros.rb +11 -14
- data/lib/primer/watcher/macros.rbc +1628 -0
- data/lib/primer/watcher.rb +2 -7
- data/lib/primer/watcher.rbc +1416 -0
- data/lib/primer/worker/active_record_agent.rb +30 -33
- data/lib/primer/worker/active_record_agent.rbc +2840 -0
- data/lib/primer/worker/changes_agent.rb +20 -0
- data/lib/primer/worker/changes_agent.rbc +578 -0
- data/lib/primer/worker.rb +20 -3
- data/lib/primer/worker.rbc +1254 -0
- data/lib/primer.rb +10 -2
- data/lib/primer.rbc +944 -0
- data/spec/db/test.sqlite3 +0 -0
- data/spec/models/artist.rb +3 -2
- data/spec/models/artist.rbc +288 -0
- data/spec/models/blog_post.rb +3 -1
- data/spec/models/blog_post.rbc +181 -0
- data/spec/models/calendar.rbc +209 -0
- data/spec/models/concert.rbc +211 -0
- data/spec/models/performance.rbc +177 -0
- data/spec/models/person.rb +1 -0
- data/spec/models/person.rbc +306 -0
- data/spec/models/watchable.rbc +363 -0
- data/spec/primer/bus_spec.rbc +940 -0
- data/spec/primer/cache_spec.rb +3 -3
- data/spec/primer/cache_spec.rbc +8535 -0
- data/spec/primer/helpers/erb_spec.rb +14 -14
- data/spec/primer/helpers/erb_spec.rbc +2485 -0
- data/spec/primer/lazyness_spec.rb +61 -0
- data/spec/primer/lazyness_spec.rbc +1408 -0
- data/spec/primer/watcher/active_record_spec.rb +15 -15
- data/spec/primer/watcher/active_record_spec.rbc +5202 -0
- data/spec/primer/watcher_spec.rbc +2645 -0
- data/spec/schema.rbc +775 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/spec_helper.rbc +1193 -0
- data/spec/templates/page.erb +0 -1
- metadata +77 -70
- data/example/models/blog_post.rb +0 -4
@@ -14,7 +14,7 @@ describe Primer::Watcher::ActiveRecordMacros do
|
|
14
14
|
|
15
15
|
@artist.concerts << @festival
|
16
16
|
|
17
|
-
Primer::Worker::ActiveRecordAgent.
|
17
|
+
Primer::Worker::ActiveRecordAgent.run!
|
18
18
|
Primer::Watcher.enable!
|
19
19
|
end
|
20
20
|
|
@@ -63,13 +63,13 @@ describe Primer::Watcher::ActiveRecordMacros do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it "publishes a message when an attribute changes" do
|
66
|
-
should_publish(:active_record,
|
66
|
+
should_publish(:active_record, "update", "Person", anything, anything)
|
67
67
|
should_publish(:changes, "ActiveRecord", "Person", @person.id, "name")
|
68
68
|
@person.update_attribute(:name, "Aaron")
|
69
69
|
end
|
70
70
|
|
71
71
|
it "publishes messages when an object is deleted" do
|
72
|
-
should_publish(:active_record,
|
72
|
+
should_publish(:active_record, "destroy", "Person", anything)
|
73
73
|
should_publish(:changes, "ActiveRecord", "Person", @person.id, "id")
|
74
74
|
should_publish(:changes, "ActiveRecord", "Person", @person.id, "name")
|
75
75
|
should_publish(:changes, "ActiveRecord", "Person", @person.id, "age")
|
@@ -78,13 +78,13 @@ describe Primer::Watcher::ActiveRecordMacros do
|
|
78
78
|
end
|
79
79
|
|
80
80
|
it "publishes a message about a belongs_to association when the foreign key changes" do
|
81
|
-
should_publish(:active_record,
|
81
|
+
should_publish(:active_record, "create", "BlogPost", anything)
|
82
82
|
should_publish(:changes, "ActiveRecord", "Person", @person.id, "blog_posts")
|
83
83
|
BlogPost.create(:person => @person, :title => "How to make a time machine")
|
84
84
|
end
|
85
85
|
|
86
86
|
it "publishes a message about a belongs_to association when the object changes" do
|
87
|
-
should_publish(:active_record,
|
87
|
+
should_publish(:active_record, "update", "BlogPost", anything, anything)
|
88
88
|
should_publish(:changes, "ActiveRecord", "BlogPost", @post.id, "person_id")
|
89
89
|
should_publish(:changes, "ActiveRecord", "BlogPost", @post.id, "person")
|
90
90
|
should_publish(:changes, "ActiveRecord", "Person", @impostor.id, "blog_posts")
|
@@ -93,13 +93,13 @@ describe Primer::Watcher::ActiveRecordMacros do
|
|
93
93
|
end
|
94
94
|
|
95
95
|
it "publishes a message when a has_many collection gains a member" do
|
96
|
-
should_publish(:active_record,
|
96
|
+
should_publish(:active_record, "create", "BlogPost", anything)
|
97
97
|
should_publish(:changes, "ActiveRecord", "Person", @person.id, "blog_posts")
|
98
98
|
BlogPost.create(:person => @person, :title => "How to make a time machine")
|
99
99
|
end
|
100
100
|
|
101
101
|
it "publishes a message when a has_many collection loses a member" do
|
102
|
-
should_publish(:active_record,
|
102
|
+
should_publish(:active_record, "destroy", "BlogPost", anything)
|
103
103
|
should_publish(:changes, "ActiveRecord", "BlogPost", @post.id, "id")
|
104
104
|
should_publish(:changes, "ActiveRecord", "BlogPost", @post.id, "person_id")
|
105
105
|
should_publish(:changes, "ActiveRecord", "BlogPost", @post.id, "title")
|
@@ -109,7 +109,7 @@ describe Primer::Watcher::ActiveRecordMacros do
|
|
109
109
|
end
|
110
110
|
|
111
111
|
it "publishes a message when an object is pushed to a has_many :through has_many" do
|
112
|
-
should_publish(:active_record,
|
112
|
+
should_publish(:active_record, "create", "Performance", anything)
|
113
113
|
should_publish(:changes, "ActiveRecord", "Concert", @concert.id, "performances")
|
114
114
|
should_publish(:changes, "ActiveRecord", "Artist", @artist.id, "performances")
|
115
115
|
should_publish(:changes, "ActiveRecord", "Artist", @artist.id, "concerts")
|
@@ -117,7 +117,7 @@ describe Primer::Watcher::ActiveRecordMacros do
|
|
117
117
|
end
|
118
118
|
|
119
119
|
it "publishes a message when a join object is pushed to a has_many :through has_many" do
|
120
|
-
should_publish(:active_record,
|
120
|
+
should_publish(:active_record, "create", "Performance", anything)
|
121
121
|
should_publish(:changes, "ActiveRecord", "Concert", @concert.id, "performances")
|
122
122
|
should_publish(:changes, "ActiveRecord", "Artist", @artist.id, "performances")
|
123
123
|
should_publish(:changes, "ActiveRecord", "Artist", @artist.id, "concerts")
|
@@ -125,7 +125,7 @@ describe Primer::Watcher::ActiveRecordMacros do
|
|
125
125
|
end
|
126
126
|
|
127
127
|
it "publishes a message when a join object is created for has_many :through has_many" do
|
128
|
-
should_publish(:active_record,
|
128
|
+
should_publish(:active_record, "create", "Performance", anything)
|
129
129
|
should_publish(:changes, "ActiveRecord", "Concert", @concert.id, "performances")
|
130
130
|
should_publish(:changes, "ActiveRecord", "Artist", @artist.id, "performances")
|
131
131
|
should_publish(:changes, "ActiveRecord", "Artist", @artist.id, "concerts")
|
@@ -134,7 +134,7 @@ describe Primer::Watcher::ActiveRecordMacros do
|
|
134
134
|
|
135
135
|
it "publishes messages when a join object is deleted from a has_many :through has_many collection" do
|
136
136
|
@performance = @festival.performances.first
|
137
|
-
should_publish(:active_record,
|
137
|
+
should_publish(:active_record, "destroy", "Performance", anything)
|
138
138
|
should_publish(:changes, "ActiveRecord", "Performance", @performance.id, "artist_id")
|
139
139
|
should_publish(:changes, "ActiveRecord", "Performance", @performance.id, "artist")
|
140
140
|
should_publish(:changes, "ActiveRecord", "Performance", @performance.id, "concert_id")
|
@@ -148,7 +148,7 @@ describe Primer::Watcher::ActiveRecordMacros do
|
|
148
148
|
|
149
149
|
it "publishes messages when a member is deleted from a has_many :through has_many collection" do
|
150
150
|
@performance = @festival.performances.first
|
151
|
-
should_publish(:active_record,
|
151
|
+
should_publish(:active_record, "destroy", "Performance", anything)
|
152
152
|
should_publish(:changes, "ActiveRecord", "Performance", @performance.id, "artist_id")
|
153
153
|
should_publish(:changes, "ActiveRecord", "Performance", @performance.id, "artist")
|
154
154
|
should_publish(:changes, "ActiveRecord", "Artist", @artist.id, "performances")
|
@@ -157,7 +157,7 @@ describe Primer::Watcher::ActiveRecordMacros do
|
|
157
157
|
should_publish(:changes, "ActiveRecord", "Performance", @performance.id, "concert")
|
158
158
|
should_publish(:changes, "ActiveRecord", "Concert", @festival.id, "performances")
|
159
159
|
should_publish(:changes, "ActiveRecord", "Performance", @performance.id, "id")
|
160
|
-
should_publish(:active_record,
|
160
|
+
should_publish(:active_record, "destroy", "Concert", anything)
|
161
161
|
should_publish(:changes, "ActiveRecord", "Concert", @festival.id, "id")
|
162
162
|
should_publish(:changes, "ActiveRecord", "Concert", @festival.id, "calendar_id")
|
163
163
|
should_publish(:changes, "ActiveRecord", "Concert", @festival.id, "calendar")
|
@@ -167,7 +167,7 @@ describe Primer::Watcher::ActiveRecordMacros do
|
|
167
167
|
end
|
168
168
|
|
169
169
|
it "publishes messages when a join object is pushed to a has_many :through belongs_to" do
|
170
|
-
should_publish(:active_record,
|
170
|
+
should_publish(:active_record, "update", "Concert", anything, anything)
|
171
171
|
should_publish(:changes, "ActiveRecord", "Concert", @concert.id, "calendar_id")
|
172
172
|
should_publish(:changes, "ActiveRecord", "Concert", @concert.id, "calendar")
|
173
173
|
should_publish(:changes, "ActiveRecord", "Calendar", @calendar.id, "gigs")
|
@@ -177,7 +177,7 @@ describe Primer::Watcher::ActiveRecordMacros do
|
|
177
177
|
|
178
178
|
it "publishes messages when a join object is removed from a has_many :through belongs_to" do
|
179
179
|
@calendar.gigs << @festival
|
180
|
-
should_publish(:active_record,
|
180
|
+
should_publish(:active_record, "update", "Concert", anything, anything)
|
181
181
|
should_publish(:changes, "ActiveRecord", "Concert", @festival.id, "calendar_id")
|
182
182
|
should_publish(:changes, "ActiveRecord", "Concert", @festival.id, "calendar")
|
183
183
|
should_publish(:changes, "ActiveRecord", "Calendar", @calendar.id, "gigs")
|