kontrast 0.6.1 → 0.6.2
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.
- checksums.yaml +4 -4
- data/lib/kontrast/api_endpoint_runner.rb +1 -2
- data/lib/kontrast/page_runner.rb +1 -2
- data/lib/kontrast/thumbnail_creator.rb +19 -13
- data/lib/kontrast/version.rb +1 -1
- data/spec/thumbnail_creator_spec.rb +40 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e5150f17ebb77d6b2e4ccabf768e77a34f5ff85
|
4
|
+
data.tar.gz: 926687107b868968c53f545432fc52910b964943
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6517d32d57c3b2341a15b366b2c5de2c737d1cb2ed53db70b2ba5bcb26acdf88f599f7e1460b610e3da856177bdec7fde02fd6ea9af6e22595ce104edfcbf966
|
7
|
+
data.tar.gz: a3cb71cdac6916115ad88d06b8c75b80bbd9a07c542af6de639e34115da1e897318fd083a5275c4fec9074827000e666963198a2813e398a4eab17b9cb953afe
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Kontrast
|
2
2
|
class ApiEndpointRunner
|
3
3
|
include ImageUploader
|
4
|
-
include ThumbnailCreator
|
5
4
|
|
6
5
|
attr_accessor :diffs
|
7
6
|
|
@@ -68,7 +67,7 @@ module Kontrast
|
|
68
67
|
['.', '..'].include?(file_name) || file_name.include?('.json')
|
69
68
|
}
|
70
69
|
|
71
|
-
create_thumbnails(test, images)
|
70
|
+
ThumbnailCreator.create_thumbnails(test, images)
|
72
71
|
|
73
72
|
# Upload to S3
|
74
73
|
if Kontrast.configuration.run_parallel
|
data/lib/kontrast/page_runner.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Kontrast
|
2
2
|
class PageRunner
|
3
3
|
include ImageUploader
|
4
|
-
include ThumbnailCreator
|
5
4
|
|
6
5
|
attr_reader :diffs
|
7
6
|
|
@@ -60,7 +59,7 @@ module Kontrast
|
|
60
59
|
|
61
60
|
# Create thumbnails for gallery
|
62
61
|
print "Creating thumbnails... "
|
63
|
-
create_thumbnails(test, ['test.png', 'production.png', 'diff.png'])
|
62
|
+
ThumbnailCreator.create_thumbnails(test, ['test.png', 'production.png', 'diff.png'])
|
64
63
|
|
65
64
|
# Upload to S3
|
66
65
|
if Kontrast.configuration.run_parallel
|
@@ -1,18 +1,24 @@
|
|
1
1
|
module Kontrast
|
2
|
-
|
2
|
+
module ThumbnailCreator
|
3
3
|
|
4
|
-
|
5
|
-
# Load images
|
6
|
-
images = image_names.map do |image|
|
7
|
-
Magick::Image.read(File.join(Kontrast.path, test.to_s, image)).first
|
8
|
-
end
|
4
|
+
module_function
|
9
5
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
6
|
+
def create_thumbnails(test, image_names)
|
7
|
+
# Crop images
|
8
|
+
Workers.map(image_names) do |image_name|
|
9
|
+
src_path = File.join(Kontrast.path, test.to_s, image_name)
|
10
|
+
|
11
|
+
# Resize to at least 200 width, the crop the top part of the image at 200x200
|
12
|
+
# '+repage' means "don't keep the part of the image not shown in the crop"
|
13
|
+
# http://www.imagemagick.org/discourse-server/viewtopic.php?t=18545
|
14
|
+
options = '-resize "200x200^" -gravity North -crop 200x200+0+0 +repage'
|
15
|
+
`convert "#{src_path}" #{options} "#{thumb_path(test, image_name)}"`
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def thumb_path(test, image_name)
|
20
|
+
filename = "#{File.basename(image_name, ".*")}_thumb.png"
|
21
|
+
File.join(Kontrast.path, test.to_s, filename)
|
17
22
|
end
|
23
|
+
end
|
18
24
|
end
|
data/lib/kontrast/version.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'kontrast'
|
4
|
+
|
5
|
+
describe Kontrast::ThumbnailCreator do
|
6
|
+
let(:kontrast_path) { "/path/to/kontrast" }
|
7
|
+
let(:test) { "home_1280" }
|
8
|
+
let(:image_names) do
|
9
|
+
[
|
10
|
+
"diff_0.jpg",
|
11
|
+
"test_0.jpg",
|
12
|
+
"prod_0.jpg",
|
13
|
+
]
|
14
|
+
end
|
15
|
+
|
16
|
+
before do
|
17
|
+
allow(Kontrast).to receive(:path).and_return(kontrast_path)
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'thumb_path' do
|
21
|
+
it 'should return a png' do
|
22
|
+
image_name = "diff_0.jpg"
|
23
|
+
|
24
|
+
thumb_path = Kontrast::ThumbnailCreator.thumb_path(test, image_name)
|
25
|
+
|
26
|
+
expect(thumb_path).to eql "#{kontrast_path}/#{test}/diff_0_thumb.png"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'create_thumbnails' do
|
31
|
+
it 'creates thumbnails' do
|
32
|
+
allow(Kontrast::ThumbnailCreator).to receive(:`)
|
33
|
+
|
34
|
+
Kontrast::ThumbnailCreator.create_thumbnails(test, image_names)
|
35
|
+
|
36
|
+
|
37
|
+
expect(Kontrast::ThumbnailCreator).to have_received(:`).with(/^convert.*/).exactly(3).times
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kontrast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Rubnich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -219,6 +219,7 @@ files:
|
|
219
219
|
- spec/test_builder_spec.rb
|
220
220
|
- spec/test_spec.rb
|
221
221
|
- spec/test_suite_spec.rb
|
222
|
+
- spec/thumbnail_creator_spec.rb
|
222
223
|
homepage: https://github.com/harrystech/kontrast
|
223
224
|
licenses:
|
224
225
|
- MIT
|
@@ -261,3 +262,4 @@ test_files:
|
|
261
262
|
- spec/test_builder_spec.rb
|
262
263
|
- spec/test_spec.rb
|
263
264
|
- spec/test_suite_spec.rb
|
265
|
+
- spec/thumbnail_creator_spec.rb
|