apes 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/doc/Apes.html +1 -1
  4. data/doc/Apes/Concerns.html +1 -1
  5. data/doc/Apes/Concerns/Errors.html +1 -1
  6. data/doc/Apes/Concerns/Pagination.html +1 -1
  7. data/doc/Apes/Concerns/Request.html +23 -27
  8. data/doc/Apes/Concerns/Response.html +1 -1
  9. data/doc/Apes/Controller.html +1 -1
  10. data/doc/Apes/Errors.html +1 -1
  11. data/doc/Apes/Errors/AuthenticationError.html +1 -1
  12. data/doc/Apes/Errors/BadRequestError.html +1 -1
  13. data/doc/Apes/Errors/BaseError.html +1 -1
  14. data/doc/Apes/Errors/InvalidDataError.html +1 -1
  15. data/doc/Apes/Errors/MissingDataError.html +1 -1
  16. data/doc/Apes/Model.html +1 -1
  17. data/doc/Apes/PaginationCursor.html +1 -1
  18. data/doc/Apes/RuntimeConfiguration.html +5 -5
  19. data/doc/Apes/Serializers.html +1 -1
  20. data/doc/Apes/Serializers/JSON.html +1 -1
  21. data/doc/Apes/Serializers/JWT.html +1 -1
  22. data/doc/Apes/Serializers/List.html +1 -1
  23. data/doc/Apes/UrlsParser.html +1 -1
  24. data/doc/Apes/Validators.html +1 -1
  25. data/doc/Apes/Validators/BaseValidator.html +1 -1
  26. data/doc/Apes/Validators/BooleanValidator.html +1 -1
  27. data/doc/Apes/Validators/EmailValidator.html +1 -1
  28. data/doc/Apes/Validators/PhoneValidator.html +1 -1
  29. data/doc/Apes/Validators/ReferenceValidator.html +1 -1
  30. data/doc/Apes/Validators/TimestampValidator.html +1 -1
  31. data/doc/Apes/Validators/UuidValidator.html +1 -1
  32. data/doc/Apes/Validators/ZipCodeValidator.html +1 -1
  33. data/doc/Apes/Version.html +2 -2
  34. data/doc/_index.html +1 -1
  35. data/doc/file.README.html +1 -1
  36. data/doc/index.html +1 -1
  37. data/doc/top-level-namespace.html +1 -1
  38. data/lib/apes/concerns/request.rb +1 -3
  39. data/lib/apes/runtime_configuration.rb +1 -1
  40. data/lib/apes/version.rb +1 -1
  41. data/spec/apes/concerns/request_spec.rb +15 -1
  42. data/spec/apes/runtime_configuration_spec.rb +1 -1
  43. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b17680f70819d6bf72c0169dc4b3239d2ce027a1
4
- data.tar.gz: 433a38eb075debb0ce24c0175e4b3dfa7cd3448c
3
+ metadata.gz: 8a4b6fab1b14d71ede16a3f88bb76667ca6b8060
4
+ data.tar.gz: f2064a34117073756dc3d358000e17e8557d6df2
5
5
  SHA512:
6
- metadata.gz: 0acdbf772972650d5c1378590943f4fa93e887075431fbe2ad0170bbf2252674efa7809f50a98c77cbfa09fe9beb8be3e1b93a2c3ee50a6c137b4a4ad378ba5a
7
- data.tar.gz: 08bfc68f9d5327ea22ba316bd319ea423004658eafa6ea060bc883dbe083b1b9eb749602a2bad91e6d21f967387566d08f12c4f481fce79e0a4a6ac762e62798
6
+ metadata.gz: b28248a214851797484557cbe137b73105f322248b1c4bd853bd6928366d9edd8860a28acd7b7e2a8c088ae614c353626cc3c3d4b1a8d7e610fe7b6d65ce8250
7
+ data.tar.gz: d03abf06b7810967502130cecbdcaebe6384799ec52c746db0f579e37f7466136b7d29a5ef483a9e99efe61576e249e9374ee8705b5a4c8561c9432c44fe9e37
@@ -1,3 +1,7 @@
1
+ ### 2016-06-14 / 1.0.1
2
+
3
+ * Try to use the Origin request header first in CORS handling.
4
+
1
5
  ### 2016-06-04 / 1.0.0
2
6
 
3
7
  * Initial version.
@@ -121,7 +121,7 @@ Licensed under the MIT license, which can be found at http://www.opensource.org/
121
121
  </div>
122
122
 
123
123
  <div id="footer">
124
- Generated on Sat Jun 4 12:41:53 2016 by
124
+ Generated on Tue Jun 14 10:21:03 2016 by
125
125
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
126
126
  0.8.7.6 (ruby-2.3.0).
127
127
  </div>
@@ -118,7 +118,7 @@
118
118
  </div>
119
119
 
120
120
  <div id="footer">
121
- Generated on Sat Jun 4 12:41:53 2016 by
121
+ Generated on Tue Jun 14 10:21:04 2016 by
122
122
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
123
123
  0.8.7.6 (ruby-2.3.0).
124
124
  </div>
@@ -1080,7 +1080,7 @@
1080
1080
  </div>
1081
1081
 
1082
1082
  <div id="footer">
1083
- Generated on Sat Jun 4 12:41:53 2016 by
1083
+ Generated on Tue Jun 14 10:21:04 2016 by
1084
1084
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1085
1085
  0.8.7.6 (ruby-2.3.0).
1086
1086
  </div>
@@ -627,7 +627,7 @@
627
627
  </div>
628
628
 
629
629
  <div id="footer">
630
- Generated on Sat Jun 4 12:41:53 2016 by
630
+ Generated on Tue Jun 14 10:21:04 2016 by
631
631
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
632
632
  0.8.7.6 (ruby-2.3.0).
633
633
  </div>
@@ -358,18 +358,18 @@
358
358
  <pre class="lines">
359
359
 
360
360
 
361
+ 77
362
+ 78
361
363
  79
362
364
  80
363
365
  81
364
366
  82
365
367
  83
366
368
  84
367
- 85
368
- 86
369
- 87</pre>
369
+ 85</pre>
370
370
  </td>
371
371
  <td>
372
- <pre class="code"><span class="info file"># File 'lib/apes/concerns/request.rb', line 79</span>
372
+ <pre class="code"><span class="info file"># File 'lib/apes/concerns/request.rb', line 77</span>
373
373
 
374
374
  <span class='kw'>def</span> <span class='id identifier rubyid_request_cast_attributes'>request_cast_attributes</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_attributes'>attributes</span><span class='rparen'>)</span>
375
375
  <span class='id identifier rubyid_types'>types</span> <span class='op'>=</span> <span class='id identifier rubyid_target'>target</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_column_types'>column_types</span>
@@ -491,6 +491,8 @@
491
491
  <pre class="lines">
492
492
 
493
493
 
494
+ 55
495
+ 56
494
496
  57
495
497
  58
496
498
  59
@@ -504,12 +506,10 @@
504
506
  67
505
507
  68
506
508
  69
507
- 70
508
- 71
509
- 72</pre>
509
+ 70</pre>
510
510
  </td>
511
511
  <td>
512
- <pre class="code"><span class="info file"># File 'lib/apes/concerns/request.rb', line 57</span>
512
+ <pre class="code"><span class="info file"># File 'lib/apes/concerns/request.rb', line 55</span>
513
513
 
514
514
  <span class='kw'>def</span> <span class='id identifier rubyid_request_extract_model'>request_extract_model</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='label'>type_field:</span> <span class='symbol'>:type</span><span class='comma'>,</span> <span class='label'>attributes_field:</span> <span class='symbol'>:attributes</span><span class='comma'>,</span> <span class='label'>relationships_field:</span> <span class='symbol'>:relationships</span><span class='rparen'>)</span>
515
515
  <span class='id identifier rubyid_data'>data</span> <span class='op'>=</span> <span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span>
@@ -562,17 +562,13 @@
562
562
  16
563
563
  17
564
564
  18
565
- 19
566
- 20
567
- 21</pre>
565
+ 19</pre>
568
566
  </td>
569
567
  <td>
570
568
  <pre class="code"><span class="info file"># File 'lib/apes/concerns/request.rb', line 14</span>
571
569
 
572
570
  <span class='kw'>def</span> <span class='id identifier rubyid_request_handle_cors'>request_handle_cors</span>
