isimud 0.5.2

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.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/.rspec +2 -0
  4. data/.ruby-version +1 -0
  5. data/.yardoc/checksums +15 -0
  6. data/.yardoc/object_types +0 -0
  7. data/.yardoc/objects/root.dat +0 -0
  8. data/.yardoc/proxy_types +0 -0
  9. data/Gemfile +23 -0
  10. data/Gemfile.lock +123 -0
  11. data/README.md +218 -0
  12. data/Rakefile +2 -0
  13. data/config.ru +7 -0
  14. data/config/tddium.yml +11 -0
  15. data/doc/Isimud.html +1696 -0
  16. data/doc/Isimud/BunnyClient.html +1004 -0
  17. data/doc/Isimud/Client.html +812 -0
  18. data/doc/Isimud/Event.html +1500 -0
  19. data/doc/Isimud/EventListener.html +1217 -0
  20. data/doc/Isimud/EventObserver.html +367 -0
  21. data/doc/Isimud/EventObserver/ClassMethods.html +292 -0
  22. data/doc/Isimud/Generators.html +117 -0
  23. data/doc/Isimud/Generators/ConfigGenerator.html +192 -0
  24. data/doc/Isimud/Generators/InitializerGenerator.html +192 -0
  25. data/doc/Isimud/Logging.html +230 -0
  26. data/doc/Isimud/ModelWatcher.html +312 -0
  27. data/doc/Isimud/ModelWatcher/ClassMethods.html +511 -0
  28. data/doc/Isimud/Railtie.html +123 -0
  29. data/doc/Isimud/TestClient.html +1003 -0
  30. data/doc/Isimud/TestClient/Queue.html +556 -0
  31. data/doc/_index.html +290 -0
  32. data/doc/class_list.html +58 -0
  33. data/doc/css/common.css +1 -0
  34. data/doc/css/full_list.css +57 -0
  35. data/doc/css/style.css +339 -0
  36. data/doc/file.README.html +338 -0
  37. data/doc/file_list.html +60 -0
  38. data/doc/frames.html +26 -0
  39. data/doc/index.html +338 -0
  40. data/doc/js/app.js +219 -0
  41. data/doc/js/full_list.js +181 -0
  42. data/doc/js/jquery.js +4 -0
  43. data/doc/method_list.html +711 -0
  44. data/doc/top-level-namespace.html +112 -0
  45. data/isimud.gemspec +25 -0
  46. data/lib/isimud.rb +91 -0
  47. data/lib/isimud/bunny_client.rb +95 -0
  48. data/lib/isimud/client.rb +48 -0
  49. data/lib/isimud/event.rb +112 -0
  50. data/lib/isimud/event_listener.rb +200 -0
  51. data/lib/isimud/event_observer.rb +81 -0
  52. data/lib/isimud/logging.rb +11 -0
  53. data/lib/isimud/model_watcher.rb +144 -0
  54. data/lib/isimud/railtie.rb +9 -0
  55. data/lib/isimud/tasks.rb +20 -0
  56. data/lib/isimud/test_client.rb +89 -0
  57. data/lib/isimud/version.rb +3 -0
  58. data/lib/rails/generators/isimud/config_generator.rb +12 -0
  59. data/lib/rails/generators/isimud/initializer_generator.rb +12 -0
  60. data/lib/rails/generators/isimud/templates/initializer.rb +17 -0
  61. data/lib/rails/generators/isimud/templates/isimud.yml +20 -0
  62. data/spec/internal/app/models/admin.rb +2 -0
  63. data/spec/internal/app/models/company.rb +34 -0
  64. data/spec/internal/app/models/user.rb +27 -0
  65. data/spec/internal/config/database.yml +3 -0
  66. data/spec/internal/config/routes.rb +3 -0
  67. data/spec/internal/db/schema.rb +22 -0
  68. data/spec/internal/log/.gitignore +1 -0
  69. data/spec/internal/public/favicon.ico +0 -0
  70. data/spec/isimud/bunny_client_spec.rb +125 -0
  71. data/spec/isimud/event_listener_spec.rb +86 -0
  72. data/spec/isimud/event_observer_spec.rb +32 -0
  73. data/spec/isimud/event_spec.rb +74 -0
  74. data/spec/isimud/model_watcher_spec.rb +189 -0
  75. data/spec/isimud/test_client_spec.rb +28 -0
  76. data/spec/isimud_spec.rb +49 -0
  77. data/spec/spec_helper.rb +55 -0
  78. metadata +195 -0
