Class: OmahPluginSps
- Inherits:
-
Object
- Object
- OmahPluginSps
- Defined in:
- lib/omah-plugin-sps.rb
Instance Method Summary collapse
-
#initialize(settings: {address: 'localhost', port: 59000}, variables: {}) ⇒ OmahPluginSps
constructor
A new instance of OmahPluginSps.
- #on_newmail(messages, doc) ⇒ Object
- #on_newmessage(h) ⇒ Object
Constructor Details
#initialize(settings: {address: 'localhost', port: 59000}, variables: {}) ⇒ OmahPluginSps
Returns a new instance of OmahPluginSps.
9 10 11 12 13 14 15 16 17 |
# File 'lib/omah-plugin-sps.rb', line 9 def initialize(settings: {address: 'localhost', port: 59000}, variables: {}) address, port = settings[:address], settings[:port] @sps = SPSPub.new(address: address, port: port) h = variables @email_address = h[:email_address] ? h[:email_address] : \ h[:user_name] + '@' + h[:address].split('.')[1..-1].join('.') end |
Instance Method Details
#on_newmail(messages, doc) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/omah-plugin-sps.rb', line 19 def on_newmail(, doc) m = 'message' m += 's' if .length > 1 fqm = "email/new: %s received %s new %s" \ % [@email_address, .length, m] @sps.notice fqm end |
#on_newmessage(h) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/omah-plugin-sps.rb', line 30 def (h) if h[:tags] then tag = h[:tags].split.first fqm = "email/notice/%s: from: %s subject: %s %s" % [tag, h[:from], h[:subject], h[:link]] @sps.notice fqm # sleep 0.3 end end |