Class: Adaptation::Adaptor
Overview
script/generate adaptor hello
Class Method Summary collapse
Instance Method Summary collapse
-
#logger ⇒ Object
Returns the logger to output results in the current environment log file.
-
#process(message) ⇒ Object
:nodoc:.
-
#publish(*options) ⇒ Object
Publishes a message to the MOM.
Class Method Details
Instance Method Details
#logger ⇒ Object
Returns the logger to output results in the current environment log file. Example:
> logger.info "this is going to log/development.log"
19 20 21 |
# File 'lib/adaptation/adaptor.rb', line 19 def logger Adaptation::Base.logger end |
#process(message) ⇒ Object
:nodoc:
13 14 |
# File 'lib/adaptation/adaptor.rb', line 13 def process #:nodoc: end |
#publish(*options) ⇒ Object
Publishes a message to the MOM. The message can be an instance of Adaptation::Message or a String.
When executed in test environment messages are not published to the MOM. They are written to a mocked MOM and their publication can be asserted in tests with assert_message_published.
By default it uses script/publish ito publish. This can be overwritten specifying the oappublish instruction in configuration file config/settings.yml.
By default it publishes in topic ADAPTATION. This can be overwritten specifying the application setting in config/settings.yml file.
Example settings file:
oappublish: /bin/echo
application: MY_TOPIC
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/adaptation/adaptor.rb', line 37 def publish * = nil if .first.is_a?(Message) = .first elsif .first.is_a?(String) = .first = [1..(.index(/(>| )/) - 1)] = Adaptation::Message.get_class_object(.capitalize) = .new() end xml = .to_xml.to_s.gsub("'", "\"") publish_method = $config["oappublish"] || "#{ADAPTOR_ROOT}/script/publish" topic = $config["application"] || "ADAPTATION" unless system("#{publish_method} '#{$config["application"]}' '#{xml}'") logger.error "Problem publishing: #{xml}" end end |