goggles 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,18 +3,16 @@ require "image_size"
3
3
  module Goggles
4
4
 
5
5
  def diff_images
6
- size_to_smallest!
7
-
8
6
  images = Dir.glob("#{@gg_result_dir}/*/*.png").sort
9
-
10
7
  raise Goggles::EmptyResultError, "No screenshots found in results directory: #{@gg_result_dir}" if images.empty?
11
8
 
9
+ size_to_smallest!
10
+
12
11
  until images.empty?
13
12
  one = images.slice!(0)
14
13
  two = images.slice!(0)
15
14
 
16
- out_path = one.dup
17
- discard = out_path.slice!(/[^_]*$/)
15
+ out_path = one.gsub(/[^_]*$/, '')
18
16
 
19
17
  diff_out = "#{out_path}diff.png"
20
18
  data_out = "#{out_path}data.txt"
@@ -27,49 +25,26 @@ module Goggles
27
25
  images = Dir.glob("#{@gg_result_dir}/*/*.png").sort
28
26
 
29
27
  until images.empty?
30
- one = images.slice!(0)
31
- two = images.slice!(0)
32
-
33
- File.open(one, 'rb') do |file_one|
34
- size_one = ImageSize.new(file_one.read).size
35
- first_width = size_one[0]
36
- first_height = size_one[1]
37
-
38
- File.open(two, 'rb') do |file_two|
39
- size_two = ImageSize.new(file_two.read).size
40
- second_width = size_two[0]
41
- second_height = size_two[1]
42
-
43
- if first_width > second_width
44
- width = second_width
45
- w_file = one
46
- else
47
- width = first_width
48
- w_file = two
49
- end
50
-
51
- if first_height > second_height
52
- height = second_height
53
- h_file = one
54
- else
55
- height = first_height
56
- h_file = two
28
+ pair = images.slice!(0..1)
29
+ widths = []
30
+ heights = []
31
+
32
+ File.open(pair[0], 'rb') do |one|
33
+ size = ImageSize.new(one.read).size
34
+ widths << size[0]
35
+ heights << size[1]
36
+
37
+ File.open(pair[1], 'rb') do |two|
38
+ size = ImageSize.new(two.read).size
39
+ widths << size[0]
40
+ heights << size[1]
41
+
42
+ pair.each do |file|
43
+ `convert #{file} -background none -extent #{widths.sort[0]}x#{heights.sort[0]} #{file}`
57
44
  end
58
-
59
- cut_to_width(w_file, width)
60
- cut_to_height(h_file, height)
61
-
62
45
  end
63
46
  end
64
47
  end
65
48
  end
66
49
 
67
- def cut_to_width(file, w)
68
- `convert #{file} -background none -extent #{w}x0 #{file}`
69
- end
70
-
71
- def cut_to_height(file, h)
72
- `convert #{file} -background none -extent 0x#{h} #{file}`
73
- end
74
-
75
50
  end
@@ -1,3 +1,3 @@
1
1
  module Goggles
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goggles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-23 00:00:00.000000000 Z
12
+ date: 2014-01-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler