datawire_mdk 2.0.5

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.
@@ -0,0 +1,575 @@
1
+ # Quark 1.0.406 run at 2016-08-31 13:21:53.028839
2
+ module Quark
3
+ require "quark"
4
+ def self.mdk_runtime; MdkRuntime; end
5
+ module MdkRuntime
6
+ def self.files; Files; end
7
+ module Files
8
+ require "datawire-quark-core"
9
+ require_relative '../quark/reflect' # 0 ('quark',) ('mdk_runtime',)
10
+ require_relative '../datawire_mdk_md' # 0 () ('mdk_runtime',)
11
+ require_relative 'actors' # 1 () ()
12
+ require_relative '../mdk_runtime' # 0 () ('mdk_runtime',)
13
+
14
+
15
+ def self.SubscribeChanges; SubscribeChanges; end
16
+ ##
17
+ # Message to FileActor asking to be notified of files' changing contents and
18
+ # deletions for the given directory or file path.
19
+ #
20
+
21
+ class SubscribeChanges < ::DatawireQuarkCore::QuarkObject
22
+ attr_accessor :path
23
+ extend ::DatawireQuarkCore::Static
24
+
25
+ static mdk_runtime_files_SubscribeChanges_ref: -> { nil }
26
+
27
+
28
+
29
+ def initialize(path)
30
+
31
+ self.__init_fields__
32
+ (self).path = path
33
+
34
+ nil
35
+ end
36
+
37
+
38
+
39
+
40
+ def _getClass()
41
+
42
+ return "mdk_runtime.files.SubscribeChanges"
43
+
44
+ nil
45
+ end
46
+
47
+ def _getField(name)
48
+
49
+ if ((name) == ("path"))
50
+ return (self).path
51
+ end
52
+ return nil
53
+
54
+ nil
55
+ end
56
+
57
+ def _setField(name, value)
58
+
59
+ if ((name) == ("path"))
60
+ (self).path = ::DatawireQuarkCore.cast(value) { ::String }
61
+ end
62
+
63
+ nil
64
+ end
65
+
66
+ def __init_fields__()
67
+
68
+ self.path = nil
69
+
70
+ nil
71
+ end
72
+
73
+
74
+ end
75
+ SubscribeChanges.unlazy_statics
76
+
77
+ def self.FileContents; FileContents; end
78
+ ##
79
+ # Message from FileActor with contents of a file.
80
+
81
+ class FileContents < ::DatawireQuarkCore::QuarkObject
82
+ attr_accessor :path, :contents
83
+ extend ::DatawireQuarkCore::Static
84
+
85
+ static mdk_runtime_files_FileContents_ref: -> { nil }
86
+
87
+
88
+
89
+ def initialize(path, contents)
90
+
91
+ self.__init_fields__
92
+ (self).path = path
93
+ (self).contents = contents
94
+
95
+ nil
96
+ end
97
+
98
+
99
+
100
+
101
+ def _getClass()
102
+
103
+ return "mdk_runtime.files.FileContents"
104
+
105
+ nil
106
+ end
107
+
108
+ def _getField(name)
109
+
110
+ if ((name) == ("path"))
111
+ return (self).path
112
+ end
113
+ if ((name) == ("contents"))
114
+ return (self).contents
115
+ end
116
+ return nil
117
+
118
+ nil
119
+ end
120
+
121
+ def _setField(name, value)
122
+
123
+ if ((name) == ("path"))
124
+ (self).path = ::DatawireQuarkCore.cast(value) { ::String }
125
+ end
126
+ if ((name) == ("contents"))
127
+ (self).contents = ::DatawireQuarkCore.cast(value) { ::String }
128
+ end
129
+
130
+ nil
131
+ end
132
+
133
+ def __init_fields__()
134
+
135
+ self.path = nil
136
+ self.contents = nil
137
+
138
+ nil
139
+ end
140
+
141
+
142
+ end
143
+ FileContents.unlazy_statics
144
+
145
+ def self.FileDeleted; FileDeleted; end
146
+ ##
147
+ # Message from FileActor indicating a file was deleted.
148
+
149
+ class FileDeleted < ::DatawireQuarkCore::QuarkObject
150
+ attr_accessor :path
151
+ extend ::DatawireQuarkCore::Static
152
+
153
+ static mdk_runtime_files_FileDeleted_ref: -> { nil }
154
+
155
+
156
+
157
+ def initialize(path)
158
+
159
+ self.__init_fields__
160
+ (self).path = path
161
+
162
+ nil
163
+ end
164
+
165
+
166
+
167
+
168
+ def _getClass()
169
+
170
+ return "mdk_runtime.files.FileDeleted"
171
+
172
+ nil
173
+ end
174
+
175
+ def _getField(name)
176
+
177
+ if ((name) == ("path"))
178
+ return (self).path
179
+ end
180
+ return nil
181
+
182
+ nil
183
+ end
184
+
185
+ def _setField(name, value)
186
+
187
+ if ((name) == ("path"))
188
+ (self).path = ::DatawireQuarkCore.cast(value) { ::String }
189
+ end
190
+
191
+ nil
192
+ end
193
+
194
+ def __init_fields__()
195
+
196
+ self.path = nil
197
+
198
+ nil
199
+ end
200
+
201
+
202
+ end
203
+ FileDeleted.unlazy_statics
204
+
205
+ def self.FileActor; FileActor; end
206
+ ##
207
+ # File interactions.
208
+ #
209
+ # Accepts:
210
+ # - SubscribeChanges messages, which result in FileContents and FiledDeleted
211
+ # messages being sent to original subscriber.
212
+ #
213
+
214
+ class FileActor < ::DatawireQuarkCore::QuarkObject
215
+ extend ::DatawireQuarkCore::Static
216
+
217
+ static mdk_runtime_files_FileActor_ref: -> { nil }
218
+
219
+
220
+
221
+ def initialize()
222
+ self.__init_fields__
223
+
224
+ nil
225
+ end
226
+
227
+
228
+
229
+
230
+ ##
231
+ # Create a temporary directory and return its path.
232
+
233
+ def mktempdir()
234
+ raise NotImplementedError, '`FileActor.mktempdir` is an abstract method'
235
+
236
+ nil
237
+ end
238
+
239
+ ##
240
+ # Write a file with UTF-8 encoded text.
241
+
242
+ def write(path, contents)
243
+ raise NotImplementedError, '`FileActor.write` is an abstract method'
244
+
245
+ nil
246
+ end
247
+
248
+ ##
249
+ # Delete a file.
250
+
251
+ def delete(path)
252
+ raise NotImplementedError, '`FileActor.delete` is an abstract method'
253
+
254
+ nil
255
+ end
256
+
257
+ def _getClass()
258
+
259
+ return "mdk_runtime.files.FileActor"
260
+
261
+ nil
262
+ end
263
+
264
+ def _getField(name)
265
+
266
+ return nil
267
+
268
+ nil
269
+ end
270
+
271
+ def _setField(name, value)
272
+
273
+ nil
274
+
275
+ nil
276
+ end
277
+
278
+ ##
279
+ # The Actor should begin shutting down.
280
+
281
+ def onStop()
282
+
283
+ nil
284
+
285
+ nil
286
+ end
287
+
288
+ def __init_fields__()
289
+
290
+
291
+ nil
292
+ end
293
+
294
+
295
+ end
296
+ FileActor.unlazy_statics
297
+
298
+ def self.FileActorImpl; FileActorImpl; end
299
+ ##
300
+ # Polling-based subscriptions.
301
+ #
302
+ # Should switch to inotify later on.
303
+ #
304
+ # Shim over native implementations. Need better way to do this.
305
+ #
306
+
307
+ class FileActorImpl < ::Quark.mdk_runtime.files.FileActor
308
+ attr_accessor :scheduling, :dispatcher, :subscriptions, :stopped
309
+ extend ::DatawireQuarkCore::Static
310
+
311
+ static quark_List_mdk_runtime_files__Subscription__ref: -> { nil }
312
+ static mdk_runtime_files_FileActorImpl_ref: -> { nil }
313
+
314
+
315
+
316
+ def initialize(runtime)
317
+
318
+ super()
319
+ (self).scheduling = runtime.getScheduleService()
320
+
321
+ nil
322
+ end
323
+
324
+
325
+
326
+
327
+ def mktempdir()
328
+
329
+ return ""
330
+
331
+ nil
332
+ end
333
+
334
+ def write(path, contents)
335
+
336
+ false
337
+
338
+ nil
339
+ end
340
+
341
+ def delete(path)
342
+
343
+ false
344
+
345
+ nil
346
+ end
347
+
348
+ def _checkSubscriptions()
349
+
350
+ if ((self).stopped)
351
+ return
352
+ end
353
+ (self).dispatcher.tell(self, ::Quark.mdk_runtime.Schedule.new("poll", 1.0), (self).scheduling)
354
+ idx = 0
355
+ while ((idx) < (((self).subscriptions).size)) do
356
+ ((self).subscriptions)[idx].poll()
357
+ idx = (idx) + (1)
358
+ end
359
+
360
+ nil
361
+ end
362
+
363
+ def onStart(dispatcher)
364
+
365
+ (self).dispatcher = dispatcher
366
+ self._checkSubscriptions()
367
+
368
+ nil
369
+ end
370
+
371
+ def onStop()
372
+
373
+ (self).stopped = true
374
+
375
+ nil
376
+ end
377
+
378
+ def onMessage(origin, message)
379
+
380
+ typeId = (::Quark.quark.reflect.QuarkClass.get(::DatawireQuarkCore._getClass(message))).id
381
+ if ((typeId) == ("mdk_runtime.Happening"))
382
+ self._checkSubscriptions()
383
+ return
384
+ end
385
+ if ((typeId) == ("mdk_runtime.files.SubscribeChanges"))
386
+ subscribe = ::DatawireQuarkCore.cast(message) { ::Quark.mdk_runtime.files.SubscribeChanges }
387
+ ((self).subscriptions) << (::Quark.mdk_runtime.files._Subscription.new(self, origin, (subscribe).path))
388
+ return
389
+ end
390
+
391
+ nil
392
+ end
393
+
394
+ def _send(message, destination)
395
+
396
+ (self).dispatcher.tell(self, message, destination)
397
+
398
+ nil
399
+ end
400
+
401
+ def _getClass()
402
+
403
+ return "mdk_runtime.files.FileActorImpl"
404
+
405
+ nil
406
+ end
407
+
408
+ def _getField(name)
409
+
410
+ if ((name) == ("scheduling"))
411
+ return (self).scheduling
412
+ end
413
+ if ((name) == ("dispatcher"))
414
+ return (self).dispatcher
415
+ end
416
+ if ((name) == ("subscriptions"))
417
+ return (self).subscriptions
418
+ end
419
+ if ((name) == ("stopped"))
420
+ return (self).stopped
421
+ end
422
+ return nil
423
+
424
+ nil
425
+ end
426
+
427
+ def _setField(name, value)
428
+
429
+ if ((name) == ("scheduling"))
430
+ (self).scheduling = ::DatawireQuarkCore.cast(value) { ::Quark.mdk_runtime.actors.Actor }
431
+ end
432
+ if ((name) == ("dispatcher"))
433
+ (self).dispatcher = ::DatawireQuarkCore.cast(value) { ::Quark.mdk_runtime.actors.MessageDispatcher }
434
+ end
435
+ if ((name) == ("subscriptions"))
436
+ (self).subscriptions = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::List }
437
+ end
438
+ if ((name) == ("stopped"))
439
+ (self).stopped = ::DatawireQuarkCore.cast(value) { ::Object }
440
+ end
441
+
442
+ nil
443
+ end
444
+
445
+ def __init_fields__()
446
+
447
+ super
448
+ self.scheduling = nil
449
+ self.dispatcher = nil
450
+ self.subscriptions = ::DatawireQuarkCore::List.new([])
451
+ self.stopped = false
452
+
453
+ nil
454
+ end
455
+
456
+
457
+ end
458
+ FileActorImpl.unlazy_statics
459
+
460
+ def self._Subscription; Subscription; end
461
+ ##
462
+ # A specific file notification subscription.
463
+
464
+ class Subscription < ::DatawireQuarkCore::QuarkObject
465
+ attr_accessor :path, :actor, :subscriber, :previous_listing
466
+ extend ::DatawireQuarkCore::Static
467
+
468
+ static mdk_runtime_files__Subscription_ref: -> { nil }
469
+
470
+
471
+
472
+ def initialize(actor, subscriber, path)
473
+
474
+ self.__init_fields__
475
+ (self).subscriber = subscriber
476
+ (self).actor = actor
477
+ (self).path = path
478
+
479
+ nil
480
+ end
481
+
482
+
483
+
484
+
485
+ def poll()
486
+
487
+ new_listing = []
488
+ idx = 0
489
+ while ((idx) < ((new_listing).size)) do
490
+ (self).actor._send(::Quark.mdk_runtime.files.FileContents.new((new_listing)[idx], ""), (self).subscriber)
491
+ idx = (idx) + (1)
492
+ end
493
+ idx = 0
494
+ jdx = nil
495
+ found = nil
496
+ while ((idx) < ((@previous_listing).size)) do
497
+ jdx = 0
498
+ found = false
499
+ while ((jdx) < ((new_listing).size)) do
500
+ if (((@previous_listing)[idx]) == ((new_listing)[jdx]))
501
+ found = true
502
+ break
503
+ end
504
+ jdx = (jdx) + (1)
505
+ end
506
+ if (!(found))
507
+ (self).actor._send(::Quark.mdk_runtime.files.FileDeleted.new((@previous_listing)[idx]), (self).subscriber)
508
+ end
509
+ idx = (idx) + (1)
510
+ end
511
+ (self).previous_listing = new_listing
512
+
513
+ nil
514
+ end
515
+
516
+ def _getClass()
517
+
518
+ return "mdk_runtime.files._Subscription"
519
+
520
+ nil
521
+ end
522
+
523
+ def _getField(name)
524
+
525
+ if ((name) == ("path"))
526
+ return (self).path
527
+ end
528
+ if ((name) == ("actor"))
529
+ return (self).actor
530
+ end
531
+ if ((name) == ("subscriber"))
532
+ return (self).subscriber
533
+ end
534
+ if ((name) == ("previous_listing"))
535
+ return (self).previous_listing
536
+ end
537
+ return nil
538
+
539
+ nil
540
+ end
541
+
542
+ def _setField(name, value)
543
+
544
+ if ((name) == ("path"))
545
+ (self).path = ::DatawireQuarkCore.cast(value) { ::String }
546
+ end
547
+ if ((name) == ("actor"))
548
+ (self).actor = ::DatawireQuarkCore.cast(value) { ::Quark.mdk_runtime.files.FileActorImpl }
549
+ end
550
+ if ((name) == ("subscriber"))
551
+ (self).subscriber = ::DatawireQuarkCore.cast(value) { ::Quark.mdk_runtime.actors.Actor }
552
+ end
553
+ if ((name) == ("previous_listing"))
554
+ (self).previous_listing = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::List }
555
+ end
556
+
557
+ nil
558
+ end
559
+
560
+ def __init_fields__()
561
+
562
+ self.path = nil
563
+ self.actor = nil
564
+ self.subscriber = nil
565
+ self.previous_listing = ::DatawireQuarkCore::List.new([])
566
+
567
+ nil
568
+ end
569
+
570
+
571
+ end
572
+ Subscription.unlazy_statics
573
+ end # module Files
574
+ end # module MdkRuntime
575
+ end # module Quark