module Pixage
Public Instance Methods
compare(expected, actual, args={})
click to toggle source
@method compare(expected_image_file_path, actual_image_file_path, options={}) @param expected_image_file_path [String] @param actual_image_file_path [String] @parm args [Hash] @return [String] – file path of the diff.png file
# File lib/pixage/cli.rb, line 12 def compare(expected, actual, args={}) images = manage_paths(expected,actual) options = manage_options(args) create_pixage_report_dir Compare.new.compare_images(images,options) end
console_log(text, status, loud=false)
click to toggle source
# File lib/pixage/logger.rb, line 5 def console_log(text, status, loud=false) text=text.upcase if loud case status.downcase.to_sym when :warning puts text.yellow when :error, :exception puts text.red when :pass, :success puts text.green else puts text end end
create_compare_execution_dir(dir_name)
click to toggle source
# File lib/pixage/params.rb, line 43 def create_compare_execution_dir(dir_name) create_pixage_report_dir Dir.mkdir("pixage_report/#{dir_name}") end
create_pixage_report_dir()
click to toggle source
# File lib/pixage/params.rb, line 39 def create_pixage_report_dir Dir.mkdir("pixage_report") unless Dir.exists?("pixage_report") end
manage_options(args={})
click to toggle source
# File lib/pixage/params.rb, line 19 def manage_options(args={}) options = YAML.load_file(File.join(File.dirname(__FILE__) + "/../../data/defaults.yml")) args.each do |key,val| if key.downcase == :fuzz options[:fuzz] = val.to_i elsif key.downcase == :threshold options[:threshold] = val.to_i elsif key.downcase == :color options[:color] = val.to_s.downcase elsif key.downcase == :resize options[:resize] = val.to_s.downcase elsif key.downcase == :force options[:force] = val.to_s.downcase else console_log("Unrecognised option `--#{key}=#{val}`, defaults will be applied.", :warning) end end return options end
manage_paths(expected,actual)
click to toggle source
# File lib/pixage/params.rb, line 6 def manage_paths(expected,actual) images = {} expected = Pathname.new(expected) actual = Pathname.new(actual) if expected.relative? images[:expected] = expected.realpath end if actual.relative? images[:actual] = actual.realpath end images end
resize_n_compare(expected, actual, args={})
click to toggle source
@method resize_n_compare
(expected_image_file_path, actual_image_file_path, options={}) @param expected_image_file_path [String] @param actual_image_file_path [String] @params args [Hash] @return [String] – file path of the diff.png file
# File lib/pixage/cli.rb, line 26 def resize_n_compare(expected, actual, args={}) images = manage_paths(expected,actual) options = manage_options(args) create_pixage_report_dir Compare.new.resize_n_compare_images(images,options) end