mini_paperclip 0.1.0 → 0.1.1
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51135052187a9097d6989759082fcdba81aecfb7259909ba8bbf1dd17bf70036
|
4
|
+
data.tar.gz: 47673d86acfd5538bd0fb43cb373041add3281217ffae31d4bfcb71a7c2cf08b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 703405ef627eecc1df7856f65f9f27877fb675c95b8c2eb9bbe45c998f71cbebba1b37101bf44d8ec9ce64782a0a39caa06cde4752fa6007279366760acb0659
|
7
|
+
data.tar.gz: ded84756cf123fe3ffe82b8c47b59ac30c9ab39785056c4644a21e2ffd0183dd9e2250623f0307de41394c9392a0f650e64af3d0862163b1a5cc73522c0ed8ed
|
data/lib/mini_paperclip.rb
CHANGED
@@ -38,11 +38,13 @@ module MiniPaperclip
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def exists?(style)
|
41
|
-
|
41
|
+
Aws::S3::Client.new.head_object(
|
42
42
|
bucket: @config.s3_bucket_name,
|
43
43
|
key: s3_object_key(style),
|
44
44
|
)
|
45
|
-
|
45
|
+
true
|
46
|
+
rescue Aws::S3::Errors::NotFound
|
47
|
+
false
|
46
48
|
end
|
47
49
|
end
|
48
50
|
end
|
@@ -16,26 +16,24 @@ module MiniPaperclip
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
|
+
|
19
20
|
# validate_attachment :image,
|
20
21
|
# geometry: {
|
21
22
|
# width: { less_than_or_equal_to: 3000 },
|
22
23
|
# height: { less_than_or_equal_to: 3000 } }
|
23
24
|
def validate_each(record, attribute, value)
|
24
25
|
return unless value.waiting_write_file
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
29
|
-
return unless !geometry_string.empty?
|
30
|
-
width, height = geometry_string.split(',').map(&:to_i)
|
26
|
+
image_size = ImageSize.new(value.waiting_write_file)
|
27
|
+
# invalid format should not relate geometry
|
28
|
+
return unless image_size.format
|
31
29
|
|
32
30
|
expected_width_less_than_or_equal_to = options.dig(:width, :less_than_or_equal_to)
|
33
31
|
expected_height_less_than_or_equal_to = options.dig(:height, :less_than_or_equal_to)
|
34
|
-
unless (!expected_width_less_than_or_equal_to || width <= expected_width_less_than_or_equal_to) &&
|
35
|
-
(!expected_height_less_than_or_equal_to || height <= expected_height_less_than_or_equal_to)
|
32
|
+
unless (!expected_width_less_than_or_equal_to || image_size.width <= expected_width_less_than_or_equal_to) &&
|
33
|
+
(!expected_height_less_than_or_equal_to || image_size.height <= expected_height_less_than_or_equal_to)
|
36
34
|
record.errors.add(attribute, :geometry, {
|
37
|
-
actual_width: width,
|
38
|
-
actual_height: height,
|
35
|
+
actual_width: image_size.width,
|
36
|
+
actual_height: image_size.height,
|
39
37
|
expected_width_less_than_or_equal_to: expected_width_less_than_or_equal_to,
|
40
38
|
expected_height_less_than_or_equal_to: expected_height_less_than_or_equal_to,
|
41
39
|
})
|
data/mini_paperclip.gemspec
CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.add_runtime_dependency "activemodel"
|
18
18
|
spec.add_runtime_dependency "activesupport"
|
19
19
|
spec.add_runtime_dependency "aws-sdk-s3"
|
20
|
+
spec.add_runtime_dependency "image_size"
|
20
21
|
|
21
22
|
spec.metadata["homepage_uri"] = spec.homepage
|
22
23
|
spec.metadata["source_code_uri"] = spec.homepage
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_paperclip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ksss
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mini_magick
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: image_size
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: Subset from paperclip because paperclip has deprecated
|
84
98
|
email:
|
85
99
|
- co000ri@gmail.com
|