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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ea43e949553e6313e96caa956b829708b0aecf7
4
- data.tar.gz: 852017f1bc06dc74f14b4b828fa7f9bf23f73c84
3
+ metadata.gz: ec487cd15cef4ce67b58a62ea1b9dc71202d0e40
4
+ data.tar.gz: 641188b0b8799312a4ae42d2318ca5eb4ca36005
5
5
  SHA512:
6
- metadata.gz: b179fd78488d123798f1db4cb90cbf9e6661628b3b6a91f38cdb37b38be04cbe9800c41bb44b925c70f974754d55fe09ef0dcd032b5c667cf118e139c16d6d0d
7
- data.tar.gz: 2fe5a53c4d20a69292d9dbe4993aaeff5df5802c8d3a0faa469615286fb89269a0b3923a313b3caa67b17fcc6dd0b7e3921f6ef3c42faea522eff877e1a3efe1
6
+ metadata.gz: eb26c9710230741ebb90fc04a2ee271492186d52d381eef9ea99e8beb28cdbc0b3ef51ccc796e94ea64911065ee9c549a1532af4aa41754c4fa05c56b6ecb621
7
+ data.tar.gz: aa4cbb39249701500481b0df49177ce08dfb264a7c49f290888c1c427642705a1ab49a526e3a8f446e8cbb51a905754f9ad00a1aa785152aa8e23815f46193f2
data/lib/active_pubsub.rb CHANGED
@@ -6,6 +6,7 @@ require "bunny"
6
6
  require "celluloid"
7
7
  require "active_support/all"
8
8
  require "active_attr"
9
+ require "pry"
9
10
 
10
11
  module ActivePubsub
11
12
  class << self
@@ -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::OrderedOptions
7
- def initialize(options = {})
8
- options[:address] = ENV['RABBITMQ_URL']
9
- options[:publish_as] = nil
10
- options[:service_namespace] = nil
11
- super
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) || "amqp://guest:guest@localhost:5672")
9
+ @connection = ::Bunny.new(::ActivePubsub.config.try(:address) || ENV["RABBITMQ_URL"])
9
10
  @connection.start
10
11
  @channel = connection.create_channel
11
12
  end
@@ -1,3 +1,3 @@
1
1
  module ActivePubsub
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  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.1
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