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.
- checksums.yaml +4 -4
- data/.editorconfig +35 -0
- data/.ruby-version +1 -1
- data/.travis.yml +0 -2
- data/Guardfile +1 -1
- data/README.md +13 -8
- data/Rakefile +10 -0
- data/config.ru +3 -3
- data/index.html +1 -0
- data/jsonapionify.gemspec +13 -8
- data/lib/jsonapionify/api/action.rb +60 -50
- data/lib/jsonapionify/api/attribute.rb +13 -2
- data/lib/jsonapionify/api/base/app_builder.rb +17 -2
- data/lib/jsonapionify/api/base/class_methods.rb +33 -17
- data/lib/jsonapionify/api/base/delegation.rb +4 -1
- data/lib/jsonapionify/api/base/doc_helper.rb +13 -4
- data/lib/jsonapionify/api/base/resource_definitions.rb +13 -2
- data/lib/jsonapionify/api/base.rb +22 -6
- data/lib/jsonapionify/api/context_delegate.rb +2 -2
- data/lib/jsonapionify/api/errors.rb +7 -2
- data/lib/jsonapionify/api/errors_object.rb +1 -1
- data/lib/jsonapionify/api/header_options.rb +6 -5
- data/lib/jsonapionify/api/param_options.rb +49 -7
- data/lib/jsonapionify/api/relationship/many.rb +0 -5
- data/lib/jsonapionify/api/relationship/one.rb +10 -9
- data/lib/jsonapionify/api/relationship.rb +17 -5
- data/lib/jsonapionify/api/resource/builders.rb +39 -10
- data/lib/jsonapionify/api/resource/class_methods.rb +17 -6
- data/lib/jsonapionify/api/resource/defaults/actions.rb +0 -1
- data/lib/jsonapionify/api/resource/defaults/errors.rb +11 -11
- data/lib/jsonapionify/api/resource/defaults/options.rb +53 -0
- data/lib/jsonapionify/api/resource/defaults/params.rb +9 -0
- data/lib/jsonapionify/api/resource/defaults/request_contexts.rb +17 -11
- data/lib/jsonapionify/api/resource/definitions/actions.rb +51 -45
- data/lib/jsonapionify/api/resource/definitions/attributes.rb +2 -2
- data/lib/jsonapionify/api/resource/definitions/helpers.rb +18 -0
- data/lib/jsonapionify/api/resource/definitions/pagination.rb +183 -53
- data/lib/jsonapionify/api/resource/definitions/params.rb +43 -12
- data/lib/jsonapionify/api/resource/definitions/request_headers.rb +1 -67
- data/lib/jsonapionify/api/resource/definitions/scopes.rb +2 -13
- data/lib/jsonapionify/api/resource/definitions/sorting.rb +71 -58
- data/lib/jsonapionify/api/resource/error_handling.rb +2 -2
- data/lib/jsonapionify/api/resource/includer.rb +6 -0
- data/lib/jsonapionify/api/resource.rb +14 -3
- data/lib/jsonapionify/api/response.rb +2 -2
- data/lib/jsonapionify/api/server/mock_response.rb +2 -2
- data/lib/jsonapionify/api/server/request.rb +11 -7
- data/lib/jsonapionify/api/server.rb +1 -1
- data/lib/jsonapionify/api/sort_field.rb +59 -0
- data/lib/jsonapionify/api/sort_field_set.rb +36 -0
- data/lib/jsonapionify/callbacks.rb +3 -3
- data/lib/jsonapionify/continuation.rb +1 -0
- data/lib/jsonapionify/deep_sort_collection.rb +22 -0
- data/lib/jsonapionify/documentation/template.erb +196 -77
- data/lib/jsonapionify/documentation.rb +9 -9
- data/lib/jsonapionify/indented_string.rb +1 -0
- data/lib/jsonapionify/inherited_attributes.rb +4 -3
- data/lib/jsonapionify/structure/collections/base.rb +2 -1
- data/lib/jsonapionify/structure/helpers/errors.rb +1 -1
- data/lib/jsonapionify/structure/helpers/object_defaults.rb +2 -1
- data/lib/jsonapionify/structure/helpers/validations.rb +2 -1
- data/lib/jsonapionify/structure/objects/base.rb +4 -3
- data/lib/jsonapionify/structure/objects/top_level.rb +1 -1
- data/lib/jsonapionify/types/boolean_type.rb +2 -2
- data/lib/jsonapionify/types/date_string_type.rb +1 -1
- data/lib/jsonapionify/types/time_string_type.rb +1 -1
- data/lib/jsonapionify/version.rb +1 -1
- data/lib/jsonapionify.rb +16 -2
- metadata +69 -10
- data/fixtures/documentation.json +0 -364
- data/lib/jsonapionify/api/resource/http.rb +0 -11
- data/lib/jsonapionify/enumerable_observer.rb +0 -91
- 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  | 
| 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 | 
            -
                   | 
