Sha256: ce486d20135aa9974c5917ac693afd4a29f8697dabad56d4a2125ace7c27302b

Contents?: true

Size: 744 Bytes

Versions: 2

Compression:

Stored size: 744 Bytes

Contents

module RailsIdle
  class TreeBuilder
    def initialize(collector)
      @storage = collector.storage
    end
    
    def tree
      @tree ||= build_tree
    end
    
    private
    
    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
    
    def parse_path(path)
      path.split(/,|\/|::/)
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails-idle-0.0.10 lib/rails-idle/tree_builder.rb
rails-idle-0.0.9 lib/rails-idle/tree_builder.rb