Class: RubyLens::ShowcaseWriter

Inherits:
ReportWriter show all
Defined in:
lib/rubylens/showcase_writer.rb

Constant Summary collapse

MARKER =
'<meta name="rubylens-artifact" content="showcase">'
SHELL_PATH =
File.expand_path("../../assets/shells/showcase.html", __dir__)
STYLESHEET_PATH =
File.expand_path("../../assets/styles/showcase.css", __dir__)
RUNTIME_PATH =
File.expand_path("../../assets/runtime/report.js", __dir__)

Constants inherited from ReportWriter

ReportWriter::MODEL_PLACEHOLDER

Instance Method Summary collapse

Methods inherited from ReportWriter

#rubylens_report?, #write

Constructor Details

#initialize(template_path: nil, asset_assembler: nil) ⇒ ShowcaseWriter

Returns a new instance of ShowcaseWriter.



12
13
14
15
16
17
18
19
# File 'lib/rubylens/showcase_writer.rb', line 12

def initialize(template_path: nil, asset_assembler: nil)
  asset_assembler ||= ReportAssetAssembler.new(
    shell_path: SHELL_PATH,
    stylesheet_path: STYLESHEET_PATH,
    runtime_path: RUNTIME_PATH,
  ) unless template_path
  super(template_path:, asset_assembler:)
end

Instance Method Details

#rubylens_showcase?(path) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
# File 'lib/rubylens/showcase_writer.rb', line 21

def rubylens_showcase?(path)
  File.file?(path) && File.open(path, "rb") { |file| file.read(2048).include?(MARKER) }
rescue Errno::ENOENT, Errno::EACCES
  false
end