datafoodconsortium-connector 1.0.0.pre.alpha.3 → 1.0.0.pre.alpha.4

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: dc7b3dff19469ef0f0d10261f098d083fcfec5183f4d8b82dc6dcf9a8f365885
4
- data.tar.gz: bfb6f3b592b8292b658de4387adf23c8ea87772f1cd8e16e5392623b2b1e06b3
3
+ metadata.gz: 730da5a9c16ad3380e7374e8cb2ef7c6ce1e85b5dedc262843a77b9facce6eb0
4
+ data.tar.gz: 8ec5484fe9a2e862b6077b64ef20e17df76a81fadb9d1ea124c2d9c7ede0463d
5
5
  SHA512:
6
- metadata.gz: 7b0841f41d9dc80c8ccf2b6c3b99290ecfb25f47ac90910dbf1b88fcf6c7325d0414ec61572e1823f2b9b198df7594a2cef7fa186653e36f6c8100cdba78bae8
7
- data.tar.gz: 7c4d472de1f3acbcd8379765d5eddb7f2f5fbfc569c1e24204742808903cf683cbd6820d9bfd8fbe600ed4bba1c0ca33bf6a15d10c67325d916c743ee5f5eaac
6
+ metadata.gz: fc53bf8269ffa64dd5c39b5fe4c2f0fdc9ed1105ffe3dbef20f432b2b708e5339188ae06d9cb2457097f0702467af70bed06d9ae63f3193cb528d81311dff694
7
+ data.tar.gz: 1d4c609a3fa0a3976c51c51294ab41a2786a391522e7dc4aeac6e517c0677fc830eefacb9b92d43c724f12bf4cdcbe2bf5446c0c14ccaf05781acfdc6db0976e
@@ -27,24 +27,26 @@ class DataFoodConsortium::Connector::Connector
27
27
 
28
28
  include Singleton
29
29
 
30
+ attr_accessor :context
31
+
30
32
  attr_reader :FACETS
31
33
  attr_reader :MEASURES
32
34
  attr_reader :PRODUCT_TYPES
33
35
 
34
- def export(subject)
35
- return @exporter.process(subject);
36
+ def export(subject, *subjects)
37
+ return @exporter.process(subject, *subjects)
36
38
  end
37
39
 
38
40
  def loadFacets(data)
39
- @FACETS = loadThesaurus(data);
41
+ @FACETS = loadThesaurus(data)
40
42
  end
41
43
 
42
44
  def loadMeasures(data)
43
- @MEASURES = loadThesaurus(data);
45
+ @MEASURES = loadThesaurus(data)
44
46
  end
45
47
 
46
48
  def loadProductTypes(data)
47
- @PRODUCT_TYPES = loadThesaurus(data);
49
+ @PRODUCT_TYPES = loadThesaurus(data)
48
50
  end
49
51
 
50
52
  private
@@ -52,12 +54,7 @@ class DataFoodConsortium::Connector::Connector
52
54
  def initialize()
53
55
  super()
54
56
 
55
- @context = JSON.parse(%({
56
- "@context": {
57
- "dfc-b": "http://static.datafoodconsortium.org/ontologies/DFC_BusinessOntology.owl#"
58
- }
59
- }))['@context']
60
-
57
+ @context = "http://static.datafoodconsortium.org/ontologies/context.json"
61
58
  @exporter = DataFoodConsortium::Connector::JsonLdSerializer.new(@context)
62
59
  @parser = DataFoodConsortium::Connector::SKOSParser.new
63
60
 
@@ -25,14 +25,26 @@ require 'json/ld'
25
25
 
26
26
  class DataFoodConsortium::Connector::JsonLdSerializer
27
27
 
28
- def initialize(context)
28
+ def initialize(context = nil)
29
29
  @context = context
30
30
  @hashSerializer = VirtualAssembly::Semantizer::HashSerializer.new
31
31
  end
32
32
 
33
- def process(subject)
34
- input = subject.serialize(@hashSerializer)
35
- jsonLd = JSON::LD::API.compact(input, @context)
33
+ def process(subject, *subjects)
34
+ subjects.insert(0, subject)
35
+
36
+ if (subjects.empty?)
37
+ return ""
38
+ end
39
+
40
+ inputs = []
41
+
42
+ subjects.each do |subject|
43
+ inputs.push(subject.serialize(@hashSerializer))
44
+ end
45
+
46
+ jsonLd = JSON::LD::API.compact(inputs, @context)
47
+
36
48
  return JSON.generate(jsonLd)
37
49
  end
38
50
 
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.3
4
+ version: 1.0.0.pre.alpha.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-01-25 00:00:00.000000000 Z
11
+ date: 2023-02-13 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.1
22
+ version: 1.0.2
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.1
32
+ version: 1.0.2
33
33
  description: A library to easily integrate the DFC standard within your application.
34
34
  email: maxime@lecoqlibre.fr
35
35
  executables: []