Skip to content

Commit

Permalink
When doing property generator expansion, only add @id to node objects…
Browse files Browse the repository at this point in the history
…, not any object.
  • Loading branch information
gkellogg committed Dec 18, 2012
1 parent 0c45ef6 commit b97e63b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/json/ld/expand.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def label_blanknodes(element, namer)
element.keys.sort.each do |k|
label_blanknodes(element[k], namer)
end
unless element.has_key?('@id')
if node?(element) and !element.has_key?('@id')
element['@id'] = namer.get_name(nil)
end
end
Expand Down
9 changes: 8 additions & 1 deletion spec/expand_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -808,17 +808,24 @@
}
},
"@id" => "site:node/1",
"field_tags" => { "@type" => "site:term/this-is-a-tag" }
"field_tags" => [
{ "@type" => "site:term/this-is-a-tag" },
"foo"
]
},
:output => [{
"@id" => "http://example.com/node/1",
"http://schema.org/about" => [{
"@id" => "_:t0",
"@type" => ["http://example.com/term/this-is-a-tag"]
}, {
"@value" => "foo"
}],
"http://example.com/vocab/field_tags" => [{
"@id" => "_:t0",
"@type" => ["http://example.com/term/this-is-a-tag"]
}, {
"@value" => "foo"
}]
}]
}
Expand Down
4 changes: 4 additions & 0 deletions spec/suite_expand_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
m.entries.each do |t|
specify "#{t.property('input')}: #{t.name}" do
begin
case t.property('input')
when /expand-(0038)/
pending("BNode re-naming")
end
t.debug = ["test: #{t.inspect}", "source: #{t.input.read}"]
t.debug << "context: #{t.context.read}" if t.property('context')
result = JSON::LD::API.expand(t.input, nil, nil,
Expand Down

0 comments on commit b97e63b

Please sign in to comment.