jsonapionify 0.0.1.pre → 0.9.0

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 (73) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +35 -0
  3. data/.ruby-version +1 -1
  4. data/.travis.yml +0 -2
  5. data/Guardfile +1 -1
  6. data/README.md +13 -8
  7. data/Rakefile +10 -0
  8. data/config.ru +3 -3
  9. data/index.html +1 -0
  10. data/jsonapionify.gemspec +13 -8
  11. data/lib/jsonapionify/api/action.rb +60 -50
  12. data/lib/jsonapionify/api/attribute.rb +13 -2
  13. data/lib/jsonapionify/api/base/app_builder.rb +17 -2
  14. data/lib/jsonapionify/api/base/class_methods.rb +33 -17
  15. data/lib/jsonapionify/api/base/delegation.rb +4 -1
  16. data/lib/jsonapionify/api/base/doc_helper.rb +13 -4
  17. data/lib/jsonapionify/api/base/resource_definitions.rb +13 -2
  18. data/lib/jsonapionify/api/base.rb +22 -6
  19. data/lib/jsonapionify/api/context_delegate.rb +2 -2
  20. data/lib/jsonapionify/api/errors.rb +7 -2
  21. data/lib/jsonapionify/api/errors_object.rb +1 -1
  22. data/lib/jsonapionify/api/header_options.rb +6 -5
  23. data/lib/jsonapionify/api/param_options.rb +49 -7
  24. data/lib/jsonapionify/api/relationship/many.rb +0 -5
  25. data/lib/jsonapionify/api/relationship/one.rb +10 -9
  26. data/lib/jsonapionify/api/relationship.rb +17 -5
  27. data/lib/jsonapionify/api/resource/builders.rb +39 -10
  28. data/lib/jsonapionify/api/resource/class_methods.rb +17 -6
  29. data/lib/jsonapionify/api/resource/defaults/actions.rb +0 -1
  30. data/lib/jsonapionify/api/resource/defaults/errors.rb +11 -11
  31. data/lib/jsonapionify/api/resource/defaults/options.rb +53 -0
  32. data/lib/jsonapionify/api/resource/defaults/params.rb +9 -0
  33. data/lib/jsonapionify/api/resource/defaults/request_contexts.rb +17 -11
  34. data/lib/jsonapionify/api/resource/definitions/actions.rb +51 -45
  35. data/lib/jsonapionify/api/resource/definitions/attributes.rb +2 -2
  36. data/lib/jsonapionify/api/resource/definitions/helpers.rb +18 -0
  37. data/lib/jsonapionify/api/resource/definitions/pagination.rb +183 -53
  38. data/lib/jsonapionify/api/resource/definitions/params.rb +43 -12
  39. data/lib/jsonapionify/api/resource/definitions/request_headers.rb +1 -67
  40. data/lib/jsonapionify/api/resource/definitions/scopes.rb +2 -13
  41. data/lib/jsonapionify/api/resource/definitions/sorting.rb +71 -58
  42. data/lib/jsonapionify/api/resource/error_handling.rb +2 -2
  43. data/lib/jsonapionify/api/resource/includer.rb +6 -0
  44. data/lib/jsonapionify/api/resource.rb +14 -3
  45. data/lib/jsonapionify/api/response.rb +2 -2
  46. data/lib/jsonapionify/api/server/mock_response.rb +2 -2
  47. data/lib/jsonapionify/api/server/request.rb +11 -7
  48. data/lib/jsonapionify/api/server.rb +1 -1
  49. data/lib/jsonapionify/api/sort_field.rb +59 -0
  50. data/lib/jsonapionify/api/sort_field_set.rb +36 -0
  51. data/lib/jsonapionify/callbacks.rb +3 -3
  52. data/lib/jsonapionify/continuation.rb +1 -0
  53. data/lib/jsonapionify/deep_sort_collection.rb +22 -0
  54. data/lib/jsonapionify/documentation/template.erb +196 -77
  55. data/lib/jsonapionify/documentation.rb +9 -9
  56. data/lib/jsonapionify/indented_string.rb +1 -0
  57. data/lib/jsonapionify/inherited_attributes.rb +4 -3
  58. data/lib/jsonapionify/structure/collections/base.rb +2 -1
  59. data/lib/jsonapionify/structure/helpers/errors.rb +1 -1
  60. data/lib/jsonapionify/structure/helpers/object_defaults.rb +2 -1
  61. data/lib/jsonapionify/structure/helpers/validations.rb +2 -1
  62. data/lib/jsonapionify/structure/objects/base.rb +4 -3
  63. data/lib/jsonapionify/structure/objects/top_level.rb +1 -1
  64. data/lib/jsonapionify/types/boolean_type.rb +2 -2
  65. data/lib/jsonapionify/types/date_string_type.rb +1 -1
  66. data/lib/jsonapionify/types/time_string_type.rb +1 -1
  67. data/lib/jsonapionify/version.rb +1 -1
  68. data/lib/jsonapionify.rb +16 -2
  69. metadata +69 -10
  70. data/fixtures/documentation.json +0 -364
  71. data/lib/jsonapionify/api/resource/http.rb +0 -11
  72. data/lib/jsonapionify/enumerable_observer.rb +0 -91
  73. data/lib/jsonapionify/unstrict_proc.rb +0 -28
