emp_json 1.4.0.pre.g2575975e4 → 1.5.0.pre.g6cf4f565b

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: 42aaaba45f4492719c1b3528f66916835db5953cc0653e8be87480c190b8f406
4
- data.tar.gz: 98f3f75abd3a9b9132451d82920081b4e5a1700eaccb5267ba2a5f60334895b0
3
+ metadata.gz: 11b28b325f99ceb1bc68f260a755deb077071e653fc4d33e40208864eae4ca24
4
+ data.tar.gz: 7124ff6529878a36154d44b4539b2979c9037d7918bd8c291a5f7dd923b1bc64
5
5
  SHA512:
6
- metadata.gz: 298e200bc75c0f5bf8bb4c6e42d3c2f5369ba24a0ab50b9d4cb0ecfa9e245b9b33930f5c2a15ffc00ac1aa2180762eb048507794c53d5a9d76f73b4f1178ba1d
7
- data.tar.gz: 4fe179db61decfb069f343f64f5f3f4f5aba494ec9f0a88061485ecad5a13d3e36d61fe86b35f7ef6ed05bdd86593444682649f61fd67d6cbc29719006c3dd06
6
+ metadata.gz: 3ad683190047a06b3350590d75a53ca96bff81dd51245716f6c1b0cc589504003b9c7640e76204b21722af0258319e3707743f841a7a1dbd8ff6b79e7fc9f7b2
7
+ data.tar.gz: 4afd4527667e7bd3488690f72a311ba9b1d31519eb841987d5c2b21a5c839f5035f1be2810957dc1db42ba14a9fe4ff29a3eba38d52531d4bc591f555c44eb11
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- emp_json (1.4.0.pre.g2575975e4)
4
+ emp_json (1.5.0.pre.g6cf4f565b)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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,9 @@ 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_FLOAT = "#{RDF_XSD}float"
33
+ RDF_XSD_DOUBLE = "#{RDF_XSD}double"
34
+ RDF_XSD_DECIMAL = "#{RDF_XSD}decimal"
31
35
 
32
36
  def object_to_value(value)
33
37
  return primitive_to_value(value.iri) if value.respond_to?(:iri)
@@ -59,7 +63,9 @@ module Empathy
59
63
  shorthand(EMP_TYPE_BOOL, value.to_s)
60
64
  when Integer
61
65
  integer_to_value(value)
62
- when Float, Numeric
66
+ when Float
67
+ shorthand(EMP_TYPE_DOUBLE, value.to_s)
68
+ when Numeric
63
69
  use_rdf_rb_for_primitive(value)
64
70
  when RDF::Literal
65
71
  rdf_literal_to_value(value)
@@ -79,7 +85,7 @@ module Empathy
79
85
  end
80
86
  end
81
87
 
82
- def rdf_literal_to_value(value) # rubocop:disable Metrics/AbcSize
88
+ def rdf_literal_to_value(value) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
83
89
  case value.datatype.to_s
84
90
  when RDF_RDFV_LANGSTRING
85
91
  {
@@ -95,10 +101,14 @@ module Empathy
95
101
  shorthand(EMP_TYPE_DATETIME, value.value)
96
102
  when RDF_XSD_BOOLEAN
97
103
  shorthand(EMP_TYPE_BOOL, value.value)
104
+ when RDF_XSD_DOUBLE
105
+ shorthand(EMP_TYPE_DOUBLE, value.value)
106
+ when RDF_XSD_DECIMAL, RDF_XSD_FLOAT
107
+ primitive(value.datatype.to_s, value.value)
98
108
  when RDF_XSD_INTEGER
99
109
  integer_to_value(value.to_i)
100
110
  else
101
- throw "unknown RDF::Literal"
111
+ throw "unknown RDF::Literal: #{value.datatype}"
102
112
  end
103
113
  end
104
114
 
@@ -56,7 +56,8 @@ module Empathy
56
56
  end
57
57
 
58
58
  def retrieve_id(resource)
59
- return resource.to_s if resource.is_a?(URI) || resource.is_a?(RDF::URI) || resource.is_a?(RDF::Node)
59
+ return RDF::URI(resource) if resource.is_a?(URI)
60
+ return resource if resource.is_a?(RDF::URI) || resource.is_a?(RDF::Node)
60
61
 
61
62
  resource.try(:iri) || resource.try(:subject) || resource.try(:id) || resource
62
63
  end
@@ -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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Empathy
4
4
  module EmpJson
5
- VERSION = "1.4.0"
5
+ VERSION = "1.5.0"
6
6
  end
7
7
  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,12 @@ module Empathy
42
44
 
43
45
  RDF_XSD_INTEGER: "http://www.w3.org/2001/XMLSchema#integer"
44
46
 
47
+ RDF_XSD_FLOAT: "http://www.w3.org/2001/XMLSchema#float"
48
+
49
+ RDF_XSD_DOUBLE: "http://www.w3.org/2001/XMLSchema#double"
50
+
51
+ RDF_XSD_DECIMAL: "http://www.w3.org/2001/XMLSchema#decimal"
52
+
45
53
  type shorthand = { type: string, v: string }
46
54
  type primitive = { type: string, dt: string, v: string }
47
55
 
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.0.pre.g2575975e4
4
+ version: 1.5.0.pre.g6cf4f565b
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-15 00:00:00.000000000 Z
11
+ date: 2022-08-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Serializer for the EmpJson specification.
14
14
  email: