Class: Calabash::Formatters::Html

Inherits:
Cucumber::Formatter::Html
  • Object
show all
Defined in:
lib/calabash/formatters/html.rb

Instance Method Summary collapse

Instance Method Details

#_output_relative?Boolean

Returns:

  • (Boolean)

26
27
28
29
30
31
# File 'lib/calabash/formatters/html.rb', line 26

def _output_relative?
  if @io.is_a?(File)
    path = @io.path
    _relative_uri?(path)
  end
end

#_relative_uri?(src) ⇒ Boolean

Returns:

  • (Boolean)

19
20
21
22
23
# File 'lib/calabash/formatters/html.rb', line 19

def _relative_uri?(src)
  uri = URI.parse(src)
  return false if uri.scheme
  not Pathname.new(src).absolute?
end

#embed_image(src, label) ⇒ Object


8
9
10
11
12
13
14
15
16
17
# File 'lib/calabash/formatters/html.rb', line 8

def embed_image(src, label)
  if _output_relative? && _relative_uri?(src)
    output_dir = Pathname.new(File.dirname(@io.path))
    src_path = Pathname.new(src)
    embed_relative_path = src_path.relative_path_from(output_dir)
    super(embed_relative_path.to_s, label)
  else
    super(src, label)
  end
end