active_pubsub 0.0.1 → 0.0.2
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 +4 -4
- data/lib/active_pubsub.rb +1 -0
- data/lib/active_pubsub/config.rb +7 -6
- data/lib/active_pubsub/connection.rb +2 -1
- data/lib/active_pubsub/version.rb +1 -1
- data/spec/active_pubsub/config_spec.rb +20 -0
- data/spec/test.db +0 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec487cd15cef4ce67b58a62ea1b9dc71202d0e40
|
4
|
+
data.tar.gz: 641188b0b8799312a4ae42d2318ca5eb4ca36005
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb26c9710230741ebb90fc04a2ee271492186d52d381eef9ea99e8beb28cdbc0b3ef51ccc796e94ea64911065ee9c549a1532af4aa41754c4fa05c56b6ecb621
|
7
|
+
data.tar.gz: aa4cbb39249701500481b0df49177ce08dfb264a7c49f290888c1c427642705a1ab49a526e3a8f446e8cbb51a905754f9ad00a1aa785152aa8e23815f46193f2
|
data/lib/active_pubsub.rb
CHANGED
data/lib/active_pubsub/config.rb
CHANGED
@@ -3,12 +3,13 @@ require 'active_support/ordered_options'
|
|
3
3
|
module ActivePubsub
|
4
4
|
### IMPORTANT ###
|
5
5
|
# Set service namespace if your subscriber has namespace set or it wont get events"
|
6
|
-
class Config < ::ActiveSupport::
|
7
|
-
def initialize(
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
class Config < ::ActiveSupport::InheritableOptions
|
7
|
+
def initialize(*args)
|
8
|
+
super(*args)
|
9
|
+
|
10
|
+
self[:address] ||= ENV['RABBITMQ_URL']
|
11
|
+
self[:publish_as] ||= nil
|
12
|
+
self[:service_namespace] ||= nil
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
require "bunny"
|
2
2
|
|
3
|
+
|
3
4
|
module ActivePubsub
|
4
5
|
class Connection < Delegator
|
5
6
|
attr_accessor :connection, :channel
|
6
7
|
|
7
8
|
def initialize(options = {})
|
8
|
-
@connection = ::Bunny.new(::ActivePubsub.config.try(:address) || "
|
9
|
+
@connection = ::Bunny.new(::ActivePubsub.config.try(:address) || ENV["RABBITMQ_URL"])
|
9
10
|
@connection.start
|
10
11
|
@channel = connection.create_channel
|
11
12
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ::ActivePubsub::Config do
|
4
|
+
let(:address) { "somewhere" }
|
5
|
+
let(:publish_as) { "my_namespace" }
|
6
|
+
let(:service_namespace) { "my_service_namespace"}
|
7
|
+
subject { described_class.new(:publish_as => publish_as, :address => address, :service_namespace => service_namespace) }
|
8
|
+
|
9
|
+
its(:publish_as) { should eq publish_as }
|
10
|
+
its(:address) { should eq address}
|
11
|
+
its(:service_namespace) { should eq service_namespace }
|
12
|
+
|
13
|
+
context "defaults" do
|
14
|
+
subject { described_class.new }
|
15
|
+
its(:address) { should eq ENV["RABBITMQ_URL"] }
|
16
|
+
its(:publish_as) { should eq nil }
|
17
|
+
its(:service_namespace) { should eq nil }
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/spec/test.db
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_pubsub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Ayre
|
@@ -305,6 +305,7 @@ files:
|
|
305
305
|
- lib/active_pubsub/railtie.rb
|
306
306
|
- lib/active_pubsub/subscriber.rb
|
307
307
|
- lib/active_pubsub/version.rb
|
308
|
+
- spec/active_pubsub/config_spec.rb
|
308
309
|
- spec/active_pubsub/connection_spec.rb
|
309
310
|
- spec/active_pubsub/publishable_spec.rb
|
310
311
|
- spec/active_pubsub/publisher_spec.rb
|
@@ -339,6 +340,7 @@ specification_version: 4
|
|
339
340
|
summary: Pubsub using RabbitMQ and ActiveRecord, observe model events from different
|
340
341
|
services.
|
341
342
|
test_files:
|
343
|
+
- spec/active_pubsub/config_spec.rb
|
342
344
|
- spec/active_pubsub/connection_spec.rb
|
343
345
|
- spec/active_pubsub/publishable_spec.rb
|
344
346
|
- spec/active_pubsub/publisher_spec.rb
|