@@ -0,0 +1,511 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Module: Isimud::ModelWatcher::ClassMethods
8
+
9
+ &mdash; Documentation by YARD 0.8.7.6
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../../';
20
+ framesUrl = "../../frames.html#!Isimud/ModelWatcher/ClassMethods.html";
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../../_index.html">Index (C)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../../Isimud.html" title="Isimud (module)">Isimud</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../ModelWatcher.html" title="Isimud::ModelWatcher (module)">ModelWatcher</a></span></span>
36
+ &raquo;
37
+ <span class="title">ClassMethods</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="../../class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="../../method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="../../file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Module: Isimud::ModelWatcher::ClassMethods
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ <dt class="r1 last">Defined in:</dt>
82
+ <dd class="r1 last">lib/isimud/model_watcher.rb</dd>
83
+
84
+ </dl>
85
+ <div class="clear"></div>
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ <h2>
96
+ Instance Method Summary
97
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
98
+ </h2>
99
+
100
+ <ul class="summary">
101
+
102
+ <li class="public ">
103
+ <span class="summary_signature">
104
+
105
+ <a href="#isimud_model_watcher_type-instance_method" title="#isimud_model_watcher_type (instance method)">- (Object) <strong>isimud_model_watcher_type</strong> </a>
106
+
107
+
108
+
109
+ </span>
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+ <span class="summary_desc"><div class='inline'></div></span>
120
+
121
+ </li>
122
+
123
+
124
+ <li class="public ">
125
+ <span class="summary_signature">
126
+
127
+ <a href="#sync_include-instance_method" title="#sync_include (instance method)">- (Object) <strong>sync_include</strong>(_sync_includes) </a>
128
+
129
+
130
+
131
+ </span>
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+ <span class="summary_desc"><div class='inline'>
142
+ <p>Include the following tables when fetching records for synchronization.</p>
143
+ </div></span>
144
+
145
+ </li>
146
+
147
+
148
+ <li class="public ">
149
+ <span class="summary_signature">
150
+
151
+ <a href="#synchronize-instance_method" title="#synchronize (instance method)">- (Integer) <strong>synchronize</strong>(options = {}) </a>
152
+
153
+
154
+
155
+ </span>
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+ <span class="summary_desc"><div class='inline'>
166
+ <p>Synchronize instances of this model with the data warehouse.</p>
167
+ </div></span>
168
+
169
+ </li>
170
+
171
+
172
+ <li class="public ">
173
+ <span class="summary_signature">
174
+
175
+ <a href="#watch_attributes-instance_method" title="#watch_attributes (instance method)">- (Object) <strong>watch_attributes</strong>(*attributes) </a>
176
+
177
+
178
+
179
+ </span>
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+ <span class="summary_desc"><div class='inline'>
190
+ <p>Set attributes to observe and include in messages.</p>
191
+ </div></span>
192
+
193
+ </li>
194
+
195
+
196
+ </ul>
197
+
198
+
199
+
200
+
201
+ <div id="instance_method_details" class="method_details_list">
202
+ <h2>Instance Method Details</h2>
203
+
204
+
205
+ <div class="method_details first">
206
+ <h3 class="signature first" id="isimud_model_watcher_type-instance_method">
207
+
208
+ - (<tt>Object</tt>) <strong>isimud_model_watcher_type</strong>
209
+
210
+
211
+
212
+
213
+
214
+ </h3><table class="source_code">
215
+ <tr>
216
+ <td>
217
+ <pre class="lines">
218
+
219
+
220
+ 72
221
+ 73
222
+ 74</pre>
223
+ </td>
224
+ <td>
225
+ <pre class="code"><span class="info file"># File 'lib/isimud/model_watcher.rb', line 72</span>
226
+
227
+ <span class='kw'>def</span> <span class='id identifier rubyid_isimud_model_watcher_type'>isimud_model_watcher_type</span>
228
+ <span class='lparen'>(</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:base_class</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_base_class'>base_class</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='op'>:</span> <span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_demodulize'>demodulize</span>
229
+ <span class='kw'>end</span></pre>
230
+ </td>
231
+ </tr>
232
+ </table>
233
+ </div>
234
+
235
+ <div class="method_details ">
236
+ <h3 class="signature " id="sync_include-instance_method">
237
+
238
+ - (<tt>Object</tt>) <strong>sync_include</strong>(_sync_includes)
239
+
240
+
241
+
242
+
243
+
244
+ </h3><div class="docstring">
245
+ <div class="discussion">
246
+
247
+ <p>Include the following tables when fetching records for synchronization</p>
248
+
249
+
250
+ </div>
251
+ </div>
252
+ <div class="tags">
253
+
254
+
255
+ </div><table class="source_code">
256
+ <tr>
257
+ <td>
258
+ <pre class="lines">
259
+
260
+
261
+ 37
262
+ 38
263
+ 39</pre>
264
+ </td>
265
+ <td>
266
+ <pre class="code"><span class="info file"># File 'lib/isimud/model_watcher.rb', line 37</span>
267
+
268
+ <span class='kw'>def</span> <span class='id identifier rubyid_sync_include'>sync_include</span><span class='lparen'>(</span><span class='id identifier rubyid__sync_includes'>_sync_includes</span><span class='rparen'>)</span>
269
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_sync_includes'>sync_includes</span> <span class='op'>=</span> <span class='id identifier rubyid__sync_includes'>_sync_includes</span>
270
+ <span class='kw'>end</span></pre>
271
+ </td>
272
+ </tr>
273
+ </table>
274
+ </div>
275
+
276
+ <div class="method_details ">
277
+ <h3 class="signature " id="synchronize-instance_method">
278
+
279
+ - (<tt>Integer</tt>) <strong>synchronize</strong>(options = {})
280
+
281
+
282
+
283
+
284
+
285
+ </h3><div class="docstring">
286
+ <div class="discussion">
287
+
288
+ <p>Synchronize instances of this model with the data warehouse. This is
289
+ accomplished by calling isimud_notify_updated() on each instance fetched
290
+ from the database.</p>
291
+
292
+
293
+ </div>
294
+ </div>
295
+ <div class="tags">
296
+ <p class="tag_title">Parameters:</p>
297
+ <ul class="param">
298
+
299
+ <li>
300
+
301
+ <span class='name'>options</span>
302
+
303
+
304
+ <span class='type'>(<tt>Hash</tt>)</span>
305
+
306
+
307
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
308
+
309
+
310
+ &mdash;
311
+ <div class='inline'>
312
+ <p>synchronize options</p>
313
+ </div>
314
+
315
+ </li>
316
+
317
+ </ul>
318
+
319
+
320
+
321
+
322
+ <p class="tag_title">Options Hash (<tt>options</tt>):</p>
323
+ <ul class="option">
324
+
325
+ <li>
326
+ <span class="name">:where</span>
327
+ <span class="type">(<tt>ActiveRecord::Relation</tt>)</span>
328
+ <span class="default">
329
+
330
+ </span>
331
+
332
+ &mdash; <div class='inline'>
333
+ <p>where_clause filter for limiting records to sync. By default, all records
334
+ are synchronized.</p>
335
+ </div>
336
+
337
+ </li>
338
+
339
+ <li>
340
+ <span class="name">:output</span>
341
+ <span class="type">(<tt>IO</tt>)</span>
342
+ <span class="default">
343
+
344
+ </span>
345
+
346
+ &mdash; <div class='inline'>
347
+ <p>optional stream for writing progress. A &#39;.&#39; is printed for every
348
+ 100 records synchronized.</p>
349
+ </div>
350
+
351
+ </li>
352
+
353
+ </ul>
354
+
355
+
356
+ <p class="tag_title">Returns:</p>
357
+ <ul class="return">
358
+
359
+ <li>
360
+
361
+
362
+ <span class='type'>(<tt>Integer</tt>)</span>
363
+
364
+
365
+
366
+ &mdash;
367
+ <div class='inline'>
368
+ <p>number of records synchronized</p>
369
+ </div>
370
+
371
+ </li>
372
+
373
+ </ul>
374
+
375
+ </div><table class="source_code">
376
+ <tr>
377
+ <td>
378
+ <pre class="lines">
379
+
380
+
381
+ 47
382
+ 48
383
+ 49
384
+ 50
385
+ 51
386
+ 52
387
+ 53
388
+ 54
389
+ 55
390
+ 56
391
+ 57
392
+ 58
393
+ 59
394
+ 60
395
+ 61
396
+ 62
397
+ 63
398
+ 64
399
+ 65
400
+ 66
401
+ 67
402
+ 68
403
+ 69
404
+ 70</pre>
405
+ </td>
406
+ <td>
407
+ <pre class="code"><span class="info file"># File 'lib/isimud/model_watcher.rb', line 47</span>
408
+
409
+ <span class='kw'>def</span> <span class='id identifier rubyid_synchronize'>synchronize</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
410
+ <span class='id identifier rubyid_where_clause'>where_clause</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:where</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
411
+ <span class='id identifier rubyid_output'>output</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:output</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>nil</span>
412
+ <span class='id identifier rubyid_count'>count</span> <span class='op'>=</span> <span class='int'>0</span>
413
+ <span class='id identifier rubyid_query'>query</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='id identifier rubyid_where_clause'>where_clause</span><span class='rparen'>)</span>
414
+ <span class='id identifier rubyid_query'>query</span> <span class='op'>=</span> <span class='id identifier rubyid_query'>query</span><span class='period'>.</span><span class='id identifier rubyid_includes'>includes</span><span class='lparen'>(</span><span class='id identifier rubyid_sync_includes'>sync_includes</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_sync_includes'>sync_includes</span>
415
+ <span class='id identifier rubyid_query'>query</span><span class='period'>.</span><span class='id identifier rubyid_find_each'>find_each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_m'>m</span><span class='op'>|</span>
416
+ <span class='kw'>next</span> <span class='kw'>unless</span> <span class='id identifier rubyid_m'>m</span><span class='period'>.</span><span class='id identifier rubyid_isimud_synchronize?'>isimud_synchronize?</span>
417
+ <span class='kw'>begin</span>
418
+ <span class='id identifier rubyid_m'>m</span><span class='period'>.</span><span class='id identifier rubyid_isimud_sync'>isimud_sync</span>
419
+ <span class='kw'>rescue</span> <span class='const'>Bunny</span><span class='op'>::</span><span class='const'>ClientTimeout</span><span class='comma'>,</span> <span class='const'>Timeout</span><span class='op'>::</span><span class='const'>Error</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
420
+ <span class='id identifier rubyid_output'>output</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_output'>output</span><span class='period'>.</span><span class='id identifier rubyid_print'>print</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\n</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_e'>e</span><span class='embexpr_end'>}</span><span class='tstring_content'>, sleeping for 10 seconds</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
421
+ <span class='id identifier rubyid_sleep'>sleep</span><span class='lparen'>(</span><span class='int'>10</span><span class='rparen'>)</span>
422
+ <span class='id identifier rubyid_m'>m</span><span class='period'>.</span><span class='id identifier rubyid_isimud_sync'>isimud_sync</span>
423
+ <span class='kw'>end</span>
424
+ <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_count'>count</span> <span class='op'>+=</span> <span class='int'>1</span><span class='rparen'>)</span> <span class='op'>%</span> <span class='int'>100</span> <span class='op'>==</span> <span class='int'>0</span>
425
+ <span class='id identifier rubyid_output'>output</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_output'>output</span><span class='period'>.</span><span class='id identifier rubyid_print'>print</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>.</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
426
+ <span class='kw'>end</span>
427
+ <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_count'>count</span> <span class='op'>%</span> <span class='int'>1000</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='int'>0</span>
428
+ <span class='const'>GC</span><span class='period'>.</span><span class='id identifier rubyid_start'>start</span>
429
+ <span class='kw'>end</span>
430
+ <span class='kw'>end</span>
431
+ <span class='id identifier rubyid_count'>count</span>
432
+ <span class='kw'>end</span></pre>
433
+ </td>
434
+ </tr>
435
+ </table>
436
+ </div>
437
+
438
+ <div class="method_details ">
439
+ <h3 class="signature " id="watch_attributes-instance_method">
440
+
441
+ - (<tt>Object</tt>) <strong>watch_attributes</strong>(*attributes)
442
+
443
+
444
+
445
+
446
+
447
+ </h3><div class="docstring">
448
+ <div class="discussion">
449
+
450
+ <p>Set attributes to observe and include in messages. Any property method with
451
+ a return value may be included in the list of attributes.</p>
452
+
453
+
454
+ </div>
455
+ </div>
456
+ <div class="tags">
457
+ <p class="tag_title">Parameters:</p>
458
+ <ul class="param">
459
+
460
+ <li>
461
+
462
+ <span class='name'>attributes</span>
463
+
464
+
465
+ <span class='type'>(<tt>Array&lt;String,Symbol&gt;</tt>)</span>
466
+
467
+
468
+
469
+ &mdash;
470
+ <div class='inline'>
471
+ <p>list of attributes / properties</p>
472
+ </div>
473
+
474
+ </li>
475
+
476
+ </ul>
477
+
478
+
479
+ </div><table class="source_code">
480
+ <tr>
481
+ <td>
482
+ <pre class="lines">
483
+
484
+
485
+ 32
486
+ 33
487
+ 34</pre>
488
+ </td>
489
+ <td>
490
+ <pre class="code"><span class="info file"># File 'lib/isimud/model_watcher.rb', line 32</span>
491
+
492
+ <span class='kw'>def</span> <span class='id identifier rubyid_watch_attributes'>watch_attributes</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_attributes'>attributes</span><span class='rparen'>)</span>
493
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_isimud_watch_attributes'>isimud_watch_attributes</span> <span class='op'>=</span> <span class='id identifier rubyid_attributes'>attributes</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:to_sym</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_attributes'>attributes</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
494
+ <span class='kw'>end</span></pre>
495
+ </td>
496
+ </tr>
497
+ </table>
498
+ </div>
499
+
500
+ </div>
501
+
502
+ </div>
503
+
504
+ <div id="footer">
505
+ Generated on Fri Apr 3 09:28:08 2015 by
506
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
507
+ 0.8.7.6 (ruby-2.2.1).
508
+ </div>
509
+
510
+ </body>
511
+ </html>