emp_json 1.3.0 → 1.4.0.pre.g4cafffeae
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: d2cfd4b534090019df728bd1403998dec3dfb37c6028c3f423f4688cfaa4cd8f
|
4
|
+
data.tar.gz: 6d312acaac6c1c97bbaba8e9a2c7a5873af24765f7d473866a5745c3c1e98691
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ccf00e83ea0fc8da9fb80b989c16dcfd3b34780359bdc5d6e442041c591dafd3066c14abfa68cfd6d72c1fc3012ce9fced3ef8a71c13c6e236bec788fe679c0
|
7
|
+
data.tar.gz: 6e9290bbc3c01f72f1b3414a3b74fb2040d547b5fac2762c1ff4ecee1ff1eb40b49e6205319f276cd593c96401417098246842be69ae7dfc13f91d71bc2bbb84
|
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
|
|
data/lib/empathy/emp_json.rb
CHANGED
@@ -10,9 +10,21 @@ require "empathy/emp_json/serializer"
|
|
10
10
|
|
11
11
|
module Empathy
|
12
12
|
module EmpJson
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
# Class for checking if certain gems are present
|
14
|
+
class SupportChecker
|
15
|
+
class << self
|
16
|
+
def check(gem)
|
17
|
+
require gem
|
18
|
+
true
|
19
|
+
rescue LoadError
|
20
|
+
false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
SUPPORTS_RDF_RB = SupportChecker.check("rdf")
|
26
|
+
SUPPORTS_SEQUENCE = SupportChecker.check("linked_rails")
|
27
|
+
SUPPORTS_AR = SupportChecker.check("active_record")
|
16
28
|
|
17
29
|
class Error < StandardError; end
|
18
30
|
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.g4cafffeae
|
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:
|
@@ -75,9 +75,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
75
|
version: 2.7.0.preview1
|
76
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
|
-
- - "
|
78
|
+
- - ">"
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version:
|
80
|
+
version: 1.3.1
|
81
81
|
requirements: []
|
82
82
|
rubygems_version: 3.3.7
|
83
83
|
signing_key:
|