dynamic_image 2.0.13 → 2.0.14

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
  SHA1:
3
- metadata.gz: e5235c5c6dd04f5af0cbe9fcb4c293efe989c813
4
- data.tar.gz: e403c4b977e1b3e4b2d9160da2906a4085eb97c2
3
+ metadata.gz: 20c84bf7939b0450acb161b046d8c42e5f3c8e12
4
+ data.tar.gz: '09367ca2c355b0d54180247e87bf9d72dd38c02c'
5
5
  SHA512:
6
- metadata.gz: bc7e89d53054bbd04c0cbc2a0c95c36c0314b44c0bf2e04b3cd473e085e86a096b1d36fed8b4c8627c1dae53eefa04d31080ad266c093f97a3a1d1651f54bb46
7
- data.tar.gz: b2d747f2c2dd3e2e45b7f41130b4397dd21abed915fd2990deebdd4a170b16a09978c47502f1b5c8114a4a5cc8516462d392d852b7c976f5652dfd93e6538ee9
6
+ metadata.gz: f2ab39cadc60f5ffd21e3ecb017a77f2ccc2442427c97efb10acdc62d19c30f0c4793fc3460e283337bc02fce92cbdb14a1125dcef75e0cc34b38b3aec0553b9
7
+ data.tar.gz: 7d2b3816a103a1f76079326ed4aa90b2e9eb43ee4a7803c1bb8b1b4825ac0e64a0d7f3feac616f3a2dfa72703a8ace2ed5fc16f71b19f771d83b5332991fa6ae
@@ -7,7 +7,7 @@ module DynamicImage
7
7
  extend ActiveSupport::Concern
8
8
 
9
9
  module ClassMethods
10
- def belongs_to_image(name, scope = nil, options = {})
10
+ def belongs_to_image(name, scope = nil, **options)
11
11
  belongs_to(name, scope, options)
12
12
 
13
13
  define_method "#{name}=" do |new_image|
@@ -31,7 +31,7 @@ module DynamicImage
31
31
  # # => <img alt="Avatar" height="62" src="..." width="100" />
32
32
  def dynamic_image_tag(record_or_array, options = {})
33
33
  record = extract_dynamic_image_record(record_or_array)
34
- options = { alt: image_alt(record.filename) }.merge(options)
34
+ options = { alt: filename_to_alt(record.filename) }.merge(options)
35
35
 
36
36
  size = fit_size!(record_or_array, options)
37
37
  url_options = options.extract!(*allowed_dynamic_image_url_options)
@@ -161,6 +161,13 @@ module DynamicImage
161
161
  end
162
162
  end
163
163
 
164
+ def filename_to_alt(str)
165
+ File.basename(str, ".*".freeze)
166
+ .sub(/-[[:xdigit:]]{32,64}\z/, "".freeze)
167
+ .tr("-_".freeze, " ".freeze)
168
+ .capitalize
169
+ end
170
+
164
171
  def fit_size!(record_or_array, options)
165
172
  record = extract_dynamic_image_record(record_or_array)
166
173
  action = options[:action].try(:to_s)
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module DynamicImage
4
- VERSION = "2.0.13".freeze
4
+ VERSION = "2.0.14".freeze
5
5
  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.13
4
+ version: 2.0.14
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: 2018-05-09 00:00:00.000000000 Z
11
+ date: 2018-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -98,14 +98,14 @@ dependencies:
98
98
  requirements:
99
99
  - - "~>"
100
100
  - !ruby/object:Gem::Version
101
- version: 3.5.1
101
+ version: 3.7.0
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - "~>"
107
107
  - !ruby/object:Gem::Version
108
- version: 3.5.1
108
+ version: 3.7.0
109
109
  description: DynamicImage is a Rails plugin that simplifies image uploading and processing
110
110
  email:
111
111
  - inge@elektronaut.no