adaptation 0.1.1 → 0.1.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.
- data/CHANGELOG +6 -0
- data/dispatches/publish.rb +2 -0
- data/lib/adaptation/adaptor.rb +5 -2
- data/lib/adaptation/base.rb +1 -1
- data/lib/adaptation/mom.rb +21 -6
- data/lib/rails_generator/generators/components/adaptor/templates/functional_test.rb +0 -1
- data/lib/rails_generator/generators/components/message/templates/unit_test.rb +4 -4
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -31,3 +31,9 @@
|
|
31
31
|
- added method 'maps_xml' to Adaptation::Message (and 'mapped_xml')
|
32
32
|
- removed 'check' method from Adaptation::Message (using valid? instead)
|
33
33
|
- removed breakpoint.rb library
|
34
|
+
* 0.1.2
|
35
|
+
- messages publish with publish method in Adaptor::Adaptor need quotation marks
|
36
|
+
- adaptors without ApplicationAdaptor complained, so if ApplicationAdapotr doesn't
|
37
|
+
exist return an Adaptation::Adaptor in base.rb
|
38
|
+
- embedded mom publish method changed. Subscribrers publish, and a separated mom loop
|
39
|
+
will send messages to other subscribers.
|
data/dispatches/publish.rb
CHANGED
data/lib/adaptation/adaptor.rb
CHANGED
@@ -10,6 +10,9 @@ module Adaptation
|
|
10
10
|
#
|
11
11
|
class Adaptor
|
12
12
|
|
13
|
+
def process message
|
14
|
+
end
|
15
|
+
|
13
16
|
def logger
|
14
17
|
Adaptation::Base.logger
|
15
18
|
end
|
@@ -21,11 +24,11 @@ module Adaptation
|
|
21
24
|
elsif options.first.is_a?(String)
|
22
25
|
xml_message = options.first
|
23
26
|
message_type = xml_message[1..(xml_message.index(/(>| )/) - 1)]
|
24
|
-
message_class = get_class_object(message_type.capitalize)
|
27
|
+
message_class = Adaptation::Message.get_class_object(message_type.capitalize)
|
25
28
|
message_object = message_class.to_object(xml_message)
|
26
29
|
end
|
27
30
|
|
28
|
-
xml = message_object.to_xml
|
31
|
+
xml = message_object.to_xml.to_s.gsub("'", "\"")
|
29
32
|
unless system("#{$config["oappublish"]} '#{$config["application"]}' '#{xml}'")
|
30
33
|
puts "Problem publishing: #{xml}"
|
31
34
|
end
|
data/lib/adaptation/base.rb
CHANGED
@@ -69,7 +69,7 @@ module Adaptation
|
|
69
69
|
# without implementation for this type of message
|
70
70
|
|
71
71
|
adaptor_class = Adaptation::Adaptor.get_class_object("#{message_type.capitalize}Adaptor")
|
72
|
-
adaptor = adaptor_class.nil? ? ApplicationAdaptor.new : adaptor_class.new
|
72
|
+
adaptor = adaptor_class.nil? ? ApplicationAdaptor.new : adaptor_class.new rescue Adaptation::Adaptor.new
|
73
73
|
|
74
74
|
unless message.is_a?(String) # TODO: remove when feature explained in line 67 implemented
|
75
75
|
unless message.valid?
|
data/lib/adaptation/mom.rb
CHANGED
@@ -9,6 +9,7 @@ module Adaptation
|
|
9
9
|
|
10
10
|
def initialize mom_uri
|
11
11
|
@mom_uri = mom_uri
|
12
|
+
@messages = []
|
12
13
|
end
|
13
14
|
|
14
15
|
def subscribe drb_uri
|
@@ -26,17 +27,31 @@ module Adaptation
|
|
26
27
|
puts "Received message in topic: #{topic}"
|
27
28
|
puts "#{message}"
|
28
29
|
puts "-----------------------------------"
|
29
|
-
|
30
|
-
puts "Calling #{uri}"
|
31
|
-
DRb.start_service
|
32
|
-
oapdaemon = DRbObject.new(nil, uri)
|
33
|
-
oapdaemon.process message, topic
|
34
|
-
end
|
30
|
+
@messages << [message, topic]
|
35
31
|
end
|
36
32
|
|
37
33
|
def start
|
38
34
|
DRb.start_service(@mom_uri, self)
|
39
35
|
puts "MOM started. Listening at #{@mom_uri}"
|
36
|
+
|
37
|
+
loop do
|
38
|
+
unless @messages.empty?
|
39
|
+
@messages.each do |message|
|
40
|
+
get_subscribers.each do |uri|
|
41
|
+
begin
|
42
|
+
puts "Calling #{uri}"
|
43
|
+
DRb.start_service
|
44
|
+
oapdaemon = DRbObject.new(nil, uri)
|
45
|
+
oapdaemon.process message[0], message[1]
|
46
|
+
rescue
|
47
|
+
puts "Couldn't send message to subscriber: #{uri}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
@messages.delete message
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
40
55
|
DRb.thread.join # Don't exit just yet
|
41
56
|
end
|
42
57
|
|
@@ -7,17 +7,17 @@ class <%= class_name %>Test < Test::Unit::TestCase
|
|
7
7
|
assert true
|
8
8
|
end
|
9
9
|
|
10
|
-
# assert
|
10
|
+
# assert the message is defined correctly comparing the initial xml
|
11
|
+
# from the fixture with the xml obtained from the Adaptation::Message
|
12
|
+
# object created with that fixture
|
11
13
|
#def test_not_parsed
|
12
14
|
# assert_parsed :<%= file_name %>
|
13
|
-
# assert_not_parsed :<%= file_name %>_with_unknown_element
|
14
|
-
# assert_not_parsed :<%= file_name %>_with_unknown_attribute
|
15
15
|
#end
|
16
16
|
|
17
17
|
# assert message passes our validations
|
18
18
|
#def test_validates
|
19
19
|
# assert_validates :<%= file_name %>
|
20
|
-
# assert_not_validates :<%= file_name %>
|
20
|
+
# assert_not_validates :<%= file_name %>_incorrect
|
21
21
|
#end
|
22
22
|
|
23
23
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adaptation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xavi Vila Morell
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-01-
|
12
|
+
date: 2009-01-14 00:00:00 +01:00
|
13
13
|
default_executable: adaptation
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|