meshx-plugin-sdk 0.0.6 → 0.0.7
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.
- checksums.yaml +4 -4
- data/lib/meshx-plugin-sdk.rb +53 -26
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3bf6ecabe26119c0568758141559606b088d74e870ea8a6c12833c54f5e4111
|
4
|
+
data.tar.gz: ba9b2f28d78e312bfe386e4498b736fdf79956564d180400026b6fc2ac0d41ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 347573dfea28927e4d53f8301a138a352fd94d18a611e30fed3587f13e45e7de2eea93fbfc2b52ad8c6a14300b144ac7f1b64d9dae00acf7361415e4def02675
|
7
|
+
data.tar.gz: 5ec0f0bfc776a00c00f5c52e2786270df76007bbe10b506bca6c5cf16316cdc4d3a2c259f9cc0ecdbd268ff94c06182942ed90b3f948a2e6b275b878ab2009b2
|
data/lib/meshx-plugin-sdk.rb
CHANGED
@@ -129,36 +129,55 @@ class Controller
|
|
129
129
|
end
|
130
130
|
|
131
131
|
def run()
|
132
|
+
|
133
|
+
begin
|
134
|
+
@log.info("calling on_init()")
|
135
|
+
@plugin.on_init()
|
136
|
+
rescue StandardError => e
|
137
|
+
@log.error("error calling on_init(): #{e.message}")
|
138
|
+
end
|
139
|
+
|
140
|
+
begin
|
141
|
+
@log.info("calling on_start()")
|
142
|
+
@plugin.on_start()
|
143
|
+
rescue StandardError => e
|
144
|
+
@log.error("error calling on_start(): #{e.message}")
|
145
|
+
end
|
146
|
+
|
132
147
|
keep_reading = true
|
133
148
|
@log.info("starting controller loop")
|
134
149
|
while keep_reading
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
150
|
+
begin
|
151
|
+
rtn = @api.get_messages()
|
152
|
+
@log.info("rtn: #{rtn.message} #{rtn.error} #{rtn.exit_code}")
|
153
|
+
# convert message to fileevent
|
154
|
+
if valid_json?(rtn.message)
|
155
|
+
hash = JSON.parse()
|
156
|
+
hash["items"].each do |item|
|
157
|
+
@log.info("message kind: #{item["kind"]}")
|
158
|
+
case item["kind"]
|
159
|
+
when "FileEvent"
|
160
|
+
@log.info("FileEvent")
|
161
|
+
event = FileEvent.new(item)
|
162
|
+
@plugin.on_file_event(event)
|
163
|
+
when "FolderEvent"
|
164
|
+
@log.info("FolderEvent")
|
165
|
+
event = FolderEvent.new(item)
|
166
|
+
@plugin.on_folder_event(event)
|
167
|
+
when "CompleteEvent"
|
168
|
+
@log.info("CompleteEvent")
|
169
|
+
event = CompleteEvent.new(item)
|
170
|
+
@plugin.on_complete_event(event)
|
171
|
+
keep_reading = false
|
172
|
+
else
|
173
|
+
@log.info("unknown event kind: #{item["kind"]}")
|
174
|
+
end
|
158
175
|
end
|
159
|
-
|
160
|
-
|
161
|
-
|
176
|
+
else
|
177
|
+
@log.info("invalid message [#{rtn.message}]")
|
178
|
+
end
|
179
|
+
rescue Exception => e
|
180
|
+
@log.error("error event processing: #{e.message}")
|
162
181
|
end
|
163
182
|
end
|
164
183
|
@log.info("ending controller loop sending complete event")
|
@@ -166,6 +185,14 @@ class Controller
|
|
166
185
|
if res2.exit_code != 0
|
167
186
|
@log.error("failed to send complete event: #{res2.error} #{res2.exit_code}")
|
168
187
|
end
|
188
|
+
|
189
|
+
begin
|
190
|
+
@log.info("calling on_end()")
|
191
|
+
@plugin.on_end()
|
192
|
+
rescue StandardError => e
|
193
|
+
@log.error("error calling on_end(): #{e.message}")
|
194
|
+
end
|
195
|
+
|
169
196
|
end
|
170
197
|
end
|
171
198
|
|