datafoodconsortium-connector 2.0.0.pre.beta4 → 2.0.0.pre.beta6

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: 2793b3c148d5db9d19bb82a711bf4cf7f438d40b338a30b5a40a7f0ff7a7df9e
4
- data.tar.gz: 8c335762e0bbba6fd2afc6e50fce0ca4c82e54498f401d16d66133cdc0b77096
3
+ metadata.gz: c82f6284382291eb8bb3b42ca119b42bde29a1205a6cdecbb8e3570f80f81a7e
4
+ data.tar.gz: 7a70114944a8b5f7b7d68d49dfeeb9cddfdd92afe4d651cc70cf4675b0ce5540
5
5
  SHA512:
6
- metadata.gz: 422db860ac8f9404a7bc5e4eb8f50f8f84bb1809cabd2555a8d628756c331b84c7be5d7da69c944b35a68831bb5e2995e8a7cf5f4d95f516888852219592365c
7
- data.tar.gz: 525d285d284ac07f9e7f4f0f3ee8cf000e54f499e5e609eac50b030299e4a07bf015b3ae350621e0d0358805fe3b97035ed2fab867961d8a13756e808f179968
6
+ metadata.gz: 2af23cf4349eef552d993e0847d04db71fe0e4de5a5a13ca9790dd78b2d572e4902b6b359b55e1f37a7ded77c1df73118c389e87f4902811f6ab25be44c42676
7
+ data.tar.gz: 53b97c2659f3f5c0a1189ec4ec3b5a18948d42eee7e29d3e85c7224dc14c0e3e4f3c399a7763a1c90d57dafdf5ee99b3913c4791b25c20458fa594c37aa1393d
@@ -37,7 +37,7 @@ class DataFoodConsortium::Connector::Address
37
37
  # @return [String]
38
38
  attr_accessor :city
39
39
 
40
- # @return [String]
40
+ # @return [ISKOSConcept]
41
41
  attr_accessor :country
42
42
 
43
43
  # @return [Real]
@@ -53,7 +53,7 @@ class DataFoodConsortium::Connector::Address
53
53
  # @param street [String]
54
54
  # @param postalCode [String]
55
55
  # @param city [String]
56
- # @param country [String]
56
+ # @param country [ISKOSConcept]
57
57
  # @param latitude [Real]
58
58
  # @param longitude [Real]
59
59
  # @param region [String]
@@ -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,24 +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_2.0.0.json"
12
+ URL_NORMALISED = "http://w3id.org/dfc/ontology/context/context_2.0.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_2.0.0.jsonld",
18
- "http://www.datafoodconsortium.org/"
24
+ "http://www.datafoodconsortium.org/wp-content/plugins/wordpress-context-jsonld/context_2.0.0.jsonld",
25
+ URL_NORMALISED
19
26
  )
20
27
 
28
+ # This was the file the DFC website refers to in a link header.
21
29
  alias_preloaded(
22
- "https://w3id.org/dfc/ontology/context/context_2.0.0.json",
23
- "http://www.datafoodconsortium.org/"
30
+ "http://www.datafoodconsortium.org/wp-content/plugins/wordpress-context-jsonld/context_2.0.0.jsonld",
31
+ URL_NORMALISED
24
32
  )
25
33
 
34
+ # This is the old URL that's not online anymore.
35
+ # Keep it for compatiblity with all versions before 1.8.
26
36
  alias_preloaded(
27
- "https://cdn.jsdelivr.net/gh/datafoodconsortium/ontology/context/context_2.0.0.json",
28
- "http://www.datafoodconsortium.org/"
37
+ "http://static.datafoodconsortium.org/ontologies/context.json",
38
+ URL_NORMALISED
29
39
  )
30
40
 
31
41
  # The hash serializer expects only string values in the context.
@@ -38,4 +48,4 @@ module DataFoodConsortium
38
48
  end
39
49
  end
40
50
  end
41
- end
51
+ end
@@ -29,6 +29,9 @@ class DataFoodConsortium::Connector::CustomerCategory
29
29
 
30
30
  SEMANTIC_TYPE = "dfc-b:CustomerCategory".freeze
31
31
 
