datafoodconsortium-connector 1.0.0.pre.alpha.2 → 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: 8c9d2e50fcad8ae240d942178bc865c4ababb788688ab262ea1977665702da9d
4
- data.tar.gz: c09ef2980a0f2144a52b67c80fabb4e1397c735a38d19c44c1d15483d2b286d0
3
+ metadata.gz: 730da5a9c16ad3380e7374e8cb2ef7c6ce1e85b5dedc262843a77b9facce6eb0
4
+ data.tar.gz: 8ec5484fe9a2e862b6077b64ef20e17df76a81fadb9d1ea124c2d9c7ede0463d
5
5
  SHA512:
6
- metadata.gz: 2adc59cf77f5aba4d1c0b147dc357ee2894139701b68c996b7b078d6d0c9a107ad3859217e6495e1bb5764be28327e22057bac524fff3d8455c3e64ce297fd0f
7
- data.tar.gz: a7e8caf6e4b354dac8d2442de27a812ee690669e0d0b58702da19056a086d0def5fec4d40ef30048bd9bd9f51832737384b47a81c4a6178bfc3f5539d0a7700d
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
 
@@ -26,8 +26,10 @@ require 'datafoodconsortium/connector/skos_parser_element'
26
26
  class DataFoodConsortium::Connector::SKOSInstance
27
27
 
28
28
  def addAttribute(name, value)
29
- instance_variable_set("@#{name}", value)
30
- self.class.send(:attr_reader, name)
29
+ self.instance_variable_set("@#{name}", value)
30
+ self.define_singleton_method(name) do
31
+ return instance_variable_get("@#{name}")
32
+ end
31
33
  end
32
34
 
33
35
  def hasAttribute(name)
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.2
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-23 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: []