class Object

Constants

DsMediaLibrary

HACK work around autoloading sometimes demanding this specific inflection

Public Instance Methods

recurse_tree(root, structure = [], prefix = "") click to toggle source
# File lib/ds_media_library/cucumber.rb, line 51
def recurse_tree root, structure = [], prefix = ""
  root.all(:xpath, "./li").each do |li|
    if label = li.first("label", minimum: 0)
      type_name, created_at = if label[:class].include?("folder")
         2.times.map { "" }
      else
        li.all("div")[1..2].map(&:text)
      end
      structure << [prefix + label.text, type_name, created_at]
    end
    if root = li.first("ul", minimum: 0)
      new_prefix = prefix.empty? ? "- #{prefix}" : prefix + "  "
      structure = recurse_tree(root, structure, new_prefix)
    end
  end
  structure
end