image_quality_check 0.4.2 → 0.5.0

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: 117aa39519dafb842aff6479fc119b581d1bf1e1ae5060794b7b13aeb1d8e310
4
- data.tar.gz: 30c63c19b58559ff9169803e431d7c5d3426312cc4f3ee3a88f513f3e8c56fca
3
+ metadata.gz: d9e3e782cc7e109a7b147f4aa88363ba220fe01dde01093bfcd0a363c8e963b3
4
+ data.tar.gz: 0a73b6c510b7ac5601a8774ad12278a93baca8da59ce52ed98e12bf296db0c72
5
5
  SHA512:
6
- metadata.gz: e4696e959efef7c81fd29683ca0c5b0e8b62726f9270d0ecf6d0560b1bc0018e1b685c3c7b307a4c88cc791ad087c1ce7d65d6c8be726d6e5d01295990f9e5ae
7
- data.tar.gz: 436cf2d6b3d38077a5dc88face11393fcaf62564faf3b0fb48f475f80a4c0c89c5d612e8e9ded118f5b88fbed44d4f3ba8b842664a9a13aba08fa8a8ff2960c4
6
+ metadata.gz: ed4b6d4b297327b7bd4adf0b005b123e03a567b109a7e7ebb9bbb97e2243baf9f9a97b826a036fe6bd1fcc892a08a5b690b2a3c1a2cf5b2a272c176c9d1a0daf
7
+ data.tar.gz: 8d3b334b6f4d205e06ab86d889b5698dc3d4e72cc3b4916242c20e49ec8574e692af0b9b7a51066b2752fe3eef303a84b19ffc3cdc0598c873dbcf0d38dcd2e5
@@ -13,7 +13,7 @@ class ImageQualityCheck::DetermineQuality
13
13
  @tmp_file = tmp_file
14
14
  end
15
15
 
16
- def run(&block)
16
+ def run
17
17
  unless @tmp_file
18
18
  @tmp_file = Tempfile.new(['image_quality'])
19
19
  @tmp_file.binmode
@@ -32,7 +32,7 @@ class ImageQualityCheck::DetermineQuality
32
32
  result = {
33
33
  quality: determine_quality,
34
34
  details: @analyse_result,
35
- messages: @messages,
35
+ messages: @messages
36
36
  }
37
37
  yield(result) if block_given?
38
38
  result
@@ -64,23 +64,28 @@ class ImageQualityCheck::DetermineQuality
64
64
  def read!(tmp_file)
65
65
  case @column.class.to_s
66
66
  when 'ActiveStorage::Attached::One'
67
+ return false if !@column.blob || !@column.attached?
68
+
69
+ copied_from_disk = false
67
70
  if @column.blob.service.respond_to?(:path_for)
68
- if !@column.blob || !File.exist?(@column.blob.service.send(:path_for, @column.blob.key))
69
- false
70
- else
71
- FileUtils.cp(@column.blob.service.send(:path_for, @column.blob.key), tmp_file.path)
72
- true
73
- end
74
- else
75
- if !@column.blob || !@column.blob.attached?
76
- false
77
- else
78
- tmp_file.write(@column.download)
79
- tmp_file.rewind
80
- true
71
+ begin
72
+ path = @column.blob.service.send(:path_for, @column.blob.key)
73
+ if File.exist?(path)
74
+ FileUtils.cp(path, tmp_file.path)
75
+ copied_from_disk = true
76
+ end
77
+ rescue NoMethodError
78
+ # MirrorService responds to :path_for but may delegate to a service
79
+ # that doesn't support it (e.g. S3Service)
81
80
  end
82
81
  end
83
- when "Paperclip::Attachment"
82
+
83
+ unless copied_from_disk
84
+ tmp_file.write(@column.download)
85
+ tmp_file.rewind
86
+ end
87
+ true
88
+ when 'Paperclip::Attachment'
84
89
  if @column.options[:storage] == :s3
85
90
  @column.copy_to_local_file(:original, tmp_file.path)
86
91
  true
@@ -1,3 +1,3 @@
1
1
  module ImageQualityCheck
2
- VERSION = "0.4.2"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: image_quality_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Wienert
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-12-09 00:00:00.000000000 Z
11
+ date: 2026-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n