Sha256: 0165c8d6eb1287be8f6934b0af28385e899fe3b38882a16d952cc5ba31172e2d

Contents?: true

Size: 699 Bytes

Versions: 2

Compression:

Stored size: 699 Bytes

Contents

class Dump
  attr_reader :path
  attr_accessor :flamegraph_json, :graph_data
  def initialize(path)
    @path = path
  end

  def checksum
    @checksum ||= Digest::SHA1.file(@path)
  end

  def content
    @content ||= File.open(@path).read
  end

  def path=(new_path)
    @path = new_path
    check_checksum!
  end

  def check_checksum!
    return unless @checksum

    if Digest::SHA1.file(@path) != checksum
      puts "\n\nFile reloaded"
      @checksum, @content = nil, nil
    end
  end

  def flame_graph_path
    @path + ".#{checksum}.flames.json"
  end

  def graph_path
    @path + ".#{checksum}.digraph.dot"
  end

  def graph_image_path
    @path + ".#{checksum}.graph.png"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stackprof-webnav-1.0.1 lib/stackprof-webnav/dump.rb
stackprof-webnav-1.0.0 lib/stackprof-webnav/dump.rb