Class: Hiptest::Nodes::TestPlan

Inherits:
Node
  • Object
show all
Defined in:
lib/hiptest-publisher/nodes.rb

Instance Attribute Summary

Attributes inherited from Node

#children, #parent

Instance Method Summary collapse

Methods inherited from Node

#==, #each_direct_children, #each_sub_nodes, #kind, #pretty_print_instance_variables, #project, #render

Constructor Details

#initialize(folders = []) ⇒ TestPlan

Returns a new instance of TestPlan.



412
413
414
415
416
417
418
419
# File 'lib/hiptest-publisher/nodes.rb', line 412

def initialize(folders = [])
  super()
  @uids_mapping = {}
  @children = {
    :root_folder => nil,
    :folders => folders
  }
end

Instance Method Details

#find_folder_by_uid(uid) ⇒ Object



438
439
440
# File 'lib/hiptest-publisher/nodes.rb', line 438

def find_folder_by_uid(uid)
  return @uids_mapping[uid]
end

#organize_foldersObject



421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
# File 'lib/hiptest-publisher/nodes.rb', line 421

def organize_folders
  @children[:root_folder] = @children[:folders].find(&:root?)
  @children[:root_folder].parent = self if @children[:root_folder]

  @children[:folders].each do |folder|
    @uids_mapping[folder.uid] = folder
  end

  @children[:folders].each do |folder|
    next if folder.root?

    parent = find_folder_by_uid(folder.parent_uid) || @children[:root_folder]
    folder.parent = parent
    parent.children[:subfolders] << folder unless parent.children[:subfolders].include?(folder)
  end
end