@@ -5,7 +5,7 @@
5
5
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1">
7
7
  <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
8
- <title><%= api.title %>></title>
8
+ <title><%= api.title %></title>
9
9
 
10
10
  <link href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABU1BMVEUAAAAzerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerczerfsspsqAAAAcHRSTlMAAQIDBAYHCAkKCwwNDg8QERIUFRcYGxweICIjJSgqLC0vMDEyNjc6PD5AQUJDREVGR05PVFVXWVthYmZnaGltcHN4fH+AgoiPkZSXmJqdnqKoq62wtbm8vsHDxcfOz9HV19rc4Obo6evt8fX3+fv9oZ9KRwAAAeFJREFUWMPt1NdT1FAYhvE3YRFWLAsWxIYoIkWlCHZQmiCoIIIFFFFAl/78/1deGJ1NOCV4Zrza7y7fOc9vZjczkapTnZxzGXbvhwBjwNcQYBMYCegbAVoCgAFgPwoAloDXuW8XFt/EmQ1ApySp9G3Y23+Cd2mhFaAoSaUyjPp7GE/tJoBVSYp+gEf43XMvtSwDj//+GU4h6Z+klk0AzZKkmvduwdhrENhNXqJbMPf6ALz88+ASLH0tQIf8gqXXDYA6eYXCsrnXFPC5cmEWrL22gYfyCfb+LMA5eQR7rwfAdnaZFQor1l4rwJTcgqs/BtAup+DqdROgVi4hWnb0mgY+Gk8SYVgnANgrGm9FO8CQ2e4CYE3qB+B7venSeYAzxr4NgHJJTuERsOXrXcIXYNLbS30WoR7gmr+3CrcACjl6qdcozAJL1v50amkSoj1g4FB/3dRLdwFYrxQuADTm7E3CU2Azdy/dyQprwJjpC2fuDwnHAa4coZdup4RugJqj9BlhDlgw/P6f9l7qAWBGkuJ9oL/yMD7w9olwVZIuApxKHU76e6kb2iRJz4CNzOELfy+1JB/xdeB59rC9qLxzEuCS/n16gYM4AHgLzAf0MUBPANAA0BAAqHlk9ZWqU53/Nb8AOJAKnq/8xU4AAAAASUVORK5CYII=" rel="icon" type="image/x-icon"/>
11
11
 
@@ -15,20 +15,47 @@
15
15
  <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.0.0/styles/agate.min.css">
16
16
  <link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:400,200,300,500,600,700' rel='stylesheet' type='text/css'>
17
17
  <link href='//fonts.googleapis.com/css?family=Source+Code+Pro:400,200,300,500,600,700' rel='stylesheet' type='text/css'>
18
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
18
19
  <style>
19
20
  body {
21
+ margin-top: 100px;
20
22
  font-family: 'Source Sans Pro', Helvetica, Arial, sans-serif;
21
23
  color: #4c555a;
22
24
  }
23
25
 
26
+ #back-top {
27
+ top: 60px;
28
+ position: fixed;
29
+ margin-left: -12px;
30
+ }
31
+
32
+ #backtop a {
33
+ color: #CCC;
34
+ text-decoration: none;
35
+ }
36
+
37
+ #back-top a:hover {
38
+ color: #777;
39
+ text-decoration: none;
40
+ }
41
+
42
+ .affix-top {
43
+ position: fixed;
44
+ }
45
+
24
46
  .affix {
25
- top: 20px;
47
+ position: fixed;
48
+ }
49
+
50
+ .relative {
51
+ position: relative;
26
52
  }