32
+ # @return [String]
33
+ attr_accessor :name
34
+
32
35
  # @return [String]
33
36
  attr_accessor :description
34
37
 
@@ -36,13 +39,16 @@ class DataFoodConsortium::Connector::CustomerCategory
36
39
  attr_accessor :members
37
40
 
38
41
  # @param semanticId [String]
42
+ # @param name [String]
39
43
  # @param description [String]
40
44
  # @param members [IAgent]
41
- def initialize(semanticId, description: nil, members: [])
45
+ def initialize(semanticId, name: nil, description: nil, members: [])
42
46
  super(semanticId)
47
+ @name = name
43
48
  @description = description
44
49
  @members = members
45
50
  self.semanticType = "dfc-b:CustomerCategory"
51
+ registerSemanticProperty("dfc-b:name", &method("name")).valueSetter = method("name=")
46
52
  registerSemanticProperty("dfc-b:description", &method("description")).valueSetter = method("description=")
47
53
  registerSemanticProperty("dfc-b:isMemberOf", &method("members")).valueSetter = method("members=")
48
54
  end
@@ -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.
@@ -21,29 +21,35 @@
21
21
  # SOFTWARE.
22
22
 
23
23
 
24
-
25
24
  require "virtual_assembly/semantizer"
26
25
 
27
- class DataFoodConsortium::Connector::Quantity
26
+ class DataFoodConsortium::Connector::OpeningHoursSpecification
28
27
  include VirtualAssembly::Semantizer::SemanticObject
29
28
 
30
- SEMANTIC_TYPE = "dfc-b:Quantity".freeze
31
-
32
- # @return [ISKOSConcept]
33
- attr_accessor :unit
34
-
35
- # @return [Real]
36
- attr_accessor :value
37
-
38
- # @param unit [ISKOSConcept]
39
- # @param value [Real]
40
- def initialize(unit: nil, value: nil)
41
- super()
42
- @unit = unit
43
- @value = value
44
- self.semanticType = "dfc-b:Quantity"
45
- registerSemanticProperty("dfc-b:hasUnit", &method("unit")).valueSetter = method("unit=")
46
- registerSemanticProperty("dfc-b:value", &method("value")).valueSetter = method("value=")
29
+ SEMANTIC_TYPE = "https://schema.org/OpeningHoursSpecification".freeze
30
+
31
+ # @return [String]
32
+ attr_accessor :dayOfWeek
33
+
34
+ # @return [Time]
35
+ attr_accessor :opens
36
+
37
+ # @return [Time]
38
+ attr_accessor :closes
39
+
40
+ # @param semanticId [String]
41
+ # @param dayOfWeek [String]
42
+ # @param opens [Time]
43
+ # @param closes [Time]
44
+ def initialize(semanticId, dayOfWeek: nil, opens: nil, closes: nil)
45
+ super(semanticId)
46
+ @dayOfWeek = dayOfWeek
47
+ @opens = opens
48
+ @closes = closes
49
+ self.semanticType = "https://schema.org/OpeningHoursSpecification"
50
+ registerSemanticProperty("https://schema.org/dayOfWeek", &method("dayOfWeek")).valueSetter = method("dayOfWeek=")
51
+ registerSemanticProperty("https://schema.org/opens", &method("opens")).valueSetter = method("opens=")
52
+ registerSemanticProperty("https://schema.org/closes", &method("closes")).valueSetter = method("closes=")
47
53
  end
48
54
 
49
55
 
@@ -47,7 +47,7 @@ class DataFoodConsortium::Connector::PlannedConsumptionFlow < DataFoodConsortium
47
47
  @transformation = transformation
48
48
  @product = product
49
49
  self.semanticType = "dfc-b:AsPlannedConsumptionFlow"
50
- registerSemanticProperty("dfc-b:incomeOf", &method("transformation")).valueSetter = method("transformation=")
50
+ registerSemanticProperty("dfc-b:inputOf", &method("transformation")).valueSetter = method("transformation=")
51
51
  registerSemanticProperty("dfc-b:consumes", &method("product")).valueSetter = method("product=")
52
52
  end
53
53
 
