Sha256: 2bf4882f5bea548c50a9d82a3173f766a0eaf5a20ade07f526e33ba104589a24

Contents?: true

Size: 979 Bytes

Versions: 21

Compression:

Stored size: 979 Bytes

Contents

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

# @!visibility private
module Calabash
  # @!visibility private
  module Formatters
    # @!visibility private
    class Html < ::Cucumber::Formatter::Html
      # @!visibility private
      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

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

      # @!visibility private
      def _output_relative?
        if @io.is_a?(File)
          path = @io.path
          _relative_uri?(path)
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
calabash-cucumber-0.23.7 lib/calabash/formatters/html.rb
calabash-cucumber-0.23.6 lib/calabash/formatters/html.rb
calabash-cucumber-0.23.5 lib/calabash/formatters/html.rb
calabash-cucumber-0.23.4 lib/calabash/formatters/html.rb
calabash-cucumber-0.23.3 lib/calabash/formatters/html.rb
calabash-cucumber-0.23.2 lib/calabash/formatters/html.rb
calabash-cucumber-0.23.1 lib/calabash/formatters/html.rb
calabash-cucumber-0.23.0 lib/calabash/formatters/html.rb
calabash-cucumber-0.22.2 lib/calabash/formatters/html.rb
calabash-cucumber-0.21.10 lib/calabash/formatters/html.rb
calabash-cucumber-0.21.8 lib/calabash/formatters/html.rb
calabash-cucumber-0.21.7 lib/calabash/formatters/html.rb
calabash-cucumber-0.21.6 lib/calabash/formatters/html.rb
calabash-cucumber-0.21.5 lib/calabash/formatters/html.rb
calabash-cucumber-0.21.4 lib/calabash/formatters/html.rb
calabash-cucumber-0.21.2 lib/calabash/formatters/html.rb
calabash-cucumber-0.21.1 lib/calabash/formatters/html.rb
calabash-cucumber-0.20.5 lib/calabash/formatters/html.rb
calabash-cucumber-0.20.4 lib/calabash/formatters/html.rb
calabash-cucumber-0.20.3 lib/calabash/formatters/html.rb