Class: RubyLens::ShowcaseWriter
- Inherits:
-
ReportWriter
- Object
- ReportWriter
- RubyLens::ShowcaseWriter
- Defined in:
- lib/rubylens/showcase_writer.rb
Constant Summary collapse
- MARKER =
'<meta name="rubylens-artifact" content="showcase">'- SHELL_PATH =
File.("../../assets/shells/showcase.html", __dir__)
- STYLESHEET_PATH =
File.("../../assets/styles/showcase.css", __dir__)
- RUNTIME_PATH =
File.("../../assets/runtime/report.js", __dir__)
Constants inherited from ReportWriter
ReportWriter::MODEL_PLACEHOLDER
Instance Method Summary collapse
-
#initialize(template_path: nil, asset_assembler: nil) ⇒ ShowcaseWriter
constructor
A new instance of ShowcaseWriter.
- #rubylens_showcase?(path) ⇒ Boolean
Methods inherited from ReportWriter
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
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 |