573
- <span class='id identifier rubyid_cors_source'>cors_source</span> <span class='op'>=</span> <span class='const'>Apes</span><span class='op'>::</span><span class='const'>RuntimeConfiguration</span><span class='period'>.</span><span class='id identifier rubyid_development?'>development?</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>http://</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_request_source_host'>request_source_host</span><span class='embexpr_end'>}</span><span class='tstring_content'>:4200</span><span class='tstring_end'>&quot;</span></span> <span class='op'>:</span> <span class='const'>Apes</span><span class='op'>::</span><span class='const'>RuntimeConfiguration</span><span class='period'>.</span><span class='id identifier rubyid_cors_source'>cors_source</span>
574
-
575
- <span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Access-Control-Allow-Origin</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_cors_source'>cors_source</span>
571
+ <span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Access-Control-Allow-Origin</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_request'>request</span><span class='period'>.</span><span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Origin</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='const'>Apes</span><span class='op'>::</span><span class='const'>RuntimeConfiguration</span><span class='period'>.</span><span class='id identifier rubyid_cors_source'>cors_source</span>
576
572
  <span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Access-Control-Allow-Methods</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>POST, GET, PUT, DELETE, OPTIONS</span><span class='tstring_end'>&quot;</span></span>
577
573
  <span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Access-Control-Allow-Headers</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Content-Type, X-User-Email, X-User-Token</span><span class='tstring_end'>&quot;</span></span>
578
574
  <span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Access-Control-Max-Age</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='int'>1</span><span class='period'>.</span><span class='id identifier rubyid_year'>year</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
@@ -624,12 +620,12 @@
624
620
  <pre class="lines">
625
621
 
626
622
 
627
- 39
628
- 40
629
- 41</pre>
623
+ 37
624
+ 38
625
+ 39</pre>
630
626
  </td>
631
627
  <td>
632
- <pre class="code"><span class="info file"># File 'lib/apes/concerns/request.rb', line 39</span>
628
+ <pre class="code"><span class="info file"># File 'lib/apes/concerns/request.rb', line 37</span>
633
629
 
634
630
  <span class='kw'>def</span> <span class='id identifier rubyid_request_source_host'>request_source_host</span>
635
631
  <span class='ivar'>@api_source</span> <span class='op'>||=</span> <span class='const'>URI</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_request'>request</span><span class='period'>.</span><span class='id identifier rubyid_url'>url</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_host'>host</span>
@@ -681,12 +677,12 @@
681
677
  <pre class="lines">
682
678
 
683
679
 
684
- 46
685
- 47
686
- 48</pre>
680
+ 44
681
+ 45
682
+ 46</pre>
687
683
  </td>
688
684
  <td>
689
- <pre class="code"><span class="info file"># File 'lib/apes/concerns/request.rb', line 46</span>
685
+ <pre class="code"><span class="info file"># File 'lib/apes/concerns/request.rb', line 44</span>
690
686
 
691
687
  <span class='kw'>def</span> <span class='id identifier rubyid_request_valid_content_type'>request_valid_content_type</span>
692
688
  <span class='const'>Apes</span><span class='op'>::</span><span class='const'>Concerns</span><span class='op'>::</span><span class='const'>Request</span><span class='op'>::</span><span class='const'>CONTENT_TYPE</span>
@@ -721,6 +717,8 @@
721
717
  <pre class="lines">
722
718
 
723
719
 
720
+ 22
721
+ 23
724
722
  24
725
723
  25
726
724
  26
@@ -729,12 +727,10 @@
729
727
  29
730
728
  30
731
729
  31
732
- 32
733
- 33
734
- 34</pre>
730
+ 32</pre>
735
731
  </td>
736
732
  <td>
737
- <pre class="code"><span class="info file"># File 'lib/apes/concerns/request.rb', line 24</span>
733
+ <pre class="code"><span class="info file"># File 'lib/apes/concerns/request.rb', line 22</span>
738
734
 
739
735
  <span class='kw'>def</span> <span class='id identifier rubyid_request_validate'>request_validate</span>
740
736
  <span class='id identifier rubyid_content_type'>content_type</span> <span class='op'>=</span> <span class='id identifier rubyid_request_valid_content_type'>request_valid_content_type</span>
@@ -757,7 +753,7 @@
757
753
  </div>
758
754
 
759
755
  <div id="footer">
760
- Generated on Sat Jun 4 12:41:53 2016 by
756
+ Generated on Tue Jun 14 10:21:04 2016 by
761
757
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
762
758
  0.8.7.6 (ruby-2.3.0).
