class RailsIdle::TreeBuilder
Public Class Methods
new(collector)
click to toggle source
# File lib/rails-idle/tree_builder.rb, line 3 def initialize(collector) @storage = collector.storage end
Public Instance Methods
tree()
click to toggle source
# File lib/rails-idle/tree_builder.rb, line 7 def tree @tree ||= build_tree end
Private Instance Methods
build_tree()
click to toggle source
# File lib/rails-idle/tree_builder.rb, line 13 def build_tree root = {} @storage.objects_list.each do |path| items = parse_path(path) tree = root items.each do |item| tree[item] = {} unless tree[item] tree = tree[item] end tree[RailsIdle::Storage::COUNTER_KEY] = @storage.get(path, RailsIdle::Storage::COUNTER_KEY) tree[RailsIdle::Storage::EXECUTION_KEY] = @storage.get(path, RailsIdle::Storage::EXECUTION_KEY) end root end
parse_path(path)
click to toggle source
# File lib/rails-idle/tree_builder.rb, line 28 def parse_path(path) path.split(/,|\/|::/) end