| 47 | 
            +
                  position: fixed;
         | 
| 48 | 
            +
                }
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                .relative {
         | 
| 51 | 
            +
                  position: relative;
         | 
| 26 52 | 
             
                }
         | 
| 27 53 |  | 
| 28 54 | 
             
                .navbar-default {
         | 
| 29 | 
            -
                   | 
| 55 | 
            +
                  left: 0;
         | 
| 56 | 
            +
                  border-radius: 0;
         | 
| 30 57 | 
             
                  background-color: #4c555a;
         | 
| 31 | 
            -
                  border:  | 
| 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:  | 
| 197 | 
            +
                  margin-top: 0;
         | 
| 159 198 | 
             
                }
         | 
| 160 199 |  | 
| 161 200 | 
             
                section:last-child {
         | 
| 162 | 
            -
                  border-bottom:  | 
| 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:  | 
| 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:  | 
| 229 | 
            +
                  padding-left: 0;
         | 
| 186 230 | 
             
                }
         | 
| 187 231 |  | 
| 188 232 | 
             
                ul.attributes .row-attribute {
         | 
| 189 233 | 
             
                  border-bottom: 1px solid #f0f4f7;
         | 
| 190 | 
            -
                  padding: 15px  | 
| 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:  | 
| 240 | 
            +
                  padding-left: 0;
         | 
| 197 241 | 
             
                }
         | 
| 198 242 |  | 
| 199 243 | 
             
                ul.attributes > li:last-child > p {
         | 
| 200 | 
            -
                  margin-bottom:  | 
| 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:  | 
| 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  | 
| 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:  | 
| 259 | 
            -
                  margin:  | 
| 260 | 
            -
                  border-radius:  | 
| 302 | 
            +
                  padding: 0;
         | 
| 303 | 
            +
                  margin: 0;
         | 
| 304 | 
            +
                  border-radius: 0;
         | 
| 261 305 | 
             
                  position: relative;
         | 
| 262 | 
            -
                  margin: 10px  | 
| 263 | 
            -
                  padding:  | 
| 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 | 
            -
             | 
| 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=" | 
| 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  | 
| 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 | 
            -
                           | 
| 328 | 
            -
             | 
| 329 | 
            -
             | 
| 330 | 
            -
                                 | 
| 331 | 
            -
             | 
| 332 | 
            -
             | 
| 333 | 
            -
             | 
| 334 | 
            -
             | 
| 335 | 
            -
             | 
| 336 | 
            -
                                           | 
| 337 | 
            -
             | 
| 338 | 
            -
                                           | 
| 339 | 
            -
             | 
| 340 | 
            -
             | 
| 341 | 
            -
             | 
| 342 | 
            -
             | 
| 343 | 
            -
             | 
| 344 | 
            -
             | 
| 345 | 
            -
             | 
| 346 | 
            -
             | 
| 347 | 
            -
             | 
| 348 | 
            -
             | 
| 349 | 
            -
             | 
| 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 | 
| 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 | 
            -
                  < | 
| 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 | 
            -
             | 
| 440 | 
            -
                   | 
| 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:  | 
| 534 | 
            +
                offset: 140
         | 
| 456 535 | 
             
              });
         | 
| 457 536 |  | 
| 458 537 | 
             
              $sidebar.affix({
         | 
| 459 538 | 
             
                offset: {
         | 
| 460 | 
            -
                  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 | 
            -
                 | 
| 476 | 
            -
                   | 
| 477 | 
            -
             | 
| 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 | 
            -
             | 
| 480 | 
            -
             | 
| 481 | 
            -
             | 
| 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: | 
| 12 | 
            -
                  tables: | 
| 13 | 
            -
                  fenced_code_blocks: | 
| 14 | 
            -
                  strikethrough: | 
| 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: | 
| 17 | 
            -
                  space_after_headers: | 
| 18 | 
            -
                  underline: | 
| 19 | 
            -
                  highlight: | 
| 20 | 
            -
                  quote: | 
| 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)
         | 
| @@ -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 | 
            -
                     | 
| 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  | 
| 7 | 
            +
                  include EnumerableObserver
         | 
| 7 8 | 
             
                  include Helpers::InheritsOrigin
         | 
| 8 9 | 
             
                  attr_reader :parent
         | 
| 9 10 |  | 
| @@ -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  | 
| 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  | 
| 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  | 
| 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?
         | 
    
        data/lib/jsonapionify/version.rb
    CHANGED