datafoodconsortium-connector 1.2.0 → 1.3.0

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: 8c8a65b126a0a4837acd570ccc5fe0057fb49ab6440958bed35cfec693944e2d
4
- data.tar.gz: cd7f2ed362d8a06a7d9605b1dcfa1e3591cb903b7319b6b0297a9c9e3f1fb9be
3
+ metadata.gz: 53c5f255a48f339e30ae7ab2745a661f5989c6e91fd81ec639fa179ef82e7111
4
+ data.tar.gz: 1b5f034696fb9540252bcb3f4431e0fe404a331c9c228098a2ab73c3c01b3532
5
5
  SHA512:
6
- metadata.gz: aa01d91de19e4282f94c4ae4e7c09fa5e2bde5a8f29b5b166ffb530502ef86455ee8011ee69590d2656042ca1373914e93ca7433829fa7233f3570d377390288
7
- data.tar.gz: 5b60adf9c9825f3ae395290749bd545b866d9a1daa4c3090c715af1102f656c75293f473408879fbe2a6ace73819b7a4fa3cefb64bfb28837e82079270b9a4f5
6
+ metadata.gz: a3d9907d5f5b7b7529b464cde69eccc6e0c6de00a45097b58f79369d933c5cc08195f61716d4d9108e51b53c9a134b4312c8529ad8131d6e6e59aac13dca6400
7
+ data.tar.gz: 97aa860ebfb2b1fd8ccd32c85c55a01e3f6ce2973856dd51df1a92621bcf523fdcdaf51d314caa7f605ebda2f933267e6e689b2d7d37e17bcefcf12241328d43
@@ -35,8 +35,8 @@ module DataFoodConsortium::Connector
35
35
  attr_reader :MEASURES
36
36
  attr_reader :PRODUCT_TYPES
37
37
 
38
- def export(subject, *subjects)
39
- return @exporter.process(subject, *subjects)
38
+ def export(*subjects)
39
+ @exporter.process(*subjects)
40
40
  end
41
41
 
42
42
  def import(json_string_or_io)
@@ -8,27 +8,34 @@ module DataFoodConsortium
8
8
  #
9
9
  # Similar to: https://github.com/ruby-rdf/json-ld-preloaded/
10
10
  class Context < JSON::LD::Context
11
- URL = "https://www.datafoodconsortium.org"
11
+ URL = "https://w3id.org/dfc/ontology/context/context_1.16.0.json"
12
+ URL_NORMALISED = "http://w3id.org/dfc/ontology/context/context_1.16.0.json"
12
13
 
13
- add_preloaded("http://www.datafoodconsortium.org/") { parse(json) }
14
+ # All context URIs have to use http because https is normalised to http
15
+ # during the lookup of preloaded contexts.
16
+ # And if the URI doesn't have a path, it must end with `/`.
17
+ add_preloaded(URL_NORMALISED) { parse(json) }
18
+
19
+ # The default context always pointing to the latest version:
20
+ alias_preloaded("http://www.datafoodconsortium.org/", URL_NORMALISED)
14
21
 
15
22
  # This is the current file the DFC website refers to in a link header.
16
23
  alias_preloaded(
17
- "https://www.datafoodconsortium.org/wp-content/plugins/wordpress-context-jsonld/context_1.16.0.jsonld",
18
- "http://www.datafoodconsortium.org/"
24
+ "http://www.datafoodconsortium.org/wp-content/plugins/wordpress-context-jsonld/context_1.16.0.jsonld",
25
+ URL_NORMALISED
19
26
  )
20
27
 
21
28
  # This was the file the DFC website refers to in a link header.
22
29
  alias_preloaded(
23
- "https://www.datafoodconsortium.org/wp-content/plugins/wordpress-context-jsonld/context.jsonld",
24
- "http://www.datafoodconsortium.org/"
30
+ "http://www.datafoodconsortium.org/wp-content/plugins/wordpress-context-jsonld/context.jsonld",
31
+ URL_NORMALISED
25
32
  )
26
33
 
27
34
  # This is the old URL that's not online anymore.
28
35
  # Keep it for compatiblity with all versions before 1.8.
29
36
  alias_preloaded(
30
37
  "http://static.datafoodconsortium.org/ontologies/context.json",
31
- "http://www.datafoodconsortium.org/"
38
+ URL_NORMALISED
32
39
  )
33
40
 
34
41
  # The hash serializer expects only string values in the context.
@@ -31,8 +31,6 @@ class DataFoodConsortium::Connector::JsonLdSerializer
31
31
  end
32
32
 
33
33
  def process(*subjects)
34
- return "" if subjects.empty?
35
-
36
34
  # Insert an input context on each subject so the properties could be prefixed. This way,
37
35
  # the DFC's context can be used.
38
36
  # See https://github.com/datafoodconsortium/connector-ruby/issues/11.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datafoodconsortium-connector
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxime Lecoq
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2025-11-24 00:00:00.000000000 Z
12
+ date: 2025-12-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: virtual_assembly-semantizer