@@ -27,13 +27,11 @@ module Expand
2727 # Special rules for expanding a frame
2828 # @param [Boolean] from_map
2929 # Expanding from a map, which could be an `@type` map, so don't clear out context term definitions
30- # @param [Boolean] ordered (true)
31- # Ensure output objects have keys ordered properly
3230 #
3331 # @return [Array<Hash{String => Object}>]
3432 def expand ( input , active_property , context ,
3533 base : nil , framing : false ,
36- from_map : false , ordered : true , log_depth : nil )
34+ from_map : false , log_depth : nil )
3735 log_debug ( "expand" , depth : log_depth . to_i ) { "input: #{ input . inspect } , active_property: #{ active_property . inspect } , context: #{ context . inspect } " }
3836 framing = false if active_property == '@default'
3937 expanded_active_property = context . expand_iri ( active_property , vocab : true , as_string : true , base : base ) if active_property
@@ -50,7 +48,6 @@ def expand(input, active_property, context,
5048 # Initialize expanded item to the result of using this algorithm recursively, passing active context, active property, and item as element.
5149 v = expand ( v , active_property , context ,
5250 base : base ,
53- ordered : ordered ,
5451 framing : framing ,
5552 from_map : from_map ,
5653 log_depth : log_depth . to_i + 1 )
@@ -119,7 +116,6 @@ def expand(input, active_property, context,
119116 base : base ,
120117 expanded_active_property : expanded_active_property ,
121118 framing : framing ,
122- ordered : ordered ,
123119 type_key : type_key ,
124120 type_scoped_context : type_scoped_context ,
125121 log_depth : log_depth . to_i + 1 )
@@ -188,7 +184,7 @@ def expand(input, active_property, context,
188184 end
189185
190186 # Re-order result keys if ordering
191- if ordered
187+ if @options [ : ordered]
192188 output_object . keys . sort . each_with_object ( { } ) { |kk , memo | memo [ kk ] = output_object [ kk ] }
193189 else
194190 output_object
@@ -221,15 +217,14 @@ def expand_object(input, active_property, context, output_object,
221217 framing :,
222218 type_key :,
223219 type_scoped_context :,
224- ordered :,
225220 log_depth : nil )
226221 nests = [ ]
227222
228223 input_type = Array ( input [ type_key ] ) . last
229224 input_type = context . expand_iri ( input_type , vocab : true , as_string : true , base : base ) if input_type
230225
231226 # Then, proceed and process each property and value in element as follows:
232- keys = ordered ? input . keys . sort : input . keys
227+ keys = @options [ : ordered] ? input . keys . sort : input . keys
233228 keys . each do |key |
234229 # For each key and value in element, ordered lexicographically by key:
235230 value = input [ key ]
@@ -300,7 +295,6 @@ def expand_object(input, active_property, context, output_object,
300295 included_result = as_array ( expand ( value , active_property , context ,
301296 base : base ,
302297 framing : framing ,
303- ordered : ordered ,
304298 log_depth : log_depth . to_i + 1 ) )
305299
306300 # Expanded values must be node objects
@@ -362,7 +356,6 @@ def expand_object(input, active_property, context, output_object,
362356 value = expand ( value , '@graph' , context ,
363357 base : base ,
364358 framing : framing ,
365- ordered : ordered ,
366359 log_depth : log_depth . to_i + 1 )
367360 as_array ( value )
368361 when '@value'
@@ -458,7 +451,6 @@ def expand_object(input, active_property, context, output_object,
458451 value = expand ( value , active_property , context ,
459452 base : base ,
460453 framing : framing ,
461- ordered : ordered ,
462454 log_depth : log_depth . to_i + 1 )
463455
464456 # Spec FIXME: need to be sure that result is an array
@@ -470,7 +462,6 @@ def expand_object(input, active_property, context, output_object,
470462 expand ( value , active_property , context ,
471463 base : base ,
472464 framing : framing ,
473- ordered : ordered ,
474465 log_depth : log_depth . to_i + 1 )
475466 when '@reverse'
476467 # If expanded property is @reverse and value is not a JSON object, an invalid @reverse value error has been detected and processing is aborted.
@@ -482,7 +473,6 @@ def expand_object(input, active_property, context, output_object,
482473 value = expand ( value , '@reverse' , context ,
483474 base : base ,
484475 framing : framing ,
485- ordered : ordered ,
486476 log_depth : log_depth . to_i + 1 )
487477
488478 # If expanded value contains an @reverse member, i.e., properties that are reversed twice, execute for each of its property and item the following steps:
@@ -519,7 +509,6 @@ def expand_object(input, active_property, context, output_object,
519509 [ expand ( value , expanded_property , context ,
520510 base : base ,
521511 framing : framing ,
522- ordered : ordered ,
523512 log_depth : log_depth . to_i + 1 )
524513 ] . flatten
525514 when '@nest'
@@ -549,7 +538,7 @@ def expand_object(input, active_property, context, output_object,
549538 ary = [ ]
550539
551540 # For each key-value pair language-language value in value, ordered lexicographically by language
552- keys = ordered ? value . keys . sort : value . keys
541+ keys = @options [ : ordered] ? value . keys . sort : value . keys
553542 keys . each do |k |
554543 expanded_k = context . expand_iri ( k , vocab : true , as_string : true , base : base )
555544
@@ -594,7 +583,7 @@ def expand_object(input, active_property, context, output_object,
594583 end
595584
596585 # For each key-value in the object:
597- keys = ordered ? value . keys . sort : value . keys
586+ keys = @options [ : ordered] ? value . keys . sort : value . keys
598587 keys . each do |k |
599588 # If container mapping in the active context includes @type, and k is a term in the active context having a local context, use that context when expanding values
600589 map_context = container_context . term_definitions [ k ] . context if container . include? ( '@type' ) && container_context . term_definitions [ k ]
@@ -612,7 +601,6 @@ def expand_object(input, active_property, context, output_object,
612601 base : base ,
613602 framing : framing ,
614603 from_map : true ,
615- ordered : ordered ,
616604 log_depth : log_depth . to_i + 1 )
617605 index_value . each do |item |
618606 case
@@ -653,7 +641,6 @@ def expand_object(input, active_property, context, output_object,
653641 expand ( value , key , context ,
654642 base : base ,
655643 framing : framing ,
656- ordered : ordered ,
657644 log_depth : log_depth . to_i + 1 )
658645 end
659646
@@ -725,7 +712,6 @@ def expand_object(input, active_property, context, output_object,
725712 base : base ,
726713 framing : framing ,
727714 expanded_active_property : expanded_active_property ,
728- ordered : ordered ,
729715 type_key : type_key ,
730716 type_scoped_context : type_scoped_context ,
731717 log_depth : log_depth . to_i + 1 )
0 commit comments