virtual_assembly-semantizer 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d4643867375d8d1c6d4828a81e1c322d24bb0b230b711d1d959d1593b9901b2
|
4
|
+
data.tar.gz: 63aaeb5ddfef5149ca23656a759a270856d3984de0933f9e49b354bbd61b907a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2387084e7f1bc560ac7a44bddebf213cfda8b9b00dee8d75e8026d67f40b1172f1a047ed1931def2cc83d61f42ed774970f49d3debcc774ca7cb8db51d9a0f86
|
7
|
+
data.tar.gz: 44b7c5011c9d4b1789d9cb59b853cc9e64774eb0adee78e5e654e8212658f76e649ee7498c804f20d4280209aa63bc53a14e7da4c8ed717cdac2953879c5a0f4
|
@@ -25,6 +25,11 @@
|
|
25
25
|
# {"http://xmlns.com/foaf/0.1/name" => "John"}.
|
26
26
|
class VirtualAssembly::Semantizer::HashSerializer
|
27
27
|
|
28
|
+
# The inputContext must be a hash like { prefix => uri }
|
29
|
+
def initialize(inputContext = nil)
|
30
|
+
@inputContext = inputContext
|
31
|
+
end
|
32
|
+
|
28
33
|
# This is the main method to begin the serialization.
|
29
34
|
#
|
30
35
|
# The subject should be a SemanticObject.
|
@@ -33,7 +38,7 @@ class VirtualAssembly::Semantizer::HashSerializer
|
|
33
38
|
|
34
39
|
# We iterate over all the semantic properties of the subject.
|
35
40
|
subject.semanticProperties.each do |property|
|
36
|
-
name = property.name
|
41
|
+
name = @inputContext? self.prefixName(property.name): property.name
|
37
42
|
value = property.value
|
38
43
|
|
39
44
|
if (value == nil)
|
@@ -67,7 +72,17 @@ class VirtualAssembly::Semantizer::HashSerializer
|
|
67
72
|
return result;
|
68
73
|
end
|
69
74
|
|
70
|
-
private
|
75
|
+
private
|
76
|
+
|
77
|
+
# Replace each URI with its prefix
|
78
|
+
def prefixName(name)
|
79
|
+
@inputContext.each do |prefix, uri|
|
80
|
+
if (!name.start_with?("@") && name.start_with?(uri))
|
81
|
+
return name.sub(uri, prefix + ':')
|
82
|
+
end
|
83
|
+
end
|
84
|
+
return name
|
85
|
+
end
|
71
86
|
|
72
87
|
# Serialize a collection of values.
|
73
88
|
def exportCollection(values)
|
@@ -58,10 +58,8 @@ module VirtualAssembly::Semantizer::SemanticObject
|
|
58
58
|
|
59
59
|
# If the semanticId is nil, the object will be treated as a blank node.
|
60
60
|
def initialize(semanticId = nil, semanticType = nil)
|
61
|
-
@semanticId = semanticId
|
62
|
-
@semanticType = semanticType
|
63
61
|
@semanticProperties = Array.new
|
64
|
-
|
62
|
+
|
65
63
|
# This Hash allows us to find a property using its name.
|
66
64
|
#
|
67
65
|
# Hash<String, Integer>
|
@@ -70,6 +68,10 @@ module VirtualAssembly::Semantizer::SemanticObject
|
|
70
68
|
# The value store the index of the property in the
|
71
69
|
# semanticProperties array (Integer).
|
72
70
|
@semanticPropertiesNameIndex = Hash.new
|
71
|
+
|
72
|
+
# Ensure to call the setter methods
|
73
|
+
self.semanticId = semanticId
|
74
|
+
self.semanticType = semanticType
|
73
75
|
end
|
74
76
|
|
75
77
|
def hasSemanticProperty?(name)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: virtual_assembly-semantizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maxime Lecoq
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-ld
|