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

#initializeShowcaseWriter

Returns a new instance of ShowcaseWriter.



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

def initialize
  super(asset_assembler: ReportAssetAssembler.new(
    shell_path: SHELL_PATH,
    stylesheet_path: STYLESHEET_PATH,
    runtime_path: RUNTIME_PATH,
  ))
end

Instance Method Details

#rubylens_showcase?(path) ⇒ Boolean

Returns:

  • (Boolean)


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

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