goggles 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/goggles/comparison.rb +19 -44
- data/lib/goggles/version.rb +1 -1
- metadata +2 -2
data/lib/goggles/comparison.rb
CHANGED
@@ -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.
|
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
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
data/lib/goggles/version.rb
CHANGED
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.
|
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-
|
12
|
+
date: 2014-01-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|