dynamic_image 2.0.21 → 2.0.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/dynamic_image/belongs_to.rb +1 -1
- data/lib/dynamic_image/controller.rb +2 -2
- data/lib/dynamic_image/engine.rb +1 -1
- data/lib/dynamic_image/image_sizing.rb +2 -2
- data/lib/dynamic_image/model/dimensions.rb +2 -2
- data/lib/dynamic_image/processed_image.rb +18 -18
- data/lib/dynamic_image/version.rb +1 -1
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfb9c218b8902487079281c04685088ba37cee03ba5944425c8e391869ed1f54
|
4
|
+
data.tar.gz: 6be8904c347f0721fe0d52f4693c65c7a7c96d77d81b169c00b83859df46c741
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 712f4d5d9077baec9e3f67d01ae686a38ef380686a37a5c6c91b2e0d27db50e2623cd30c3b25e107a3b03fc6e0712fe20bc0643fc47ae73473ee735e94d031b5
|
7
|
+
data.tar.gz: 8ef5cd0021f2d32bc0876923c19f9e059edd5fdb52e06893cbab4dc4d739f72551f5bf53da8ee0007854f78d2cb5cc1de157542e40be9d27b17c6eeee735ccdb
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
[![Version](https://img.shields.io/gem/v/dynamic_image.svg?style=flat)](https://rubygems.org/gems/dynamic_image)
|
2
|
-
|
2
|
+
![Build](https://github.com/elektronaut/dynamic_image/workflows/Build/badge.svg)
|
3
3
|
[![Code Climate](https://codeclimate.com/github/elektronaut/dynamic_image/badges/gpa.svg)](https://codeclimate.com/github/elektronaut/dynamic_image)
|
4
4
|
[![Code Climate](https://codeclimate.com/github/elektronaut/dynamic_image/badges/coverage.svg)](https://codeclimate.com/github/elektronaut/dynamic_image)
|
5
5
|
[![Inline docs](http://inch-ci.org/github/elektronaut/dynamic_image.svg)](http://inch-ci.org/github/elektronaut/dynamic_image)
|
@@ -8,7 +8,7 @@ module DynamicImage
|
|
8
8
|
|
9
9
|
module ClassMethods
|
10
10
|
def belongs_to_image(name, scope = nil, **options)
|
11
|
-
belongs_to(name, scope, options)
|
11
|
+
belongs_to(name, scope, **options)
|
12
12
|
|
13
13
|
define_method "#{name}=" do |new_image|
|
14
14
|
if new_image.present? && !new_image.is_a?(DynamicImage::Model)
|
@@ -59,7 +59,7 @@ module DynamicImage
|
|
59
59
|
render(file: File.join(File.dirname(__FILE__), "templates/show"),
|
60
60
|
layout: false, locals: { options: options })
|
61
61
|
end
|
62
|
-
format.any(:gif, :jpeg, :png, :tiff, :webp) do
|
62
|
+
format.any(:gif, :jpeg, :jpg, :png, :tiff, :webp) do
|
63
63
|
send_image(DynamicImage::ProcessedImage.new(@record, options))
|
64
64
|
end
|
65
65
|
end
|
@@ -69,7 +69,7 @@ module DynamicImage
|
|
69
69
|
return unless stale?(@record)
|
70
70
|
|
71
71
|
respond_to do |format|
|
72
|
-
format.any(:gif, :jpeg, :png, :tiff, :webp) do
|
72
|
+
format.any(:gif, :jpeg, :jpg, :png, :tiff, :webp) do
|
73
73
|
send_data(@record.data,
|
74
74
|
filename: filename,
|
75
75
|
content_type: @record.content_type,
|
data/lib/dynamic_image/engine.rb
CHANGED
@@ -31,7 +31,7 @@ module DynamicImage
|
|
31
31
|
ActiveSupport.on_load(:active_record) do
|
32
32
|
send :include, DynamicImage::BelongsTo
|
33
33
|
end
|
34
|
-
ActionDispatch::Routing::Mapper.
|
34
|
+
ActionDispatch::Routing::Mapper.include DynamicImage::Routing
|
35
35
|
|
36
36
|
ActionDispatch::ExceptionWrapper.rescue_responses.merge!(
|
37
37
|
"DynamicImage::Errors::InvalidSignature" => :unauthorized
|
@@ -70,27 +70,30 @@ module DynamicImage
|
|
70
70
|
private
|
71
71
|
|
72
72
|
def coalesced(image)
|
73
|
-
|
73
|
+
gif? ? DynamicImage::ImageReader.new(image.coalesce.to_blob).read : image
|
74
|
+
end
|
74
75
|
|
75
|
-
|
76
|
+
def create_variant(size)
|
77
|
+
record.variants.create(
|
78
|
+
variant_params(size).merge(filename: record.filename,
|
79
|
+
content_type: content_type,
|
80
|
+
data: crop_and_resize(size))
|
81
|
+
)
|
76
82
|
end
|
77
83
|
|
78
84
|
def crop_and_resize(size)
|
79
85
|
normalized do |image|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
86
|
+
next unless record.cropped? || size != record.size
|
87
|
+
|
88
|
+
image.crop(image_sizing.crop_geometry_string(size))
|
89
|
+
image.resize(size)
|
84
90
|
end
|
85
91
|
end
|
86
92
|
|
87
93
|
def find_or_create_variant(size)
|
88
|
-
record.variants.find_by(variant_params(size)) ||
|
89
|
-
|
90
|
-
|
91
|
-
content_type: content_type,
|
92
|
-
data: crop_and_resize(size))
|
93
|
-
)
|
94
|
+
record.variants.find_by(variant_params(size)) || create_variant(size)
|
95
|
+
rescue ActiveRecord::RecordNotUnique
|
96
|
+
record.variants.find_by(variant_params(size))
|
94
97
|
end
|
95
98
|
|
96
99
|
def format
|
@@ -152,12 +155,9 @@ module DynamicImage
|
|
152
155
|
def variant_params(size)
|
153
156
|
crop_size, crop_start = image_sizing.crop_geometry(size)
|
154
157
|
|
155
|
-
{ width: size.x.round,
|
156
|
-
|
157
|
-
|
158
|
-
crop_height: crop_size.y,
|
159
|
-
crop_start_x: crop_start.x,
|
160
|
-
crop_start_y: crop_start.y,
|
158
|
+
{ width: size.x.round, height: size.y.round,
|
159
|
+
crop_width: crop_size.x, crop_height: crop_size.y,
|
160
|
+
crop_start_x: crop_start.x, crop_start_y: crop_start.y,
|
161
161
|
format: format }
|
162
162
|
end
|
163
163
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamic_image
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Inge Jørgensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dis
|
@@ -78,6 +78,20 @@ dependencies:
|
|
78
78
|
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: 2.2.1
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: rails-controller-testing
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
81
95
|
- !ruby/object:Gem::Dependency
|
82
96
|
name: rspec-rails
|
83
97
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,6 +106,20 @@ dependencies:
|
|
92
106
|
- - "~>"
|
93
107
|
- !ruby/object:Gem::Version
|
94
108
|
version: 3.7.0
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: simplecov
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - "~>"
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: 0.17.1
|
116
|
+
type: :development
|
117
|
+
prerelease: false
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - "~>"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 0.17.1
|
95
123
|
- !ruby/object:Gem::Dependency
|
96
124
|
name: sqlite3
|
97
125
|
requirement: !ruby/object:Gem::Requirement
|