datafoodconsortium-connector 1.0.0.pre.alpha.5 → 1.0.0.pre.alpha.6
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: a824076ba3dcb7d84a5c79b1a234cfe93df085e210eaf3e4afdc75fa2a0d08d2
|
4
|
+
data.tar.gz: da11b64f9b159ae00eb6dedd3340aa8de443a44cc43f57325b6b73ba6d96cc91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d2717adafc6a45469a2c1e690f9d3721ff1c4fa6ecc9210b8da21e31aa123ece3b1621f866631578bb6356cafe0d1e128ae170eccd2174da96795a53566ed75
|
7
|
+
data.tar.gz: b4f8bf9eb7d8057564d5f5891a1a66009cee8e11eb725798985bb8efc7098741548cf01ec528908c9fc1feed9f3916d2532f0dabe7c842ba12bceace2e65bf8f
|
@@ -54,8 +54,21 @@ class DataFoodConsortium::Connector::Connector
|
|
54
54
|
def initialize()
|
55
55
|
super()
|
56
56
|
|
57
|
+
# used to prefix properties
|
58
|
+
# so the DFC's context can be used.
|
59
|
+
# See https://github.com/datafoodconsortium/connector-ruby/issues/11.
|
60
|
+
inputContext = {
|
61
|
+
"dfc-b" => "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#",
|
62
|
+
"dfc-p" => "http://static.datafoodconsortium.org/ontologies/DFC_ProductOntology.owl#",
|
63
|
+
"dfc-t" => "http://static.datafoodconsortium.org/ontologies/DFC_TechnicalOntology.owl#",
|
64
|
+
"dfc-m" => "http://static.datafoodconsortium.org/data/measures.rdf#",
|
65
|
+
"dfc-pt" => "http://static.datafoodconsortium.org/data/productTypes.rdf#",
|
66
|
+
"dfc-f" => "http://static.datafoodconsortium.org/data/facets.rdf#"
|
67
|
+
}
|
68
|
+
|
57
69
|
@context = "http://static.datafoodconsortium.org/ontologies/context.json"
|
58
|
-
|
70
|
+
|
71
|
+
@exporter = DataFoodConsortium::Connector::JsonLdSerializer.new(@context, inputContext)
|
59
72
|
@parser = DataFoodConsortium::Connector::SKOSParser.new
|
60
73
|
|
61
74
|
@FACETS = []
|
@@ -25,9 +25,9 @@ require 'json/ld'
|
|
25
25
|
|
26
26
|
class DataFoodConsortium::Connector::JsonLdSerializer
|
27
27
|
|
28
|
-
def initialize(
|
29
|
-
@
|
30
|
-
@hashSerializer = VirtualAssembly::Semantizer::HashSerializer.new
|
28
|
+
def initialize(outputContext = nil, inputContext = nil)
|
29
|
+
@outputContext = outputContext
|
30
|
+
@hashSerializer = VirtualAssembly::Semantizer::HashSerializer.new(inputContext)
|
31
31
|
end
|
32
32
|
|
33
33
|
def process(subject, *subjects)
|
@@ -39,11 +39,16 @@ class DataFoodConsortium::Connector::JsonLdSerializer
|
|
39
39
|
|
40
40
|
inputs = []
|
41
41
|
|
42
|
+
# Insert an input context on each subject so the properties could be prefixed. This way,
|
43
|
+
# the DFC's context can be used.
|
44
|
+
# See https://github.com/datafoodconsortium/connector-ruby/issues/11.
|
42
45
|
subjects.each do |subject|
|
43
|
-
|
46
|
+
input = { "@context" => "http://static.datafoodconsortium.org/ontologies/context.json" }
|
47
|
+
input.merge!(subject.serialize(@hashSerializer))
|
48
|
+
inputs.push(input)
|
44
49
|
end
|
45
|
-
|
46
|
-
jsonLd = JSON::LD::API.compact(inputs, @
|
50
|
+
|
51
|
+
jsonLd = JSON::LD::API.compact(inputs, @outputContext)
|
47
52
|
|
48
53
|
return JSON.generate(jsonLd)
|
49
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datafoodconsortium-connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.pre.alpha.
|
4
|
+
version: 1.0.0.pre.alpha.6
|
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: virtual_assembly-semantizer
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '1.0'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 1.0.
|
22
|
+
version: 1.0.4
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '1.0'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 1.0.
|
32
|
+
version: 1.0.4
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: minitest
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|