27
53
 
28
54
  .navbar-default {
29
- border-radius: 0px;
55
+ left: 0;
56
+ border-radius: 0;
30
57
  background-color: #4c555a;
31
- border: 0px;
58
+ border: 0;
32
59
  }
33
60
 
34
61
  .navbar-default .navbar-collapse, .navbar-default .navbar-form {
@@ -52,13 +79,25 @@
52
79
  letter-spacing: 0.3px;
53
80
  }
54
81
 
82
+ .navbar-default .navbar-nav > li > a:link, .navbar-default .navbar-nav > li > a:visited, .navbar-default .navbar-nav > li > a:active {
83
+ color: #e1e8ed;
84
+ }
85
+
86
+ .navbar-default .navbar-nav > li > a:hover {
87
+ color: #939da3;
88
+ }
89
+
55
90
  /* sidebar */
56
- #sidebar {
91
+ #sidebar ul {
57
92
  padding-left: 20px;
58
93
  margin-top: 20px;
59
94
  margin-bottom: 20px;
60
95
  }
61
96
 
97
+ #sidebar li {
98
+ list-style: none;
99
+ }
100
+
62
101
  #sidebar li.nav-H2 {
63
102
  padding-left: 20px;
64
103
  padding-top: 10px;
@@ -155,11 +194,11 @@
155
194
  }
156
195
 
157
196
  section:first-child {
158
- margin-top: 0px;
197
+ margin-top: 0;
159
198
  }
160
199
 
161
200
  section:last-child {
162
- border-bottom: 0px;
201
+ border-bottom: 0;
163
202
  }
164
203
 
165
204
  section.group h3 {
@@ -175,29 +214,34 @@
175
214
  font-size: 13px;
176
215
  letter-spacing: 1px;
177
216
  padding-bottom: 10px;
178
- margin-bottom: 0px;
217
+ margin-bottom: 20px;
179
218
  border-bottom: 1px solid #e1e8ed;
180
219
  }
181
220
 
221
+ section.group h5 {
222
+ font-weight: bold;
223
+ text-transform: uppercase;
224
+ }
225
+
182
226
  ul.attributes {
183
227
  list-style-type: none;
184
228
  font-size: 14px;
185
- padding-left: 0px;
229
+ padding-left: 0;
186
230
  }
187
231
 
188
232
  ul.attributes .row-attribute {
189
233
  border-bottom: 1px solid #f0f4f7;
190
- padding: 15px 0px;
234
+ padding: 15px 0;
191
235
  }
192
236
 
193
237
  ul.relationships {
194
238
  margin-top: 10px;
195
239
  list-style-type: none;
196
- padding-left: 0px;
240
+ padding-left: 0;
197
241
  }
198
242
 
199
243
  ul.attributes > li:last-child > p {
200
- margin-bottom: 0px;
244
+ margin-bottom: 0;
201
245
  }
202
246
 
203
247
  .attribute-name strong {
@@ -214,7 +258,7 @@
214
258
  color: #939da3;
215
259
  font-size: 13px;
216
260
  font-weight: 300;
217
- margin-bottom: 0px;
261
+ margin-bottom: 0;
218
262
  }
219
263
 
220
264
  ul.attributes .allowed {
@@ -227,7 +271,7 @@
227
271
 
228
272
  footer {
229
273
  margin-top: 60px;
230
- padding: 10px 0px;
274
+ padding: 10px 0;
231
275
  border-top: 1px solid #e7e7e7;
232
276
  background-color: #4c555a;
233
277
  text-align: center;
@@ -255,12 +299,12 @@
255
299
  }
256
300
 
257
301
  pre.nostyle {
258
- padding: 0px;
259
- margin: 0px;
260
- border-radius: 0px;
302
+ padding: 0;
303
+ margin: 0;
304
+ border-radius: 0;
261
305
  position: relative;
262
- margin: 10px 0px;
263
- padding: 0px;
306
+ margin: 10px 0;
307
+ padding: 0;
264
308
  border: 1px solid #e1e8ed;
265
309
  font-size: 12px;
266
310
  line-height: 16px;
@@ -278,18 +322,21 @@
278
322
  background-color: #4c555a;
279
323
  }
280
324
 
325
+ #back-top {
326
+ display: none;
327
+ }
281
328
  </style>
