Skip to content

Commit

Permalink
Bump context from 1.8.2 to 1.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mkllnk committed Jan 14, 2025
1 parent da0cd6e commit 3593dc5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
10 changes: 6 additions & 4 deletions lib/datafoodconsortium/connector/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
"dfc-b:from": {
"@type": "@id"
},
"dfc-b:fulfills": {
"@type": "@id"
},
"dfc-b:geographicalOriginOf": {
"@type": "@id"
},
Expand Down Expand Up @@ -245,6 +248,9 @@
"dfc-b:inputOf": {
"@type": "@id"
},
"dfc-b:isFulfilledBy": {
"@type": "@id"
},
"dfc-b:isIngredientOf": {
"@type": "@id"
},
Expand Down
2 changes: 1 addition & 1 deletion lib/datafoodconsortium/connector/importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3593dc5

Please sign in to comment.