763
759
  </div>
@@ -931,7 +931,7 @@
931
931
  </div>
932
932
 
933
933
  <div id="footer">
934
- Generated on Sat Jun 4 12:41:53 2016 by
934
+ Generated on Tue Jun 14 10:21:04 2016 by
935
935
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
936
936
  0.8.7.6 (ruby-2.3.0).
937
937
  </div>
@@ -1091,7 +1091,7 @@ It ensures that the host is always included and that is set properly in developm
1091
1091
  </div>
1092
1092
 
1093
1093
  <div id="footer">
1094
- Generated on Sat Jun 4 12:41:54 2016 by
1094
+ Generated on Tue Jun 14 10:21:04 2016 by
1095
1095
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1096
1096
  0.8.7.6 (ruby-2.3.0).
1097
1097
  </div>
@@ -116,7 +116,7 @@
116
116
  </div>
117
117
 
118
118
  <div id="footer">
119
- Generated on Sat Jun 4 12:41:53 2016 by
119
+ Generated on Tue Jun 14 10:21:04 2016 by
120
120
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
121
121
  0.8.7.6 (ruby-2.3.0).
122
122
  </div>
@@ -124,7 +124,7 @@
124
124
  </div>
125
125
 
126
126
  <div id="footer">
127
- Generated on Sat Jun 4 12:41:53 2016 by
127
+ Generated on Tue Jun 14 10:21:04 2016 by
128
128
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
129
129
  0.8.7.6 (ruby-2.3.0).
130
130
  </div>
@@ -148,7 +148,7 @@
148
148
  </div>
149
149
 
150
150
  <div id="footer">
151
- Generated on Sat Jun 4 12:41:53 2016 by
151
+ Generated on Tue Jun 14 10:21:04 2016 by
152
152
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
153
153
  0.8.7.6 (ruby-2.3.0).
154
154
  </div>
@@ -311,7 +311,7 @@
311
311
  </div>
312
312
 
313
313
  <div id="footer">
314
- Generated on Sat Jun 4 12:41:53 2016 by
314
+ Generated on Tue Jun 14 10:21:04 2016 by
315
315
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
316
316
  0.8.7.6 (ruby-2.3.0).
317
317
  </div>
@@ -148,7 +148,7 @@
148
148
  </div>
149
149
 
150
150
  <div id="footer">
151
- Generated on Sat Jun 4 12:41:53 2016 by
151
+ Generated on Tue Jun 14 10:21:04 2016 by
152
152
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
153
153
  0.8.7.6 (ruby-2.3.0).
154
154
  </div>
@@ -148,7 +148,7 @@
148
148
  </div>
149
149
 
150
150
  <div id="footer">
151
- Generated on Sat Jun 4 12:41:53 2016 by
151
+ Generated on Tue Jun 14 10:21:04 2016 by
152
152
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
153
153
  0.8.7.6 (ruby-2.3.0).
154
154
  </div>
@@ -369,7 +369,7 @@
369
369
  </div>
370
370
 
371
371
  <div id="footer">
372
- Generated on Sat Jun 4 12:41:53 2016 by
372
+ Generated on Tue Jun 14 10:21:04 2016 by
373
373
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
374
374
  0.8.7.6 (ruby-2.3.0).
375
375
  </div>
@@ -2129,7 +2129,7 @@
2129
2129
  </div>
2130
2130
 
2131
2131
  <div id="footer">
2132
- Generated on Sat Jun 4 12:41:54 2016 by
2132
+ Generated on Tue Jun 14 10:21:05 2016 by
2133
2133
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
2134
2134
  0.8.7.6 (ruby-2.3.0).
2135
2135
  </div>
@@ -127,7 +127,7 @@
127
127
  <li class="public ">
128
128
  <span class="summary_signature">
129
129
 
