Class: Dump

Inherits:
Object
  • Object
show all
Defined in:
lib/stackprof-webnav/dump.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Dump

Returns a new instance of Dump.



4
5
6
# File 'lib/stackprof-webnav/dump.rb', line 4

def initialize(path)
  @path = path
end

Instance Attribute Details

#flamegraph_jsonObject

Returns the value of attribute flamegraph_json.



3
4
5
# File 'lib/stackprof-webnav/dump.rb', line 3

def flamegraph_json
  @flamegraph_json
end

#graph_dataObject

Returns the value of attribute graph_data.



3
4
5
# File 'lib/stackprof-webnav/dump.rb', line 3

def graph_data
  @graph_data
end

#pathObject

Returns the value of attribute path.



2
3
4
# File 'lib/stackprof-webnav/dump.rb', line 2

def path
  @path
end

Instance Method Details

#check_checksum!Object



21
22
23
24
25
26
27
28
# File 'lib/stackprof-webnav/dump.rb', line 21

def check_checksum!
  return unless @checksum

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

#checksumObject



8
9
10
# File 'lib/stackprof-webnav/dump.rb', line 8

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

#contentObject



12
13
14
# File 'lib/stackprof-webnav/dump.rb', line 12

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

#flame_graph_pathObject



30
31
32
# File 'lib/stackprof-webnav/dump.rb', line 30

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

#graph_image_pathObject



38
39
40
# File 'lib/stackprof-webnav/dump.rb', line 38

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

#graph_pathObject



34
35
36
# File 'lib/stackprof-webnav/dump.rb', line 34

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