@@ -47,7 +47,7 @@ class DataFoodConsortium::Connector::PlannedLocalConsumptionFlow < DataFoodConso
47
47
  @transformation = transformation
48
48
  @product = product
49
49
  self.semanticType = "dfc-b:AsPlannedLocalConsumptionFlow"
50
- registerSemanticProperty("dfc-b:incomeOf", &method("transformation")).valueSetter = method("transformation=")
50
+ registerSemanticProperty("dfc-b:inputOf", &method("transformation")).valueSetter = method("transformation=")
51
51
  registerSemanticProperty("dfc-b:consumes", &method("product")).valueSetter = method("product=")
52
52
  end
53
53
 
@@ -47,7 +47,7 @@ class DataFoodConsortium::Connector::PlannedLocalProductionFlow < DataFoodConsor
47
47
  @transformation = transformation
48
48
  @product = product
49
49
  self.semanticType = "dfc-b:AsPlannedLocalProductionFlow"
50
- registerSemanticProperty("dfc-b:outcomeOf", &method("transformation")).valueSetter = method("transformation=")
50
+ registerSemanticProperty("dfc-b:outputOf", &method("transformation")).valueSetter = method("transformation=")
51
51
  registerSemanticProperty("dfc-b:produces", &method("product")).valueSetter = method("product=")
52
52
  end
53
53
 
@@ -70,8 +70,8 @@ class DataFoodConsortium::Connector::PlannedLocalTransformation
70
70
  registerSemanticProperty("dfc-b:cost", &method("cost")).valueSetter = method("cost=")
71
71
  registerSemanticProperty("dfc-b:startDate", &method("startDate")).valueSetter = method("startDate=")
72
72
  registerSemanticProperty("dfc-b:endDate", &method("endDate")).valueSetter = method("endDate=")
73
- registerSemanticProperty("dfc-b:hasIncome", &method("consumptionFlow")).valueSetter = method("consumptionFlow=")
74
- registerSemanticProperty("dfc-b:hasOutcome", &method("productionFlow")).valueSetter = method("productionFlow=")
73
+ registerSemanticProperty("dfc-b:hasInput", &method("consumptionFlow")).valueSetter = method("consumptionFlow=")
74
+ registerSemanticProperty("dfc-b:hasOutput", &method("productionFlow")).valueSetter = method("productionFlow=")
75
75
  end
76
76
 
77
77
 
@@ -47,7 +47,7 @@ class DataFoodConsortium::Connector::PlannedProductionFlow < DataFoodConsortium:
47
47
  @transformation = transformation
48
48
  @product = product
49
49
  self.semanticType = "dfc-b:AsPlannedProductionFlow"
50
- registerSemanticProperty("dfc-b:outcomeOf", &method("transformation")).valueSetter = method("transformation=")
50
+ registerSemanticProperty("dfc-b:outputOf", &method("transformation")).valueSetter = method("transformation=")
51
51
  registerSemanticProperty("dfc-b:produces", &method("product")).valueSetter = method("product=")
52
52
  end
53
53
 
@@ -51,8 +51,8 @@ class DataFoodConsortium::Connector::PlannedTransformation
51
51
  @productionFlow = productionFlow
52
52
  self.semanticType = "dfc-b:AsPlannedTransformation"
53
53
  registerSemanticProperty("dfc-b:hasTransformationType", &method("transformationType")).valueSetter = method("transformationType=")
54
- registerSemanticProperty("dfc-b:hasIncome", &method("consumptionFlow")).valueSetter = method("consumptionFlow=")
55
- registerSemanticProperty("dfc-b:hasOutcome", &method("productionFlow")).valueSetter = method("productionFlow=")
54
+ registerSemanticProperty("dfc-b:hasInput", &method("consumptionFlow")).valueSetter = method("consumptionFlow=")
55
+ registerSemanticProperty("dfc-b:hasOutput", &method("productionFlow")).valueSetter = method("productionFlow=")
56
56
  end
57
57
 
58
58
 
@@ -47,7 +47,7 @@ class DataFoodConsortium::Connector::RealizedConsumptionFlow < DataFoodConsortiu
47
47
  @transformation = transformation
48
48
  @product = product
49
49
  self.semanticType = "dfc-b:AsRealizedConsumptionFlow"