282
329
 
283
330
  <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
284
331
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
285
332
  <!--[if lt IE 9]>
286
333
  <script
287
- src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
334
+ src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
288
335
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
289
336
  <![endif]-->
290
337
  </head>
291
338
  <body>
292
- <nav class="navbar navbar-default" role="navigation">
339
+ <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
293
340
  <div class="container">
294
341
  <!-- Brand and toggle get grouped for better mobile display -->
295
342
  <div class="navbar-header">
@@ -299,15 +346,25 @@
299
346
  <span class="icon-bar"></span>
300
347
  <span class="icon-bar"></span>
301
348
  </button>
302
- <a class="navbar-brand" href="<%= api.base_url %>">
349
+ <a class="navbar-brand" href="#">
303
350
  <%= api.title %>
304
351
  </a>
305
352
  </div>
353
+
354
+ <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
355
+ <ul class="nav navbar-nav navbar-left">
356
+ <% api.links.each do |link| %>
357
+ <li>
358
+ <a href="<%= link.href %>" target="_blank"><%= link.title %></a>
359
+ </li>
360
+ <% end %>
361
+ </ul>
362
+ </div>
306
363
  </div>
307
364
  </nav>
308
365
 
309
366
  <div class="container">
310
- <div class="row">
367
+ <div class="row relative">
311
368
 
312
369
  <!--Main Content -->
313
370
  <div class="col-md-9" id="_main">
@@ -318,38 +375,51 @@
318
375
 
319
376
  <h2>Resources</h2>
320
377
  <% api.resources.each do |resource| %>
321
- <section id="<%= resource.name %>" class="group">
322
- <h3><%= resource.name.titleize %></h3>
378
+ <section class="group">
379
+ <h3 id="<%= resource.name %>"><%= resource.name.titleize %></h3>
323
380
 
324
381
  <p><%= resource.description %></p>
325
382
 
326
383
  <div class="details">
327
- <h4>Attributes</h4>
328
- <ul class="attributes">
329
- <% resource.attributes.each do |attribute| %>
330
- <li>
331
- <div class="row-attribute">
332
- <div class="col-xs-4 attribute-name">
333
- <strong><%= attribute.name %></strong>
334
- <i class="attribute-type"><%= attribute.type %></i>
335
- <% if attribute.required %>
336
- <p class="optional">required</p>
337
- <% else %>
338
- <p class="optional">optional</p>
339
- <% end %>
340
- </div>
341
- <div class="col-xs-8 attribute-description">
342
- <%= attribute.description.gsub(/`(.*?)`/, "<code class='inline'>\\1</code>") %>
343
- <p class="allowed">Allowed: <%= "#{attribute.allow.to_sentence}" %></p>
344
- </div>
345
- <div style="clear: both;"></div>
346
- </div>
347
- </li>
348
- <% end %>
349
- </ul>
384
+ <% if resource.attributes.present? %>
385
+ <h4 id="<%= resource.name %>-attributes">Attributes</h4>
386
+ <ul class="attributes">
387
+ <% resource.attributes.each do |attribute| %>
388
+ <li>
389
+ <div class="row-attribute">
390
+ <div class="col-xs-4 attribute-name">
391
+ <strong><%= attribute.name %></strong>
392
+ <i class="attribute-type"><%= attribute.type %></i>
393
+ <% if attribute.required %>
394
+ <p class="optional">required</p>
395
+ <% else %>
396
+ <p class="optional">optional</p>
397
+ <% end %>
398
+ </div>
399
+ <div class="col-xs-8 attribute-description">
400
+ <%= attribute.description.gsub(/`(.*?)`/, "<code class='inline'>\\1</code>") %>
401
+ <p class="allowed">Allowed: <%= "#{attribute.allow.to_sentence}" %></p>
402
+ </div>
403
+ <div style="clear: both;"></div>
404
+ </div>
405
+ </li>
406
+ <% end %>
407
+ </ul>
408
+ <% end %>
409
+
410
+ <% if resource.relationships.present? %>
411
+ <h4 id="<%= resource.name %>-relationships">Relationships</h4>
412
+ <ul class="relationships">
413
+ <% resource.relationships.each do |relationship| %>
414
+ <li id="<%= resource.name %>-<%= relationship.name %>" class="subgroup">
415
+ <strong><a href="#<%= relationship.resource %>"><%= relationship.name %></a></strong>
416
+ </li>
417
+ <% end %>
418
+ </ul>
419
+ <% end %>
350
420
 
351
421
  <% resource.actions.each do |action| %>
352
- <h4><%= action.name.titleize %> <%= action.name == 'list' ? resource.name.pluralize : resource.name.singularize %></h4>
422
+ <h4 id="<%= action.id %>"><%= action.label.titleize %></h4>
353
423
  <% action.sample_requests.each do |sample_request| %>
354
424
  <h5>Request</h5>
355
425
  <pre><code class="http"><%= sample_request.request %></code></pre>
@@ -357,14 +427,6 @@
357
427
  <pre><code class="http"><%= sample_request.response %></code></pre>
358
428
  <% end %>
359
429
  <% end %>
360
- <h4 id="<%= resource.name %>-relationships">Relationships</h4>
361
- <ul class="relationships">
362
- <% resource.relationships.each do |relationship| %>
363
- <li id="<%= resource.name %>-<%= relationship.name %>" class="subgroup">
364
- <strong><a href="#<%= relationship.resource %>"><%= relationship.name %></a></strong>
365
- </li>
366
- <% end %>
367
- </ul>
368
430
  </div>
369
431
  </section>
370
432
  <% end %>
@@ -373,7 +435,17 @@
373
435
 
374
436
  <!--Side Bar -->
375
437
  <nav class="col-md-3 bs-docs-sidebar hidden-sm hidden-xs scrollspy">
376
- <ul id="sidebar" class="nav" data-spy="affix"></ul>
438
+ <div id="sidebar">
439
+ <div id="back-top" style="display: block;">
440
+ <a href="#">
441
+ <span class="fa-stack fa-sm">
442
+ <i class="fa fa-square fa-stack-2x"></i>
443
+ <i class="fa fa-arrow-up fa-stack-1x fa-inverse"></i>
444
+ </span>
445
+ </a>
446
+ </div>
447
+ <ul class="nav" data-spy="affix"></ul>
448
+ </div>
377
449
  </nav>
378
450
 
379
451
  </div>
@@ -411,19 +483,19 @@
411
483
  $e = $(e);
412
484
  switch (e.tagName) {
413
485
  case 'H2':
414
- nav[key] = {};
415
- nav[key]['_element'] = $e;
416
- currentH2 = nav[key];
486
+ nav[ key ] = {};
487
+ nav[ key ][ '_element' ] = $e;
488
+ currentH2 = nav[ key ];
417
489
  break;
418
490
  case 'H3':
419
- currentH2[key] = {};
420
- currentH2[key]['_element'] = $e;
421
- currentH3 = currentH2[key];
491
+ currentH2[ key ] = {};
492
+ currentH2[ key ][ '_element' ] = $e;
493
+ currentH3 = currentH2[ key ];
422
494
  break;
423
495
  case 'H4':
424
- currentH3[key] = {};
425
- currentH3[key]['_element'] = $e;
426
- currentH4 = currentH3[key];
496
+ currentH3[ key ] = {};
497
+ currentH3[ key ][ '_element' ] = $e;
498
+ currentH4 = currentH3[ key ];
427
499
  break;
428
500
  }
429
501
  });
@@ -436,8 +508,15 @@
436
508
  return
437
509
  }
438
510
  $e = $(sublist._element);
439
- $e.attr('id', id);
440
- var $listItem = $('<li class="nav-' + $e[0].tagName + '"></li>');
511
+
512
+ // Set or get the ID
513
+ if ($e.attr('id')) {
514
+ id = $e.attr('id');
515
+ } else {
516
+ $e.attr('id', id);
517
+ }
518
+
519
+ var $listItem = $('<li class="nav-' + $e[ 0 ].tagName + '"></li>');
441
520
  $listItem.append($('<a href="#' + id + '">' + $e.text() + '</a>'));
442
521
  var $subList = $('<ul class="nav"></ul>');
443
522
  buildNavigation(sublist, $subList);
@@ -452,12 +531,12 @@
452
531
 
453
532
  $('body').scrollspy({
454
533
  target: '.bs-docs-sidebar',
455
- offset: 40
534
+ offset: 140
456
535
  });
457
536
 
