module Selenium::WebDriver::ProfileHelper

def self.decoded(json)

def self.decoded(json)
  JSON.parse(json).fetch('zip')
end

def self.included(base)

def self.included(base)
  base.extend ClassMethods
end

def as_json(*)

def as_json(*)
  {'zip' => encoded}
end

def create_tmp_copy(directory)

def create_tmp_copy(directory)
  tmp_directory = Dir.mktmpdir('webdriver-rb-profilecopy')
  # TODO: must be a better way..
  FileUtils.rm_rf tmp_directory
  FileUtils.mkdir_p File.dirname(tmp_directory), mode: 0o700
  FileUtils.cp_r directory, tmp_directory
  tmp_directory
end

def encoded

def encoded
  Zipper.zip(layout_on_disk)
end

def to_json(*)

def to_json(*)
  JSON.generate as_json
end

def verify_model(model)

def verify_model(model)
  return unless model
  raise Errno::ENOENT, model unless File.exist?(model)
  raise Errno::ENOTDIR, model unless File.directory?(model)
  model
end