omg_image 0.0.3 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e039abdce55ba5038ced0e0915cc6569ada2b8b94a5a5c118f90c607b960a8bd
4
- data.tar.gz: b8ce28a058a94a2a746ffd7d9d9644bf52cf8dc6fd7550910a628e8091f48ef5
3
+ metadata.gz: 6d11fbb19b0784a35ae4e855a0d2426c74b2d3f297aec6fa37e007e1d0f8455a
4
+ data.tar.gz: 15fde70c74210d1d1359d41a03967808a07fd8e1e2dfeb120f8163157c3ff5ec
5
5
  SHA512:
6
- metadata.gz: 62bdcbd5f8ba976757eb1f0a806aba21d7ac801a955a371fd59f71c5063d1e43ebac4122ae0538bc45bcde57851744dd89dfc14e959fc6dab471306fb3e30a56
7
- data.tar.gz: 1bbd2a413f3b912d409522eb5147bd5266f807209d9352d0737e0f09c53be6ef94f2d8b9a1e96a39cec350cc13389d9adc49ee1ca0bb4ba4a9094f3d595ca635
6
+ metadata.gz: dd5e145b67e6e6384634907cb84dd0a31a8c745753853e64fdcc0e7e3fada226395168492c29c6f1194d84eaec9c7d7a388ffd86bd23e767ca6db8c82ae67e19
7
+ data.tar.gz: 7ed59bc149b69d64e6efd0a583c31b8c6dce8e9863a4d88cdeede60908689b911dc472a0f4dccc8dd4e6d46d08500c9cfde057dbd7f9c79552a087e2e4475815
@@ -13,6 +13,7 @@ module OmgImage
13
13
  options[:key] ||= options.to_s
14
14
 
15
15
  image = OmgImage::Image.find_by(key: options[:key])
16
+ log_smt " found #{image.present?}"
16
17
  if image && !image.file.attached?
17
18
  image.destroy
18
19
  image = nil
@@ -37,8 +38,8 @@ module OmgImage
37
38
 
38
39
  output = BetterTempfile.new("image.png")
39
40
 
40
- options = { file: output, size: options[:size], path: input.path }
41
- command = build_chrome_command(options)
41
+ cli_options = { file: output, size: options[:size], path: input.path }
42
+ command = build_chrome_command(cli_options)
42
43
  log_smt " => #{command}"
43
44
 
44
45
  start = Time.now
@@ -46,13 +47,16 @@ module OmgImage
46
47
  process = open4.spawn(command, timeout: 10)
47
48
  rescue Timeout::Error
48
49
  Process.kill('KILL', process.pid) rescue nil
50
+ log_smt "omg error: please retry. options: #{options}"
51
+ return nil
49
52
  end
50
53
  log_smt " to_image: #{(Time.now - start).round(2)}"
51
54
 
52
- image = OmgImage::Image.find_or_create_by(key: options[:key])
55
+ image = OmgImage::Image.find_by(key: options[:key])
56
+ image ||= OmgImage::Image.new(key: options[:key])
53
57
  if !image.file.attached?
54
58
  image.file.attach(io: File.open(output.path), filename: "image.png", content_type: "image/png")
55
- image.save
59
+ image.save!
56
60
  end
57
61
 
58
62
  image.file
@@ -10,6 +10,6 @@
10
10
  module OmgImage
11
11
  class Image < ApplicationRecord
12
12
  has_one_attached :file
13
- validates :key, presence: true
13
+ validates :key, presence: true, length: {minimum: 1, maximum: 250}
14
14
  end
15
15
  end
@@ -1,3 +1,3 @@
1
1
  module OmgImage
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omg_image
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Kasyanchuk