Module: Pixage

Defined in:
lib/pixage/cli.rb,
lib/pixage/logger.rb,
lib/pixage/params.rb,
lib/pixage/diagnosis.rb,
lib/pixage/images/compare.rb,
lib/pixage/images/convert.rb

Defined Under Namespace

Classes: Compare, Convert, Diagnosis

Instance Method Summary collapse

Instance Method Details

#compare(expected, actual, args = {}) ⇒ String

Returns – file path of the diff.png file.

Parameters:

  • expected_image_file_path (String)
  • actual_image_file_path (String)

Returns:

  • (String)

    – file path of the diff.png file



# File 'lib/pixage/cli.rb', line 6

#console_log(text, status, loud = false) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# 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) ⇒ Object



43
44
45
46
# 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_dirObject



39
40
41
# 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 = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 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) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# 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 = {}) ⇒ String

Returns – file path of the diff.png file.

Parameters:

  • expected_image_file_path (String)
  • actual_image_file_path (String)

Returns:

  • (String)

    – file path of the diff.png file



# File 'lib/pixage/cli.rb', line 20