emp_json 1.3.0.pre.g9596e781b → 1.4.0.pre.g116cfb0af

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: 84cc8976cd03cf429641613fd5467538ea535c49e88c71809061f4c3090cb84d
4
- data.tar.gz: da8634f8408c17d6d32ec1cca6681016a455f36d51a1c22a96005339a39a392b
3
+ metadata.gz: db8ae7e00135fe90e122cafa2334da420e5f880ad18b9bc38ef5185974896c71
4
+ data.tar.gz: 6570ec075a62745233853b38e5d9d6d15a4732356b8c22afb9c087818912a94e
5
5
  SHA512:
6
- metadata.gz: b549efd7b3131794ec10737312dd71ccef5f8b2ac64aeaa3ecc15662e3fd18fe87813c6493b89db8cb2f932f557e51b239bbbfbccddfb10cef4bcaee75a1c271
7
- data.tar.gz: 812cb4fe6c46d2b823e7a1f50422762f3289912a304299dd865a7ce15ab8935c83f7798f96921439f554f0d6eb623e66a0c14c142509a8b6893a080590a8bc87
6
+ metadata.gz: 850ba38394542800c7f40f08f9be4403ccf1a8b5a91ade1d56852f16fb89238c544b3569db778a7139aee37cc4ea6aa6889172f18cc1bfb1e46214b3eebbff7a
7
+ data.tar.gz: e2fbc4da1d07b53a03da240a325423eeed185099a24b9c1f069a4f181975f658c88b80e1def378d9284aedd469f77a01c9b59fd9e795885f9921f74b2576a772
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- emp_json (1.3.0.pre.g9596e781b)
4
+ emp_json (1.4.0.pre.g116cfb0af)
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,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, Numeric
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
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Empathy
4
4
  module EmpJson
5
- VERSION = "1.3.0"
5
+ VERSION = "1.4.0"
6
6
  end
7
7
  end
@@ -10,9 +10,21 @@ require "empathy/emp_json/serializer"
10
10
 
11
11
  module Empathy
12
12
  module EmpJson
13
- SUPPORTS_RDF_RB = Object.const_defined?("RDF")
14
- SUPPORTS_SEQUENCE = Object.const_defined?("LinkedRails")
15
- SUPPORTS_AR = Object.const_defined?("ActiveRecord")
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.3.0.pre.g9596e781b
4
+ version: 1.4.0.pre.g116cfb0af
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-02 00:00:00.000000000 Z
11
+ date: 2022-08-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Serializer for the EmpJson specification.
14
14
  email: