Class: LanGrove::Plugin::Notifier

Inherits:
Base
  • Object
show all
Defined in:
lib/langrove/plugin/notifier.rb

Instance Attribute Summary

Attributes inherited from Base

#logger

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#config_exception, #type

Constructor Details

#initialize(root, config, name = nil) ⇒ Notifier

Returns a new instance of Notifier.



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/langrove/plugin/notifier.rb', line 108

def initialize( root, config, name = nil )
  
  super( root, config, name )
  
  validate_config
  
  @provides = {
    
    :notifier => {
      
      :version => NOTIFIER_VERSION
      
    }
    
  }

end

Class Method Details

.typeObject



87
88
89
90
91
# File 'lib/langrove/plugin/notifier.rb', line 87

def self.type
  
  :notifier
  
end

Instance Method Details

#notify(handler) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/langrove/plugin/notifier.rb', line 22

def notify( handler )
  
  #
  # OVERRIDE
  # 
  # To perform the necessary Notification
  # 
  # handler.capsule contains a Notification (Hash) as follows:
  # 
  #  'system' => 'value'
  # 
  #    Populated with the system context of the Daemon that
  #    generated the notification
  # 
  # 
  #  'application' => 'value'
  # 
  #    Populated with the application context of the Daemon that
  #    generated the notification
  # 
  # 
  #  'source' => 'value' 
  # 
  #    Usually the source hostname
  # 
  # 
  #  'key' => 'thing'
  # 
  #    The short_name of some 'thing'
  #
  # 
  #  'state' => 'on'
  # 
  #    The state of that 'thing',
  #    being either of -
  # 
  #      'on'     - the 'thing' just started
  #      'repeat' - the 'thing' is repeating
  #      'off'    - the 'thing' has stopped
  # 
  # 
  #  'value' => n | 'abc'
  # 
  #    The 'thing' may have an associated
  #    value of some kind.
  # 
  # 
  #  'delta' => n
  # 
  #    If the value was numeric, 
  #    and the 'thing' is :repeat(ing)
  #    then this will contain the 
  #    difference between the current
  #    :value and the previous :value
  # 
  # 

  raise LanGrove::PluginException.new(
  
    "#{self.class}.notify() not implemented."
    
  )

end

#notify_handler(handler) ⇒ Object



126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/langrove/plugin/notifier.rb', line 126

def notify_handler( handler )
  
  unless transform( handler )
    
    @logger.error "SKIPPING notification: #{handler.capsule}"
    
    return
    
  end
  
  notify(  handler )
  
end

#transform(handler) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/langrove/plugin/notifier.rb', line 93

def transform( handler )
  
  return handler.transform( :notifier, handler.capsule ) do |notification|

    @notification = {

      :in_message => handler.capsule,
      :out_message => notification

    }

  end
    
end

#validate_configObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/langrove/plugin/notifier.rb', line 10

def validate_config

  #
  # OVERRIDE
  #
  # To validate any extended config
  # 
  
  @config
  
end