loggable_activity 0.1.39 → 0.1.40

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/.document +1 -0
  3. data/.nojekyll +1 -0
  4. data/.rubocop.yml +1 -1
  5. data/doc/.nojekyll +1 -0
  6. data/doc/CHANGELOG_md.html +125 -0
  7. data/doc/CODE_OF_CONDUCT_md.html +220 -0
  8. data/doc/CONSIDERTIONS_md.html +227 -0
  9. data/doc/CreateLoggableActivities.html +144 -0
  10. data/doc/CreateLoggableEncryptionKeys.html +140 -0
  11. data/doc/CreateLoggablePayloads.html +144 -0
  12. data/doc/GETTING-STARTED_md.html +186 -0
  13. data/doc/Gemfile.html +104 -0
  14. data/doc/Gemfile_lock.html +152 -0
  15. data/doc/LICENSE_txt.html +104 -0
  16. data/doc/LoggableActivity/CurrentUser.html +99 -0
  17. data/doc/LoggableActivity/Generators/InstallGenerator.html +178 -0
  18. data/doc/LoggableActivity/Generators.html +91 -0
  19. data/doc/README_md.html +138 -0
  20. data/doc/ROADMAP_md.html +151 -0
  21. data/doc/Rakefile.html +102 -0
  22. data/doc/bin/setup.html +100 -0
  23. data/doc/notes/CHEAT_SHEET_md.html +130 -0
  24. data/doc/sig/loggable_activity_rbs.html +101 -0
  25. data/docs/LoggableActivity/Activity.html +494 -0
  26. data/docs/LoggableActivity/Configuration.html +183 -0
  27. data/docs/LoggableActivity/Encryption.html +220 -0
  28. data/docs/LoggableActivity/EncryptionError.html +99 -0
  29. data/docs/LoggableActivity/EncryptionKey.html +327 -0
  30. data/docs/LoggableActivity/Error.html +97 -0
  31. data/docs/LoggableActivity/Hooks.html +172 -0
  32. data/docs/LoggableActivity/Payload.html +159 -0
  33. data/docs/LoggableActivity/PayloadsBuilder.html +154 -0
  34. data/docs/LoggableActivity/UpdatePayloadsBuilder.html +199 -0
  35. data/docs/LoggableActivity.html +100 -0
  36. data/docs/created.rid +10 -0
  37. data/docs/css/fonts.css +167 -0
  38. data/docs/css/rdoc.css +687 -0
  39. data/docs/fonts/Lato-Light.ttf +0 -0
  40. data/docs/fonts/Lato-LightItalic.ttf +0 -0
  41. data/docs/fonts/Lato-Regular.ttf +0 -0
  42. data/docs/fonts/Lato-RegularItalic.ttf +0 -0
  43. data/docs/fonts/SourceCodePro-Bold.ttf +0 -0
  44. data/docs/fonts/SourceCodePro-Regular.ttf +0 -0
  45. data/docs/images/add.png +0 -0
  46. data/docs/images/arrow_up.png +0 -0
  47. data/docs/images/brick.png +0 -0
  48. data/docs/images/brick_link.png +0 -0
  49. data/docs/images/bug.png +0 -0
  50. data/docs/images/bullet_black.png +0 -0
  51. data/docs/images/bullet_toggle_minus.png +0 -0
  52. data/docs/images/bullet_toggle_plus.png +0 -0
  53. data/docs/images/date.png +0 -0
  54. data/docs/images/delete.png +0 -0
  55. data/docs/images/find.png +0 -0
  56. data/docs/images/loadingAnimation.gif +0 -0
  57. data/docs/images/macFFBgHack.png +0 -0
  58. data/docs/images/package.png +0 -0
  59. data/docs/images/page_green.png +0 -0
  60. data/docs/images/page_white_text.png +0 -0
  61. data/docs/images/page_white_width.png +0 -0
  62. data/docs/images/plugin.png +0 -0
  63. data/docs/images/ruby.png +0 -0
  64. data/docs/images/tag_blue.png +0 -0
  65. data/docs/images/tag_green.png +0 -0
  66. data/docs/images/transparent.png +0 -0
  67. data/docs/images/wrench.png +0 -0
  68. data/docs/images/wrench_orange.png +0 -0
  69. data/docs/images/zoom.png +0 -0
  70. data/docs/index.html +91 -0
  71. data/docs/js/darkfish.js +97 -0
  72. data/docs/js/navigation.js +105 -0
  73. data/docs/js/navigation.js.gz +0 -0
  74. data/docs/js/search.js +110 -0
  75. data/docs/js/search_index.js +1 -0
  76. data/docs/js/search_index.js.gz +0 -0
  77. data/docs/js/searcher.js +229 -0
  78. data/docs/js/searcher.js.gz +0 -0
  79. data/docs/table_of_contents.html +184 -0
  80. data/lib/generators/loggable_activity/install_generator.rb +2 -1
  81. data/lib/generators/loggable_activity/templates/current_user.rb +1 -1
  82. data/lib/generators/loggable_activity/templates/loggable_activity.yml +29 -0
  83. data/lib/loggable_activity/activity.rb +208 -59
  84. data/lib/loggable_activity/configuration.rb +18 -0
  85. data/lib/loggable_activity/encryption.rb +20 -1
  86. data/lib/loggable_activity/encryption_key.rb +81 -14
  87. data/lib/loggable_activity/hooks.rb +10 -7
  88. data/lib/loggable_activity/payload.rb +45 -11
  89. data/lib/loggable_activity/payloads_builder.rb +50 -4
  90. data/lib/loggable_activity/update_payloads_builder.rb +64 -2
  91. data/lib/loggable_activity/version.rb +1 -1
  92. metadata +81 -9
  93. data/.DS_Store +0 -0
  94. data/loggable_activity-0.1.32.gem +0 -0
  95. data/loggable_activity-0.1.33.gem +0 -0
  96. data/loggable_activity-0.1.34.gem +0 -0
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/docs/index.html ADDED
@@ -0,0 +1,91 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>RDoc Documentation</title>
8
+
9
+ <script type="text/javascript">
10
+ var rdoc_rel_prefix = "./";
11
+ var index_rel_prefix = "./";
12
+ </script>
13
+
14
+ <script src="./js/navigation.js" defer></script>
15
+ <script src="./js/search.js" defer></script>
16
+ <script src="./js/search_index.js" defer></script>
17
+ <script src="./js/searcher.js" defer></script>
18
+ <script src="./js/darkfish.js" defer></script>
19
+
20
+ <link href="./css/fonts.css" rel="stylesheet">
21
+ <link href="./css/rdoc.css" rel="stylesheet">
22
+
23
+
24
+ <body id="top" role="document" class="file">
25
+ <nav role="navigation">
26
+ <div id="project-navigation">
27
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
28
+ <h2>
29
+ <a href="./index.html" rel="home">Home</a>
30
+ </h2>
31
+
32
+ <div id="table-of-contents-navigation">
33
+ <a href="./table_of_contents.html#pages">Pages</a>
34
+ <a href="./table_of_contents.html#classes">Classes</a>
35
+ <a href="./table_of_contents.html#methods">Methods</a>
36
+ </div>
37
+ </div>
38
+
39
+
40
+ <div id="search-section" role="search" class="project-section initially-hidden">
41
+ <form action="#" method="get" accept-charset="utf-8">
42
+ <div id="search-field-wrapper">
43
+ <input id="search-field" role="combobox" aria-label="Search"
44
+ aria-autocomplete="list" aria-controls="search-results"
45
+ type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
46
+ title="Type to search, Up and Down to navigate, Enter to load">
47
+ </div>
48
+
49
+ <ul id="search-results" aria-label="Search Results"
50
+ aria-busy="false" aria-expanded="false"
51
+ aria-atomic="false" class="initially-hidden"></ul>
52
+ </form>
53
+ </div>
54
+
55
+ </div>
56
+
57
+ <div id="project-metadata">
58
+
59
+
60
+ <div id="classindex-section" class="nav-section">
61
+ <h3>Class and Module Index</h3>
62
+
63
+ <ul class="link-list">
64
+ <li><details open><summary><code><a href="./LoggableActivity.html">LoggableActivity</a></code></summary>
65
+ <ul class="link-list">
66
+ <li><code><a href="./LoggableActivity/Activity.html">Activity</a></code>
67
+ <li><code><a href="./LoggableActivity/Configuration.html">Configuration</a></code>
68
+ <li><code><a href="./LoggableActivity/Encryption.html">Encryption</a></code>
69
+ <li><code><a href="./LoggableActivity/EncryptionError.html">EncryptionError</a></code>
70
+ <li><code><a href="./LoggableActivity/EncryptionKey.html">EncryptionKey</a></code>
71
+ <li><code><a href="./LoggableActivity/Hooks.html">Hooks</a></code>
72
+ <li><code><a href="./LoggableActivity/Payload.html">Payload</a></code>
73
+ <li><code><a href="./LoggableActivity/PayloadsBuilder.html">PayloadsBuilder</a></code>
74
+ <li><code><a href="./LoggableActivity/UpdatePayloadsBuilder.html">UpdatePayloadsBuilder</a></code>
75
+ </ul></details>
76
+ </div>
77
+
78
+ </div>
79
+ </nav>
80
+
81
+ <main role="main">
82
+ <p>This is the API documentation for RDoc Documentation.
83
+ </main>
84
+
85
+
86
+ <footer id="validator-badges" role="contentinfo">
87
+ <p><a href="https://validator.w3.org/check/referer">Validate</a>
88
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.6.2.
89
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
90
+ </footer>
91
+
@@ -0,0 +1,97 @@
1
+ /**
2
+ *
3
+ * Darkfish Page Functions
4
+ * $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $
5
+ *
6
+ * Author: Michael Granger <mgranger@laika.com>
7
+ *
8
+ */
9
+
10
+ /* Provide console simulation for firebug-less environments */
11
+ /*
12
+ if (!("console" in window) || !("firebug" in console)) {
13
+ var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
14
+ "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
15
+
16
+ window.console = {};
17
+ for (var i = 0; i < names.length; ++i)
18
+ window.console[names[i]] = function() {};
19
+ };
20
+ */
21
+
22
+
23
+ function showSource( e ) {
24
+ var target = e.target;
25
+ while (!target.classList.contains('method-detail')) {
26
+ target = target.parentNode;
27
+ }
28
+ if (typeof target !== "undefined" && target !== null) {
29
+ target = target.querySelector('.method-source-code');
30
+ }
31
+ if (typeof target !== "undefined" && target !== null) {
32
+ target.classList.toggle('active-menu')
33
+ }
34
+ };
35
+
36
+ function hookSourceViews() {
37
+ document.querySelectorAll('.method-heading').forEach(function (codeObject) {
38
+ codeObject.addEventListener('click', showSource);
39
+ });
40
+ };
41
+
42
+ function hookSearch() {
43
+ var input = document.querySelector('#search-field');
44
+ var result = document.querySelector('#search-results');
45
+ result.classList.remove("initially-hidden");
46
+
47
+ var search_section = document.querySelector('#search-section');
48
+ search_section.classList.remove("initially-hidden");
49
+
50
+ var search = new Search(search_data, input, result);
51
+
52
+ search.renderItem = function(result) {
53
+ var li = document.createElement('li');
54
+ var html = '';
55
+
56
+ // TODO add relative path to <script> per-page
57
+ html += '<p class="search-match"><a href="' + index_rel_prefix + this.escapeHTML(result.path) + '">' + this.hlt(result.title);
58
+ if (result.params)
59
+ html += '<span class="params">' + result.params + '</span>';
60
+ html += '</a>';
61
+
62
+
63
+ if (result.namespace)
64
+ html += '<p class="search-namespace">' + this.hlt(result.namespace);
65
+
66
+ if (result.snippet)
67
+ html += '<div class="search-snippet">' + result.snippet + '</div>';
68
+
69
+ li.innerHTML = html;
70
+
71
+ return li;
72
+ }
73
+
74
+ search.select = function(result) {
75
+ window.location.href = result.firstChild.firstChild.href;
76
+ }
77
+
78
+ search.scrollIntoView = search.scrollInWindow;
79
+ };
80
+
81
+ function hookFocus() {
82
+ document.addEventListener("keydown", (event) => {
83
+ if (document.activeElement.tagName === 'INPUT') {
84
+ return;
85
+ }
86
+ if (event.key === "/") {
87
+ event.preventDefault();
88
+ document.querySelector('#search-field').focus();
89
+ }
90
+ });
91
+ }
92
+
93
+ document.addEventListener('DOMContentLoaded', function() {
94
+ hookSourceViews();
95
+ hookSearch();
96
+ hookFocus();
97
+ });
@@ -0,0 +1,105 @@
1
+ /*
2
+ * Navigation allows movement using the arrow keys through the search results.
3
+ *
4
+ * When using this library you will need to set scrollIntoView to the
5
+ * appropriate function for your layout. Use scrollInWindow if the container
6
+ * is not scrollable and scrollInElement if the container is a separate
7
+ * scrolling region.
8
+ */
9
+ Navigation = new function() {
10
+ this.initNavigation = function() {
11
+ var _this = this;
12
+
13
+ document.addEventListener('keydown', function(e) {
14
+ _this.onkeydown(e);
15
+ });
16
+
17
+ this.navigationActive = true;
18
+ }
19
+
20
+ this.setNavigationActive = function(state) {
21
+ this.navigationActive = state;
22
+ }
23
+
24
+ this.onkeydown = function(e) {
25
+ if (!this.navigationActive) return;
26
+ switch(e.key) {
27
+ case 'ArrowLeft':
28
+ if (this.moveLeft()) e.preventDefault();
29
+ break;
30
+ case 'ArrowUp':
31
+ if (e.key == 'ArrowUp' || e.ctrlKey) {
32
+ if (this.moveUp()) e.preventDefault();
33
+ }
34
+ break;
35
+ case 'ArrowRight':
36
+ if (this.moveRight()) e.preventDefault();
37
+ break;
38
+ case 'ArrowDown':
39
+ if (e.key == 'ArrowDown' || e.ctrlKey) {
40
+ if (this.moveDown()) e.preventDefault();
41
+ }
42
+ break;
43
+ case 'Enter':
44
+ if (this.current) e.preventDefault();
45
+ this.select(this.current);
46
+ break;
47
+ }
48
+ if (e.ctrlKey && e.shiftKey) this.select(this.current);
49
+ }
50
+
51
+ this.moveRight = function() {
52
+ }
53
+
54
+ this.moveLeft = function() {
55
+ }
56
+
57
+ this.move = function(isDown) {
58
+ }
59
+
60
+ this.moveUp = function() {
61
+ return this.move(false);
62
+ }
63
+
64
+ this.moveDown = function() {
65
+ return this.move(true);
66
+ }
67
+
68
+ /*
69
+ * Scrolls to the given element in the scrollable element view.
70
+ */
71
+ this.scrollInElement = function(element, view) {
72
+ var offset, viewHeight, viewScroll, height;
73
+ offset = element.offsetTop;
74
+ height = element.offsetHeight;
75
+ viewHeight = view.offsetHeight;
76
+ viewScroll = view.scrollTop;
77
+
78
+ if (offset - viewScroll + height > viewHeight) {
79
+ view.scrollTop = offset - viewHeight + height;
80
+ }
81
+ if (offset < viewScroll) {
82
+ view.scrollTop = offset;
83
+ }
84
+ }
85
+
86
+ /*
87
+ * Scrolls to the given element in the window. The second argument is
88
+ * ignored
89
+ */
90
+ this.scrollInWindow = function(element, ignored) {
91
+ var offset, viewHeight, viewScroll, height;
92
+ offset = element.offsetTop;
93
+ height = element.offsetHeight;
94
+ viewHeight = window.innerHeight;
95
+ viewScroll = window.scrollY;
96
+
97
+ if (offset - viewScroll + height > viewHeight) {
98
+ window.scrollTo(window.scrollX, offset - viewHeight + height);
99
+ }
100
+ if (offset < viewScroll) {
101
+ window.scrollTo(window.scrollX, offset);
102
+ }
103
+ }
104
+ }
105
+
Binary file
data/docs/js/search.js ADDED
@@ -0,0 +1,110 @@
1
+ Search = function(data, input, result) {
2
+ this.data = data;
3
+ this.input = input;
4
+ this.result = result;
5
+
6
+ this.current = null;
7
+ this.view = this.result.parentNode;
8
+ this.searcher = new Searcher(data.index);
9
+ this.init();
10
+ }
11
+
12
+ Search.prototype = Object.assign({}, Navigation, new function() {
13
+ var suid = 1;
14
+
15
+ this.init = function() {
16
+ var _this = this;
17
+ var observer = function(e) {
18
+ switch(e.key) {
19
+ case 'ArrowUp':
20
+ case 'ArrowDown':
21
+ return;
22
+ }
23
+ _this.search(_this.input.value);
24
+ };
25
+ this.input.addEventListener('keyup', observer);
26
+ this.input.addEventListener('click', observer); // mac's clear field
27
+
28
+ this.searcher.ready(function(results, isLast) {
29
+ _this.addResults(results, isLast);
30
+ })
31
+
32
+ this.initNavigation();
33
+ this.setNavigationActive(false);
34
+ }
35
+
36
+ this.search = function(value, selectFirstMatch) {
37
+ value = value.trim().toLowerCase();
38
+ if (value) {
39
+ this.setNavigationActive(true);
40
+ } else {
41
+ this.setNavigationActive(false);
42
+ }
43
+
44
+ if (value == '') {
45
+ this.lastQuery = value;
46
+ this.result.innerHTML = '';
47
+ this.result.setAttribute('aria-expanded', 'false');
48
+ this.setNavigationActive(false);
49
+ } else if (value != this.lastQuery) {
50
+ this.lastQuery = value;
51
+ this.result.setAttribute('aria-busy', 'true');
52
+ this.result.setAttribute('aria-expanded', 'true');
53
+ this.firstRun = true;
54
+ this.searcher.find(value);
55
+ }
56
+ }
57
+
58
+ this.addResults = function(results, isLast) {
59
+ var target = this.result;
60
+ if (this.firstRun && (results.length > 0 || isLast)) {
61
+ this.current = null;
62
+ this.result.innerHTML = '';
63
+ }
64
+
65
+ for (var i=0, l = results.length; i < l; i++) {
66
+ var item = this.renderItem.call(this, results[i]);
67
+ item.setAttribute('id', 'search-result-' + target.childElementCount);
68
+ target.appendChild(item);
69
+ };
70
+
71
+ if (this.firstRun && results.length > 0) {
72
+ this.firstRun = false;
73
+ this.current = target.firstChild;
74
+ this.current.classList.add('search-selected');
75
+ }
76
+ //TODO: ECMAScript
77
+ //if (jQuery.browser.msie) this.$element[0].className += '';
78
+
79
+ if (isLast) this.result.setAttribute('aria-busy', 'false');
80
+ }
81
+
82
+ this.move = function(isDown) {
83
+ if (!this.current) return;
84
+ var next = isDown ? this.current.nextElementSibling : this.current.previousElementSibling;
85
+ if (next) {
86
+ this.current.classList.remove('search-selected');
87
+ next.classList.add('search-selected');
88
+ this.input.setAttribute('aria-activedescendant', next.getAttribute('id'));
89
+ this.scrollIntoView(next, this.view);
90
+ this.current = next;
91
+ this.input.value = next.firstChild.firstChild.text;
92
+ this.input.select();
93
+ }
94
+ return true;
95
+ }
96
+
97
+ this.hlt = function(html) {
98
+ return this.escapeHTML(html).
99
+ replace(/\u0001/g, '<em>').
100
+ replace(/\u0002/g, '</em>');
101
+ }
102
+
103
+ this.escapeHTML = function(html) {
104
+ return html.replace(/[&<>"`']/g, function(c) {
105
+ return '&#' + c.charCodeAt(0) + ';';
106
+ });
107
+ }
108
+
109
+ });
110
+
@@ -0,0 +1 @@
1
+ var search_data = {"index":{"searchIndex":["loggableactivity","activity","configuration","encryption","encryptionerror","encryptionkey","hooks","payload","payloadsbuilder","updatepayloadsbuilder","activities_for_actor()","actor_display_name()","attrs()","attrs()","blank?()","build_payloads()","build_update_payloads()","create_encryption_key()","decrypt()","encrypt()","for_class()","for_record()","for_record_by_type_and_id()","latest()","load_config_file()","log()","mark_as_deleted()","primary_payload_attrs()","random_key()","record_display_name()","relations_attrs()","update_activity_attrs()"],"longSearchIndex":["loggableactivity","loggableactivity::activity","loggableactivity::configuration","loggableactivity::encryption","loggableactivity::encryptionerror","loggableactivity::encryptionkey","loggableactivity::hooks","loggableactivity::payload","loggableactivity::payloadsbuilder","loggableactivity::updatepayloadsbuilder","loggableactivity::activity::activities_for_actor()","loggableactivity::activity#actor_display_name()","loggableactivity::activity#attrs()","loggableactivity::payload#attrs()","loggableactivity::encryption::blank?()","loggableactivity::payloadsbuilder#build_payloads()","loggableactivity::updatepayloadsbuilder#build_update_payloads()","loggableactivity::encryptionkey::create_encryption_key()","loggableactivity::encryption::decrypt()","loggableactivity::encryption::encrypt()","loggableactivity::configuration::for_class()","loggableactivity::encryptionkey::for_record()","loggableactivity::encryptionkey::for_record_by_type_and_id()","loggableactivity::activity::latest()","loggableactivity::configuration::load_config_file()","loggableactivity::hooks#log()","loggableactivity::encryptionkey#mark_as_deleted()","loggableactivity::activity#primary_payload_attrs()","loggableactivity::encryptionkey::random_key()","loggableactivity::activity#record_display_name()","loggableactivity::activity#relations_attrs()","loggableactivity::activity#update_activity_attrs()"],"info":[["LoggableActivity","","LoggableActivity.html","",""],["LoggableActivity::Activity","","LoggableActivity/Activity.html","","<p>Represents one action in the activity log.\n"],["LoggableActivity::Configuration","","LoggableActivity/Configuration.html","","<p>This class is used to load the configuration file located at config/loggable_activity.yml\n"],["LoggableActivity::Encryption","","LoggableActivity/Encryption.html","","<p>This module is used to encrypt and decrypt attributes\n"],["LoggableActivity::EncryptionError","","LoggableActivity/EncryptionError.html","","<p>This error is raised when encryption or decryption fails\n"],["LoggableActivity::EncryptionKey","","LoggableActivity/EncryptionKey.html","","<p>This class represents the encryption key used to unlock the data for one payload. When deleted, only …\n"],["LoggableActivity::Hooks","","LoggableActivity/Hooks.html","","<p>This module provides hooks for creating activities when included in a model.\n"],["LoggableActivity::Payload","","LoggableActivity/Payload.html","","<p>This class represents a payload in the log, containing encrypted data of one record in the database. …\n"],["LoggableActivity::PayloadsBuilder","","LoggableActivity/PayloadsBuilder.html","","<p>This module is responsible for building payloads used in loggable activities.\n"],["LoggableActivity::UpdatePayloadsBuilder","","LoggableActivity/UpdatePayloadsBuilder.html","","<p>This module is responsible for building update payloads used in loggable activities.\n"],["activities_for_actor","LoggableActivity::Activity","LoggableActivity/Activity.html#method-c-activities_for_actor","(actor, limit = 20, params = { offset: 0 })","<p>Returns a list of activities for a given actor.\n"],["actor_display_name","LoggableActivity::Activity","LoggableActivity/Activity.html#method-i-actor_display_name","()","<p>Returns the display name for a actor. what method to use if defined in ‘/config/loggable_activity.yaml’ …\n"],["attrs","LoggableActivity::Activity","LoggableActivity/Activity.html#method-i-attrs","()","<p>Returns a list of attributes of the activity includig the indliced relations. The included relations …\n"],["attrs","LoggableActivity::Payload","LoggableActivity/Payload.html#method-i-attrs","()","<p>Returns the decrypted attributes of the payload based on its type.\n<p>@return [Hash] The decrypted attributes. …\n"],["blank?","LoggableActivity::Encryption","LoggableActivity/Encryption.html#method-c-blank-3F","(value)",""],["build_payloads","LoggableActivity::PayloadsBuilder","LoggableActivity/PayloadsBuilder.html#method-i-build_payloads","()","<p>Builds payloads for the loggable activity.\n\n<pre>Example:\n build_payloads\n\nReturns:\n #&lt;LoggableActivity::Payload:0x0000000109658718&gt; ...</pre>\n"],["build_update_payloads","LoggableActivity::UpdatePayloadsBuilder","LoggableActivity/UpdatePayloadsBuilder.html#method-i-build_update_payloads","()","<p>Builds payloads for an activity update event.\n\n<pre>Example:\n build_update_payloads\n\n Returns:\n [\n [0] #&lt;LoggableActivity::Payload:0x00000001047d31d8&gt; ...</pre>\n"],["create_encryption_key","LoggableActivity::EncryptionKey","LoggableActivity/EncryptionKey.html#method-c-create_encryption_key","(record_type, record_id, parent_key = nil)","<p>Creates an encryption key for a record, optionally using a parent key.\n\n<pre>@param record_type [String] The ...</pre>\n"],["decrypt","LoggableActivity::Encryption","LoggableActivity/Encryption.html#method-c-decrypt","(data, encryption_key)","<p>Decrypts the given data using the given encryption key\n<p>Example:\n\n<pre>LoggableActivity::Encryption.decrypt(&#39;SOME_ENCRYPTED_STRING&#39;, ...</pre>\n"],["encrypt","LoggableActivity::Encryption","LoggableActivity/Encryption.html#method-c-encrypt","(data, encryption_key)","<p>Encrypts the given data using the given encryption key\n<p>Example:\n\n<pre>LoggableActivity::Encryption.encrypt(&#39;my ...</pre>\n"],["for_class","LoggableActivity::Configuration","LoggableActivity/Configuration.html#method-c-for_class","(class_name)","<p>Returns the configuration data for the given class\n<p>Example:\n\n<pre class=\"ruby\"><span class=\"ruby-constant\">LoggableActivity</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Configuration</span>.<span class=\"ruby-identifier\">for_class</span>(<span class=\"ruby-string\">&#39;User&#39;</span>)\n</pre>\n"],["for_record","LoggableActivity::EncryptionKey","LoggableActivity/EncryptionKey.html#method-c-for_record","(record, parent_key = nil)","<p>Returns an encryption key for a record, optionally using a parent key.\n\n<pre>@param record [ActiveRecord::Base] ...</pre>\n"],["for_record_by_type_and_id","LoggableActivity::EncryptionKey","LoggableActivity/EncryptionKey.html#method-c-for_record_by_type_and_id","(record_type, record_id, parent_key = nil)","<p>Returns an encryption key for a record by its type and ID, optionally using a parent key.\n\n<pre>@param record_type ...</pre>\n"],["latest","LoggableActivity::Activity","LoggableActivity/Activity.html#method-c-latest","(limit = 20, params = { offset: 0 })","<p>Returns a list of activities ordered by creation date.\n"],["load_config_file","LoggableActivity::Configuration","LoggableActivity/Configuration.html#method-c-load_config_file","(config_file_path)",""],["log","LoggableActivity::Hooks","LoggableActivity/Hooks.html#method-i-log","(action, actor: nil, params: {})","<p>Logs an activity with the specified action, actor, and params.\n\n<pre>@param action [Symbol] The action to log ...</pre>\n"],["mark_as_deleted","LoggableActivity::EncryptionKey","LoggableActivity/EncryptionKey.html#method-i-mark_as_deleted","()","<p>Marks the encryption key as deleted by updating the key to nil.\n"],["primary_payload_attrs","LoggableActivity::Activity","LoggableActivity/Activity.html#method-i-primary_payload_attrs","()","<p>Returns the attributes for the primary payload, without the relations.\n<p>Example:\n\n<pre class=\"ruby\"><span class=\"ruby-ivar\">@activity</span>.<span class=\"ruby-identifier\">primary_payload_attrs</span>\n</pre>\n"],["random_key","LoggableActivity::EncryptionKey","LoggableActivity/EncryptionKey.html#method-c-random_key","()","<p>Generates a random encryption key.\n\n<pre>@return [String] The generated encryption key.</pre>\n<p>Example:\n"],["record_display_name","LoggableActivity::Activity","LoggableActivity/Activity.html#method-i-record_display_name","()","<p>Returns the display name for a record. what method to use if defined in ‘/config/loggable_activity.yaml’ …\n"],["relations_attrs","LoggableActivity::Activity","LoggableActivity/Activity.html#method-i-relations_attrs","()","<p>Returns the attributes for the relations.\n<p>Example:\n\n<pre class=\"ruby\"><span class=\"ruby-ivar\">@activity</span>.<span class=\"ruby-identifier\">relations_attrs</span>\n</pre>\n"],["update_activity_attrs","LoggableActivity::Activity","LoggableActivity/Activity.html#method-i-update_activity_attrs","()","<p>Returns the attributes of an upddate activity.\n<p>Example:\n\n<pre class=\"ruby\"><span class=\"ruby-ivar\">@activity</span>.<span class=\"ruby-identifier\">update_activity_attrs</span>\n</pre>\n"]]}}
Binary file
@@ -0,0 +1,229 @@
1
+ Searcher = function(data) {
2
+ this.data = data;
3
+ this.handlers = [];
4
+ }
5
+
6
+ Searcher.prototype = new function() {
7
+ // search is performed in chunks of 1000 for non-blocking user input
8
+ var CHUNK_SIZE = 1000;
9
+ // do not try to find more than 100 results
10
+ var MAX_RESULTS = 100;
11
+ var huid = 1;
12
+ var suid = 1;
13
+ var runs = 0;
14
+
15
+ this.find = function(query) {
16
+ var queries = splitQuery(query);
17
+ var regexps = buildRegexps(queries);
18
+ var highlighters = buildHilighters(queries);
19
+ var state = { from: 0, pass: 0, limit: MAX_RESULTS, n: suid++};
20
+ var _this = this;
21
+
22
+ this.currentSuid = state.n;
23
+
24
+ if (!query) return;
25
+
26
+ var run = function() {
27
+ // stop current search thread if new search started
28
+ if (state.n != _this.currentSuid) return;
29
+
30
+ var results =
31
+ performSearch(_this.data, regexps, queries, highlighters, state);
32
+ var hasMore = (state.limit > 0 && state.pass < 4);
33
+
34
+ triggerResults.call(_this, results, !hasMore);
35
+ if (hasMore) {
36
+ setTimeout(run, 2);
37
+ }
38
+ runs++;
39
+ };
40
+ runs = 0;
41
+
42
+ // start search thread
43
+ run();
44
+ }
45
+
46
+ /* ----- Events ------ */
47
+ this.ready = function(fn) {
48
+ fn.huid = huid;
49
+ this.handlers.push(fn);
50
+ }
51
+
52
+ /* ----- Utilities ------ */
53
+ function splitQuery(query) {
54
+ return query.split(/(\s+|::?|\(\)?)/).filter(function(string) {
55
+ return string.match(/\S/);
56
+ });
57
+ }
58
+
59
+ function buildRegexps(queries) {
60
+ return queries.map(function(query) {
61
+ return new RegExp(query.replace(/(.)/g, '([$1])([^$1]*?)'), 'i');
62
+ });
63
+ }
64
+
65
+ function buildHilighters(queries) {
66
+ return queries.map(function(query) {
67
+ return query.split('').map(function(l, i) {
68
+ return '\u0001$' + (i*2+1) + '\u0002$' + (i*2+2);
69
+ }).join('');
70
+ });
71
+ }
72
+
73
+ // function longMatchRegexp(index, longIndex, regexps) {
74
+ // for (var i = regexps.length - 1; i >= 0; i--){
75
+ // if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false;
76
+ // };
77
+ // return true;
78
+ // }
79
+
80
+
81
+ /* ----- Mathchers ------ */
82
+
83
+ /*
84
+ * This record matches if the index starts with queries[0] and the record
85
+ * matches all of the regexps
86
+ */
87
+ function matchPassBeginning(index, longIndex, queries, regexps) {
88
+ if (index.indexOf(queries[0]) != 0) return false;
89
+ for (var i=1, l = regexps.length; i < l; i++) {
90
+ if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
91
+ return false;
92
+ };
93
+ return true;
94
+ }
95
+
96
+ /*
97
+ * This record matches if the longIndex starts with queries[0] and the
98
+ * longIndex matches all of the regexps
99
+ */
100
+ function matchPassLongIndex(index, longIndex, queries, regexps) {
101
+ if (longIndex.indexOf(queries[0]) != 0) return false;
102
+ for (var i=1, l = regexps.length; i < l; i++) {
103
+ if (!longIndex.match(regexps[i]))
104
+ return false;
105
+ };
106
+ return true;
107
+ }
108
+
109
+ /*
110
+ * This record matches if the index contains queries[0] and the record
111
+ * matches all of the regexps
112
+ */
113
+ function matchPassContains(index, longIndex, queries, regexps) {
114
+ if (index.indexOf(queries[0]) == -1) return false;
115
+ for (var i=1, l = regexps.length; i < l; i++) {
116
+ if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
117
+ return false;
118
+ };
119
+ return true;
120
+ }
121
+
122
+ /*
123
+ * This record matches if regexps[0] matches the index and the record
124
+ * matches all of the regexps
125
+ */
126
+ function matchPassRegexp(index, longIndex, queries, regexps) {
127
+ if (!index.match(regexps[0])) return false;
128
+ for (var i=1, l = regexps.length; i < l; i++) {
129
+ if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
130
+ return false;
131
+ };
132
+ return true;
133
+ }
134
+
135
+
136
+ /* ----- Highlighters ------ */
137
+ function highlightRegexp(info, queries, regexps, highlighters) {
138
+ var result = createResult(info);
139
+ for (var i=0, l = regexps.length; i < l; i++) {
140
+ result.title = result.title.replace(regexps[i], highlighters[i]);
141
+ result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
142
+ };
143
+ return result;
144
+ }
145
+
146
+ function hltSubstring(string, pos, length) {
147
+ return string.substring(0, pos) + '\u0001' + string.substring(pos, pos + length) + '\u0002' + string.substring(pos + length);
148
+ }
149
+
150
+ function highlightQuery(info, queries, regexps, highlighters) {
151
+ var result = createResult(info);
152
+ var pos = 0;
153
+ var lcTitle = result.title.toLowerCase();
154
+
155
+ pos = lcTitle.indexOf(queries[0]);
156
+ if (pos != -1) {
157
+ result.title = hltSubstring(result.title, pos, queries[0].length);
158
+ }
159
+
160
+ result.namespace = result.namespace.replace(regexps[0], highlighters[0]);
161
+ for (var i=1, l = regexps.length; i < l; i++) {
162
+ result.title = result.title.replace(regexps[i], highlighters[i]);
163
+ result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
164
+ };
165
+ return result;
166
+ }
167
+
168
+ function createResult(info) {
169
+ var result = {};
170
+ result.title = info[0];
171
+ result.namespace = info[1];
172
+ result.path = info[2];
173
+ result.params = info[3];
174
+ result.snippet = info[4];
175
+ result.badge = info[6];
176
+ return result;
177
+ }
178
+
179
+ /* ----- Searching ------ */
180
+ function performSearch(data, regexps, queries, highlighters, state) {
181
+ var searchIndex = data.searchIndex;
182
+ var longSearchIndex = data.longSearchIndex;
183
+ var info = data.info;
184
+ var result = [];
185
+ var i = state.from;
186
+ var l = searchIndex.length;
187
+ var togo = CHUNK_SIZE;
188
+ var matchFunc, hltFunc;
189
+
190
+ while (state.pass < 4 && state.limit > 0 && togo > 0) {
191
+ if (state.pass == 0) {
192
+ matchFunc = matchPassBeginning;
193
+ hltFunc = highlightQuery;
194
+ } else if (state.pass == 1) {
195
+ matchFunc = matchPassLongIndex;
196
+ hltFunc = highlightQuery;
197
+ } else if (state.pass == 2) {
198
+ matchFunc = matchPassContains;
199
+ hltFunc = highlightQuery;
200
+ } else if (state.pass == 3) {
201
+ matchFunc = matchPassRegexp;
202
+ hltFunc = highlightRegexp;
203
+ }
204
+
205
+ for (; togo > 0 && i < l && state.limit > 0; i++, togo--) {
206
+ if (info[i].n == state.n) continue;
207
+ if (matchFunc(searchIndex[i], longSearchIndex[i], queries, regexps)) {
208
+ info[i].n = state.n;
209
+ result.push(hltFunc(info[i], queries, regexps, highlighters));
210
+ state.limit--;
211
+ }
212
+ };
213
+ if (searchIndex.length <= i) {
214
+ state.pass++;
215
+ i = state.from = 0;
216
+ } else {
217
+ state.from = i;
218
+ }
219
+ }
220
+ return result;
221
+ }
222
+
223
+ function triggerResults(results, isLast) {
224
+ this.handlers.forEach(function(fn) {
225
+ fn.call(this, results, isLast)
226
+ });
227
+ }
228
+ }
229
+