lib/lookbook/services/entities/entity_tree_builder.rb in lookbook-1.5.5 vs lib/lookbook/services/entities/entity_tree_builder.rb in lookbook-2.0.0.beta.0
- old
+ new
@@ -11,30 +11,30 @@
root_node = TreeNode.new
entities.each do |entity|
current_node = root_node
path_segments = parse_segments(entity.logical_path)
path_segments.each.with_index(1) do |segment, i|
- name, position_prefix = segment
+ name, priority_prefix = segment
content = entity if entity.depth == i # entities are always on the leaf nodes
- current_node.add_child(name, content, position: position_prefix) unless current_node.has_child?(name)
+ current_node.add_child(name, content, priority: priority_prefix) unless current_node.has_child?(name)
current_node = current_node.get_child(name)
if content && content.type == :preview
- content.visible_examples.each do |example|
- current_node.add_child(example.name, example)
+ content.visible_scenarios.each do |scenario|
+ current_node.add_child(scenario.name, scenario)
end
end
end
end
root_node
end
def parse_segments(path)
path.split("/").map do |segment|
unless segment.start_with?(".")
- position, name = PositionPrefixParser.call(segment)
- [name, position || 10000]
+ priority, name = PriorityPrefixParser.call(segment)
+ [name, priority || 10000]
end
end.compact
end
def entities