<commit_before># This is an example of how you can set up screenshots for your
# browser testing. Just run cucumber with --format html --out report.html
#
# The code below will work on OS X or Windows (with IE Watir only).
# Adding support for other platforms should be easy - as long as there is a 
# ruby library or command line tool to take pictures.
#

#TODO: fix the screenshots on windows - does not stores
module Screenshots      
  if Cucumber::OS_X
    def embed_screenshot(id, to_html)
      save_screenshot(id, to_html)
    end
  elsif Cucumber::WINDOWS
    def embed_screenshot(id, to_html)
      id = Dir.pwd.gsub("/","\\") + "\\" + id.gsub("/","\\")
      save_screenshot(id, to_html)
    end  
    else
    # Other platforms...
    def embed_screenshot(id, to_html)
      save_screenshot(id, to_html)
    end
  end
  
  def save_screenshot(id, to_html)
    File.open("#{id}.jpg",'wb') do |f|
       f.write(Base64.decode64(@browser.driver.screenshot_as(:base64)))
     end
    to_html.gsub!("public/","") if to_html =~ /public/
    embed("#{to_html}.jpg", "image/jpg")
  end
  
end
World(Screenshots)

# After do |scenario|
#    embed_screenshot("#{@screenshot_path}screenshot-#{Time.new.to_i}")  if scenario.failed?
# end        

# Other variants:
#
# Only take screenshot on failures
#
#   After do |scenario|
#     embed_screenshot("screenshot-#{Time.new.to_i}") if scenario.failed?<commit_msg>updated screenshot, still issue with windows<commit_after># This is an example of how you can set up screenshots for your
# browser testing. Just run cucumber with --format html --out report.html
#
# The code below will work on OS X or Windows (with IE Watir only).
# Adding support for other platforms should be easy - as long as there is a 
# ruby library or command line tool to take pictures.
#

#TODO: fix the screenshots on windows - does not stores
module Screenshots      
  if Cucumber::OS_X
    def embed_screenshot(id, to_html)
      save_screenshot(id, to_html)
    end
  elsif Cucumber::WINDOWS
    def embed_screenshot(id, to_html)
      id = Dir.pwd.gsub("/","\\") + "\\" + id.gsub("/","\\")
      save_screenshot(id, to_html)
    end  
    else
    # Other platforms...
    def embed_screenshot(id, to_html)
      save_screenshot(id, to_html)
    end
  end
  
  def save_screenshot(id, to_html)
    @browser.driver.save_screenshot("#{id}.png")
    to_html.gsub!("public/","") if to_html =~ /public/
    embed("#{to_html}.png", "image/png")
  end
  
end
World(Screenshots)

# After do |scenario|
#    embed_screenshot("#{@screenshot_path}screenshot-#{Time.new.to_i}")  if scenario.failed?
# end        

# Other variants:
#
# Only take screenshot on failures
#
#   After do |scenario|
#     embed_screenshot("screenshot-#{Time.new.to_i}") if scenario.failed?
{'fraction_non_alphanumeric': 0.12347451543431442, 'fraction_numerical': 0.0021536252692031586, 'mean_word_length': 3.3075734157650696, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5806553', 'n_tokens_mistral': 983, 'n_tokens_neox': 966, 'n_words': 276}