happo 2.5.1 → 2.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5838ef8f0db830d6dc8e742de8d68c8f421d3bb8
4
- data.tar.gz: 81578571296075c8ad8acf18fcc0f09ccef84124
3
+ metadata.gz: 5a09a6eec66779447b6ca4ab2bae97639a1b0580
4
+ data.tar.gz: fc22584f040c324fc81c00ae3f50eacd78ad7bbb
5
5
  SHA512:
6
- metadata.gz: 79ec55650363bebf05e2099441cf08d805ed83fbcda9e4da2c7baaedf22badf71e20e4e93d88741b365eb6345b86e6a3a306cfe6739b2b6705dfb577d25770f9
7
- data.tar.gz: 37ddd1fcba910ac54e78073fe60f5ff8608fa4879173eb9c7a83285425eb16aa325791975e162d7092c545d822f3436e5148d95febff46fc7fab82fa0eafa667
6
+ metadata.gz: 4b20a65e01766a900074ef668295ef21d807dbcbf731230335ee304cd4628647d324dca7bfcf63cb174fa04dd2ba4f214e74a25a9f01f5aa1ba94c745824c09a
7
+ data.tar.gz: 2158fbc4558027fa4e5a9f4af41d1361c3b9ccf098e151aa6f56cca23f8c154c638eaf557a53051ff71d32719eb68970b2e8abaf24f6ee76d1d527bb570f58bd
@@ -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 |image|
23
- image[:previous] = upload_image(image, 'previous')
24
- image[:diff] = upload_image(image, 'diff')
25
- image[:current] = upload_image(image, 'current')
26
- image
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 |image|
30
- image[:current] = upload_image(image, 'current')
31
- image
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 = find_or_build_bucket.objects.build("#{directory}/index.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
- if @s3_bucket_path.nil? || @s3_bucket_path.empty?
59
- SecureRandom.uuid
60
- else
61
- File.join(@s3_bucket_path, SecureRandom.uuid)
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(image, variant)
66
- bucket = find_or_build_bucket
67
- img_name = "#{image[:description]}_#{image[:viewport]}_#{variant}.png"
68
- s3_image = bucket.objects.build("#{directory}/#{img_name}")
69
- s3_image.content = open(Happo::Utils.path_to(image[:description],
70
- image[:viewport],
71
- "#{variant}.png"))
72
- s3_image.content_type = 'image/png'
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
@@ -1,4 +1,4 @@
1
1
  # Defines the gem version.
2
2
  module Happo
3
- VERSION = '2.5.1'
3
+ VERSION = '2.5.2'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: happo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.1
4
+ version: 2.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henric Trotzig