Skip to content

Commit a89fb3c

Browse files
committed
Don't pass namer as option to create_node_map, as it is an instance variable.
1 parent 04a3cb7 commit a89fb3c

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

lib/json/ld/api.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def self.flatten(input, context, options = {})
252252

253253
# Initialize node map to a JSON object consisting of a single member whose key is @default and whose value is an empty JSON object.
254254
graphs = {'@default' => {}}
255-
create_node_map(value, graphs, '@default', namer)
255+
create_node_map(value, graphs)
256256

257257
default_graph = graphs['@default']
258258
graphs.keys.kw_sort.reject {|k| k == '@default'}.each do |graph_name|
@@ -355,7 +355,7 @@ def self.frame(input, frame, options = {})
355355

356356
# Get framing nodes from expanded input, replacing Blank Node identifiers as necessary
357357
old_dbg, @options[:debug] = @options[:debug], nil
358-
create_node_map(value, framing_state[:graphs], '@merged', namer)
358+
create_node_map(value, framing_state[:graphs], '@merged')
359359
@options[:debug] = old_dbg
360360
framing_state[:subjects] = framing_state[:graphs]['@merged']
361361
debug(".frame") {"subjects: #{framing_state[:subjects].to_json(JSON_STATE) rescue 'malformed json'}"}
@@ -415,7 +415,7 @@ def self.toRdf(input, options = {}, &block)
415415

416416
# Generate _nodeMap_
417417
graphs = {'@default' => {}}
418-
create_node_map(expanded_input, graphs, '@default', namer)
418+
create_node_map(expanded_input, graphs)
419419
debug(".toRdf") {"node map: #{graphs.to_json(JSON_STATE) rescue 'malformed json'}"}
420420

421421
# Start generating statements

lib/json/ld/flatten.rb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,21 @@ module Flatten
1212
# map of nodes
1313
# @param [String] graph
1414
# The name of the currently active graph that the processor should use when processing.
15-
# @param [JSON::LD::BlankNodeNamer] namer
16-
# The UniqueNamer for assigning blank node names
1715
# @param [String] name
1816
# The name assigned to the current input if it is a bnode
1917
# @param [Array] list
2018
# List to append to, nil for none
2119
def create_node_map(input,
2220
graphs,
2321
graph = '@default',
24-
namer = BlankNodeNamer.new('b'),
2522
name = nil,
2623
list = nil)
2724
depth do
2825
debug("node_map") {"graph: #{graph}, input: #{input.inspect}, name: #{name}"}
2926
case input
3027
when Array
3128
# If input is an array, process each entry in input recursively by passing item for input, node map, active graph, active subject, active property, and list.
32-
input.map {|o| create_node_map(o, graphs, graph, namer, nil,list)}
29+
input.map {|o| create_node_map(o, graphs, graph, nil, list)}
3330
when Hash
3431
type = input['@type']
3532
if value?(input)
@@ -66,7 +63,7 @@ def create_node_map(input,
6663
items.each do |item|
6764
item_name = item['@id']
6865
item_name = namer.get_name(item_name) if blank_node?(item_name)
69-
create_node_map(item, graphs, graph, namer, item_name)
66+
create_node_map(item, graphs, graph, item_name)
7067
add_value(graphs[graph][item_name],
7168
reverse_property,
7269
referenced_node,
@@ -77,7 +74,7 @@ def create_node_map(input,
7774
when '@graph'
7875
graphs[name] ||= {}
7976
g = graph == '@merged' ? graph : name
80-
create_node_map(objects, graphs, g, namer)
77+
create_node_map(objects, graphs, g)
8178
when /^@(?!type)/
8279
# copy non-@type keywords
8380
if property == '@index' && subject['@index']
@@ -103,15 +100,15 @@ def create_node_map(input,
103100

104101
# add reference and recurse
105102
add_value(subject, property, {'@id' => id}, property_is_array: true, allow_duplicate: false)
106-
create_node_map(o, graphs, graph, namer, id)
103+
create_node_map(o, graphs, graph, id)
107104
when list?(o)
108105
olist = []
109-
create_node_map(o['@list'], graphs, graph, namer, name, olist)
106+
create_node_map(o['@list'], graphs, graph, name, olist)
110107
o = {'@list' => olist}
111108
add_value(subject, property, o, property_is_array: true, allow_duplicate: true)
112109
else
113110
# handle @value
114-
create_node_map(o, graphs, graph, namer, name)
111+
create_node_map(o, graphs, graph, name)
115112
add_value(subject, property, o, property_is_array: true, allow_duplicate: false)
116113
end
117114
end

0 commit comments

Comments
 (0)