458
537
  $sidebar.affix({
459
538
  offset: {
460
- top: $sidebar.offset().top
539
+ top: 500
461
540
  }
462
541
  });
463
542
 
@@ -472,16 +551,56 @@
472
551
  var hash = this.hash;
473
552
 
474
553
  // animate
475
- $('html, body').animate({
476
- scrollTop: $(hash).offset().top - 20
477
- }, 300, function () {
554
+ if (hash) {
555
+ $('html, body').animate({
556
+ scrollTop: $(hash).offset().top - 70
557
+ }, 300, function () {
558
+
559
+ // when done, add hash to url
560
+ // (default click behaviour)
561
+ if (window.location)
562
+ window.location.hash = hash;
563
+ });
564
+ } else {
565
+ $('html, body').animate({ scrollTop: 0 }, 'slow', function () {
566
+ sidebarTop();
567
+ });
478
568
 
479
- // when done, add hash to url
480
- // (default click behaviour)
481
- window.location.hash = hash;
569
+ }
570
+ });
571
+
572
+ function sidebarTop() {
573
+ var sidebarlOffset = $('#sidebar ul').offset().top;
574
+
575
+ if ($('.active:last').offset()) {
576
+ var activeElementOffset = $('.active:last').offset().top;
577
+ }
578
+ var difference = activeElementOffset - sidebarlOffset;
579
+ if (difference > (window.innerHeight / 5)) {
580
+ var top = (difference - (window.innerHeight / 5));
581
+ $('.affix').css('top', -top);
582
+ } else {
583
+ $('.affix').removeAttr('style');
584
+ }
585
+ }
586
+
587
+ $(document).ready(function () {
588
+ // hide #back-top first
589
+ $(window).scroll(function () {
590
+ if ($(this).scrollTop() > 100) {
591
+ $('#back-top').fadeIn();
592
+ } else {
593
+ $('#back-top').fadeOut();
594
+ }
482
595
  });
596
+ });
483
597
 
598
+ $(window).on("load resize scroll", function () {
599
+ sidebarTop();
484
600
  });
601
+
602
+ $('table').addClass('table')
603
+
485
604
  </script>
486
605
  </body>
487
606
  </html>
@@ -8,16 +8,16 @@ module JSONAPIonify
8
8
  using JSONAPIonify::IndentedString
9
9
  RENDERER = Redcarpet::Markdown.new(
10
10
  Redcarpet::Render::HTML,
11
- autolink: true,
12
- tables: true,
13
- fenced_code_blocks: true,
14
- strikethrough: true,
11
+ autolink: true,
12
+ tables: true,
13
+ fenced_code_blocks: true,
14
+ strikethrough: true,
15
15
  disable_indented_code_blocks: true,
16
- no_intra_emphasis: true,
17
- space_after_headers: true,
18
- underline: true,
19
- highlight: true,
20
- quote: true
16
+ no_intra_emphasis: true,
17
+ space_after_headers: true,
18
+ underline: true,
19
+ highlight: true,
20
+ quote: true
21
21
  )
22
22
 
23
23
  def self.render_markdown(string)
@@ -5,6 +5,7 @@ module JSONAPIonify
5
5
  refine String do
6
6
  def deindent
7
7
  shortest_line_length = lines.each_with_object([]) do |line, ary|
8
+ next if line.empty?
8
9
  ary << line.match(/^\s*/)[0].length if line.rstrip.present?
9
10
  end.sort.first
10
11
 
@@ -1,3 +1,5 @@
1
+ require 'enumerable_observer'
2
+
1
3
  module JSONAPIonify
2
4
  module InheritedAttributes
3
5
 
@@ -39,7 +41,7 @@ module JSONAPIonify
39
41
  end if instance_writer
40
42
 
41
43
  # Define Inheritor
42
- mod = Module.new do
44
+ extend (Module.new do
43
45
  define_method :inherited do |subclass|
44
46
  super(subclass)
45
47
 
@@ -56,8 +58,7 @@ module JSONAPIonify
56
58
  observer.added { |items| subclass_var.deep_merge! items.to_h }
57
59
  observer.removed { |items| subclass_var.delete_if { |k, v| items.to_h[k] == v } }
58
60
  end
59
- end
60
- extend mod
61
+ end)
61
62
  end
62
63
  end
63
64
 
@@ -1,9 +1,10 @@
1
+ require 'enumerable_observer'
1
2
  require 'active_support/core_ext/module/delegation'
