<commit_before>require "yaml"

class Wraith
  attr_accessor :config

  def initialize(config_name)
    config_file = "#{config_name}.yaml"
    @config = YAML::load(File.open("configs/#{config_file}"))
  end

  def widths
    @config['screen_widths']
  end

  def domains
    @config['domains']
  end

  def base_domain
    domains[base_domain_label]
  end

  def comp_domain
    domains[comp_domain_label]
  end

  def base_domain_label
    domains.keys[0]
  end

  def comp_domain_label
    domains.keys[1]
  end

  def paths
    @config['paths']
  end

  def capture_page_image (url, width, file_name)
    puts `phantomjs #{@config['phantomjs_options']} snap.js "#{url}" "#{width}" "#{file_name}"`
  end

  # Support for slimerjs, uncomment code below and comment out capture_page_image option above
  # def capture_page_image (url, width, file_name)
  #   puts `slimerjs snap.js "#{url}" "#{width}" "#{file_name}"`
  # end

  def compare_images (base, compare, output, info)
    puts `compare -fuzz 20% -metric AE -highlight-color blue #{base} #{compare} #{output} 2>#{info}`
  end

  def self.crop_images (crop, height)
    puts `convert #{crop} -background none -extent 0x#{height} #{crop}`
  end

  def crop_images(crop, height)
    self.class.crop_images
  end

  def thumbnail_image(png_path, output_path)
    `convert #{png_path} -thumbnail 200 -crop 200x200+0+0 #{output_path}`
  end
end
<commit_msg>tidy rake file<commit_after>require "yaml"

class Wraith
  attr_accessor :config

  def initialize(config_name)
    @config = YAML::load(File.open("configs/#{config_name}.yaml"))
  end

  def widths
    @config['screen_widths']
  end

  def domains
    @config['domains']
  end

  def base_domain
    domains[base_domain_label]
  end

  def comp_domain
    domains[comp_domain_label]
  end

  def base_domain_label
    domains.keys[0]
  end

  def comp_domain_label
    domains.keys[1]
  end

  def paths
    @config['paths']
  end

  def capture_page_image (url, width, file_name)
    puts `phantomjs #{@config['phantomjs_options']} snap.js "#{url}" "#{width}" "#{file_name}"`
  end

  # Support for slimerjs, uncomment code below and comment out capture_page_image option above
  # def capture_page_image (url, width, file_name)
  #   puts `slimerjs snap.js "#{url}" "#{width}" "#{file_name}"`
  # end

  def compare_images (base, compare, output, info)
    puts `compare -fuzz 20% -metric AE -highlight-color blue #{base} #{compare} #{output} 2>#{info}`
  end

  def self.crop_images (crop, height)
    puts `convert #{crop} -background none -extent 0x#{height} #{crop}`
  end

  def crop_images(crop, height)
    self.class.crop_images
  end

  def thumbnail_image(png_path, output_path)
    `convert #{png_path} -thumbnail 200 -crop 200x200+0+0 #{output_path}`
  end
end

{'fraction_non_alphanumeric': 0.12275664034458005, 'fraction_numerical': 0.012203876525484566, 'mean_word_length': 3.9066901408450705, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '565003', 'n_tokens_mistral': 1036, 'n_tokens_neox': 989, 'n_words': 254}