bustle 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +13 -0
- data/lib/bustle/concerns/publisher_resource.rb +10 -0
- data/lib/bustle/concerns/subscriber_resource.rb +10 -0
- data/lib/bustle/concerns/target_resource.rb +9 -0
- data/lib/bustle/models/activity.rb +2 -0
- data/lib/bustle/models/publisher.rb +2 -0
- data/lib/bustle/models/subscriber.rb +2 -0
- data/lib/bustle/models/subscription.rb +2 -0
- data/lib/bustle/version.rb +1 -1
- data/lib/bustle.rb +3 -0
- data/spec/bustle/models/activity_spec.rb +2 -0
- data/spec/bustle/models/publisher_spec.rb +1 -0
- data/spec/bustle/models/subscriber_spec.rb +1 -0
- data/spec/bustle/models/subscription_spec.rb +2 -0
- data/spec/support/shared_examples/_pubsub_resource.rb +17 -0
- data/spec/support/shared_examples/publisher_resource.rb +6 -0
- data/spec/support/shared_examples/subscriber_resource.rb +6 -0
- data/spec/support/shared_examples/target_resource.rb +17 -0
- metadata +15 -4
data/README.md
CHANGED
@@ -163,6 +163,19 @@ Bustle::Publishers.get(publisher).destroy
|
|
163
163
|
Bustle::Subscriptions.get(bustle_publisher, bustle_subscriber).destroy
|
164
164
|
```
|
165
165
|
|
166
|
+
#### Find Referenced Resources
|
167
|
+
|
168
|
+
These are helpful for finding referenced resources.
|
169
|
+
|
170
|
+
```ruby
|
171
|
+
Bustle::Activity#publisher_resource
|
172
|
+
Bustle::Activity#target_resource
|
173
|
+
Bustle::Publisher#target_resource
|
174
|
+
Bustle::Subscriber#target_resource
|
175
|
+
Bustle::Subscription#publisher_resource
|
176
|
+
Bustle::Subscription#subscriber_resource
|
177
|
+
```
|
178
|
+
|
166
179
|
#### Publish an Activity
|
167
180
|
|
168
181
|
```ruby
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Bustle::Concern
|
2
|
+
module PublisherResource
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
def publisher_resource
|
6
|
+
publisher = Bustle::Publisher.to_adapter.get!(self.publisher_id)
|
7
|
+
publisher.resource_class.constantize.to_adapter.get!(publisher.resource_id)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Bustle::Concern
|
2
|
+
module SubscriberResource
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
def subscriber_resource
|
6
|
+
subscriber = Bustle::Subscriber.to_adapter.get!(self.subscriber_id)
|
7
|
+
subscriber.resource_class.constantize.to_adapter.get!(subscriber.resource_id)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/lib/bustle/version.rb
CHANGED
data/lib/bustle.rb
CHANGED
@@ -6,6 +6,9 @@ require "bustle/concerns/filterable"
|
|
6
6
|
require "bustle/concerns/by_publisher"
|
7
7
|
require "bustle/concerns/for_subscriber"
|
8
8
|
require "bustle/concerns/resource_collection"
|
9
|
+
require "bustle/concerns/publisher_resource"
|
10
|
+
require "bustle/concerns/subscriber_resource"
|
11
|
+
require "bustle/concerns/target_resource"
|
9
12
|
require "bustle/activities"
|
10
13
|
require "bustle/publishers"
|
11
14
|
require "bustle/subscribers"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
shared_examples '_pubsub_resource' do
|
2
|
+
context "pubsub_resource" do
|
3
|
+
let(:pubsub_resource) { Bustle::Dummy::User.create! :name => 'Fred' }
|
4
|
+
let(:factory_class) { described_class }
|
5
|
+
let(:factory_name) { factory_class.to_s.split('::').last.downcase.to_sym }
|
6
|
+
|
7
|
+
let(:record) do
|
8
|
+
resource = pubsub_class.add pubsub_resource
|
9
|
+
create factory_name,
|
10
|
+
"#{pubsub_type}_id" => resource.id
|
11
|
+
end
|
12
|
+
|
13
|
+
it "references the resource" do
|
14
|
+
record.send("#{pubsub_type}_resource").should == pubsub_resource
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
shared_examples 'target_resource' do
|
2
|
+
context "target_resource" do
|
3
|
+
let(:target_resource) { Bustle::Dummy::User.create! :name => 'Fred' }
|
4
|
+
let(:factory_class) { described_class }
|
5
|
+
let(:factory_name) { factory_class.to_s.split('::').last.downcase.to_sym }
|
6
|
+
|
7
|
+
let(:record) do
|
8
|
+
create factory_name,
|
9
|
+
:resource_class => target_resource.class.name,
|
10
|
+
:resource_id => target_resource.id
|
11
|
+
end
|
12
|
+
|
13
|
+
it "references the target resource" do
|
14
|
+
record.target_resource.should == target_resource
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bustle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -190,7 +190,10 @@ files:
|
|
190
190
|
- lib/bustle/concerns/by_publisher.rb
|
191
191
|
- lib/bustle/concerns/filterable.rb
|
192
192
|
- lib/bustle/concerns/for_subscriber.rb
|
193
|
+
- lib/bustle/concerns/publisher_resource.rb
|
193
194
|
- lib/bustle/concerns/resource_collection.rb
|
195
|
+
- lib/bustle/concerns/subscriber_resource.rb
|
196
|
+
- lib/bustle/concerns/target_resource.rb
|
194
197
|
- lib/bustle/models/activity.rb
|
195
198
|
- lib/bustle/models/publisher.rb
|
196
199
|
- lib/bustle/models/subscriber.rb
|
@@ -217,9 +220,13 @@ files:
|
|
217
220
|
- spec/spec_helper.rb
|
218
221
|
- spec/support/active_record_tables.rb
|
219
222
|
- spec/support/shared_context/app_resources.rb
|
223
|
+
- spec/support/shared_examples/_pubsub_resource.rb
|
220
224
|
- spec/support/shared_examples/has_activities.rb
|
221
225
|
- spec/support/shared_examples/model.rb
|
226
|
+
- spec/support/shared_examples/publisher_resource.rb
|
222
227
|
- spec/support/shared_examples/resource_collection.rb
|
228
|
+
- spec/support/shared_examples/subscriber_resource.rb
|
229
|
+
- spec/support/shared_examples/target_resource.rb
|
223
230
|
homepage: https://github.com/fredwu/bustle
|
224
231
|
licenses: []
|
225
232
|
post_install_message:
|
@@ -234,7 +241,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
234
241
|
version: '0'
|
235
242
|
segments:
|
236
243
|
- 0
|
237
|
-
hash: -
|
244
|
+
hash: -1077479785842864960
|
238
245
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
239
246
|
none: false
|
240
247
|
requirements:
|
@@ -243,7 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
243
250
|
version: '0'
|
244
251
|
segments:
|
245
252
|
- 0
|
246
|
-
hash: -
|
253
|
+
hash: -1077479785842864960
|
247
254
|
requirements: []
|
248
255
|
rubyforge_project:
|
249
256
|
rubygems_version: 1.8.24
|
@@ -264,6 +271,10 @@ test_files:
|
|
264
271
|
- spec/spec_helper.rb
|
265
272
|
- spec/support/active_record_tables.rb
|
266
273
|
- spec/support/shared_context/app_resources.rb
|
274
|
+
- spec/support/shared_examples/_pubsub_resource.rb
|
267
275
|
- spec/support/shared_examples/has_activities.rb
|
268
276
|
- spec/support/shared_examples/model.rb
|
277
|
+
- spec/support/shared_examples/publisher_resource.rb
|
269
278
|
- spec/support/shared_examples/resource_collection.rb
|
279
|
+
- spec/support/shared_examples/subscriber_resource.rb
|
280
|
+
- spec/support/shared_examples/target_resource.rb
|