bustle 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -0
- data/Rakefile +1 -1
- data/lib/bustle/concerns/resource_collection.rb +10 -0
- data/lib/bustle/subscriptions.rb +11 -1
- data/lib/bustle/version.rb +1 -1
- data/{specs → spec}/bustle/activities_spec.rb +0 -0
- data/{specs → spec}/bustle/models/activity_spec.rb +0 -0
- data/{specs → spec}/bustle/models/publisher_spec.rb +0 -0
- data/{specs → spec}/bustle/models/subscriber_spec.rb +0 -0
- data/{specs → spec}/bustle/models/subscription_spec.rb +0 -0
- data/{specs → spec}/bustle/publishers_spec.rb +0 -0
- data/{specs → spec}/bustle/storage/active_record_spec.rb +0 -0
- data/{specs → spec}/bustle/subscribers_spec.rb +0 -0
- data/{specs → spec}/bustle/subscriptions_spec.rb +21 -4
- data/{specs → spec}/bustle_spec.rb +0 -0
- data/{specs → spec}/spec_helper.rb +1 -1
- data/{specs → spec}/support/active_record_tables.rb +0 -0
- data/{specs → spec}/support/shared_context/app_resources.rb +0 -0
- data/{specs → spec}/support/shared_examples/has_activities.rb +0 -0
- data/{specs → spec}/support/shared_examples/model.rb +0 -0
- data/{specs → spec}/support/shared_examples/resource_collection.rb +10 -1
- metadata +37 -21
data/README.md
CHANGED
@@ -152,6 +152,7 @@ Bustle::Subscriptions.for bustle_subscriber # => an array of Bustle::Subscriptio
|
|
152
152
|
Bustle::Subscribers.remove subscriber
|
153
153
|
Bustle::Publishers.remove publisher
|
154
154
|
Bustle::Subscriptions.remove bustle_publisher, bustle_subscriber
|
155
|
+
# or use `remove!` to raise an exception if the resource cannot be found
|
155
156
|
```
|
156
157
|
|
157
158
|
Or:
|
data/Rakefile
CHANGED
@@ -23,6 +23,16 @@ module Bustle::Concern
|
|
23
23
|
)
|
24
24
|
end
|
25
25
|
|
26
|
+
def remove!(resource)
|
27
|
+
r = get(resource)
|
28
|
+
|
29
|
+
if r.nil?
|
30
|
+
raise "#{resource} does not exist therefore cannot be removed."
|
31
|
+
else
|
32
|
+
r.destroy
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
26
36
|
def remove(resource)
|
27
37
|
get(resource).destroy
|
28
38
|
end
|
data/lib/bustle/subscriptions.rb
CHANGED
@@ -27,8 +27,18 @@ module Bustle
|
|
27
27
|
)
|
28
28
|
end
|
29
29
|
|
30
|
+
def remove!(publisher, subscriber)
|
31
|
+
subscription = get(publisher, subscriber)
|
32
|
+
if subscription.nil?
|
33
|
+
raise "Subscription between #{publisher} and #{subscriber} does not exist therefore cannot be removed."
|
34
|
+
else
|
35
|
+
subscription.destroy
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
30
39
|
def remove(publisher, subscriber)
|
31
|
-
get(publisher, subscriber)
|
40
|
+
subscription = get(publisher, subscriber)
|
41
|
+
subscription.destroy unless subscription.nil?
|
32
42
|
end
|
33
43
|
end
|
34
44
|
end
|
data/lib/bustle/version.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -35,11 +35,28 @@ module Bustle
|
|
35
35
|
subscription.subscriber_id.should == subscriber.id
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
context "remove" do
|
39
|
+
it "removes a subscription" do
|
40
|
+
subscription = Subscriptions.get publisher, subscriber
|
41
|
+
|
42
|
+
Subscriptions.remove publisher, subscriber
|
43
|
+
Subscriptions.filter.count.should == 0
|
44
|
+
end
|
40
45
|
|
41
|
-
|
42
|
-
|
46
|
+
it "#remove! a subscription" do
|
47
|
+
subscription = Subscriptions.get publisher, subscriber
|
48
|
+
|
49
|
+
Subscriptions.remove! publisher, subscriber
|
50
|
+
Subscriptions.filter.count.should == 0
|
51
|
+
end
|
52
|
+
|
53
|
+
it "does not error out when removing a non-existent subscription" do
|
54
|
+
expect { Subscriptions.remove subscriber, subscriber2 }.not_to raise_error
|
55
|
+
end
|
56
|
+
|
57
|
+
it "error out when removing a non-existent subscription" do
|
58
|
+
expect { Subscriptions.remove! subscriber, subscriber2 }.to raise_error
|
59
|
+
end
|
43
60
|
end
|
44
61
|
|
45
62
|
context "finding multiple subscriptions" do
|
File without changes
|
@@ -7,7 +7,7 @@ require 'database_cleaner'
|
|
7
7
|
require 'pry'
|
8
8
|
|
9
9
|
require File.expand_path('../../lib/bustle', __FILE__)
|
10
|
-
Dir[File.expand_path('../../
|
10
|
+
Dir[File.expand_path('../../spec/support/**/*.rb', __FILE__)].each {|f| require f}
|
11
11
|
|
12
12
|
BUSTLE_STORAGES = [
|
13
13
|
Bustle::Storage::ActiveRecord
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -42,5 +42,14 @@ shared_examples 'resource_collection' do
|
|
42
42
|
described_class.remove(user)
|
43
43
|
resource_class.to_adapter.find_all({}).count.should == 0
|
44
44
|
end
|
45
|
+
|
46
|
+
it "#remove! a model record" do
|
47
|
+
described_class.remove!(user)
|
48
|
+
resource_class.to_adapter.find_all({}).count.should == 0
|
49
|
+
end
|
50
|
+
|
51
|
+
it "#remove! with error" do
|
52
|
+
expect { described_class.remove!(post) }.to raise_error
|
53
|
+
end
|
45
54
|
end
|
46
|
-
end
|
55
|
+
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.4
|
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-
|
12
|
+
date: 2012-07-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -204,22 +204,22 @@ files:
|
|
204
204
|
- lib/bustle/subscribers.rb
|
205
205
|
- lib/bustle/subscriptions.rb
|
206
206
|
- lib/bustle/version.rb
|
207
|
-
-
|
208
|
-
-
|
209
|
-
-
|
210
|
-
-
|
211
|
-
-
|
212
|
-
-
|
213
|
-
-
|
214
|
-
-
|
215
|
-
-
|
216
|
-
-
|
217
|
-
-
|
218
|
-
-
|
219
|
-
-
|
220
|
-
-
|
221
|
-
-
|
222
|
-
-
|
207
|
+
- spec/bustle/activities_spec.rb
|
208
|
+
- spec/bustle/models/activity_spec.rb
|
209
|
+
- spec/bustle/models/publisher_spec.rb
|
210
|
+
- spec/bustle/models/subscriber_spec.rb
|
211
|
+
- spec/bustle/models/subscription_spec.rb
|
212
|
+
- spec/bustle/publishers_spec.rb
|
213
|
+
- spec/bustle/storage/active_record_spec.rb
|
214
|
+
- spec/bustle/subscribers_spec.rb
|
215
|
+
- spec/bustle/subscriptions_spec.rb
|
216
|
+
- spec/bustle_spec.rb
|
217
|
+
- spec/spec_helper.rb
|
218
|
+
- spec/support/active_record_tables.rb
|
219
|
+
- spec/support/shared_context/app_resources.rb
|
220
|
+
- spec/support/shared_examples/has_activities.rb
|
221
|
+
- spec/support/shared_examples/model.rb
|
222
|
+
- spec/support/shared_examples/resource_collection.rb
|
223
223
|
homepage: https://github.com/fredwu/bustle
|
224
224
|
licenses: []
|
225
225
|
post_install_message:
|
@@ -234,7 +234,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
234
234
|
version: '0'
|
235
235
|
segments:
|
236
236
|
- 0
|
237
|
-
hash:
|
237
|
+
hash: -805955161985304810
|
238
238
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
239
239
|
none: false
|
240
240
|
requirements:
|
@@ -243,11 +243,27 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
243
243
|
version: '0'
|
244
244
|
segments:
|
245
245
|
- 0
|
246
|
-
hash:
|
246
|
+
hash: -805955161985304810
|
247
247
|
requirements: []
|
248
248
|
rubyforge_project:
|
249
249
|
rubygems_version: 1.8.24
|
250
250
|
signing_key:
|
251
251
|
specification_version: 3
|
252
252
|
summary: Activities recording and retrieving using a simple Pub/Sub architecture.
|
253
|
-
test_files:
|
253
|
+
test_files:
|
254
|
+
- spec/bustle/activities_spec.rb
|
255
|
+
- spec/bustle/models/activity_spec.rb
|
256
|
+
- spec/bustle/models/publisher_spec.rb
|
257
|
+
- spec/bustle/models/subscriber_spec.rb
|
258
|
+
- spec/bustle/models/subscription_spec.rb
|
259
|
+
- spec/bustle/publishers_spec.rb
|
260
|
+
- spec/bustle/storage/active_record_spec.rb
|
261
|
+
- spec/bustle/subscribers_spec.rb
|
262
|
+
- spec/bustle/subscriptions_spec.rb
|
263
|
+
- spec/bustle_spec.rb
|
264
|
+
- spec/spec_helper.rb
|
265
|
+
- spec/support/active_record_tables.rb
|
266
|
+
- spec/support/shared_context/app_resources.rb
|
267
|
+
- spec/support/shared_examples/has_activities.rb
|
268
|
+
- spec/support/shared_examples/model.rb
|
269
|
+
- spec/support/shared_examples/resource_collection.rb
|