Class: Rundoc::CodeCommand::Website::Screenshot

Inherits:
Rundoc::CodeCommand show all
Defined in:
lib/rundoc/code_command/website/screenshot.rb

Constant Summary

Constants inherited from Rundoc::CodeCommand

NEWLINE

Instance Attribute Summary

Attributes inherited from Rundoc::CodeCommand

#command, #contents, #keyword, #original_args, #render_command, #render_result

Instance Method Summary collapse

Methods inherited from Rundoc::CodeCommand

#hidden?, #not_hidden?, #push

Constructor Details

#initialize(name:, upload: false) ⇒ Screenshot

Returns a new instance of Screenshot.



3
4
5
6
# File 'lib/rundoc/code_command/website/screenshot.rb', line 3

def initialize(name:, upload: false)
  @driver = Rundoc::CodeCommand::Website::Driver.find(name)
  @upload = upload
end

Instance Method Details

#call(env = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rundoc/code_command/website/screenshot.rb', line 12

def call(env = {})
  puts "Taking screenshot: #{@driver.current_url}"
  filename = @driver.screenshot(
    upload: @upload,
    screenshots_dir: env[:context].screenshots_dir
  )

  relative_filename = filename.relative_path_from(env[:context].output_dir)
  env[:before] << "![Screenshot of #{@driver.current_url}](#{relative_filename})"
  ""
end

#to_md(env = {}) ⇒ Object



8
9
10
# File 'lib/rundoc/code_command/website/screenshot.rb', line 8

def to_md(env = {})
  ""
end