From da0cd6e2e015a4d49860402ab81513d0f282b325 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Tue, 14 Jan 2025 14:44:19 +1100 Subject: [PATCH 1/4] Bump DFC context from 1.8.0 to 1.8.2 --- connector.gemspec | 2 +- lib/datafoodconsortium/connector/context.rb | 40 +- .../connector/context_1.8.2.json | 450 ++++++++++++++++++ spec/export_spec.rb | 2 +- spec/supplied_product_spec.rb | 2 +- 5 files changed, 454 insertions(+), 42 deletions(-) create mode 100644 lib/datafoodconsortium/connector/context_1.8.2.json diff --git a/connector.gemspec b/connector.gemspec index 0c5376d..1d9ddde 100644 --- a/connector.gemspec +++ b/connector.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.description = "A library to easily integrate the DFC standard within your application." s.authors = ["Maxime Lecoq"] s.email = "maxime@lecoqlibre.fr" - s.files = Dir["lib/**/*.rb"] + s.files = Dir["lib/**/*.*"] s.homepage = "https://github.com/datafoodconsortium/connector-ruby/" s.license = "MIT" diff --git a/lib/datafoodconsortium/connector/context.rb b/lib/datafoodconsortium/connector/context.rb index 4b1f761..d4f9564 100644 --- a/lib/datafoodconsortium/connector/context.rb +++ b/lib/datafoodconsortium/connector/context.rb @@ -8,45 +8,7 @@ module DataFoodConsortium module Connector class Context < JSON::LD::Context - VERSION_1_8 = JSON.parse <<~JSON - { - "rdfs": "http://www.w3.org/2000/01/rdf-schema#", - "skos" : "http://www.w3.org/2004/02/skos/core#", - "dfc": "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_FullModel.owl#", - "dc": "http://purl.org/dc/elements/1.1/#", - "dfc-b": "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#", - "dfc-p": "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_ProductGlossary.owl#", - "dfc-t": "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_TechnicalOntology.owl#", - "dfc-m": "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/measures.rdf#", - "dfc-pt": "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/productTypes.rdf#", - "dfc-f": "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/facets.rdf#", - "ontosec": "http://www.semanticweb.org/ontologies/2008/11/OntologySecurity.owl#", - "dfc-p:hasUnit":{ "@type":"@id" }, - "dfc-b:hasUnit":{ "@type":"@id" }, - "dfc-b:hasQuantity":{ "@type":"@id" }, - "dfc-p:hasType":{ "@type":"@id" }, - "dfc-b:hasType":{ "@type":"@id" }, - "dfc-b:references":{ "@type":"@id" }, - "dfc-b:referencedBy":{ "@type":"@id" }, - "dfc-b:offeres":{ "@type":"@id" }, - "dfc-b:supplies":{ "@type":"@id" }, - "dfc-b:defines":{ "@type":"@id" }, - "dfc-b:affiliates":{ "@type":"@id" }, - "dfc-b:hasCertification":{ "@type":"@id" }, - "dfc-b:manages":{ "@type":"@id" }, - "dfc-b:offeredThrough":{ "@type":"@id" }, - "dfc-b:hasBrand":{ "@type":"@id" }, - "dfc-b:hasGeographicalOrigin":{ "@type":"@id" }, - "dfc-b:hasClaim":{ "@type":"@id" }, - "dfc-b:hasAllergenDimension":{ "@type":"@id" }, - "dfc-b:hasNutrientDimension":{ "@type":"@id" }, - "dfc-b:hasPhysicalDimension":{ "@type":"@id" }, - "dfc:owner":{ "@type":"@id" }, - "dfc-t:hostedBy":{ "@type":"@id" }, - "dfc-t:hasPivot":{ "@type":"@id" }, - "dfc-t:represent":{ "@type":"@id" } - } - JSON + VERSION_1_8 = JSON.parse(File.read("#{__dir__}/context_1.8.2.json"))["@context"] add_preloaded("http://www.datafoodconsortium.org/") { parse(VERSION_1_8) } diff --git a/lib/datafoodconsortium/connector/context_1.8.2.json b/lib/datafoodconsortium/connector/context_1.8.2.json new file mode 100644 index 0000000..d574d54 --- /dev/null +++ b/lib/datafoodconsortium/connector/context_1.8.2.json @@ -0,0 +1,450 @@ +{ + "@context": { + "rdfs": "http://www.w3.org/2000/01/rdf-schema#", + "skos" : "http://www.w3.org/2004/02/skos/core#", + "dfc": "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_FullModel.owl#", + "dc": "http://purl.org/dc/elements/1.1/#", + "dfc-b": "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_BusinessOntology.owl#", + "dfc-t": "https://github.com/datafoodconsortium/ontology/releases/latest/download/DFC_TechnicalOntology.owl#", + "dfc-m": "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/measures.rdf#", + "dfc-pt": "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/productTypes.rdf#", + "dfc-f": "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/facets.rdf#", + "dfc-v": "https://github.com/datafoodconsortium/taxonomies/releases/latest/download/vocabulary.rdf#", + "ontosec": "http://www.semanticweb.org/ontologies/2008/11/OntologySecurity.owl#", + "dfc-b:DFC_BusinessOntology_ObjectProperty": { + "@type": "@id" + }, + "dfc-b:DFC_Interface_Property": { + "@type": "@id" + }, + "dfc-b:addressOf": { + "@type": "@id" + }, + "dfc-b:affiliatedTo": { + "@type": "@id" + }, + "dfc-b:affiliates": { + "@type": "@id" + }, + "dfc-b:allergenCharacteristicOf": { + "@type": "@id" + }, + "dfc-b:belongsTo": { + "@type": "@id" + }, + "dfc-b:brandOf": { + "@type": "@id" + }, + "dfc-b:certificateOf": { + "@type": "@id" + }, + "dfc-b:characteristicOf": { + "@type": "@id" + }, + "dfc-b:claimOf": { + "@type": "@id" + }, + "dfc-b:composedOf": { + "@type": "@id" + }, + "dfc-b:composes": { + "@type": "@id" + }, + "dfc-b:concernedBy": { + "@type": "@id" + }, + "dfc-b:concerns": { + "@type": "@id" + }, + "dfc-b:constituedBy": { + "@type": "@id" + }, + "dfc-b:constitutes": { + "@type": "@id" + }, + "dfc-b:consumedBy": { + "@type": "@id" + }, + "dfc-b:consumes": { + "@type": "@id" + }, + "dfc-b:containerInformationOf": { + "@type": "@id" + }, + "dfc-b:coordinatedBy": { + "@type": "@id" + }, + "dfc-b:coordinates": { + "@type": "@id" + }, + "dfc-b:definedBy": { + "@type": "@id" + }, + "dfc-b:defines": { + "@type": "@id" + }, + "dfc-b:deliveredAt": { + "@type": "@id" + }, + "dfc-b:facetOf": { + "@type": "@id" + }, + "dfc-b:from": { + "@type": "@id" + }, + "dfc-b:geographicalOriginOf": { + "@type": "@id" + }, + "dfc-b:hasAddress": { + "@type": "@id" + }, + "dfc-b:hasAllergenCharacteristic": { + "@type": "@id" + }, + "dfc-b:hasAllergenDimension": { + "@type": "@id" + }, + "dfc-b:hasBrand": { + "@type": "@id" + }, + "dfc-b:hasCertification": { + "@type": "@id" + }, + "dfc-b:hasCharacteristic": { + "@type": "@id" + }, + "dfc-b:hasClaim": { + "@type": "@id" + }, + "dfc-b:hasContainerInformation": { + "@type": "@id" + }, + "dfc-b:hasDimension": { + "@type": "@id" + }, + "dfc-b:hasFacet": { + "@type": "@id" + }, + "dfc-b:hasFulfilmentStatus": { + "@type": "@id" + }, + "dfc-b:hasGeographicalOrigin": { + "@type": "@id" + }, + "dfc-b:hasIngredient": { + "@type": "@id" + }, + "dfc-b:hasInput": { + "@type": "@id" + }, + "dfc-b:hasLabellingCharacteristic": { + "@type": "@id" + }, + "dfc-b:hasLabellingDimension": { + "@type": "@id" + }, + "dfc-b:hasMainContact": { + "@type": "@id" + }, + "dfc-b:hasNatureOrigin": { + "@type": "@id" + }, + "dfc-b:hasNutrientCharacteristic": { + "@type": "@id" + }, + "dfc-b:hasNutrientDimension": { + "@type": "@id" + }, + "dfc-b:hasObject": { + "@type": "@id" + }, + "dfc-b:hasOffer": { + "@type": "@id" + }, + "dfc-b:hasOption": { + "@type": "@id" + }, + "dfc-b:hasOrderStatus": { + "@type": "@id" + }, + "dfc-b:hasOutput": { + "@type": "@id" + }, + "dfc-b:hasPart": { + "@type": "@id" + }, + "dfc-b:hasPartOrigin": { + "@type": "@id" + }, + "dfc-b:hasPaymentMethod": { + "@type": "@id" + }, + "dfc-b:hasPaymentStatus": { + "@type": "@id" + }, + "dfc-b:hasPhoneNumber": { + "@type": "@id" + }, + "dfc-b:hasPhysicalCharacteristic": { + "@type": "@id" + }, + "dfc-b:hasPhysicalDimension": { + "@type": "@id" + }, + "dfc-b:hasPrice": { + "@type": "@id" + }, + "dfc-b:hasProcess": { + "@type": "@id" + }, + "dfc-b:hasQuantity": { + "@type": "@id" + }, + "dfc-b:hasReference": { + "@type": "@id" + }, + "dfc-b:hasSocialMedia": { + "@type": "@id" + }, + "dfc-b:hasStatus": { + "@type": "@id" + }, + "dfc-b:hasTemperature": { + "@type": "@id" + }, + "dfc-b:hasTransformationType": { + "@type": "@id" + }, + "dfc-b:hasType": { + "@type": "@id" + }, + "dfc-b:hasUnit": { + "@type": "@id" + }, + "dfc-b:holds": { + "@type": "@id" + }, + "dfc-b:hostedAt": { + "@type": "@id" + }, + "dfc-b:hosts": { + "@type": "@id" + }, + "dfc-b:identifiedBy": { + "@type": "@id" + }, + "dfc-b:identifies": { + "@type": "@id" + }, + "dfc-b:industrializedBy": { + "@type": "@id" + }, + "dfc-b:industrializes": { + "@type": "@id" + }, + "dfc-b:inputOf": { + "@type": "@id" + }, + "dfc-b:isIngredientOf": { + "@type": "@id" + }, + "dfc-b:isPriceOf": { + "@type": "@id" + }, + "dfc-b:isTemperatureOf": { + "@type": "@id" + }, + "dfc-b:labellingCharacteristicOf": { + "@type": "@id" + }, + "dfc-b:listedIn": { + "@type": "@id" + }, + "dfc-b:lists": { + "@type": "@id" + }, + "dfc-b:localizedBy": { + "@type": "@id" + }, + "dfc-b:localizes": { + "@type": "@id" + }, + "dfc-b:mainContactOf": { + "@type": "@id" + }, + "dfc-b:maintainedBy": { + "@type": "@id" + }, + "dfc-b:maintains": { + "@type": "@id" + }, + "dfc-b:managedBy": { + "@type": "@id" + }, + "dfc-b:manages": { + "@type": "@id" + }, + "dfc-b:natureOriginOf": { + "@type": "@id" + }, + "dfc-b:nutrientCharacteristicOf": { + "@type": "@id" + }, + "dfc-b:objectOf": { + "@type": "@id" + }, + "dfc-b:offeredThrough": { + "@type": "@id" + }, + "dfc-b:offers": { + "@type": "@id" + }, + "dfc-b:offersTo": { + "@type": "@id" + }, + "dfc-b:optionOf": { + "@type": "@id" + }, + "dfc-b:orderedBy": { + "@type": "@id" + }, + "dfc-b:orders": { + "@type": "@id" + }, + "dfc-b:outputOf": { + "@type": "@id" + }, + "dfc-b:ownedBy": { + "@type": "@id" + }, + "dfc-b:owns": { + "@type": "@id" + }, + "dfc-b:paidWith": { + "@type": "@id" + }, + "dfc-b:partOf": { + "@type": "@id" + }, + "dfc-b:partOriginOf": { + "@type": "@id" + }, + "dfc-b:phoneNumberOf": { + "@type": "@id" + }, + "dfc-b:physicalCharacteristicOf": { + "@type": "@id" + }, + "dfc-b:pickedUpAt": { + "@type": "@id" + }, + "dfc-b:processOf": { + "@type": "@id" + }, + "dfc-b:producedBy": { + "@type": "@id" + }, + "dfc-b:produces": { + "@type": "@id" + }, + "dfc-b:proposedBy": { + "@type": "@id" + }, + "dfc-b:proposes": { + "@type": "@id" + }, + "dfc-b:referenceOf": { + "@type": "@id" + }, + "dfc-b:referencedBy": { + "@type": "@id" + }, + "dfc-b:references": { + "@type": "@id" + }, + "dfc-b:refersTo": { + "@type": "@id" + }, + "dfc-b:representedBy": { + "@type": "@id" + }, + "dfc-b:represents": { + "@type": "@id" + }, + "dfc-b:requestedBy": { + "@type": "@id" + }, + "dfc-b:requests": { + "@type": "@id" + }, + "dfc-b:satisfiedBy": { + "@type": "@id" + }, + "dfc-b:satisfies": { + "@type": "@id" + }, + "dfc-b:selectedBy": { + "@type": "@id" + }, + "dfc-b:selects": { + "@type": "@id" + }, + "dfc-b:sells": { + "@type": "@id" + }, + "dfc-b:socialMediaOf": { + "@type": "@id" + }, + "dfc-b:soldBy": { + "@type": "@id" + }, + "dfc-b:storedIn": { + "@type": "@id" + }, + "dfc-b:stores": { + "@type": "@id" + }, + "dfc-b:suppliedBy": { + "@type": "@id" + }, + "dfc-b:supplies": { + "@type": "@id" + }, + "dfc-b:suppliesTo": { + "@type": "@id" + }, + "dfc-b:to": { + "@type": "@id" + }, + "dfc-b:tracedBy": { + "@type": "@id" + }, + "dfc-b:traces": { + "@type": "@id" + }, + "dfc-b:transformedBy": { + "@type": "@id" + }, + "dfc-b:transforms": { + "@type": "@id" + }, + "dfc-b:typeOf": { + "@type": "@id" + }, + "dfc-b:uses": { + "@type": "@id" + }, + "dfc-t:represent": { + "@type": "@id" + }, + "dfc-t:hasPivot": { + "@type": "@id" + }, + "dfc-t:hostedBy": { + "@type": "@id" + }, + "dfc-t:owner": { + "@type": "@id" + } + } +} \ No newline at end of file diff --git a/spec/export_spec.rb b/spec/export_spec.rb index fdefe77..2835b13 100644 --- a/spec/export_spec.rb +++ b/spec/export_spec.rb @@ -88,7 +88,7 @@ '@context' => 'https://www.datafoodconsortium.org', '@graph' => [ { '@id' => 'https://myplatform.com/p', '@type' => 'dfc-b:Person', 'dfc-b:affiliates' => 'https://myplatform.com/e', - 'dfc-b:familyName' => 'lastName', 'dfc-b:firstName' => 'firstName', 'dfc-b:hasAddress' => 'https://myplatform.com/a' }, { '@id' => 'https://myplatform.com/a', '@type' => 'dfc-b:Address', 'dfc-b:hasCity' => 'city', 'dfc-b:hasCountry' => 'country', 'dfc-b:hasPostalCode' => 'postalCode', 'dfc-b:hasStreet' => 'street' }, { '@id' => 'https://myplatform.com/e', '@type' => 'dfc-b:Enterprise', 'dfc-b:VATnumber' => 'vatNumber', 'dfc-b:defines' => 'https://myplatform.com/cc', 'dfc-b:hasDescription' => 'description', 'dfc-b:manages' => 'https://myplatform.com/ci', 'dfc-b:name' => 'name', 'dfc-b:supplies' => 'https://myplatform.com/sp' }, { '@id' => 'https://myplatform.com/cc', '@type' => 'dfc-b:CustomerCategory', 'dfc-b:description' => 'description' }, { '@id' => 'https://myplatform.com/sp', '@type' => 'dfc-b:SuppliedProduct', 'dfc-b:alcoholPercentage' => 2.6, 'dfc-b:description' => 'description', 'dfc-b:hasCertification' => 'dfc-f:Demeter', 'dfc-b:hasClaim' => ['dfc-f:EnergyFree', 'dfc-f:FatFree', 'dfc-f:HighFibre'], 'dfc-b:hasGeographicalOrigin' => 'dfc-f:Normandy', 'dfc-b:hasNatureOrigin' => 'https://github.com/datafoodconsortium/taxonomies/releases/latest/download/facets.rdf#PlantOrigin', 'dfc-b:hasNutrientCharacteristic' => { '@type' => 'dfc-b:NutrientCharacteristic', 'dfc-b:hasNutrientDimension' => 'dfc-m:Calcium', 'dfc-b:hasUnit' => 'dfc-m:Gram', 'dfc-b:value' => 8.47 }, 'dfc-b:hasPartOrigin' => 'https://github.com/datafoodconsortium/taxonomies/releases/latest/download/facets.rdf#PlantOrigin', 'dfc-b:hasPhysicalCharacteristic' => { '@type' => 'dfc-b:PhysicalCharacteristic', 'dfc-b:hasPhysicalDimension' => 'dfc-m:Weight', 'dfc-b:hasUnit' => 'dfc-m:Kilogram', 'dfc-b:value' => 3.25 }, 'dfc-b:hasQuantity' => { '@type' => 'dfc-b:QuantitativeValue', 'dfc-b:hasUnit' => 'dfc-m:Kilogram', 'dfc-b:value' => 1.2 }, 'dfc-b:hasType' => 'dfc-pt:artichoke', 'dfc-b:lifetime' => 'lifetime', 'dfc-b:name' => 'name', 'dfc-b:totalTheoreticalStock' => 123, 'dfc-b:usageOrStorageCondition' => 'usageOrStorageConditions' }, { '@id' => 'https://myplatform.com/ci', '@type' => 'dfc-b:CatalogItem', 'dfc-b:offeredThrough' => 'https://myplatform.com/o', 'dfc-b:references' => 'https://myplatform.com/sp', 'dfc-b:sku' => 'sku', 'dfc-b:stockLimitation' => 10 }, { '@id' => 'https://myplatform.com/o', '@type' => 'dfc-b:Offer', 'dfc-b:hasPrice' => { '@type' => 'dfc-b:Price', 'dfc-b:VATrate' => 5.22, 'dfc-b:hasUnit' => 'dfc-m:Euro', 'dfc-b:value' => 12.78 }, 'dfc-b:offeredTo' => 'https://myplatform.com/cc', 'dfc-b:stockLimitation' => 52 } + 'dfc-b:familyName' => 'lastName', 'dfc-b:firstName' => 'firstName', 'dfc-b:hasAddress' => 'https://myplatform.com/a' }, { '@id' => 'https://myplatform.com/a', '@type' => 'dfc-b:Address', 'dfc-b:hasCity' => 'city', 'dfc-b:hasCountry' => 'country', 'dfc-b:hasPostalCode' => 'postalCode', 'dfc-b:hasStreet' => 'street' }, { '@id' => 'https://myplatform.com/e', '@type' => 'dfc-b:Enterprise', 'dfc-b:VATnumber' => 'vatNumber', 'dfc-b:defines' => 'https://myplatform.com/cc', 'dfc-b:hasDescription' => 'description', 'dfc-b:manages' => 'https://myplatform.com/ci', 'dfc-b:name' => 'name', 'dfc-b:supplies' => 'https://myplatform.com/sp' }, { '@id' => 'https://myplatform.com/cc', '@type' => 'dfc-b:CustomerCategory', 'dfc-b:description' => 'description' }, { '@id' => 'https://myplatform.com/sp', '@type' => 'dfc-b:SuppliedProduct', 'dfc-b:alcoholPercentage' => 2.6, 'dfc-b:description' => 'description', 'dfc-b:hasCertification' => 'dfc-f:Demeter', 'dfc-b:hasClaim' => ['dfc-f:EnergyFree', 'dfc-f:FatFree', 'dfc-f:HighFibre'], 'dfc-b:hasGeographicalOrigin' => 'dfc-f:Normandy', 'dfc-b:hasNatureOrigin' => 'dfc-f:PlantOrigin', 'dfc-b:hasNutrientCharacteristic' => { '@type' => 'dfc-b:NutrientCharacteristic', 'dfc-b:hasNutrientDimension' => 'dfc-m:Calcium', 'dfc-b:hasUnit' => 'dfc-m:Gram', 'dfc-b:value' => 8.47 }, 'dfc-b:hasPartOrigin' => 'dfc-f:PlantOrigin', 'dfc-b:hasPhysicalCharacteristic' => { '@type' => 'dfc-b:PhysicalCharacteristic', 'dfc-b:hasPhysicalDimension' => 'dfc-m:Weight', 'dfc-b:hasUnit' => 'dfc-m:Kilogram', 'dfc-b:value' => 3.25 }, 'dfc-b:hasQuantity' => { '@type' => 'dfc-b:QuantitativeValue', 'dfc-b:hasUnit' => 'dfc-m:Kilogram', 'dfc-b:value' => 1.2 }, 'dfc-b:hasType' => 'dfc-pt:artichoke', 'dfc-b:lifetime' => 'lifetime', 'dfc-b:name' => 'name', 'dfc-b:totalTheoreticalStock' => 123, 'dfc-b:usageOrStorageCondition' => 'usageOrStorageConditions' }, { '@id' => 'https://myplatform.com/ci', '@type' => 'dfc-b:CatalogItem', 'dfc-b:offeredThrough' => 'https://myplatform.com/o', 'dfc-b:references' => 'https://myplatform.com/sp', 'dfc-b:sku' => 'sku', 'dfc-b:stockLimitation' => 10 }, { '@id' => 'https://myplatform.com/o', '@type' => 'dfc-b:Offer', 'dfc-b:hasPrice' => { '@type' => 'dfc-b:Price', 'dfc-b:VATrate' => 5.22, 'dfc-b:hasUnit' => 'dfc-m:Euro', 'dfc-b:value' => 12.78 }, 'dfc-b:offeredTo' => 'https://myplatform.com/cc', 'dfc-b:stockLimitation' => 52 } ], } expect(actual).to eq(expected) diff --git a/spec/supplied_product_spec.rb b/spec/supplied_product_spec.rb index 90cdadf..259d095 100644 --- a/spec/supplied_product_spec.rb +++ b/spec/supplied_product_spec.rb @@ -49,7 +49,7 @@ ) actual = connector.export(sp) - expected = '{"@context":"https://www.datafoodconsortium.org","@id":"https://myplatform.com/sp","@type":"dfc-b:SuppliedProduct","dfc-b:name":"name","dfc-b:description":"description","dfc-b:hasType":"dfc-pt:artichoke","dfc-b:hasQuantity":{"@type":"dfc-b:QuantitativeValue","dfc-b:hasUnit":"dfc-m:Kilogram","dfc-b:value":1.2},"dfc-b:alcoholPercentage":2.6,"dfc-b:lifetime":"lifetime","dfc-b:hasClaim":["dfc-f:EnergyFree","dfc-f:FatFree","dfc-f:HighFibre"],"dfc-b:usageOrStorageCondition":"usageOrStorageConditions","dfc-b:hasNutrientCharacteristic":{"@type":"dfc-b:NutrientCharacteristic","dfc-b:hasUnit":"dfc-m:Gram","dfc-b:value":8.47,"dfc-b:hasNutrientDimension":"dfc-m:Calcium"},"dfc-b:hasPhysicalCharacteristic":{"@type":"dfc-b:PhysicalCharacteristic","dfc-b:hasUnit":"dfc-m:Kilogram","dfc-b:value":3.25,"dfc-b:hasPhysicalDimension":"dfc-m:Weight"},"dfc-b:hasGeographicalOrigin":"dfc-f:Normandy","dfc-b:hasCertification":"dfc-f:Demeter","dfc-b:hasNatureOrigin":"https://github.com/datafoodconsortium/taxonomies/releases/latest/download/facets.rdf#PlantOrigin","dfc-b:hasPartOrigin":"https://github.com/datafoodconsortium/taxonomies/releases/latest/download/facets.rdf#PlantOrigin","dfc-b:totalTheoreticalStock":123}' + expected = '{"@context":"https://www.datafoodconsortium.org","@id":"https://myplatform.com/sp","@type":"dfc-b:SuppliedProduct","dfc-b:name":"name","dfc-b:description":"description","dfc-b:hasType":"dfc-pt:artichoke","dfc-b:hasQuantity":{"@type":"dfc-b:QuantitativeValue","dfc-b:hasUnit":"dfc-m:Kilogram","dfc-b:value":1.2},"dfc-b:alcoholPercentage":2.6,"dfc-b:lifetime":"lifetime","dfc-b:hasClaim":["dfc-f:EnergyFree","dfc-f:FatFree","dfc-f:HighFibre"],"dfc-b:usageOrStorageCondition":"usageOrStorageConditions","dfc-b:hasNutrientCharacteristic":{"@type":"dfc-b:NutrientCharacteristic","dfc-b:hasUnit":"dfc-m:Gram","dfc-b:value":8.47,"dfc-b:hasNutrientDimension":"dfc-m:Calcium"},"dfc-b:hasPhysicalCharacteristic":{"@type":"dfc-b:PhysicalCharacteristic","dfc-b:hasUnit":"dfc-m:Kilogram","dfc-b:value":3.25,"dfc-b:hasPhysicalDimension":"dfc-m:Weight"},"dfc-b:hasGeographicalOrigin":"dfc-f:Normandy","dfc-b:hasCertification":"dfc-f:Demeter","dfc-b:hasNatureOrigin":"dfc-f:PlantOrigin","dfc-b:hasPartOrigin":"dfc-f:PlantOrigin","dfc-b:totalTheoreticalStock":123}' expect(actual).to eq expected end end From 3593dc5a2f1cfe481ccd1510359fe6d9e7476934 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Tue, 14 Jan 2025 15:04:31 +1100 Subject: [PATCH 2/4] Bump context from 1.8.2 to 1.14.0 --- lib/datafoodconsortium/connector/context.rb | 10 ++++++---- .../{context_1.8.2.json => context_1.14.0.json} | 6 ++++++ lib/datafoodconsortium/connector/importer.rb | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) rename lib/datafoodconsortium/connector/{context_1.8.2.json => context_1.14.0.json} (98%) diff --git a/lib/datafoodconsortium/connector/context.rb b/lib/datafoodconsortium/connector/context.rb index d4f9564..3990cf3 100644 --- a/lib/datafoodconsortium/connector/context.rb +++ b/lib/datafoodconsortium/connector/context.rb @@ -8,9 +8,7 @@ module DataFoodConsortium module Connector class Context < JSON::LD::Context - VERSION_1_8 = JSON.parse(File.read("#{__dir__}/context_1.8.2.json"))["@context"] - - add_preloaded("http://www.datafoodconsortium.org/") { parse(VERSION_1_8) } + add_preloaded("http://www.datafoodconsortium.org/") { parse(json) } # This is the actual file the DFC website refers to in a link header. alias_preloaded( @@ -27,7 +25,11 @@ class Context < JSON::LD::Context # The hash serializer expects only string values in the context. def self.inputContext - @inputContext = VERSION_1_8.select { |key, value| value.is_a? String } + @inputContext = json.select { |key, value| value.is_a? String } + end + + def self.json + @json ||= JSON.parse(File.read("#{__dir__}/context_1.14.0.json"))["@context"] end end end diff --git a/lib/datafoodconsortium/connector/context_1.8.2.json b/lib/datafoodconsortium/connector/context_1.14.0.json similarity index 98% rename from lib/datafoodconsortium/connector/context_1.8.2.json rename to lib/datafoodconsortium/connector/context_1.14.0.json index d574d54..a05b34a 100644 --- a/lib/datafoodconsortium/connector/context_1.8.2.json +++ b/lib/datafoodconsortium/connector/context_1.14.0.json @@ -92,6 +92,9 @@ "dfc-b:from": { "@type": "@id" }, + "dfc-b:fulfills": { + "@type": "@id" + }, "dfc-b:geographicalOriginOf": { "@type": "@id" }, @@ -245,6 +248,9 @@ "dfc-b:inputOf": { "@type": "@id" }, + "dfc-b:isFulfilledBy": { + "@type": "@id" + }, "dfc-b:isIngredientOf": { "@type": "@id" }, diff --git a/lib/datafoodconsortium/connector/importer.rb b/lib/datafoodconsortium/connector/importer.rb index 8c6964f..fec9fab 100644 --- a/lib/datafoodconsortium/connector/importer.rb +++ b/lib/datafoodconsortium/connector/importer.rb @@ -21,7 +21,7 @@ def self.register_type(clazz) end def self.prefixed_name(uri) - RDF::URI.new(uri).pname(prefixes: Context::VERSION_1_8) + RDF::URI.new(uri).pname(prefixes: Context.json) end def import(json_string_or_io) From 14ee9b2f7948f88b2e7135d276ac32332c10b457 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Tue, 14 Jan 2025 15:39:07 +1100 Subject: [PATCH 3/4] Bump dev dependencies --- Gemfile.lock | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 66c8ef4..09b0920 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,35 +8,39 @@ GEM remote: https://rubygems.org/ specs: bcp47_spec (0.2.1) + bigdecimal (3.1.9) diff-lcs (1.5.1) htmlentities (4.3.4) json-canonicalization (1.0.0) - json-ld (3.3.1) + json-ld (3.3.2) htmlentities (~> 4.3) json-canonicalization (~> 1.0) link_header (~> 0.0, >= 0.0.8) multi_json (~> 1.15) rack (>= 2.2, < 4) rdf (~> 3.3) + rexml (~> 3.2) link_header (0.0.8) multi_json (1.15.0) - rack (3.0.10) - rdf (3.3.1) + rack (3.1.8) + rdf (3.3.2) bcp47_spec (~> 0.2) + bigdecimal (~> 3.1, >= 3.1.5) link_header (~> 0.0, >= 0.0.8) + rexml (3.4.0) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) - rspec-core (3.13.0) + rspec-core (3.13.2) rspec-support (~> 3.13.0) - rspec-expectations (3.13.0) + rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-mocks (3.13.0) + rspec-mocks (3.13.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-support (3.13.1) + rspec-support (3.13.2) virtual_assembly-semantizer (1.1.1) json-ld (~> 3.2, >= 3.2.3) From fdb6eb738a0c5922dc63a9a773f997d0b48d79ea Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Tue, 14 Jan 2025 15:47:36 +1100 Subject: [PATCH 4/4] Release 1.1.0 --- CHANGELOG.md | 15 ++++++++++++++- Gemfile.lock | 2 +- connector.gemspec | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bb7fd0..05dce7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.0] - 2025-01-14 + +This version has been generated using: + +- [Connector code generator](https://github.com/datafoodconsortium/connector-codegen) [main](https://github.com/datafoodconsortium/connector-codegen/commit/8742cb8ee82a312f5735c4739e95e7cbf85ca0b3). +- [UML data model](https://github.com/datafoodconsortium/data-model-uml) [next](https://github.com/datafoodconsortium/data-model-uml/commit/621e823c21c79a58b117bae97132da9140e47be6). + +### Changed + +- Bump DFC context from 1.8.0 to 1.14.0 +- Bump dev dependencies + ## [1.0.0] - 2025-01-09 This version has been generated using: @@ -154,7 +166,8 @@ This version has been generated using the [code generator](https://github.com/da - Initial version of this library. -[unreleased]: https://github.com/datafoodconsortium/connector-ruby/compare/v1.0.0...HEAD +[unreleased]: https://github.com/datafoodconsortium/connector-ruby/compare/v1.1.0...HEAD +[1.1.0]: https://github.com/datafoodconsortium/connector-ruby/compare/v1.0.0...v1.1.0 [1.0.0]: https://github.com/datafoodconsortium/connector-ruby/compare/v1.0.0-alpha.13...v1.0.0 [1.0.0-alpha.13]: https://github.com/datafoodconsortium/connector-ruby/compare/v1.0.0-alpha.12...v1.0.0-alpha.13 [1.0.0-alpha.12]: https://github.com/datafoodconsortium/connector-ruby/compare/v1.0.0-alpha.11...v1.0.0-alpha.12 diff --git a/Gemfile.lock b/Gemfile.lock index 09b0920..33454ce 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - datafoodconsortium-connector (1.0.0) + datafoodconsortium-connector (1.1.0) virtual_assembly-semantizer (~> 1.0, >= 1.0.5) GEM diff --git a/connector.gemspec b/connector.gemspec index 1d9ddde..b0f2874 100644 --- a/connector.gemspec +++ b/connector.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "datafoodconsortium-connector" - s.version = "1.0.0" + s.version = "1.1.0" s.summary = "Data Food Consortium connector" s.description = "A library to easily integrate the DFC standard within your application." s.authors = ["Maxime Lecoq"]