emp_json 1.3.0.pre.g0625fa6de → 1.4.0.pre.g2c7b34d0b
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ff805dc9dbb50dd3f829cae6ed5e4b6520bbf5be74a3a72db23b956b03416d9
|
4
|
+
data.tar.gz: 2cb4ba20b7678212f9961d736292315e5af18f98ded5efb79e534610cb86c03d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2fc0b677b6758c91d674484f470935037b567985a2596904033c94e0aef4c94de751cc165c718c9a6f9b336336f1eaf8e5becd89bcc70a900ada4200c238474
|
7
|
+
data.tar.gz: 9290dcf28b062bd42d5b669295e49f46eabef69a8f34d422e61fe67e0dff935171dd7d68637152cbb0d0bd64d961edab92ef92ec0111f15e0a9ce5937b406830
|
data/Gemfile.lock
CHANGED
@@ -14,6 +14,7 @@ module Empathy
|
|
14
14
|
EMP_TYPE_STRING = "s"
|
15
15
|
EMP_TYPE_BOOL = "b"
|
16
16
|
EMP_TYPE_INTEGER = "i"
|
17
|
+
EMP_TYPE_DOUBLE = "d"
|
17
18
|
EMP_TYPE_LONG = "l"
|
18
19
|
EMP_TYPE_PRIMITIVE = "p"
|
19
20
|
EMP_TYPE_LANGSTRING = "ls"
|
@@ -28,6 +29,8 @@ module Empathy
|
|
28
29
|
RDF_XSD_DATETIME = "#{RDF_XSD}dateTime"
|
29
30
|
RDF_XSD_BOOLEAN = "#{RDF_XSD}boolean"
|
30
31
|
RDF_XSD_INTEGER = "#{RDF_XSD}integer"
|
32
|
+
RDF_XSD_DECIMAL = "#{RDF_XSD}decimal"
|
33
|
+
RDF_XSD_DOUBLE = "#{RDF_XSD}double"
|
31
34
|
|
32
35
|
def object_to_value(value)
|
33
36
|
return primitive_to_value(value.iri) if value.respond_to?(:iri)
|
@@ -59,7 +62,9 @@ module Empathy
|
|
59
62
|
shorthand(EMP_TYPE_BOOL, value.to_s)
|
60
63
|
when Integer
|
61
64
|
integer_to_value(value)
|
62
|
-
when Float
|
65
|
+
when Float
|
66
|
+
shorthand(EMP_TYPE_DOUBLE, value.to_s)
|
67
|
+
when Numeric
|
63
68
|
use_rdf_rb_for_primitive(value)
|
64
69
|
when RDF::Literal
|
65
70
|
rdf_literal_to_value(value)
|
@@ -79,7 +84,7 @@ module Empathy
|
|
79
84
|
end
|
80
85
|
end
|
81
86
|
|
82
|
-
def rdf_literal_to_value(value) # rubocop:disable Metrics/AbcSize
|
87
|
+
def rdf_literal_to_value(value) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
83
88
|
case value.datatype.to_s
|
84
89
|
when RDF_RDFV_LANGSTRING
|
85
90
|
{
|
@@ -95,10 +100,14 @@ module Empathy
|
|
95
100
|
shorthand(EMP_TYPE_DATETIME, value.value)
|
96
101
|
when RDF_XSD_BOOLEAN
|
97
102
|
shorthand(EMP_TYPE_BOOL, value.value)
|
103
|
+
when RDF_XSD_DOUBLE
|
104
|
+
shorthand(EMP_TYPE_DOUBLE, value.value)
|
105
|
+
when RDF_XSD_DECIMAL
|
106
|
+
primitive(value.datatype.to_s, value.value)
|
98
107
|
when RDF_XSD_INTEGER
|
99
108
|
integer_to_value(value.to_i)
|
100
109
|
else
|
101
|
-
throw "unknown RDF::Literal"
|
110
|
+
throw "unknown RDF::Literal: #{value.datatype}"
|
102
111
|
end
|
103
112
|
end
|
104
113
|
|
@@ -58,7 +58,7 @@ module Empathy
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def value_for_attribute(attr, resource, serialization_params)
|
61
|
-
return resource.try(attr.method) if attr.method.is_a?(Symbol)
|
61
|
+
return resource.try(attr.method) if attr.method.is_a?(Symbol) || attr.method.is_a?(String)
|
62
62
|
|
63
63
|
FastJsonapi.call_proc(attr.method, resource, serialization_params)
|
64
64
|
end
|
@@ -16,6 +16,8 @@ module Empathy
|
|
16
16
|
|
17
17
|
EMP_TYPE_INTEGER: "i"
|
18
18
|
|
19
|
+
EMP_TYPE_DOUBLE: "d"
|
20
|
+
|
19
21
|
EMP_TYPE_LONG: "l"
|
20
22
|
|
21
23
|
EMP_TYPE_PRIMITIVE: "p"
|
@@ -42,6 +44,10 @@ module Empathy
|
|
42
44
|
|
43
45
|
RDF_XSD_INTEGER: "http://www.w3.org/2001/XMLSchema#integer"
|
44
46
|
|
47
|
+
RDF_XSD_DECIMAL: "http://www.w3.org/2001/XMLSchema#decimal"
|
48
|
+
|
49
|
+
RDF_XSD_DOUBLE: "http://www.w3.org/2001/XMLSchema#double"
|
50
|
+
|
45
51
|
type shorthand = { type: string, v: string }
|
46
52
|
type primitive = { type: string, dt: string, v: string }
|
47
53
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emp_json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0.pre.g2c7b34d0b
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thom van Kalkeren
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Serializer for the EmpJson specification.
|
14
14
|
email:
|