Skip to content

Commit

Permalink
Allow a referened context document to not contain @context on expansion.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Jun 12, 2012
1 parent 1578062 commit 04bbd60
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/json/ld/evaluation_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ def parse(context)
# Load context document, if it is a string
begin
ctx = JSON.load(context)
raise JSON::LD::InvalidContext::Syntax, "missing @context" unless ctx.is_a?(Hash) && ctx["@context"]
parse(ctx["@context"])
parse(ctx["@context"] || {})
rescue JSON::ParserError => e
debug("parse") {"Failed to parse @context from remote document at #{context}: #{e.message}"}
raise JSON::LD::InvalidContext::Syntax, "Failed to parse remote context at #{context}: #{e.message}" if @options[:validate]
Expand Down
5 changes: 5 additions & 0 deletions spec/evaluation_context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ def @ctx.content_type; "application/ld+json"; end
"avatar" => "http://xmlns.com/foaf/0.1/avatar"
}, @debug)
end

it "allows a non-existing @context" do
ec = subject.parse(StringIO.new("{}"))
ec.mappings.should produce({}, @debug)
end
end

context "EvaluationContext" do
Expand Down

0 comments on commit 04bbd60

Please sign in to comment.