oxymoron 1.0.10 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86d4ad98634b4369be8a81bf872d2ffec5330d8a
4
- data.tar.gz: 50365f3ffa393beb862898def01cdc511836bbf6
3
+ metadata.gz: bad6b490f6241680aeb587ef948fbfe2d37b19e1
4
+ data.tar.gz: 3fc57c653eddb2ad2549afd92a104c295624af33
5
5
  SHA512:
6
- metadata.gz: a3b97191ae95b981f11ca084d8c126614b05f48276eb494d1300a84b8888aba84b6e47c9df8ef4ef9682939416129aade02f760a72f161e8788da0f15536a676
7
- data.tar.gz: 7b3c75b55678640c5e54641ee605ffa1a2bf72eb86414a27bf0b240d97eb4f4a6272d3c24ff6dce2022a370345d8d85ba59da24a626c58496685229ff1d74270
6
+ metadata.gz: 1d28b08abd5ce544b96b34196561801081634a287d6d31e5004e0d1827fc20255ff538edaa02f919a7949e9a02646350acc94c9c49fa1d337c1f1c3a6f414997
7
+ data.tar.gz: 34dd3b32e36405d2d71782f18b88ae0e52bab067648a72fba9e9db3f95c1dbb9f0cdbafca2dcca73ee372774fe37cac0a7ca00380ad4b038e52c953545526d70
@@ -5,4 +5,37 @@ angular.module("oxymoron.config.http", [])
5
5
  */
6
6
  $httpProvider.defaults.headers.common['X-Requested-With'] = 'AngularXMLHttpRequest';
7
7
  $httpProvider.defaults.paramSerializer = '$httpParamSerializerJQLike';
8
- }])
8
+ }])
9
+
10
+ .config(["$httpProvider", function ($httpProvider) {
11
+ $httpProvider.defaults.transformResponse.push(function(responseData){
12
+ convertDateStringsToDates(responseData);
13
+ return responseData;
14
+ });
15
+ }]);
16
+
17
+ var regexIso8601 = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;
18
+
19
+ function convertDateStringsToDates(input) {
20
+ // Ignore things that aren't objects.
21
+ if (typeof input !== "object") return input;
22
+
23
+ for (var key in input) {
24
+ if (!input.hasOwnProperty(key)) continue;
25
+
26
+ var value = input[key];
27
+ var match;
28
+ // Check for string properties which look like dates.
29
+ // TODO: Improve this regex to better match ISO 8601 date strings.
30
+ if (typeof value === "string" && (match = value.match(regexIso8601))) {
31
+ // Assume that Date.parse can parse ISO 8601 strings, or has been shimmed in older browsers to do so.
32
+ var milliseconds = Date.parse(match[0]);
33
+ if (!isNaN(milliseconds)) {
34
+ input[key] = new Date(milliseconds);
35
+ }
36
+ } else if (typeof value === "object") {
37
+ // Recurse into object
38
+ convertDateStringsToDates(value);
39
+ }
40
+ }
41
+ }
@@ -1,3 +1,3 @@
1
1
  module Oxymoron
2
- VERSION = "1.0.10"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oxymoron
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kononenko Paul
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-08 00:00:00.000000000 Z
11
+ date: 2016-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print