sub_pub 0.0.12 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2c05979fc3b7a089c8cd4097cfc64afe78e45c47
4
+ data.tar.gz: 1d9685e3e04bee5f4814ff9b6744cb1708e612f4
5
+ SHA512:
6
+ metadata.gz: d504b666e641901d31eacb9c73deee45096ffbb086ee45d89d7a332275332a71902d38e9b85cfee185ea5b5e3100d5097fe5d4728683d56f9a8098ea8b44db6f
7
+ data.tar.gz: 8a93dbda5a734f57703a958f2640ce075b4593495ac340e3a33926d32ab493a32aa372ea3d1fd2196157fc4df6058ba55c72e23a15143482ed22c37d94576878
data/.gitignore CHANGED
@@ -1,3 +1,3 @@
1
1
  *.swp
2
2
  *.sqlite3
3
-
3
+ pkg/*
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sub_pub (0.0.11)
4
+ sub_pub (0.0.14)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -11,6 +11,8 @@ The result was a library that was:
11
11
  * easy to disable (when using the console, during unit tests, etc.)
12
12
  * easy to understand (b/c of AS::Notifications syncronous publishing queue)
13
13
 
14
+ - [![Build Status](https://travis-ci.org/gustly/sub_pub.png?branch=master)](https://travis-ci.org/gustly/sub_pub)
15
+
14
16
  ## Installation
15
17
 
16
18
  Add this line to your application's Gemfile:
data/lib/sub_pub.rb CHANGED
@@ -31,6 +31,10 @@ module SubPub
31
31
  Register.subscribe(*args, &block)
32
32
  end
33
33
 
34
+ def unsubscribe(subscription)
35
+ Register.unsubscribe(subscription)
36
+ end
37
+
34
38
  def unsubscribe_all
35
39
  Register.unsubscribe_all
36
40
  end
@@ -7,7 +7,7 @@ module SubPub
7
7
 
8
8
  config.after_initialize do
9
9
  Dir[
10
- File.expand_path("app/sub_pubs/*.rb", Rails.root)
10
+ File.expand_path("app/sub_pubs/**/*.rb", Rails.root)
11
11
  ].each { |file| require file }
12
12
  end
13
13
  end
@@ -73,6 +73,11 @@ module SubPub
73
73
  end
74
74
  end
75
75
 
76
+ def unsubscribe(subscription)
77
+ subscription.unsubscribe
78
+ instance.subscriptions.delete(subscription)
79
+ end
80
+
76
81
  def unsubscribe_all
77
82
  instance.subscriptions.each do |subscription|
78
83
  subscription.unsubscribe
@@ -8,6 +8,10 @@ module SubPub
8
8
  end
9
9
 
10
10
  def self.subscribe_to(topic_name)
11
+ if subscription.present?
12
+ SubPub.unsubscribe(subscription)
13
+ end
14
+
11
15
  @subscription = SubPub.subscribe(topic_name) do |topic, options|
12
16
  publish(new(options))
13
17
  end
@@ -1,3 +1,3 @@
1
1
  module SubPub
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.14"
3
3
  end
@@ -8,7 +8,6 @@ describe SubPub do
8
8
 
9
9
  model do
10
10
  has_many :fake_active_record_results
11
- validate :title, presence: true
12
11
  end
13
12
  end
14
13
 
@@ -120,6 +119,25 @@ describe SubPub do
120
119
  end
121
120
  end
122
121
 
122
+ describe "register subscription only once" do
123
+ before do
124
+ SubPub.scope = 'foo-bar'
125
+
126
+ class CreateAccountSubscriber < SubPub::Subscriber
127
+ subscribe_to("new_account_posted")
128
+
129
+ def on_publish
130
+ FakeActiveRecordUser.create(title: options[:title])
131
+ end
132
+ end
133
+ end
134
+
135
+ it "calls the subscriber properly" do
136
+ CreateAccountSubscriber.subscribe_to("new_account_posted")
137
+ SubPub::Register.instance.subscriptions.count.should == 1
138
+ end
139
+ end
140
+
123
141
  describe "active record configuration" do
124
142
  describe "after create" do
125
143
  before do
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sub_pub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
5
- prerelease:
4
+ version: 0.0.14
6
5
  platform: ruby
7
6
  authors:
8
7
  - zephyr-dev@googlegroups.com
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-01 00:00:00.000000000 Z
11
+ date: 2014-04-08 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: In process publish/subscribe for Ruby
15
14
  email:
@@ -20,6 +19,7 @@ extra_rdoc_files: []
20
19
  files:
21
20
  - .gitignore
22
21
  - .rspec
22
+ - .travis.yml
23
23
  - Gemfile
24
24
  - Gemfile.lock
25
25
  - LICENSE.txt
@@ -36,12 +36,6 @@ files:
36
36
  - lib/sub_pub/subscription.rb
37
37
  - lib/sub_pub/version.rb
38
38
  - lib/sub_pub_matchers.rb
39
- - pkg/sub_pub-0.0.3.gem
40
- - pkg/sub_pub-0.0.4.gem
41
- - pkg/sub_pub-0.0.6.gem
42
- - pkg/sub_pub-0.0.7.gem
43
- - pkg/sub_pub-0.0.8.gem
44
- - pkg/sub_pub-0.0.9.gem
45
39
  - spec/integration/sub_pub_spec.rb
46
40
  - spec/spec_helper.rb
47
41
  - spec/unit/active_record_matchers_spec.rb
@@ -52,27 +46,26 @@ files:
52
46
  - sub_pub.gemspec
53
47
  homepage: ''
54
48
  licenses: []
49
+ metadata: {}
55
50
  post_install_message:
56
51
  rdoc_options: []
57
52
  require_paths:
58
53
  - lib
59
54
  required_ruby_version: !ruby/object:Gem::Requirement
60
- none: false
61
55
  requirements:
62
- - - ! '>='
56
+ - - '>='
63
57
  - !ruby/object:Gem::Version
64
58
  version: '0'
65
59
  required_rubygems_version: !ruby/object:Gem::Requirement
66
- none: false
67
60
  requirements:
68
- - - ! '>='
61
+ - - '>='
69
62
  - !ruby/object:Gem::Version
70
63
  version: '0'
71
64
  requirements: []
72
65
  rubyforge_project:
73
- rubygems_version: 1.8.24
66
+ rubygems_version: 2.1.11
74
67
  signing_key:
75
- specification_version: 3
68
+ specification_version: 4
76
69
  summary: SubPub is a thin wrapper around ActiveSupport::Notifications, which provides
77
70
  an implementation of the Publish/Subscribe pattern.
78
71
  test_files:
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file