Module: HeapScope::Pack

Defined in:
lib/heapscope/pack.rb

Overview

Export a self-contained local report bundle (JSON + HTML + Markdown + notes). Never uploads; writes only to the destination directory.

Class Method Summary collapse

Class Method Details

.export(report, dir, label: "heapscope-report") ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/heapscope/pack.rb', line 12

def export(report, dir, label: "heapscope-report")
  FileUtils.mkdir_p(dir)
  base = File.join(dir, label)
  json_path = "#{base}.json"
  html_path = "#{base}.html"
  md_path = "#{base}.md"
  readme_path = File.join(dir, "README.txt")

  report.save(json_path)
  File.write(html_path, Report::HTML.render(report))
  File.write(md_path, report.to_markdown)
  File.write(readme_path, readme_body(report, label: label))

  {
    dir: dir,
    json: json_path,
    html: html_path,
    markdown: md_path,
    readme: readme_path
  }
end