<commit_before>require 'action_view'
require 'fileutils'
require 'cucumber/formatter/io'
require 'cucumber/formatter/duration'
require 'cucumber/core/ast/scenario'
require 'cucumber/multiline_argument/data_table'
require File.join(File.dirname(__FILE__), 'view_helper')
require File.join(File.dirname(__FILE__), 'report')

# Starting with ActionPack 4.1.1, the module Mime doesn't get initialized before it's needed by UglyFace and so
# it would blow up with errors about uninitialized constants. We need to explicitly load it to prevent this problem.
require 'action_dispatch/http/mime_type'

module UglyFace
  module Formatter

    class Html
      include Cucumber::Formatter::Io
      include Cucumber::Formatter::Duration
      include ViewHelper

      attr_reader :report, :logo

      def initialize(step_mother, path_or_io, options)
        @path = path_or_io
        set_path_and_file(path_or_io)
        @path_to_erb = File.join(File.dirname(__FILE__), '..', 'templates')
        @step_mother = step_mother
        @options = options
        # The expand option is set to true by RubyMine and cannot be turned off using the IDE. This option causes
        # a test run while using this gem to terminate.
        @options[:expand] = false unless @options.nil?
        @report = Report.new
        @img_id = 0
        @logo = 'logo.png'
        @delayed_messages = []
      end

      def set_path_and_file(path_or_io)
        return if path_or_io.nil?
        dir = File.dirname(path_or_io)
        FileUtils.mkdir_p dir unless File.directory? dir
        @io = ensure_io(path_or_io, 'html')
      end
      
      def embed(src, mime_type, label)
        case(mime_type)
        when /^image\/(png|gif|jpg|jpeg)/
          embed_image(src, label)
        end
      end

      def embed_image(src, label)
        @report.current_scenario.image << src.split(separator).last
        @report.current_scenario.image_label << label
        @report.current_scenario.image_id << "img_#{@img_id}"
        @img_id += 1
        filename = "#{File.dirname(@path)}#{separator}images"
        FileUtils.cp src, filename
      end

      def before_features(features)
        make_output_directories
        @tests_started = Time.now<commit_msg>Fixed issue with Cucumebr 2.0 support<commit_after>require 'action_view'
require 'fileutils'
require 'cucumber/formatter/io'
require 'cucumber/formatter/duration'
require 'cucumber/core/ast/scenario'
require 'cucumber/multiline_argument/data_table'
require File.join(File.dirname(__FILE__), 'view_helper')
require File.join(File.dirname(__FILE__), 'report')

# Starting with ActionPack 4.1.1, the module Mime doesn't get initialized before it's needed by UglyFace and so
# it would blow up with errors about uninitialized constants. We need to explicitly load it to prevent this problem.
require 'action_dispatch/http/mime_type'

module UglyFace
  module Formatter

    class Html
      include Cucumber::Formatter::Io
      include Cucumber::Formatter::Duration
      include ViewHelper

      attr_reader :report, :logo

      def initialize(step_mother, path_or_io, options)
        @path = path_or_io
        set_path_and_file(path_or_io)
        @path_to_erb = File.join(File.dirname(__FILE__), '..', 'templates')
        @step_mother = step_mother
        @options = options
        # The expand option is set to true by RubyMine and cannot be turned off using the IDE. This option causes
        # a test run while using this gem to terminate.
        @options[:expand] = false unless @options.nil?
        @report = Report.new
        @img_id = 0
        @logo = 'logo.png'
        @delayed_messages = []
      end

      def set_path_and_file(path_or_io)
        return if path_or_io.nil?
        dir = File.dirname(path_or_io)
        FileUtils.mkdir_p dir unless File.directory? dir
        @io = ensure_io(path_or_io)
      end
      
      def embed(src, mime_type, label)
        case(mime_type)
        when /^image\/(png|gif|jpg|jpeg)/
          embed_image(src, label)
        end
      end

      def embed_image(src, label)
        @report.current_scenario.image << src.split(separator).last
        @report.current_scenario.image_label << label
        @report.current_scenario.image_id << "img_#{@img_id}"
        @img_id += 1
        filename = "#{File.dirname(@path)}#{separator}images"
        FileUtils.cp src, filename
      end

      def before_features(features)
        make_output_directories
        @tests_started = Time.now
{'fraction_non_alphanumeric': 0.0920409070698088, 'fraction_numerical': 0.0026678523788350376, 'mean_word_length': 2.9326923076923075, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6321376', 'n_tokens_mistral': 1396, 'n_tokens_neox': 1353, 'n_words': 355}