promiscuous 0.8.4 → 0.8.5
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.
- data/lib/promiscuous/common.rb +3 -2
- data/lib/promiscuous/common/class_helpers.rb +12 -0
- data/lib/promiscuous/publisher/class.rb +2 -8
- data/lib/promiscuous/publisher/mock.rb +3 -3
- data/lib/promiscuous/subscriber/class.rb +2 -4
- data/lib/promiscuous/subscriber/lint/attributes.rb +1 -0
- data/lib/promiscuous/subscriber/polymorphic.rb +2 -3
- data/lib/promiscuous/version.rb +1 -1
- metadata +3 -2
data/lib/promiscuous/common.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
module Promiscuous::Common
|
2
|
-
autoload :Options,
|
3
|
-
autoload :Lint,
|
2
|
+
autoload :Options, 'promiscuous/common/options'
|
3
|
+
autoload :Lint, 'promiscuous/common/lint'
|
4
|
+
autoload :ClassHelpers, 'promiscuous/common/class_helpers'
|
4
5
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Promiscuous::Common::ClassHelpers
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
module ClassMethods
|
5
|
+
def guess_class_name(separator)
|
6
|
+
class_name = name.split("::").reverse.take_while { |name| name != separator }.reverse.join('::')
|
7
|
+
class_name = "::#{class_name}"
|
8
|
+
class_name = $1 if class_name =~ /^(.+)#{separator.singularize}$/
|
9
|
+
class_name
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module Promiscuous::Publisher::Class
|
2
2
|
extend ActiveSupport::Concern
|
3
|
+
include Promiscuous::Common::ClassHelpers
|
3
4
|
|
4
5
|
included { use_option :class, :as => :klass }
|
5
6
|
|
@@ -26,15 +27,8 @@ module Promiscuous::Publisher::Class
|
|
26
27
|
if super
|
27
28
|
"::#{super}".constantize
|
28
29
|
elsif name
|
29
|
-
|
30
|
-
class_name = "::#{class_name}"
|
31
|
-
class_name = $1 if class_name =~ /^(.+)Publisher$/
|
32
|
-
class_name.constantize
|
30
|
+
guess_class_name('Publishers').constantize
|
33
31
|
end
|
34
32
|
end
|
35
33
|
end
|
36
34
|
end
|
37
|
-
|
38
|
-
#define_constant('Scoped::NameScopedPublisherModel', PublisherModel) do
|
39
|
-
#field :field_4
|
40
|
-
#end
|
@@ -1,4 +1,6 @@
|
|
1
1
|
class Promiscuous::Publisher::Mock
|
2
|
+
include Promiscuous::Common::ClassHelpers
|
3
|
+
|
2
4
|
def self.publish(options)
|
3
5
|
if defined?(attributes)
|
4
6
|
if options[:attributes]
|
@@ -21,9 +23,7 @@ class Promiscuous::Publisher::Mock
|
|
21
23
|
if self.klass
|
22
24
|
self.klass
|
23
25
|
elsif name
|
24
|
-
|
25
|
-
class_name = $1 if class_name =~ /^(.+)Publisher$/
|
26
|
-
class_name
|
26
|
+
guess_class_name('Publishers')
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module Promiscuous::Subscriber::Class
|
2
2
|
extend ActiveSupport::Concern
|
3
|
+
include Promiscuous::Common::ClassHelpers
|
3
4
|
|
4
5
|
def instance
|
5
6
|
@instance ||= fetch
|
@@ -12,10 +13,7 @@ module Promiscuous::Subscriber::Class
|
|
12
13
|
if super
|
13
14
|
"::#{super}".constantize
|
14
15
|
elsif name
|
15
|
-
|
16
|
-
class_name = "::#{class_name}"
|
17
|
-
class_name = $1 if class_name =~ /^(.+)Subscriber$/
|
18
|
-
class_name.constantize
|
16
|
+
guess_class_name('Subscribers').constantize
|
19
17
|
end
|
20
18
|
end
|
21
19
|
end
|
@@ -11,6 +11,7 @@ module Promiscuous::Subscriber::Lint::Attributes
|
|
11
11
|
attributes.each { |attr| instance.respond_to?("#{attr}=") or instance.__send__("#{attr}=") }
|
12
12
|
|
13
13
|
if check_publisher
|
14
|
+
raise "The publisher of #{subscriber} does not exist" if publisher.nil?
|
14
15
|
missing_attributes = subscriber.attributes - publisher.attributes
|
15
16
|
if missing_attributes.present?
|
16
17
|
raise "#{publisher} subscribes to non published attributes: #{missing_attributes.join(", ")}"
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Promiscuous::Subscriber::Polymorphic
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
include Promiscuous::Subscriber::Envelope
|
4
|
+
include Promiscuous::Common::ClassHelpers
|
4
5
|
|
5
6
|
included do
|
6
7
|
class_attribute :polymorphic_map
|
@@ -12,9 +13,7 @@ module Promiscuous::Subscriber::Polymorphic
|
|
12
13
|
return super if super
|
13
14
|
|
14
15
|
if name
|
15
|
-
|
16
|
-
class_name = $1 if class_name =~ /^(.+)Subscriber$/
|
17
|
-
class_name
|
16
|
+
guess_class_name('Subscribers')
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
data/lib/promiscuous/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: promiscuous
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-09-
|
13
|
+
date: 2012-09-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -126,6 +126,7 @@ files:
|
|
126
126
|
- lib/promiscuous/subscriber/base.rb
|
127
127
|
- lib/promiscuous/subscriber/polymorphic.rb
|
128
128
|
- lib/promiscuous/common/lint.rb
|
129
|
+
- lib/promiscuous/common/class_helpers.rb
|
129
130
|
- lib/promiscuous/common/options.rb
|
130
131
|
- lib/promiscuous/common/lint/base.rb
|
131
132
|
- lib/promiscuous/worker.rb
|