attachment_saver 1.5.1 → 1.6.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 +5 -5
- data/Gemfile.lock +31 -32
- data/lib/attachment_saver/version.rb +1 -1
- data/lib/processors/gdk_pixbuf.rb +3 -3
- data/lib/processors/image_science.rb +1 -2
- data/lib/processors/image_size.rb +0 -1
- data/lib/processors/mini_magick.rb +1 -2
- data/lib/processors/r_magick.rb +1 -2
- data/test/file_system_datastore_test.rb +1 -1
- data/test/image_processor_test.rb +18 -13
- data/test/in_column_datastore_test.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 88bee0b1c6ab4d3d068770c288a4f724cf7c6486570b59b00141cfce744a3596
|
4
|
+
data.tar.gz: 0db2e591edefa6b2c9b1fb1ac3466bd76c8432acd885dd6c6387fa7441f6a749
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d837872c933bcc2fc557ddc210d05d1a0d46fe27f0f4c2b484cab5b6c47b836eb0dfbb6e3e00dfb24d32df51eb96520890dc92d0f20da9870924c61851db2e3e
|
7
|
+
data.tar.gz: 19577ea9e1c123a5b265943911d3f1c1a601a962fb6f5e5c79853a3bdf7ac3045f99257d59860e306815c3a5ea046fe489d577353d72b641fc0079118d8ed06a
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
attachment_saver (1.
|
4
|
+
attachment_saver (1.6.0)
|
5
5
|
activerecord
|
6
6
|
mimemagic
|
7
7
|
|
@@ -10,48 +10,47 @@ GEM
|
|
10
10
|
specs:
|
11
11
|
RubyInline (3.12.4)
|
12
12
|
ZenTest (~> 4.3)
|
13
|
-
ZenTest (4.11.
|
14
|
-
activemodel (5.2.
|
15
|
-
activesupport (= 5.2.
|
16
|
-
activerecord (5.2.
|
17
|
-
activemodel (= 5.2.
|
18
|
-
activesupport (= 5.2.
|
13
|
+
ZenTest (4.11.2)
|
14
|
+
activemodel (5.2.3)
|
15
|
+
activesupport (= 5.2.3)
|
16
|
+
activerecord (5.2.3)
|
17
|
+
activemodel (= 5.2.3)
|
18
|
+
activesupport (= 5.2.3)
|
19
19
|
arel (>= 9.0)
|
20
|
-
activesupport (5.2.
|
20
|
+
activesupport (5.2.3)
|
21
21
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
22
|
-
i18n (
|
22
|
+
i18n (>= 0.7, < 2)
|
23
23
|
minitest (~> 5.1)
|
24
24
|
tzinfo (~> 1.1)
|
25
25
|
arel (9.0.0)
|
26
|
-
concurrent-ruby (1.
|
27
|
-
gdk_pixbuf2 (3.
|
28
|
-
gio2 (= 3.
|
29
|
-
gio2 (3.
|
30
|
-
|
31
|
-
|
32
|
-
glib2 (3.2.1)
|
26
|
+
concurrent-ruby (1.1.5)
|
27
|
+
gdk_pixbuf2 (3.3.6)
|
28
|
+
gio2 (= 3.3.6)
|
29
|
+
gio2 (3.3.6)
|
30
|
+
gobject-introspection (= 3.3.6)
|
31
|
+
glib2 (3.3.6)
|
33
32
|
native-package-installer (>= 1.0.3)
|
34
|
-
pkg-config (>= 1.
|
35
|
-
gobject-introspection (3.
|
36
|
-
glib2 (= 3.
|
37
|
-
i18n (
|
33
|
+
pkg-config (>= 1.3.5)
|
34
|
+
gobject-introspection (3.3.6)
|
35
|
+
glib2 (= 3.3.6)
|
36
|
+
i18n (1.6.0)
|
38
37
|
concurrent-ruby (~> 1.0)
|
39
38
|
image_science (1.3.0)
|
40
39
|
RubyInline (~> 3.9)
|
41
|
-
image_size (
|
40
|
+
image_size (2.0.2)
|
42
41
|
metaclass (0.0.4)
|
43
|
-
mimemagic (0.3.
|
44
|
-
mini_magick (4.
|
45
|
-
minitest (5.11.
|
46
|
-
mocha (1.
|
42
|
+
mimemagic (0.3.3)
|
43
|
+
mini_magick (4.9.5)
|
44
|
+
minitest (5.11.3)
|
45
|
+
mocha (1.9.0)
|
47
46
|
metaclass (~> 0.0.1)
|
48
|
-
native-package-installer (1.0.
|
49
|
-
pkg-config (1.
|
50
|
-
rake (12.3.
|
51
|
-
rmagick (
|
52
|
-
sqlite3 (1.
|
47
|
+
native-package-installer (1.0.7)
|
48
|
+
pkg-config (1.3.7)
|
49
|
+
rake (12.3.3)
|
50
|
+
rmagick (4.0.0)
|
51
|
+
sqlite3 (1.4.1)
|
53
52
|
thread_safe (0.3.6)
|
54
|
-
tzinfo (1.2.
|
53
|
+
tzinfo (1.2.5)
|
55
54
|
thread_safe (~> 0.1)
|
56
55
|
|
57
56
|
PLATFORMS
|
@@ -70,4 +69,4 @@ DEPENDENCIES
|
|
70
69
|
sqlite3
|
71
70
|
|
72
71
|
BUNDLED WITH
|
73
|
-
1.16.
|
72
|
+
1.16.4
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'gdk_pixbuf2'
|
2
|
-
require 'misc/extended_tempfile'
|
3
2
|
require 'processors/image'
|
4
3
|
|
5
4
|
class GdkPixbufProcessorError < ImageProcessorError; end
|
@@ -67,7 +66,7 @@ module AttachmentSaver
|
|
67
66
|
end
|
68
67
|
|
69
68
|
# we leverage tempfiles as discussed in the uploaded_file method
|
70
|
-
temp =
|
69
|
+
temp = Tempfile.new(["asgtemp", ".#{derived_extension}"], tempfile_directory)
|
71
70
|
temp.binmode
|
72
71
|
temp.close
|
73
72
|
derived_image.save(temp.path, format)
|
@@ -98,7 +97,8 @@ module AttachmentSaver
|
|
98
97
|
end
|
99
98
|
|
100
99
|
def crop_to(new_width, new_height, &block) # crops to the center
|
101
|
-
|
100
|
+
method = respond_to?(:subpixbuf) ? :subpixbuf : :new_subpixbuf
|
101
|
+
image = send(method, (width - new_width)/2, (height - new_height)/2, new_width, new_height)
|
102
102
|
image.extend Operations
|
103
103
|
image.format = format
|
104
104
|
image.file_extension = file_extension
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'image_science'
|
2
2
|
require 'misc/image_science_extensions'
|
3
|
-
require 'misc/extended_tempfile'
|
4
3
|
require 'processors/image'
|
5
4
|
|
6
5
|
class ImageScienceProcessorError < ImageProcessorError; end
|
@@ -51,7 +50,7 @@ module AttachmentSaver
|
|
51
50
|
end
|
52
51
|
|
53
52
|
# we leverage tempfiles as discussed in the uploaded_file method
|
54
|
-
temp =
|
53
|
+
temp = Tempfile.new(["asitemp", ".#{derived_extension}"], tempfile_directory)
|
55
54
|
temp.binmode
|
56
55
|
temp.close
|
57
56
|
derived_image.save(temp.path)
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'mini_magick'
|
2
2
|
require 'misc/mini_magick_extensions'
|
3
|
-
require 'misc/extended_tempfile'
|
4
3
|
require 'processors/image'
|
5
4
|
|
6
5
|
class MiniMagickProcessorError < ImageProcessorError; end
|
@@ -53,7 +52,7 @@ module AttachmentSaver
|
|
53
52
|
derived_extension = derived_image.file_type_extension
|
54
53
|
|
55
54
|
# we leverage tempfiles as discussed in the uploaded_file method
|
56
|
-
temp =
|
55
|
+
temp = Tempfile.new(["asmtemp", ".#{derived_extension}"], tempfile_directory)
|
57
56
|
temp.binmode
|
58
57
|
temp.close
|
59
58
|
derived_image.write(temp.path)
|
data/lib/processors/r_magick.rb
CHANGED
@@ -3,7 +3,6 @@ begin
|
|
3
3
|
rescue LoadError
|
4
4
|
require 'RMagick'
|
5
5
|
end
|
6
|
-
require 'misc/extended_tempfile'
|
7
6
|
require 'processors/image'
|
8
7
|
|
9
8
|
class RMagickProcessorError < ImageProcessorError; end
|
@@ -48,7 +47,7 @@ module AttachmentSaver
|
|
48
47
|
derived_extension = derived_image.file_type_extension
|
49
48
|
|
50
49
|
# we leverage tempfiles as discussed in the uploaded_file method
|
51
|
-
temp =
|
50
|
+
temp = Tempfile.new(["asrtemp", ".#{derived_extension}"], tempfile_directory)
|
52
51
|
temp.binmode
|
53
52
|
temp.close
|
54
53
|
derived_image.write(temp.path)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
|
2
|
-
require 'mocha/
|
2
|
+
require 'mocha/minitest'
|
3
3
|
require 'processors/image'
|
4
4
|
require File.expand_path(File.join(File.dirname(__FILE__), 'image_operations'))
|
5
5
|
|
@@ -43,19 +43,24 @@ class ImageProcessorTest < ActiveSupport::TestCase
|
|
43
43
|
model_without_upload.expects(:examine_image).times(0)
|
44
44
|
model_without_upload.before_validate_attachment
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
46
|
+
model_with_upload_with_non_image_magic = SomeModel.new('application/octet-stream')
|
47
|
+
model_with_upload_with_non_image_magic.expects(:uploaded_file).at_least_once.returns(StringIO.new('dummy'))
|
48
|
+
model_with_upload_with_non_image_magic.expects(:examine_image).times(0)
|
49
|
+
model_with_upload_with_non_image_magic.before_validate_attachment
|
50
|
+
|
51
|
+
model_with_upload_with_image_magic = SomeModel.new('application/octet-stream')
|
52
|
+
model_with_upload_with_image_magic.expects(:uploaded_file).at_least_once.returns(StringIO.new(File.read(ImageFixtures.fixture_path('test.jpg'))))
|
53
|
+
model_with_upload_with_image_magic.expects(:examine_image).times(1)
|
54
|
+
model_with_upload_with_image_magic.before_validate_attachment
|
55
|
+
|
56
|
+
model_with_invalid_upload_with_image_magic = SomeModel.new('text/plain')
|
57
|
+
model_with_invalid_upload_with_image_magic.expects(:uploaded_file).at_least_once.returns(StringIO.new(File.read(ImageFixtures.fixture_path('test.jpg'))))
|
58
|
+
model_with_invalid_upload_with_image_magic.expects(:examine_image).times(1).raises(ImageProcessorError)
|
59
|
+
model_with_invalid_upload_with_image_magic.before_validate_attachment
|
60
|
+
assert_equal 'text/plain', model_with_invalid_upload_with_image_magic.content_type
|
61
|
+
|
57
62
|
model_with_mislabelled_non_image_upload = SomeModel.new('image/png')
|
58
|
-
model_with_mislabelled_non_image_upload.expects(:uploaded_file).
|
63
|
+
model_with_mislabelled_non_image_upload.expects(:uploaded_file).at_least_once.returns(StringIO.new(File.read(ImageFixtures.fixture_path('test.jpg'))))
|
59
64
|
model_with_mislabelled_non_image_upload.expects(:examine_image).times(1).raises(ImageProcessorError)
|
60
65
|
model_with_mislabelled_non_image_upload.before_validate_attachment
|
61
66
|
assert_equal 'application/octet-stream', model_with_mislabelled_non_image_upload.content_type
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attachment_saver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Bryant
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -234,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
234
234
|
version: '0'
|
235
235
|
requirements: []
|
236
236
|
rubyforge_project:
|
237
|
-
rubygems_version: 2.
|
237
|
+
rubygems_version: 2.7.6
|
238
238
|
signing_key:
|
239
239
|
specification_version: 4
|
240
240
|
summary: Saves attachments in files, models, or columns.
|
@@ -265,4 +265,3 @@ test_files:
|
|
265
265
|
- test/rmagick_processor_test.rb
|
266
266
|
- test/schema.rb
|
267
267
|
- test/test_helper.rb
|
268
|
-
has_rdoc: false
|