2
3
 
3
4
  module JSONAPIonify::Structure
4
5
  module Collections
5
6
  class Base < Array
6
- include JSONAPIonify::EnumerableObserver
7
+ include EnumerableObserver
7
8
  include Helpers::InheritsOrigin
8
9
  attr_reader :parent
9
10
 
@@ -48,7 +48,7 @@ module JSONAPIonify::Structure
48
48
  entity = key.present? ? key : 'object'
49
49
  messages.each do |message|
50
50
  message = "#{entity} #{message}".chomp('.') << '.'
51
- object = {
51
+ object = {
52
52
  source: {
53
53
  pointer: pointer
54
54
  },
@@ -1,10 +1,11 @@
1
+ require 'enumerable_observer'
1
2
  require 'active_support/concern'
2
3
 
3
4
  module JSONAPIonify::Structure
4
5
  module Helpers
5
6
  module ObjectDefaults
6
7
  extend ActiveSupport::Concern
7
- include JSONAPIonify::EnumerableObserver
8
+ include EnumerableObserver
8
9
 
9
10
  module ClassMethods
10
11
  # Forces the setter to a type
@@ -1,10 +1,11 @@
1
+ require 'unstrict_proc'
1
2
  require 'active_support/core_ext/class/attribute'
2
3
 
3
4
  module JSONAPIonify::Structure
4
5
  module Helpers
5
6
  module Validations
6
7
  extend ActiveSupport::Concern
7
- using JSONAPIonify::UnstrictProc
8
+ using UnstrictProc
8
9
 
9
10
  module ClassMethods
10
11
 
@@ -4,6 +4,7 @@ require 'active_support/core_ext/array/wrap'
4
4
  require 'active_support/core_ext/hash'
5
5
  require 'active_support/core_ext/array/conversions'
6
6
  require 'active_support/core_ext/hash/keys'
7
+ require 'enumerable_observer'
7
8
 
8
9
  module JSONAPIonify::Structure
9
10
  module Objects
@@ -11,7 +12,7 @@ module JSONAPIonify::Structure
11
12
 
12
13
  include JSONAPIonify::Callbacks
13
14
  include Enumerable
14
- include JSONAPIonify::EnumerableObserver
15
+ include EnumerableObserver
15
16
  include Helpers::InheritsOrigin
16
17
 
17
18
  define_callbacks :initialize, :validation
@@ -70,8 +71,8 @@ module JSONAPIonify::Structure
70
71
  # Compile as json
71
72
  attr_reader :errors, :warnings
72
73
 
73
- def compile
74
- validate
74
+ def compile(validate: true)
75
+ self.validate if validate
75
76
  to_hash
76
77
  end
77
78
 
@@ -76,7 +76,7 @@ module JSONAPIonify::Structure
76
76
  ]
77
77
 
78
78
  def compile(*)
79
- compiled = super
79
+ compiled = super(validate: ENV['RACK_ENV'] != 'production')
80
80
  compiled_errors = compiled['errors'] || []
81
81
  all_errors = compiled_errors | errors.as_collection.compile
82
82
  if all_errors.present?
@@ -2,9 +2,9 @@ module JSONAPIonify::Types
2
2
  class BooleanType < BaseType
3
3
 
4
4
  def load(value)
5
-
5
+ value
6
6
  end
7
-
7
+
8
8
  def dump(value)
9
9
  case value
10
10
  when true, false
@@ -9,7 +9,7 @@ module JSONAPIonify::Types
9
9
  def dump(value)
10
10
  case value
11
11
  when Date
12
- Oj.dump(value.to_date)
12
+ JSON.load JSON.dump(value.to_date)
13
13
  else
14
14
  raise TypeError, "#{value} is not a valid JSON #{name}."
15
15
  end
@@ -9,7 +9,7 @@ module JSONAPIonify::Types
9
9
  def dump(value)
10
10
  case value
11
11
  when Time
12
- JSON.dump(value.to_time)
12
+ JSON.load JSON.dump(value.to_time)
13
13
  else
14
14
  raise TypeError, "#{value} is not a valid JSON #{name}."
15
15
  end
@@ -1,3 +1,3 @@
1
1
  module JSONAPIonify
2
- VERSION = "0.0.1.pre"
2
+ VERSION = "0.9.0"
3
3
  end