130
- <a href="#cors_source-class_method" title="cors_source (class method)">+ (String) <strong>cors_source</strong>(default = &quot;localhost&quot;) </a>
130
+ <a href="#cors_source-class_method" title="cors_source (class method)">+ (String) <strong>cors_source</strong>(default = &quot;http://localhost&quot;) </a>
131
131
 
132
132
 
133
133
 
@@ -320,7 +320,7 @@
320
320
  <div class="method_details first">
321
321
  <h3 class="signature first" id="cors_source-class_method">
322
322
 
323
- + (<tt>String</tt>) <strong>cors_source</strong>(default = &quot;localhost&quot;)
323
+ + (<tt>String</tt>) <strong>cors_source</strong>(default = &quot;http://localhost&quot;)
324
324
 
325
325
 
326
326
 
@@ -345,7 +345,7 @@
345
345
  <span class='type'>(<tt>String</tt>)</span>
346
346
 
347
347
 
348
- <em class="default">(defaults to: <tt>&quot;localhost&quot;</tt>)</em>
348
+ <em class="default">(defaults to: <tt>&quot;http://localhost&quot;</tt>)</em>
349
349
 
350
350
 
351
351
  &mdash;
@@ -387,7 +387,7 @@
387
387
  <td>
388
388
  <pre class="code"><span class="info file"># File 'lib/apes/runtime_configuration.rb', line 59</span>
389
389
 
390
- <span class='kw'>def</span> <span class='id identifier rubyid_cors_source'>cors_source</span><span class='lparen'>(</span><span class='id identifier rubyid_default'>default</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>localhost</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
390
+ <span class='kw'>def</span> <span class='id identifier rubyid_cors_source'>cors_source</span><span class='lparen'>(</span><span class='id identifier rubyid_default'>default</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>http://localhost</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
391
391
  <span class='id identifier rubyid_fetch_with_fallback'>fetch_with_fallback</span><span class='lparen'>(</span><span class='id identifier rubyid_default'>default</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='const'>Rails</span><span class='period'>.</span><span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_secrets'>secrets</span><span class='period'>.</span><span class='id identifier rubyid_cors_source'>cors_source</span> <span class='rbrace'>}</span>
392
392
  <span class='kw'>end</span></pre>
393
393
  </td>
@@ -900,7 +900,7 @@
900
900
  </div>
901
901
 
902
902
  <div id="footer">
903
- Generated on Sat Jun 4 12:41:54 2016 by
903
+ Generated on Tue Jun 14 10:21:05 2016 by
904
904
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
905
905
  0.8.7.6 (ruby-2.3.0).
906
906
  </div>
@@ -116,7 +116,7 @@
116
116
  </div>
117
117
 
118
118
  <div id="footer">
119
- Generated on Sat Jun 4 12:41:53 2016 by
119
+ Generated on Tue Jun 14 10:21:04 2016 by
120
120
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
121
121
  0.8.7.6 (ruby-2.3.0).
122
122
  </div>
@@ -380,7 +380,7 @@
380
380
  </div>
381
381
 
382
382
  <div id="footer">
383
- Generated on Sat Jun 4 12:41:54 2016 by
383
+ Generated on Tue Jun 14 10:21:04 2016 by
384
384
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
385
385
  0.8.7.6 (ruby-2.3.0).
386
386
  </div>
@@ -443,7 +443,7 @@
443
443
  </div>
444
444
 
445
445
  <div id="footer">
446
- Generated on Sat Jun 4 12:41:54 2016 by
446
+ Generated on Tue Jun 14 10:21:04 2016 by
447
447
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
448
448
  0.8.7.6 (ruby-2.3.0).
449
449
  </div>
@@ -338,7 +338,7 @@
338
338
  </div>
339
339
 
340
340
  <div id="footer">
341
- Generated on Sat Jun 4 12:41:54 2016 by
341
+ Generated on Tue Jun 14 10:21:04 2016 by
342
342
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
343
343
  0.8.7.6 (ruby-2.3.0).
344
344
  </div>
@@ -1423,7 +1423,7 @@ To update the list: http:jecas.cz/tld-list/</p>
1423
1423
  </div>
1424
1424
 
1425
1425
  <div id="footer">
1426
- Generated on Sat Jun 4 12:41:54 2016 by
1426
+ Generated on Tue Jun 14 10:21:04 2016 by
1427
1427
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1428
1428
  0.8.7.6 (ruby-2.3.0).
1429
1429
  </div>
@@ -116,7 +116,7 @@
116
116
  </div>
117
117
 
118
118
  <div id="footer">
119
- Generated on Sat Jun 4 12:41:53 2016 by
119
+ Generated on Tue Jun 14 10:21:04 2016 by
120
120
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
121
121
  0.8.7.6 (ruby-2.3.0).
122
122
  </div>
@@ -269,7 +269,7 @@
269
269
  </div>
270
270
 
271
271
  <div id="footer">
272
- Generated on Sat Jun 4 12:41:53 2016 by
272
+ Generated on Tue Jun 14 10:21:04 2016 by
273
273
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
274
274
  0.8.7.6 (ruby-2.3.0).
275
275
  </div>
@@ -485,7 +485,7 @@
485
485
  </div>
486
486
 
487
487
  <div id="footer">
488
- Generated on Sat Jun 4 12:41:54 2016 by
488
+ Generated on Tue Jun 14 10:21:04 2016 by
489
489
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
490
490
  0.8.7.6 (ruby-2.3.0).
491
491
  </div>
@@ -341,7 +341,7 @@
341
341
  </div>
342
342
 
343
343
  <div id="footer">
344
- Generated on Sat Jun 4 12:41:53 2016 by
344
+ Generated on Tue Jun 14 10:21:04 2016 by
345
345
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
346
346
  0.8.7.6 (ruby-2.3.0).
347
347
  </div>
@@ -366,7 +366,7 @@
366
366
  </div>
367
367
 
368
368
  <div id="footer">
369
- Generated on Sat Jun 4 12:41:54 2016 by
369
+ Generated on Tue Jun 14 10:21:04 2016 by
370
370
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
371
371
  0.8.7.6 (ruby-2.3.0).
372
372
  </div>
@@ -363,7 +363,7 @@
363
363
  </div>
364
364
 
365
365
  <div id="footer">
366
- Generated on Sat Jun 4 12:41:53 2016 by
366
+ Generated on Tue Jun 14 10:21:04 2016 by
367
367
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
368
368
  0.8.7.6 (ruby-2.3.0).
369
369
  </div>
@@ -631,7 +631,7 @@
631
631
  </div>
632
632
 
633
633
  <div id="footer">
634
- Generated on Sat Jun 4 12:41:54 2016 by
634
+ Generated on Tue Jun 14 10:21:04 2016 by
635
635
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
636
636
  0.8.7.6 (ruby-2.3.0).
637
637
  </div>
@@ -363,7 +363,7 @@
363
363
  </div>
364
364
 
365
365
  <div id="footer">
366
- Generated on Sat Jun 4 12:41:53 2016 by
366
+ Generated on Tue Jun 14 10:21:04 2016 by
367
367
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
368
368
  0.8.7.6 (ruby-2.3.0).
369
369
  </div>
@@ -363,7 +363,7 @@
363
363
  </div>
364
364
 
365
365
  <div id="footer">
366
- Generated on Sat Jun 4 12:41:54 2016 by
366
+ Generated on Tue Jun 14 10:21:04 2016 by
367
367
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
368
368
  0.8.7.6 (ruby-2.3.0).
369
369
  </div>
@@ -149,7 +149,7 @@
149
149
 
150
150
  </div>
151
151
  </dt>
152
- <dd><pre class="code"><span class='int'>0</span></pre></dd>
152
+ <dd><pre class="code"><span class='int'>1</span></pre></dd>
153
153
 
154
154
  <dt id="STRING-constant" class="">STRING =
155
155
  <div class="docstring">
@@ -180,7 +180,7 @@
180
180
  </div>
181
181
 
182
182
  <div id="footer">
183
- Generated on Sat Jun 4 12:41:53 2016 by
183
+ Generated on Tue Jun 14 10:21:04 2016 by
184
184
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
185
185
  0.8.7.6 (ruby-2.3.0).
186
186
  </div>
@@ -426,7 +426,7 @@
426
426
  </div>
427
427
 
428
428
  <div id="footer">
429
- Generated on Sat Jun 4 12:41:53 2016 by
429
+ Generated on Tue Jun 14 10:21:03 2016 by
430
430
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
431
431
  0.8.7.6 (ruby-2.3.0).
432
432
  </div>
@@ -243,7 +243,7 @@ end</p>
243
243
  </div></div>
244
244
 
245
245
  <div id="footer">
246
- Generated on Sat Jun 4 12:41:53 2016 by
246
+ Generated on Tue Jun 14 10:21:03 2016 by
247
247
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
248
248
  0.8.7.6 (ruby-2.3.0).
249
249
  </div>
@@ -243,7 +243,7 @@ end</p>
243
243
  </div></div>
244
244
 
245
245
  <div id="footer">
246
- Generated on Sat Jun 4 12:41:53 2016 by
246
+ Generated on Tue Jun 14 10:21:03 2016 by
247
247
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
248
248
  0.8.7.6 (ruby-2.3.0).
249
249
  </div>
@@ -103,7 +103,7 @@
103
103
  </div>
104
104
 
105
105
  <div id="footer">
106
- Generated on Sat Jun 4 12:41:53 2016 by
106
+ Generated on Tue Jun 14 10:21:03 2016 by
107
107
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
108
  0.8.7.6 (ruby-2.3.0).
109
109
  </div>
@@ -12,9 +12,7 @@ module Apes
12
12
 
13
13
  # Sets headers for CORS handling.
14
14
  def request_handle_cors
15
- cors_source = Apes::RuntimeConfiguration.development? ? "http://#{request_source_host}:4200" : Apes::RuntimeConfiguration.cors_source
16
-
17
- headers["Access-Control-Allow-Origin"] = cors_source
15
+ headers["Access-Control-Allow-Origin"] = request.headers["Origin"] || Apes::RuntimeConfiguration.cors_source
18
16
  headers["Access-Control-Allow-Methods"] = "POST, GET, PUT, DELETE, OPTIONS"
19
17
  headers["Access-Control-Allow-Headers"] = "Content-Type, X-User-Email, X-User-Token"
20
18
  headers["Access-Control-Max-Age"] = 1.year.to_i.to_s
@@ -56,7 +56,7 @@ module Apes
56
56
  #
57
57
  # @param default [String] The fallback if no valid CORS source is found in Rails secrets file.
58
58
  # @return [String] The CORS source used by Apes.
59
- def cors_source(default = "localhost")
59
+ def cors_source(default = "http://localhost")
60
60
  fetch_with_fallback(default) { Rails.application.secrets.cors_source }
61
61
  end
62
62
 
@@ -16,7 +16,7 @@ module Apes
16
16
  MINOR = 0
17
17
 
18
18
  # The patch version.
19
- PATCH = 0
19
+ PATCH = 1
20
20
 
21
21
  # The current version of apes.
22
22
  STRING = [MAJOR, MINOR, PATCH].compact.join(".")
@@ -44,13 +44,27 @@ describe Apes::Concerns::Request do
44
44
 
45
45
  describe "#request_handle_cors" do
46
46
  it "should set the right headers" do
47
+ allow(subject.request).to receive(:headers).and_return({})
48
+ allow(subject).to receive(:request_source_host).and_return("FOO")
49
+
50
+ subject.request_handle_cors
51
+ expect(subject.headers).to eq({
52
+ "Access-Control-Allow-Headers" => "Content-Type, X-User-Email, X-User-Token",
53
+ "Access-Control-Allow-Methods" => "POST, GET, PUT, DELETE, OPTIONS",
54
+ "Access-Control-Allow-Origin" => "http://localhost",
55
+ "Access-Control-Max-Age" => "31557600"
56
+ })
57
+ end
58
+
59
+ it "should use the Origin request header when appropriate" do
60
+ allow(subject.request).to receive(:headers).and_return({"Origin" => "http://whatever.com:123"})
47
61
  allow(subject).to receive(:request_source_host).and_return("FOO")
48
62
 
49
63
  subject.request_handle_cors
50
64
  expect(subject.headers).to eq({
51
65
  "Access-Control-Allow-Headers" => "Content-Type, X-User-Email, X-User-Token",
52
66
  "Access-Control-Allow-Methods" => "POST, GET, PUT, DELETE, OPTIONS",
53
- "Access-Control-Allow-Origin" => "http://FOO:4200",
67
+ "Access-Control-Allow-Origin" => "http://whatever.com:123",
54
68
  "Access-Control-Max-Age" => "31557600"
55
69
  })
56
70
  end
@@ -81,7 +81,7 @@ describe Apes::RuntimeConfiguration do
81
81
  end
82
82
 
83
83
  it "should fallback to a default" do
84
- expect(Apes::RuntimeConfiguration.cors_source).to eq("localhost")
84
+ expect(Apes::RuntimeConfiguration.cors_source).to eq("http://localhost")
85
85
  expect(Apes::RuntimeConfiguration.cors_source("DEFAULT")).to eq("DEFAULT")
86
86
  end
87
87
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apes
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shogun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-04 00:00:00.000000000 Z
11
+ date: 2016-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lazier