Sha256: c1a3948d2e41e8926a9878906b764094164b059cf0793bae76f9b17f5fc53ec6

Contents?: true

Size: 818 Bytes

Versions: 9

Compression:

Stored size: 818 Bytes

Contents

require "cucumber/formatter/html"
require "uri"
require "pathname"

module Calabash
  module Formatters
    class Html < ::Cucumber::Formatter::Html
      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

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


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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
calabash-cucumber-0.19.2 lib/calabash/formatters/html.rb
calabash-cucumber-0.19.1 lib/calabash/formatters/html.rb
calabash-cucumber-0.19.0 lib/calabash/formatters/html.rb
calabash-cucumber-0.19.0.pre3 lib/calabash/formatters/html.rb
calabash-cucumber-0.19.0.pre2 lib/calabash/formatters/html.rb
calabash-cucumber-0.19.0.pre1 lib/calabash/formatters/html.rb
calabash-cucumber-0.18.2 lib/calabash/formatters/html.rb
calabash-cucumber-0.18.1 lib/calabash/formatters/html.rb
calabash-cucumber-0.18.0 lib/calabash-cucumber/formatters/html.rb