Class: OmahPluginSps

Inherits:
Object
  • Object
show all
Defined in:
lib/omah-plugin-sps.rb

Instance Method Summary collapse

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(messages, doc)
  
  m = 'message'
  m += 's' if messages.length > 1
  fqm = "email/new: %s received %s new %s" \
                                % [@email_address, messages.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 on_newmessage(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