50
- registerSemanticProperty("dfc-b:incomeOf", &method("transformation")).valueSetter = method("transformation=")
50
+ registerSemanticProperty("dfc-b:inputOf", &method("transformation")).valueSetter = method("transformation=")
51
51
  registerSemanticProperty("dfc-b:consumes", &method("product")).valueSetter = method("product=")
52
52
  end
53
53
 
@@ -47,7 +47,7 @@ class DataFoodConsortium::Connector::RealizedProductionFlow < DataFoodConsortium
47
47
  @transformation = transformation
48
48
  @product = product
49
49
  self.semanticType = "dfc-b:AsRealizedProductionFlow"
50
- registerSemanticProperty("dfc-b:outcomeOf", &method("transformation")).valueSetter = method("transformation=")
50
+ registerSemanticProperty("dfc-b:outputOf", &method("transformation")).valueSetter = method("transformation=")
51
51
  registerSemanticProperty("dfc-b:produces", &method("product")).valueSetter = method("product=")
52
52
  end
53
53
 
@@ -64,8 +64,8 @@ class DataFoodConsortium::Connector::RealizedTransformation
64
64
  registerSemanticProperty("dfc-b:hasTransformationType", &method("transformationType")).valueSetter = method("transformationType=")
65
65
  registerSemanticProperty("dfc-b:startDate", &method("startDate")).valueSetter = method("startDate=")
66
66
  registerSemanticProperty("dfc-b:endDate", &method("endDate")).valueSetter = method("endDate=")
67
- registerSemanticProperty("dfc-b:hasIncome", &method("consumptionFlow")).valueSetter = method("consumptionFlow=")
68
- registerSemanticProperty("dfc-b:hasOutcome", &method("productionFlow")).valueSetter = method("productionFlow=")
67
+ registerSemanticProperty("dfc-b:hasInput", &method("consumptionFlow")).valueSetter = method("consumptionFlow=")
68
+ registerSemanticProperty("dfc-b:hasOutput", &method("productionFlow")).valueSetter = method("productionFlow=")
69
69
  end
70
70
 
71
71
 
@@ -15,9 +15,9 @@ module DataFoodConsortium
15
15
  require 'datafoodconsortium/connector/allergen_characteristic.rb'
16
16
  require 'datafoodconsortium/connector/characteristic.rb'
17
17
  require 'datafoodconsortium/connector/nutrient_characteristic.rb'
18
+ require 'datafoodconsortium/connector/opening_hours_specification.rb'
18
19
  require 'datafoodconsortium/connector/physical_characteristic.rb'
19
20
  require 'datafoodconsortium/connector/quantitative_value.rb'
20
- require 'datafoodconsortium/connector/quantity.rb'
21
21
  require 'datafoodconsortium/connector/value_recur.rb'
22
22
  require 'datafoodconsortium/connector/vevent.rb'
23
23
  require 'datafoodconsortium/connector/defined_product.rb'
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: 2.0.0.pre.beta4
4
+ version: 2.0.0.pre.beta6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxime Lecoq
@@ -57,6 +57,7 @@ files:
57
57
  - lib/datafoodconsortium/connector/localized_product.rb
58
58
  - lib/datafoodconsortium/connector/nutrient_characteristic.rb
59
59
  - lib/datafoodconsortium/connector/offer.rb
60
+ - lib/datafoodconsortium/connector/opening_hours_specification.rb
60
61
  - lib/datafoodconsortium/connector/order.rb
61
62
  - lib/datafoodconsortium/connector/order_line.rb
62
63
  - lib/datafoodconsortium/connector/organization.rb
@@ -79,7 +80,6 @@ files:
79
80
  - lib/datafoodconsortium/connector/product_option.rb
80
81
  - lib/datafoodconsortium/connector/product_option_value.rb
81
82
  - lib/datafoodconsortium/connector/quantitative_value.rb
82
- - lib/datafoodconsortium/connector/quantity.rb
83
83
  - lib/datafoodconsortium/connector/real_stock.rb
84
84
  - lib/datafoodconsortium/connector/realized_consumption_flow.rb
85
85
  - lib/datafoodconsortium/connector/realized_production_flow.rb