adalog 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +29 -0
  3. data/Gemfile +3 -0
  4. data/LICENSE.md +27 -0
  5. data/README.md +144 -0
  6. data/Rakefile +7 -0
  7. data/adalog.gemspec +27 -0
  8. data/lib/adalog/active_record_repo.rb +62 -0
  9. data/lib/adalog/configuration.rb +46 -0
  10. data/lib/adalog/entry.rb +85 -0
  11. data/lib/adalog/in_memory_repo.rb +38 -0
  12. data/lib/adalog/pstore_repo.rb +62 -0
  13. data/lib/adalog/simple_logging_adapter.rb +21 -0
  14. data/lib/adalog/version.rb +3 -0
  15. data/lib/adalog/web/public/javascripts/adalog.js +2 -0
  16. data/lib/adalog/web/public/javascripts/entries-list.js +82 -0
  17. data/lib/adalog/web/public/javascripts/vanilla-js.js +103 -0
  18. data/lib/adalog/web/public/stylesheets/adalog.css +55 -0
  19. data/lib/adalog/web/public/stylesheets/entries-list.css +99 -0
  20. data/lib/adalog/web/public/stylesheets/pure/buttons-min.css +7 -0
  21. data/lib/adalog/web/public/stylesheets/pure/forms-min.css +7 -0
  22. data/lib/adalog/web/public/stylesheets/pure/menus-min.css +7 -0
  23. data/lib/adalog/web/public/stylesheets/pure/pure-base-min.css +11 -0
  24. data/lib/adalog/web/public/stylesheets/pure/pure-grids-responsive-min.css +7 -0
  25. data/lib/adalog/web/public/stylesheets/pure/tables-min.css +7 -0
  26. data/lib/adalog/web/views/adalog.html.erb +24 -0
  27. data/lib/adalog/web/views/index.html.erb +37 -0
  28. data/lib/adalog/web.rb +103 -0
  29. data/lib/adalog.rb +60 -0
  30. data/test/data/simple.yml +28 -0
  31. data/test/test_helper.rb +35 -0
  32. data/test/unit/active_record_repo.rb +9 -0
  33. data/test/unit/configuration_test.rb +62 -0
  34. data/test/unit/entry_test.rb +138 -0
  35. data/test/unit/in_memory_repo_test.rb +9 -0
  36. data/test/unit/pstore_repo_test.rb +9 -0
  37. metadata +175 -0
