happo 2.5.1 → 2.5.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/happo/uploader.rb +27 -22
- data/lib/happo/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a09a6eec66779447b6ca4ab2bae97639a1b0580
|
4
|
+
data.tar.gz: fc22584f040c324fc81c00ae3f50eacd78ad7bbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b20a65e01766a900074ef668295ef21d807dbcbf731230335ee304cd4628647d324dca7bfcf63cb174fa04dd2ba4f214e74a25a9f01f5aa1ba94c745824c09a
|
7
|
+
data.tar.gz: 2158fbc4558027fa4e5a9f4af41d1361c3b9ccf098e151aa6f56cca23f8c154c638eaf557a53051ff71d32719eb68970b2e8abaf24f6ee76d1d527bb570f58bd
|
data/lib/happo/uploader.rb
CHANGED
@@ -19,19 +19,19 @@ module Happo
|
|
19
19
|
return [] if result_summary[:diff_examples].empty? &&
|
20
20
|
result_summary[:new_examples].empty?
|
21
21
|
|
22
|
-
diff_images = result_summary[:diff_examples].map do |
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
diff_images = result_summary[:diff_examples].map do |example|
|
23
|
+
example[:previous] = upload_image(example, 'previous')
|
24
|
+
example[:diff] = upload_image(example, 'diff')
|
25
|
+
example[:current] = upload_image(example, 'current')
|
26
|
+
example
|
27
27
|
end
|
28
28
|
|
29
|
-
new_images = result_summary[:new_examples].map do |
|
30
|
-
|
31
|
-
|
29
|
+
new_images = result_summary[:new_examples].map do |example|
|
30
|
+
example[:current] = upload_image(example, 'current')
|
31
|
+
example
|
32
32
|
end
|
33
33
|
|
34
|
-
html =
|
34
|
+
html = build_object('index.html')
|
35
35
|
path = File.expand_path(
|
36
36
|
File.join(File.dirname(__FILE__), 'views', 'diffs.erb')
|
37
37
|
)
|
@@ -54,23 +54,28 @@ module Happo
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
+
def build_object(file_name)
|
58
|
+
find_or_build_bucket.objects.build("#{directory}/#{file_name}")
|
59
|
+
end
|
60
|
+
|
57
61
|
def directory
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
+
@directory ||= begin
|
63
|
+
if @s3_bucket_path.nil? || @s3_bucket_path.empty?
|
64
|
+
SecureRandom.uuid
|
65
|
+
else
|
66
|
+
File.join(@s3_bucket_path, SecureRandom.uuid)
|
67
|
+
end
|
62
68
|
end
|
63
69
|
end
|
64
70
|
|
65
|
-
def upload_image(
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
s3_image.save
|
71
|
+
def upload_image(example, variant)
|
72
|
+
img_name = "#{example[:description]}_#{example[:viewport]}_#{variant}.png"
|
73
|
+
image = build_object(img_name)
|
74
|
+
image.content = open(Happo::Utils.path_to(example[:description],
|
75
|
+
example[:viewport],
|
76
|
+
"#{variant}.png"))
|
77
|
+
image.content_type = 'image/png'
|
78
|
+
image.save
|
74
79
|
URI.escape(img_name)
|
75
80
|
end
|
76
81
|
end
|
data/lib/happo/version.rb
CHANGED