@@ -0,0 +1,103 @@
1
+ adalog.vanillaJS = (function() {
2
+
3
+ // Pure JS version of a jQuery-esque ready function.
4
+ var docReady = function docReady(callback) {
5
+ if("complete" === document.readyState || "interactive" === document.readyState) {
6
+ callback();
7
+ } else {
8
+ document.addEventListener("DOMContentLoaded", callback);
9
+ }
10
+ };
11
+
12
+ // Why does the phrase "array-like object" even exist?!
13
+ var justGiveMeAnArrayJavaScriptYouPatheticExcuseForALanguage =
14
+ function justGiveMeAnArrayJavaScriptYouPatheticExcuseForALanguage(arrayLike, force, defaultVal) {
15
+ force = !!force;
16
+ defaultVal = defaultVal || [];
17
+ if(force) {
18
+ try {
19
+ return Array.prototype.slice.call(arrayLike);
20
+ } catch(exc) {
21
+ return defaultVal;
22
+ }
23
+ } else {
24
+ return Array.prototype.slice.call(arrayLike);
25
+ }
26
+ };
27
+ var convertArrayLike = justGiveMeAnArrayJavaScriptYouPatheticExcuseForALanguage;
28
+
29
+
30
+ var eltHide = function eltHide(elt) {
31
+ elt.style.display = 'none';
32
+ };
33
+
34
+
35
+ var eltShow = function eltShow(elt, display) {
36
+ elt.style.display = display;
37
+ };
38
+
39
+
40
+ var eltShowBlock = function eltShowBlock(elt) {
41
+ eltShow(elt, 'block');
42
+ };
43
+
44
+
45
+ var eltShowInline = function eltShowInline(elt) {
46
+ eltShow(elt, 'inline');
47
+ };
48
+
49
+
50
+ var eltShowILBlock = function eltShowILBlock(elt) {
51
+ eltShow(elt, 'inline-block');
52
+ };
53
+
54
+
55
+ var eltDisplayToggle = function eltDisplayToggle(elt, revealAsDisplay) {
56
+ var currentDisplay = (window.getComputedStyle(elt, null) || elt.currentStyle).display;
57
+ if('none' === currentDisplay) {
58
+ elt.style.display = revealAsDisplay;
59
+ } else {
60
+ elt.style.display = 'none';
61
+ }
62
+ };
63
+
64
+
65
+ var findSiblingByClassName = function findSiblingByClassName(elt, className) {
66
+ return convertArrayLike(elt.parentNode.children).reduce(function(acc, child) {
67
+ if(!!acc) {
68
+ return acc;
69
+ } else if(child.classList.contains(className)) {
70
+ return child;
71
+ } else {
72
+ return false;
73
+ }
74
+ }, false);
75
+ };
76
+
77
+
78
+ var findAllSiblingsByClassName = function findAllSiblingsByClassName(elt, className) {
79
+ return convertArrayLike(elt.parentNode.children).filter(function(child) {
80
+ return child.classList.contains(className);
81
+ });
82
+ };
83
+
84
+
85
+ return {
86
+ // General purpose / not yet categorized
87
+ 'convertArrayLike': justGiveMeAnArrayJavaScriptYouPatheticExcuseForALanguage,
88
+ 'docReady' : docReady,
89
+
90
+ // Finders and element queries
91
+ 'findSiblingByClassName' : findSiblingByClassName,
92
+ 'findAllSiblingsByClassName' : findAllSiblingsByClassName,
93
+
94
+ // Element visibility
95
+ 'eltHide' : eltHide,
96
+ 'eltShow' : eltShow,
97
+ 'eltShowBlock' : eltShowBlock,
98
+ 'eltShowILBlock' : eltShowILBlock,
99
+ 'eltShowInline' : eltShowInline,
100
+ 'eltDisplayToggle' : eltDisplayToggle
101
+ };
102
+
103
+ })();
@@ -0,0 +1,55 @@
1
+ /******************************************************************************
2
+ SECTION: COMMON FONT SIZES
3
+ ******************************************************************************/
4
+ .fsize-std {
5
+ font-size: 16px !important;
6
+ }
7
+ .fsize-small {
8
+ font-size: 12px !important;
9
+ }
10
+ .fsize-tiny {
11
+ font-size: 10px !important;
12
+ }
13
+
14
+
15
+ /******************************************************************************
16
+ SECTION: DISPLAY AND POSITIONING SINGULAR CLASSES
17
+ ******************************************************************************/
18
+ .ilblock {
19
+ display: inline-block !important;
20
+ }
21
+ .block {
22
+ display: block !important;
23
+ }
24
+
25
+ .pos-rel {
26
+ position: relative;
27
+ }
28
+
29
+ .fl-left {
30
+ float: left;
31
+ }
32
+ .fl-right {
33
+ float: right;
34
+ }
35
+
36
+ .abs-top-right {
37
+ position: absolute;
38
+ top : 0;
39
+ right : 0;
40
+ }
41
+ .abs-top-left {
42
+ position: absolute;
43
+ top : 0;
44
+ left : 0;
45
+ }
46
+ .abs-bottom-left {
47
+ position: absolute;
48
+ bottom : 0;
49
+ left : 0;
50
+ }
51
+ .abs-bottom-right {
52
+ position: absolute;
53
+ bottom : 0;
54
+ right : 0;
55
+ }
@@ -0,0 +1,99 @@
1
+ @media (max-width: 1200px) {
2
+ .entries-list {
3
+ width : 100%;
4
+ padding : 4px;
5
+ }
6
+ }
7
+
8
+ @media (min-width: 1200px) {
9
+ .entries-list {
10
+ width: 75%;
11
+ }
12
+ }
13
+
14
+ .entries-list {
15
+ box-sizing : border-box;
16
+ margin-left : auto;
17
+ margin-right: auto;
18
+ text-align : center;
19
+ }
20
+ .entries-list div:after {
21
+ content : "";
22
+ display : table;
23
+ }
24
+
25
+ .entries-list .entry {
26
+ position : relative;
27
+ box-sizing : border-box;
28
+ border : 1px solid #ddd;
29
+ border-radius : 4px;
30
+ margin-bottom : 8px;
31
+ text-align : left;
32
+ font-size : 0;
33
+ cursor : pointer;
34
+ }
35
+ .entries-list .entry * {
36
+ font-size: 16px;
37
+ }
38
+
39
+ .entries-list .title-and-message {
40
+ font-size : 16px;
41
+ }
42
+
43
+ .entries-list .title {
44
+ font-weight : bold;
45
+ padding : 8px;
46
+ text-align: left;
47
+ }
48
+ @media (min-width: 768px) {
49
+ .entries-list .title {
50
+ display: inline-block;
51
+ }
52
+ }
53
+
54
+ .entries-list .message {
55
+ padding : 8px;
56
+ text-align: left;
57
+ }
58
+ @media (min-width: 768px) {
59
+ .entries-list .message {
60
+ display: inline-block;
61
+ }
62
+ }
63
+
64
+ .entries-list .timestamp {
65
+ font-size : 16px;
66
+ font-style: italic;
67
+ text-align: left;
68
+ padding : 8px;
69
+ }
70
+ @media (min-width: 768px) {
71
+ .entries-list .timestamp {
72
+ text-align: right;
73
+ }
74
+ }
75
+
76
+ .entries-list .details {
77
+ font-size : 12px;
78
+ padding : 0 8px 0px;
79
+ text-align: left;
80
+ }
81
+
82
+ .entries-list .details pre {
83
+ font-size : 12px;
84
+ background-color: #ddd;
85
+ border-radius : 4px;
86
+ padding : 4px;
87
+ margin : 0 0 4px;
88
+ }
89
+
90
+ .entries-list button.button-small {
91
+ font-size: 12px;
92
+ }
93
+
94
+ .entries-list .details-toggle-note {
95
+ display : block;
96
+ text-align : right;
97
+ margin : 0 0 4px;
98
+ color : #999;
99
+ }
@@ -0,0 +1,7 @@
1
+ /*!
2
+ Pure v0.6.0
3
+ Copyright 2014 Yahoo! Inc. All rights reserved.
4
+ Licensed under the BSD License.
5
+ https://github.com/yahoo/pure/blob/master/LICENSE.md
6
+ */
7
+ .pure-button{display:inline-block;zoom:1;line-height:normal;white-space:nowrap;vertical-align:middle;text-align:center;cursor:pointer;-webkit-user-drag:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.pure-button::-moz-focus-inner{padding:0;border:0}.pure-button{font-family:inherit;font-size:100%;padding:.5em 1em;color:#444;color:rgba(0,0,0,.8);border:1px solid #999;border:0 rgba(0,0,0,0);background-color:#E6E6E6;text-decoration:none;border-radius:2px}.pure-button-hover,.pure-button:hover,.pure-button:focus{filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#1a000000', GradientType=0);background-image:-webkit-gradient(linear,0 0,0 100%,from(transparent),color-stop(40%,rgba(0,0,0,.05)),to(rgba(0,0,0,.1)));background-image:-webkit-linear-gradient(transparent,rgba(0,0,0,.05) 40%,rgba(0,0,0,.1));background-image:-moz-linear-gradient(top,rgba(0,0,0,.05) 0,rgba(0,0,0,.1));background-image:-o-linear-gradient(transparent,rgba(0,0,0,.05) 40%,rgba(0,0,0,.1));background-image:linear-gradient(transparent,rgba(0,0,0,.05) 40%,rgba(0,0,0,.1))}.pure-button:focus{outline:0}.pure-button-active,.pure-button:active{box-shadow:0 0 0 1px rgba(0,0,0,.15) inset,0 0 6px rgba(0,0,0,.2) inset;border-color:#000\9}.pure-button[disabled],.pure-button-disabled,.pure-button-disabled:hover,.pure-button-disabled:focus,.pure-button-disabled:active{border:0;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);filter:alpha(opacity=40);-khtml-opacity:.4;-moz-opacity:.4;opacity:.4;cursor:not-allowed;box-shadow:none}.pure-button-hidden{display:none}.pure-button::-moz-focus-inner{padding:0;border:0}.pure-button-primary,.pure-button-selected,a.pure-button-primary,a.pure-button-selected{background-color:#0078e7;color:#fff}
@@ -0,0 +1,7 @@
1
+ /*!
2
+ Pure v0.6.0
3
+ Copyright 2014 Yahoo! Inc. All rights reserved.
4
+ Licensed under the BSD License.
5
+ https://github.com/yahoo/pure/blob/master/LICENSE.md
6
+ */
7
+ .pure-form input[type=text],.pure-form input[type=password],.pure-form input[type=email],.pure-form input[type=url],.pure-form input[type=date],.pure-form input[type=month],.pure-form input[type=time],.pure-form input[type=datetime],.pure-form input[type=datetime-local],.pure-form input[type=week],.pure-form input[type=number],.pure-form input[type=search],.pure-form input[type=tel],.pure-form input[type=color],.pure-form select,.pure-form textarea{padding:.5em .6em;display:inline-block;border:1px solid #ccc;box-shadow:inset 0 1px 3px #ddd;border-radius:4px;vertical-align:middle;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.pure-form input:not([type]){padding:.5em .6em;display:inline-block;border:1px solid #ccc;box-shadow:inset 0 1px 3px #ddd;border-radius:4px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.pure-form input[type=color]{padding:.2em .5em}.pure-form input[type=text]:focus,.pure-form input[type=password]:focus,.pure-form input[type=email]:focus,.pure-form input[type=url]:focus,.pure-form input[type=date]:focus,.pure-form input[type=month]:focus,.pure-form input[type=time]:focus,.pure-form input[type=datetime]:focus,.pure-form input[type=datetime-local]:focus,.pure-form input[type=week]:focus,.pure-form input[type=number]:focus,.pure-form input[type=search]:focus,.pure-form input[type=tel]:focus,.pure-form input[type=color]:focus,.pure-form select:focus,.pure-form textarea:focus{outline:0;border-color:#129FEA}.pure-form input:not([type]):focus{outline:0;border-color:#129FEA}.pure-form input[type=file]:focus,.pure-form input[type=radio]:focus,.pure-form input[type=checkbox]:focus{outline:thin solid #129FEA;outline:1px auto #129FEA}.pure-form .pure-checkbox,.pure-form .pure-radio{margin:.5em 0;display:block}.pure-form input[type=text][disabled],.pure-form input[type=password][disabled],.pure-form input[type=email][disabled],.pure-form input[type=url][disabled],.pure-form input[type=date][disabled],.pure-form input[type=month][disabled],.pure-form input[type=time][disabled],.pure-form input[type=datetime][disabled],.pure-form input[type=datetime-local][disabled],.pure-form input[type=week][disabled],.pure-form input[type=number][disabled],.pure-form input[type=search][disabled],.pure-form input[type=tel][disabled],.pure-form input[type=color][disabled],.pure-form select[disabled],.pure-form textarea[disabled]{cursor:not-allowed;background-color:#eaeded;color:#cad2d3}.pure-form input:not([type])[disabled]{cursor:not-allowed;background-color:#eaeded;color:#cad2d3}.pure-form input[readonly],.pure-form select[readonly],.pure-form textarea[readonly]{background-color:#eee;color:#777;border-color:#ccc}.pure-form input:focus:invalid,.pure-form textarea:focus:invalid,.pure-form select:focus:invalid{color:#b94a48;border-color:#e9322d}.pure-form input[type=file]:focus:invalid:focus,.pure-form input[type=radio]:focus:invalid:focus,.pure-form input[type=checkbox]:focus:invalid:focus{outline-color:#e9322d}.pure-form select{height:2.25em;border:1px solid #ccc;background-color:#fff}.pure-form select[multiple]{height:auto}.pure-form label{margin:.5em 0 .2em}.pure-form fieldset{margin:0;padding:.35em 0 .75em;border:0}.pure-form legend{display:block;width:100%;padding:.3em 0;margin-bottom:.3em;color:#333;border-bottom:1px solid #e5e5e5}.pure-form-stacked input[type=text],.pure-form-stacked input[type=password],.pure-form-stacked input[type=email],.pure-form-stacked input[type=url],.pure-form-stacked input[type=date],.pure-form-stacked input[type=month],.pure-form-stacked input[type=time],.pure-form-stacked input[type=datetime],.pure-form-stacked input[type=datetime-local],.pure-form-stacked input[type=week],.pure-form-stacked input[type=number],.pure-form-stacked input[type=search],.pure-form-stacked input[type=tel],.pure-form-stacked input[type=color],.pure-form-stacked input[type=file],.pure-form-stacked select,.pure-form-stacked label,.pure-form-stacked textarea{display:block;margin:.25em 0}.pure-form-stacked input:not([type]){display:block;margin:.25em 0}.pure-form-aligned input,.pure-form-aligned textarea,.pure-form-aligned select,.pure-form-aligned .pure-help-inline,.pure-form-message-inline{display:inline-block;*display:inline;*zoom:1;vertical-align:middle}.pure-form-aligned textarea{vertical-align:top}.pure-form-aligned .pure-control-group{margin-bottom:.5em}.pure-form-aligned .pure-control-group label{text-align:right;display:inline-block;vertical-align:middle;width:10em;margin:0 1em 0 0}.pure-form-aligned .pure-controls{margin:1.5em 0 0 11em}.pure-form input.pure-input-rounded,.pure-form .pure-input-rounded{border-radius:2em;padding:.5em 1em}.pure-form .pure-group fieldset{margin-bottom:10px}.pure-form .pure-group input,.pure-form .pure-group textarea{display:block;padding:10px;margin:0 0 -1px;border-radius:0;position:relative;top:-1px}.pure-form .pure-group input:focus,.pure-form .pure-group textarea:focus{z-index:3}.pure-form .pure-group input:first-child,.pure-form .pure-group textarea:first-child{top:1px;border-radius:4px 4px 0 0;margin:0}.pure-form .pure-group input:first-child:last-child,.pure-form .pure-group textarea:first-child:last-child{top:1px;border-radius:4px;margin:0}.pure-form .pure-group input:last-child,.pure-form .pure-group textarea:last-child{top:-2px;border-radius:0 0 4px 4px;margin:0}.pure-form .pure-group button{margin:.35em 0}.pure-form .pure-input-1{width:100%}.pure-form .pure-input-2-3{width:66%}.pure-form .pure-input-1-2{width:50%}.pure-form .pure-input-1-3{width:33%}.pure-form .pure-input-1-4{width:25%}.pure-form .pure-help-inline,.pure-form-message-inline{display:inline-block;padding-left:.3em;color:#666;vertical-align:middle;font-size:.875em}.pure-form-message{display:block;color:#666;font-size:.875em}@media only screen and (max-width :480px){.pure-form button[type=submit]{margin:.7em 0 0}.pure-form input:not([type]),.pure-form input[type=text],.pure-form input[type=password],.pure-form input[type=email],.pure-form input[type=url],.pure-form input[type=date],.pure-form input[type=month],.pure-form input[type=time],.pure-form input[type=datetime],.pure-form input[type=datetime-local],.pure-form input[type=week],.pure-form input[type=number],.pure-form input[type=search],.pure-form input[type=tel],.pure-form input[type=color],.pure-form label{margin-bottom:.3em;display:block}.pure-group input:not([type]),.pure-group input[type=text],.pure-group input[type=password],.pure-group input[type=email],.pure-group input[type=url],.pure-group input[type=date],.pure-group input[type=month],.pure-group input[type=time],.pure-group input[type=datetime],.pure-group input[type=datetime-local],.pure-group input[type=week],.pure-group input[type=number],.pure-group input[type=search],.pure-group input[type=tel],.pure-group input[type=color]{margin-bottom:0}.pure-form-aligned .pure-control-group label{margin-bottom:.3em;text-align:left;display:block;width:100%}.pure-form-aligned .pure-controls{margin:1.5em 0 0}.pure-form .pure-help-inline,.pure-form-message-inline,.pure-form-message{display:block;font-size:.75em;padding:.2em 0 .8em}}
@@ -0,0 +1,7 @@
1
+ /*!
2
+ Pure v0.6.0
3
+ Copyright 2014 Yahoo! Inc. All rights reserved.
4
+ Licensed under the BSD License.
5
+ https://github.com/yahoo/pure/blob/master/LICENSE.md
6
+ */
7
+ .pure-menu{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.pure-menu-fixed{position:fixed;left:0;top:0;z-index:3}.pure-menu-list,.pure-menu-item{position:relative}.pure-menu-list{list-style:none;margin:0;padding:0}.pure-menu-item{padding:0;margin:0;height:100%}.pure-menu-link,.pure-menu-heading{display:block;text-decoration:none;white-space:nowrap}.pure-menu-horizontal{width:100%;white-space:nowrap}.pure-menu-horizontal .pure-menu-list{display:inline-block}.pure-menu-horizontal .pure-menu-item,.pure-menu-horizontal .pure-menu-heading,.pure-menu-horizontal .pure-menu-separator{display:inline-block;*display:inline;zoom:1;vertical-align:middle}.pure-menu-item .pure-menu-item{display:block}.pure-menu-children{display:none;position:absolute;left:100%;top:0;margin:0;padding:0;z-index:3}.pure-menu-horizontal .pure-menu-children{left:0;top:auto;width:inherit}.pure-menu-allow-hover:hover>.pure-menu-children,.pure-menu-active>.pure-menu-children{display:block;position:absolute}.pure-menu-has-children>.pure-menu-link:after{padding-left:.5em;content:"\25B8";font-size:small}.pure-menu-horizontal .pure-menu-has-children>.pure-menu-link:after{content:"\25BE"}.pure-menu-scrollable{overflow-y:scroll;overflow-x:hidden}.pure-menu-scrollable .pure-menu-list{display:block}.pure-menu-horizontal.pure-menu-scrollable .pure-menu-list{display:inline-block}.pure-menu-horizontal.pure-menu-scrollable{white-space:nowrap;overflow-y:hidden;overflow-x:auto;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;padding:.5em 0}.pure-menu-horizontal.pure-menu-scrollable::-webkit-scrollbar{display:none}.pure-menu-separator{background-color:#ccc;height:1px;margin:.3em 0}.pure-menu-horizontal .pure-menu-separator{width:1px;height:1.3em;margin:0 .3em}.pure-menu-heading{text-transform:uppercase;color:#565d64}.pure-menu-link{color:#777}.pure-menu-children{background-color:#fff}.pure-menu-link,.pure-menu-disabled,.pure-menu-heading{padding:.5em 1em}.pure-menu-disabled{opacity:.5}.pure-menu-disabled .pure-menu-link:hover{background-color:transparent}.pure-menu-active>.pure-menu-link,.pure-menu-link:hover,.pure-menu-link:focus{background-color:#eee}.pure-menu-selected .pure-menu-link,.pure-menu-selected .pure-menu-link:visited{color:#000}
@@ -0,0 +1,11 @@
1
+ /*!
2
+ Pure v0.6.0
3
+ Copyright 2014 Yahoo! Inc. All rights reserved.
4
+ Licensed under the BSD License.
5
+ https://github.com/yahoo/pure/blob/master/LICENSE.md
6
+ */
7
+ /*!
8
+ normalize.css v^3.0 | MIT License | git.io/normalize
9
+ Copyright (c) Nicolas Gallagher and Jonathan Neal
10
+ */
11
+ /*! normalize.css v3.0.2 | MIT License | git.io/normalize */html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto}input[type=search]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:700}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}.hidden,[hidden]{display:none!important}.pure-img{max-width:100%;height:auto;display:block}
@@ -0,0 +1,7 @@
1
+ /*!
2
+ Pure v0.6.0
3
+ Copyright 2014 Yahoo! Inc. All rights reserved.
4
+ Licensed under the BSD License.
5
+ https://github.com/yahoo/pure/blob/master/LICENSE.md
6
+ */
7
+ @media screen and (min-width:35.5em){.pure-u-sm-1,.pure-u-sm-1-1,.pure-u-sm-1-2,.pure-u-sm-1-3,.pure-u-sm-2-3,.pure-u-sm-1-4,.pure-u-sm-3-4,.pure-u-sm-1-5,.pure-u-sm-2-5,.pure-u-sm-3-5,.pure-u-sm-4-5,.pure-u-sm-5-5,.pure-u-sm-1-6,.pure-u-sm-5-6,.pure-u-sm-1-8,.pure-u-sm-3-8,.pure-u-sm-5-8,.pure-u-sm-7-8,.pure-u-sm-1-12,.pure-u-sm-5-12,.pure-u-sm-7-12,.pure-u-sm-11-12,.pure-u-sm-1-24,.pure-u-sm-2-24,.pure-u-sm-3-24,.pure-u-sm-4-24,.pure-u-sm-5-24,.pure-u-sm-6-24,.pure-u-sm-7-24,.pure-u-sm-8-24,.pure-u-sm-9-24,.pure-u-sm-10-24,.pure-u-sm-11-24,.pure-u-sm-12-24,.pure-u-sm-13-24,.pure-u-sm-14-24,.pure-u-sm-15-24,.pure-u-sm-16-24,.pure-u-sm-17-24,.pure-u-sm-18-24,.pure-u-sm-19-24,.pure-u-sm-20-24,.pure-u-sm-21-24,.pure-u-sm-22-24,.pure-u-sm-23-24,.pure-u-sm-24-24{display:inline-block;*display:inline;zoom:1;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-u-sm-1-24{width:4.1667%;*width:4.1357%}.pure-u-sm-1-12,.pure-u-sm-2-24{width:8.3333%;*width:8.3023%}.pure-u-sm-1-8,.pure-u-sm-3-24{width:12.5%;*width:12.469%}.pure-u-sm-1-6,.pure-u-sm-4-24{width:16.6667%;*width:16.6357%}.pure-u-sm-1-5{width:20%;*width:19.969%}.pure-u-sm-5-24{width:20.8333%;*width:20.8023%}.pure-u-sm-1-4,.pure-u-sm-6-24{width:25%;*width:24.969%}.pure-u-sm-7-24{width:29.1667%;*width:29.1357%}.pure-u-sm-1-3,.pure-u-sm-8-24{width:33.3333%;*width:33.3023%}.pure-u-sm-3-8,.pure-u-sm-9-24{width:37.5%;*width:37.469%}.pure-u-sm-2-5{width:40%;*width:39.969%}.pure-u-sm-5-12,.pure-u-sm-10-24{width:41.6667%;*width:41.6357%}.pure-u-sm-11-24{width:45.8333%;*width:45.8023%}.pure-u-sm-1-2,.pure-u-sm-12-24{width:50%;*width:49.969%}.pure-u-sm-13-24{width:54.1667%;*width:54.1357%}.pure-u-sm-7-12,.pure-u-sm-14-24{width:58.3333%;*width:58.3023%}.pure-u-sm-3-5{width:60%;*width:59.969%}.pure-u-sm-5-8,.pure-u-sm-15-24{width:62.5%;*width:62.469%}.pure-u-sm-2-3,.pure-u-sm-16-24{width:66.6667%;*width:66.6357%}.pure-u-sm-17-24{width:70.8333%;*width:70.8023%}.pure-u-sm-3-4,.pure-u-sm-18-24{width:75%;*width:74.969%}.pure-u-sm-19-24{width:79.1667%;*width:79.1357%}.pure-u-sm-4-5{width:80%;*width:79.969%}.pure-u-sm-5-6,.pure-u-sm-20-24{width:83.3333%;*width:83.3023%}.pure-u-sm-7-8,.pure-u-sm-21-24{width:87.5%;*width:87.469%}.pure-u-sm-11-12,.pure-u-sm-22-24{width:91.6667%;*width:91.6357%}.pure-u-sm-23-24{width:95.8333%;*width:95.8023%}.pure-u-sm-1,.pure-u-sm-1-1,.pure-u-sm-5-5,.pure-u-sm-24-24{width:100%}}@media screen and (min-width:48em){.pure-u-md-1,.pure-u-md-1-1,.pure-u-md-1-2,.pure-u-md-1-3,.pure-u-md-2-3,.pure-u-md-1-4,.pure-u-md-3-4,.pure-u-md-1-5,.pure-u-md-2-5,.pure-u-md-3-5,.pure-u-md-4-5,.pure-u-md-5-5,.pure-u-md-1-6,.pure-u-md-5-6,.pure-u-md-1-8,.pure-u-md-3-8,.pure-u-md-5-8,.pure-u-md-7-8,.pure-u-md-1-12,.pure-u-md-5-12,.pure-u-md-7-12,.pure-u-md-11-12,.pure-u-md-1-24,.pure-u-md-2-24,.pure-u-md-3-24,.pure-u-md-4-24,.pure-u-md-5-24,.pure-u-md-6-24,.pure-u-md-7-24,.pure-u-md-8-24,.pure-u-md-9-24,.pure-u-md-10-24,.pure-u-md-11-24,.pure-u-md-12-24,.pure-u-md-13-24,.pure-u-md-14-24,.pure-u-md-15-24,.pure-u-md-16-24,.pure-u-md-17-24,.pure-u-md-18-24,.pure-u-md-19-24,.pure-u-md-20-24,.pure-u-md-21-24,.pure-u-md-22-24,.pure-u-md-23-24,.pure-u-md-24-24{display:inline-block;*display:inline;zoom:1;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-u-md-1-24{width:4.1667%;*width:4.1357%}.pure-u-md-1-12,.pure-u-md-2-24{width:8.3333%;*width:8.3023%}.pure-u-md-1-8,.pure-u-md-3-24{width:12.5%;*width:12.469%}.pure-u-md-1-6,.pure-u-md-4-24{width:16.6667%;*width:16.6357%}.pure-u-md-1-5{width:20%;*width:19.969%}.pure-u-md-5-24{width:20.8333%;*width:20.8023%}.pure-u-md-1-4,.pure-u-md-6-24{width:25%;*width:24.969%}.pure-u-md-7-24{width:29.1667%;*width:29.1357%}.pure-u-md-1-3,.pure-u-md-8-24{width:33.3333%;*width:33.3023%}.pure-u-md-3-8,.pure-u-md-9-24{width:37.5%;*width:37.469%}.pure-u-md-2-5{width:40%;*width:39.969%}.pure-u-md-5-12,.pure-u-md-10-24{width:41.6667%;*width:41.6357%}.pure-u-md-11-24{width:45.8333%;*width:45.8023%}.pure-u-md-1-2,.pure-u-md-12-24{width:50%;*width:49.969%}.pure-u-md-13-24{width:54.1667%;*width:54.1357%}.pure-u-md-7-12,.pure-u-md-14-24{width:58.3333%;*width:58.3023%}.pure-u-md-3-5{width:60%;*width:59.969%}.pure-u-md-5-8,.pure-u-md-15-24{width:62.5%;*width:62.469%}.pure-u-md-2-3,.pure-u-md-16-24{width:66.6667%;*width:66.6357%}.pure-u-md-17-24{width:70.8333%;*width:70.8023%}.pure-u-md-3-4,.pure-u-md-18-24{width:75%;*width:74.969%}.pure-u-md-19-24{width:79.1667%;*width:79.1357%}.pure-u-md-4-5{width:80%;*width:79.969%}.pure-u-md-5-6,.pure-u-md-20-24{width:83.3333%;*width:83.3023%}.pure-u-md-7-8,.pure-u-md-21-24{width:87.5%;*width:87.469%}.pure-u-md-11-12,.pure-u-md-22-24{width:91.6667%;*width:91.6357%}.pure-u-md-23-24{width:95.8333%;*width:95.8023%}.pure-u-md-1,.pure-u-md-1-1,.pure-u-md-5-5,.pure-u-md-24-24{width:100%}}@media screen and (min-width:64em){.pure-u-lg-1,.pure-u-lg-1-1,.pure-u-lg-1-2,.pure-u-lg-1-3,.pure-u-lg-2-3,.pure-u-lg-1-4,.pure-u-lg-3-4,.pure-u-lg-1-5,.pure-u-lg-2-5,.pure-u-lg-3-5,.pure-u-lg-4-5,.pure-u-lg-5-5,.pure-u-lg-1-6,.pure-u-lg-5-6,.pure-u-lg-1-8,.pure-u-lg-3-8,.pure-u-lg-5-8,.pure-u-lg-7-8,.pure-u-lg-1-12,.pure-u-lg-5-12,.pure-u-lg-7-12,.pure-u-lg-11-12,.pure-u-lg-1-24,.pure-u-lg-2-24,.pure-u-lg-3-24,.pure-u-lg-4-24,.pure-u-lg-5-24,.pure-u-lg-6-24,.pure-u-lg-7-24,.pure-u-lg-8-24,.pure-u-lg-9-24,.pure-u-lg-10-24,.pure-u-lg-11-24,.pure-u-lg-12-24,.pure-u-lg-13-24,.pure-u-lg-14-24,.pure-u-lg-15-24,.pure-u-lg-16-24,.pure-u-lg-17-24,.pure-u-lg-18-24,.pure-u-lg-19-24,.pure-u-lg-20-24,.pure-u-lg-21-24,.pure-u-lg-22-24,.pure-u-lg-23-24,.pure-u-lg-24-24{display:inline-block;*display:inline;zoom:1;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-u-lg-1-24{width:4.1667%;*width:4.1357%}.pure-u-lg-1-12,.pure-u-lg-2-24{width:8.3333%;*width:8.3023%}.pure-u-lg-1-8,.pure-u-lg-3-24{width:12.5%;*width:12.469%}.pure-u-lg-1-6,.pure-u-lg-4-24{width:16.6667%;*width:16.6357%}.pure-u-lg-1-5{width:20%;*width:19.969%}.pure-u-lg-5-24{width:20.8333%;*width:20.8023%}.pure-u-lg-1-4,.pure-u-lg-6-24{width:25%;*width:24.969%}.pure-u-lg-7-24{width:29.1667%;*width:29.1357%}.pure-u-lg-1-3,.pure-u-lg-8-24{width:33.3333%;*width:33.3023%}.pure-u-lg-3-8,.pure-u-lg-9-24{width:37.5%;*width:37.469%}.pure-u-lg-2-5{width:40%;*width:39.969%}.pure-u-lg-5-12,.pure-u-lg-10-24{width:41.6667%;*width:41.6357%}.pure-u-lg-11-24{width:45.8333%;*width:45.8023%}.pure-u-lg-1-2,.pure-u-lg-12-24{width:50%;*width:49.969%}.pure-u-lg-13-24{width:54.1667%;*width:54.1357%}.pure-u-lg-7-12,.pure-u-lg-14-24{width:58.3333%;*width:58.3023%}.pure-u-lg-3-5{width:60%;*width:59.969%}.pure-u-lg-5-8,.pure-u-lg-15-24{width:62.5%;*width:62.469%}.pure-u-lg-2-3,.pure-u-lg-16-24{width:66.6667%;*width:66.6357%}.pure-u-lg-17-24{width:70.8333%;*width:70.8023%}.pure-u-lg-3-4,.pure-u-lg-18-24{width:75%;*width:74.969%}.pure-u-lg-19-24{width:79.1667%;*width:79.1357%}.pure-u-lg-4-5{width:80%;*width:79.969%}.pure-u-lg-5-6,.pure-u-lg-20-24{width:83.3333%;*width:83.3023%}.pure-u-lg-7-8,.pure-u-lg-21-24{width:87.5%;*width:87.469%}.pure-u-lg-11-12,.pure-u-lg-22-24{width:91.6667%;*width:91.6357%}.pure-u-lg-23-24{width:95.8333%;*width:95.8023%}.pure-u-lg-1,.pure-u-lg-1-1,.pure-u-lg-5-5,.pure-u-lg-24-24{width:100%}}@media screen and (min-width:80em){.pure-u-xl-1,.pure-u-xl-1-1,.pure-u-xl-1-2,.pure-u-xl-1-3,.pure-u-xl-2-3,.pure-u-xl-1-4,.pure-u-xl-3-4,.pure-u-xl-1-5,.pure-u-xl-2-5,.pure-u-xl-3-5,.pure-u-xl-4-5,.pure-u-xl-5-5,.pure-u-xl-1-6,.pure-u-xl-5-6,.pure-u-xl-1-8,.pure-u-xl-3-8,.pure-u-xl-5-8,.pure-u-xl-7-8,.pure-u-xl-1-12,.pure-u-xl-5-12,.pure-u-xl-7-12,.pure-u-xl-11-12,.pure-u-xl-1-24,.pure-u-xl-2-24,.pure-u-xl-3-24,.pure-u-xl-4-24,.pure-u-xl-5-24,.pure-u-xl-6-24,.pure-u-xl-7-24,.pure-u-xl-8-24,.pure-u-xl-9-24,.pure-u-xl-10-24,.pure-u-xl-11-24,.pure-u-xl-12-24,.pure-u-xl-13-24,.pure-u-xl-14-24,.pure-u-xl-15-24,.pure-u-xl-16-24,.pure-u-xl-17-24,.pure-u-xl-18-24,.pure-u-xl-19-24,.pure-u-xl-20-24,.pure-u-xl-21-24,.pure-u-xl-22-24,.pure-u-xl-23-24,.pure-u-xl-24-24{display:inline-block;*display:inline;zoom:1;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-u-xl-1-24{width:4.1667%;*width:4.1357%}.pure-u-xl-1-12,.pure-u-xl-2-24{width:8.3333%;*width:8.3023%}.pure-u-xl-1-8,.pure-u-xl-3-24{width:12.5%;*width:12.469%}.pure-u-xl-1-6,.pure-u-xl-4-24{width:16.6667%;*width:16.6357%}.pure-u-xl-1-5{width:20%;*width:19.969%}.pure-u-xl-5-24{width:20.8333%;*width:20.8023%}.pure-u-xl-1-4,.pure-u-xl-6-24{width:25%;*width:24.969%}.pure-u-xl-7-24{width:29.1667%;*width:29.1357%}.pure-u-xl-1-3,.pure-u-xl-8-24{width:33.3333%;*width:33.3023%}.pure-u-xl-3-8,.pure-u-xl-9-24{width:37.5%;*width:37.469%}.pure-u-xl-2-5{width:40%;*width:39.969%}.pure-u-xl-5-12,.pure-u-xl-10-24{width:41.6667%;*width:41.6357%}.pure-u-xl-11-24{width:45.8333%;*width:45.8023%}.pure-u-xl-1-2,.pure-u-xl-12-24{width:50%;*width:49.969%}.pure-u-xl-13-24{width:54.1667%;*width:54.1357%}.pure-u-xl-7-12,.pure-u-xl-14-24{width:58.3333%;*width:58.3023%}.pure-u-xl-3-5{width:60%;*width:59.969%}.pure-u-xl-5-8,.pure-u-xl-15-24{width:62.5%;*width:62.469%}.pure-u-xl-2-3,.pure-u-xl-16-24{width:66.6667%;*width:66.6357%}.pure-u-xl-17-24{width:70.8333%;*width:70.8023%}.pure-u-xl-3-4,.pure-u-xl-18-24{width:75%;*width:74.969%}.pure-u-xl-19-24{width:79.1667%;*width:79.1357%}.pure-u-xl-4-5{width:80%;*width:79.969%}.pure-u-xl-5-6,.pure-u-xl-20-24{width:83.3333%;*width:83.3023%}.pure-u-xl-7-8,.pure-u-xl-21-24{width:87.5%;*width:87.469%}.pure-u-xl-11-12,.pure-u-xl-22-24{width:91.6667%;*width:91.6357%}.pure-u-xl-23-24{width:95.8333%;*width:95.8023%}.pure-u-xl-1,.pure-u-xl-1-1,.pure-u-xl-5-5,.pure-u-xl-24-24{width:100%}}
@@ -0,0 +1,7 @@
1
+ /*!
2
+ Pure v0.6.0
3
+ Copyright 2014 Yahoo! Inc. All rights reserved.
4
+ Licensed under the BSD License.
5
+ https://github.com/yahoo/pure/blob/master/LICENSE.md
6
+ */
7
+ .pure-table{border-collapse:collapse;border-spacing:0;empty-cells:show;border:1px solid #cbcbcb}.pure-table caption{color:#000;font:italic 85%/1 arial,sans-serif;padding:1em 0;text-align:center}.pure-table td,.pure-table th{border-left:1px solid #cbcbcb;border-width:0 0 0 1px;font-size:inherit;margin:0;overflow:visible;padding:.5em 1em}.pure-table td:first-child,.pure-table th:first-child{border-left-width:0}.pure-table thead{background-color:#e0e0e0;color:#000;text-align:left;vertical-align:bottom}.pure-table td{background-color:transparent}.pure-table-odd td{background-color:#f2f2f2}.pure-table-striped tr:nth-child(2n-1) td{background-color:#f2f2f2}.pure-table-bordered td{border-bottom:1px solid #cbcbcb}.pure-table-bordered tbody>tr:last-child>td{border-bottom-width:0}.pure-table-horizontal td,.pure-table-horizontal th{border-width:0 0 1px;border-bottom:1px solid #cbcbcb}.pure-table-horizontal tbody>tr:last-child>td{border-bottom-width:0}
@@ -0,0 +1,24 @@
1
+ <!doctype html>
2
+ <head>
3
+ <meta charset="utf-8">
4
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
5
+ <title>Simple Adapter Logging</title>
6
+ <meta name="description" content="">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1">
8
+
9
+ <link rel="stylesheet" href="<%= path_from_web_root('stylesheets/pure/pure-base-min.css') %>">
10
+ <link rel="stylesheet" href="<%= path_from_web_root('stylesheets/pure/pure-grids-responsive-min.css') %>">
11
+ <link rel="stylesheet" href="<%= path_from_web_root('stylesheets/pure/buttons-min.css') %>">
12
+ <link rel="stylesheet" href="<%= path_from_web_root('stylesheets/adalog.css') %>">
13
+ <link rel="stylesheet" href="<%= path_from_web_root('stylesheets/entries-list.css') %>">
14
+
15
+ <script src="<%= path_from_web_root('javascripts/adalog.js') %>"></script>
16
+ <script src="<%= path_from_web_root('javascripts/vanilla-js.js') %>"></script>
17
+ <script src="<%= path_from_web_root('javascripts/entries-list.js') %>"></script>
18
+ </head>
19
+ <body>
20
+
21
+ <%= yield %>
22
+
23
+ </body>
24
+ </html>
@@ -0,0 +1,37 @@
1
+ <script type="text/javascript">
2
+ adalog.entriesList.init();
3
+ </script>
4
+
5
+ <div class="entries-list">
6
+
7
+ <h1><%= heading %></h1>
8
+
9
+ <% @entries.each do |entry| %>
10
+
11
+ <div class="pure-g entry -toggle-details">
12
+ <div class="pure-u-1 pure-u-md-1-2">
13
+ <div class="title-and-message">
14
+ <div class="title"><%= entry.title %></div>
15
+ <div class="message"><%= entry.message %></div>
16
+ </div>
17
+ </div>
18
+ <div class="pure-u-1 pure-u-md-1-2">
19
+ <div class="timestamp"><%= humanize_time(entry.timestamp) %></div>
20
+ </div>
21
+ <div class="pure-u-1">
22
+ <div class="details">
23
+ <!-- <button class="pure-button button-small -show-details">Show Details</button> -->
24
+ <!-- <button class="pure-button button-small -hide-details">Hide Details</button> -->
25
+ <% unless entry.details_blank? %>
26
+ <pre class="-details-content -format-as-<%= entry.format %>"><%= entry.details.to_json %></pre>
27
+ <% end %>
28
+ <% unless entry.details_blank? %>
29
+ <div class="details-toggle-note fsize-tiny">Click to toggle details</div>
30
+ <% end %>
31
+ </div>
32
+ </div>
33
+ </div>
34
+
35
+ <% end %>
36
+
37
+ </div>
data/lib/adalog/web.rb ADDED
@@ -0,0 +1,103 @@
1
+ require 'sinatra/base'
2
+ module Adalog
3
+ class Web < Sinatra::Base
4
+
5
+ Config = Struct.new(:repo, :heading, :time_format)
6
+
7
+ attr_reader :config
8
+
9
+ def initialize(app = nil, web_options = {})
10
+ super(app)
11
+ options = default_options.merge(web_options)
12
+ @config = Adalog::Web::Config.new
13
+ determine_config_settings(config, options)
14
+ sinatra_class_option_overrides(options)
15
+ end
16
+
17
+
18
+ def determine_config_settings(config, options)
19
+ config.repo = options.fetch(:repo)
20
+ config.heading = options.fetch(:heading)
21
+ config.time_format = options.fetch(:time_format)
22
+ end
23
+
24
+
25
+ def sinatra_class_option_overrides(options)
26
+ if options.key?(:erb_layout)
27
+ class_exec { set :erb, layout: options[:erb_layout] }
28
+ end
29
+ if options.key?(:views_folder)
30
+ class_exec { set :views, options[:views_folder] }
31
+ end
32
+ end
33
+
34
+
35
+ def default_options
36
+ Adalog.configuration.web_defaults
37
+ end
38
+
39
+
40
+ set :root, File.join(File.dirname(__FILE__), 'web')
41
+ set :erb, layout: :'adalog.html'
42
+ set :views, File.join(File.dirname(__FILE__), 'web', 'views')
43
+
44
+
45
+ helpers do
46
+
47
+ def humanize_time(val)
48
+ case val
49
+ when DateTime, Time
50
+ val.strftime(config.time_format)
51
+ when String
52
+ val
53
+ else
54
+ val.to_s
55
+ end
56
+ end
57
+
58
+
59
+ def heading
60
+ config.heading
61
+ end
62
+
63
+
64
+ def path_from_web_root(path)
65
+ File.join(("#{env['SCRIPT_NAME']}/" || "/"), path)
66
+ end
67
+
68
+ end
69
+
70
+ ##
71
+ # The primary page that matters in this simple little log.
72
+ get '/' do
73
+ @entries = config.repo.all
74
+ erb :'index.html'
75
+ end
76
+
77
+ ##
78
+ # TODO: Maybe sort, do a forgiving attempt at date/time parsing and then
79
+ # filter based on that?
80
+ # get '/after/:timestamp' do
81
+ # @entries = config.repo.all
82
+ # end
83
+
84
+ ##
85
+ # TODO: Maybe sort, do a forgiving attempt at date/time parsing and then
86
+ # filter based on that?
87
+ # get '/before/:timestamp' do
88
+ # @entries = config.repo.all
89
+ # end
90
+
91
+
92
+ ##
93
+ # CONSIDER: Since this is all-destructive, should this be a confirmation
94
+ # page first and a followup action via post?
95
+ post '/clear' do
96
+ config.repo.clear!
97
+ redirect to('/')
98
+ end
99
+
100
+
101
+
102
+ end
103
+ end
data/lib/adalog.rb ADDED
@@ -0,0 +1,60 @@
1
+ Dir[File.join(File.dirname(__FILE__), "adalog", "*.rb")].each do |rb_file|
2
+ require rb_file
3
+ end
4
+
5
+ module Adalog
6
+
7
+ def self.configuration
8
+ @configuration || ((configure! { :defaults }) && @configuration)
9
+ end
10
+
11
+
12
+ def self.configure
13
+ config = Adalog::Configuration.new
14
+ yield(config)
15
+ config.validate!
16
+ config.freeze
17
+ @configuration = config
18
+ post_configuration(@configuration)
19
+ :ok
20
+ end
21
+
22
+
23
+ def self.post_configuration(config)
24
+ if config.singleton
25
+ self.extend(RepoConvenienceMethods)
26
+ end
27
+ if config.html_erb
28
+ Tilt.register(Tilt::ERBTemplate, 'html.erb')
29
+ end
30
+ end
31
+
32
+
33
+ module RepoConvenienceMethods
34
+
35
+ def repo
36
+ configuration.repo
37
+ end
38
+
39
+ def all
40
+ configuration.repo.all
41
+ end
42
+
43
+
44
+ def clear!
45
+ configuration.repo.clear!
46
+ end
47
+
48
+
49
+ def fetch(**options)
50
+ configuration.repo.fetch(**options)
51
+ end
52
+
53
+
54
+ def insert(entry = nil, **options)
55
+ configuration.repo.insert(entry, **options)
56
+ end
57
+
58
+ end
59
+
60
+ end
@@ -0,0 +1,28 @@
1
+ - title: Mixpanel Adapter
2
+ timestamp: 2016-04-24 17:25:06 -0500
3
+ message: identify
4
+ details: { first_name: 'Rick', last_name: 'Sanchez' }
5
+ - title: Startup Threads Adapter
6
+ timestamp: 2016-04-24 16:29:30 -0500
7
+ message: inventory-shipments:create
8
+ details: { item_id: "things-on-fire-hoodie", size: "MM", quantity: 1, street1: "4504 Graustark St", street2: "", city: "Houston", state: "TX", zip: "77006", country: "US" }
9
+ - title: SendGrid Adapter
10
+ timestamp: 2016-04-24 17:16:43 -0500
11
+ message: transactional-email:send-single
12
+ details: { id: "2dafa33f-e125-4428-9e4c-9756a787a13d", slug: 'scientist-welcome-email', full_name: 'Rick Sanchez', pricing_plan: 'Misunderstood Genius' }
13
+ - title: Mixpanel Adapter
14
+ timestamp: 2016-04-24 17:12:22 -0500
15
+ message: identify
16
+ details: { id: 555, email: 'rsanchez@example.com'}
17
+ - title: Mixpanel Adapter
18
+ timestamp: 2016-04-24 16:55:45 -0500
19
+ message: pageview
20
+ details: promotional signup page
21
+ - title: SendGrid Adapter
22
+ timestamp: 2016-04-24 16:45:56 -0500
23
+ message: transactional-email:send-batch
24
+ details: { id: "2dafa33f-e125-4428-9e4c-9756a787a13d", slug: 'shipping-status-update', batch_size: 300, valid: 299, invalid: 1 }
25
+ - title: Posthorn Adapter
26
+ timestamp: 2016-04-24 16:32:27 -0500
27
+ message: email-preferences:update
28
+ details: { outreach: false, newsletter: true }
@@ -0,0 +1,35 @@
1
+ require 'bundler/setup'
2
+ require 'minitest/autorun'
3
+ require 'minitest/reporters'
4
+ require 'minitest/reporters/turn_again_reporter'
5
+ Minitest::Reporters.use!(Minitest::Reporters::TurnAgainReporter.new)
6
+
7
+ require 'adalog'
8
+
9
+ ##
10
+ # Blatantly stolen from ActiveSupport::Testing::Declarative
11
+ # Allows for test files such as
12
+ # test "verify something" do
13
+ # ...
14
+ # end
15
+ # which become methods named test_verify_something, leaving a visual difference
16
+ # between tests themselves and any helper methods declared in the usual
17
+ # manner of `def some_helper_method`.
18
+ module DeclarativeTests
19
+ def test(name, &block)
20
+ test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
21
+ defined = instance_method(test_name) rescue false
22
+ raise "#{test_name} is already defined in #{self}" if defined
23
+ if block_given?
24
+ define_method(test_name, &block)
25
+ else
26
+ define_method(test_name) do
27
+ flunk "No implementation provided for #{name}"
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ class Minitest::Test
34
+ extend DeclarativeTests
35
+ end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ class ActiveRecordRepo < Minitest::Test
4
+
5
+ test "" do
6
+ skip
7
+ end
8
+
9
+ end