active_storage_validations 0.8.7 → 0.8.8

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: 8ee7d6623af014086158c960b7ef7408f4cf7527536f57539765351357160189
4
- data.tar.gz: 6819ee596bd09560ca801fade1006bfbe4bf03b820b7ca1b0f84eafe0bb47ac1
3
+ metadata.gz: a82f321d71985caf479d40c9546bc6b0c216ba97670d200e775be3274cf9a35c
4
+ data.tar.gz: 3a80b0ad6db919d7968a2162214004240d152648ee2ac8c4c4eafe1119834c1c
5
5
  SHA512:
6
- metadata.gz: c1a79fa7e8825320b308f8a689b3b09763072ec8093c5fc1f43e4686dad3dd05b4d345ce8d62149b23865b5c215b90dcdd68b292ea4ccef26456e752a35aad5a
7
- data.tar.gz: 69517cf6f0d5a5c64c39416945f06bb31ccb6c5b1c0288d883005184c96e353d44a3f9479767783bd9aae856ee2157a6ffdde48ebdb6abbf23a5f4972fd8f3b0
6
+ metadata.gz: c3d19095f455bb32b649c4ab0bfc7ae50d2d29eae69d5b3a593d6dd556de9ba7c527eb4afe9ec8032638adec23f664d200bcfab75cd726f51be97492266fc1b0
7
+ data.tar.gz: 6ab99b207ef0399354c56d499d004cd287c22a56fd1648a5c2f948eace0050e00d13d12e3bb2ca38ba730edf2539b3843637383a8d3c8dc6424daa91f764164c
data/README.md CHANGED
@@ -117,7 +117,7 @@ end
117
117
 
118
118
  ## Internationalization (I18n)
119
119
 
120
- Active Storage Validations use I18n for errors messages. For this add there keys in your translation file:
120
+ Active Storage Validations uses I18n for error messages. For this, add these keys in your translation file:
121
121
 
122
122
  ```yml
123
123
  en:
@@ -137,19 +137,18 @@ en:
137
137
  dimension_height_less_than_or_equal_to: "height must be less than or equal to %{length} pixel."
138
138
  dimension_width_equal_to: "width must be equal to %{length} pixel."
139
139
  dimension_height_equal_to: "height must be equal to %{length} pixel."
140
- aspect_ratio_not_square: "doesn't a square image"
141
- aspect_ratio_not_portrait: "doesn't contain a portrait image"
142
- aspect_ratio_not_landscape: "doesn't contain a landscape image"
143
- aspect_ratio_is_not: "doesn't contain aspect ratio of %{aspect_ratio}"
140
+ aspect_ratio_not_square: "must be a square image"
141
+ aspect_ratio_not_portrait: "must be a portrait image"
142
+ aspect_ratio_not_landscape: "must be a landscape image"
143
+ aspect_ratio_is_not: "must have an aspect ratio of %{aspect_ratio}"
144
144
  aspect_ratio_unknown: "has an unknown aspect ratio"
145
-
146
145
  ```
147
146
 
148
- In some cases Active Storage Validations provides variables to help you customize messages:
147
+ In some cases, Active Storage Validations provides variables to help you customize messages:
149
148
 
150
- The "content_type_invalid" key has two variables that you can use, a variable named "content_type" containing the content type of the send file and a variable named "authorized_type" containing the list of authorized content types.
149
+ The "content_type_invalid" key has two variables that you can use, a variable named "content_type" containing the content type of the send file and a variable named "authorized_types" containing the list of authorized content types.
151
150
 
152
- It's variables are not used by default to leave the choice to the user.
151
+ The variables are not used by default to leave the choice to the user.
153
152
 
154
153
  For example :
155
154
 
@@ -194,7 +193,7 @@ Provides RSpec-compatible and Minitest-compatible matchers for testing the valid
194
193
 
195
194
  ### RSpec
196
195
 
197
- In spec_helper.rb, you'll need to require the matchers:
196
+ In `spec_helper.rb`, you'll need to require the matchers:
198
197
 
199
198
  ```ruby
200
199
  require 'active_storage_validations/matchers'
@@ -209,7 +208,7 @@ end
209
208
  ```
210
209
 
211
210
  Example (Note that the options are chainable):
212
-
211
+
213
212
  ```ruby
214
213
  describe User do
215
214
  it { is_expected.to validate_attached_of(:avatar) }
@@ -243,7 +242,7 @@ require 'active_storage_validations/matchers'
243
242
 
244
243
  And _extend_ the module:
245
244
 
246
- ```bash
245
+ ```ruby
247
246
  class ActiveSupport::TestCase
248
247
  extend ActiveStorageValidations::Matchers
249
248
  end
@@ -281,14 +280,13 @@ end
281
280
  * verify how it works with direct upload
282
281
  * better error message when content_size is invalid
283
282
  * add more translations
284
- * add aspect ratio validation
285
283
 
286
284
  ## Tests & Contributing
287
285
 
288
286
  To run tests in root folder of gem:
289
287
 
290
288
  * `BUNDLE_GEMFILE=gemfiles/rails_5_2.gemfile bundle exec rake test` to run for Rails 5.2
291
- * `BUNDLE_GEMFILE=gemfiles/rails_6.0.gemfile bundle exec rake test` to run for Rails 6.0
289
+ * `BUNDLE_GEMFILE=gemfiles/rails_6_0.gemfile bundle exec rake test` to run for Rails 6.0
292
290
 
293
291
  To play with app `cd test/dummy` and `rails s -b 0.0.0.0` (before `rails db:migrate`).
294
292
 
@@ -296,12 +294,13 @@ To play with app `cd test/dummy` and `rails s -b 0.0.0.0` (before `rails db:migr
296
294
 
297
295
  - There is an issue in Rails which it possible to get if you have added a validation and generating for example an image preview of attachments. It can be fixed with this:
298
296
 
299
- ```
297
+ ```erb
300
298
  <% if @user.avatar.attached? && @user.avatar.attachment.blob.present? && @user.avatar.attachment.blob.persisted? %>
301
299
  <%= image_tag @user.avatar %>
302
300
  <% end %>
303
301
  ```
304
- This is Rails issue. And according to commits it will be fixed in Rails 6.
302
+
303
+ This is a Rails issue, and is fixed in Rails 6.
305
304
 
306
305
  ## Contributing
307
306
  You are welcome to contribute.
@@ -327,6 +326,9 @@ You are welcome to contribute.
327
326
  - https://github.com/giovannibonetti
328
327
  - https://github.com/dlepage
329
328
  - https://github.com/StefSchenkelaars
329
+ - https://github.com/willnet
330
+ - https://github.com/mohanklein
331
+ - https://github.com/High5Apps
330
332
 
331
333
  ## License
332
334
 
@@ -0,0 +1,22 @@
1
+ ja:
2
+ errors:
3
+ messages:
4
+ content_type_invalid: "のContent Typeが不正です"
5
+ file_size_out_of_range: "の容量 %{file_size} が許容範囲外です"
6
+ limit_out_of_range: "の数が許容範囲外です"
7
+ image_metadata_missing: "は不正な画像です"
8
+ dimension_min_inclusion: "は %{width} x %{height} ピクセル以上の大きさにしてください"
9
+ dimension_max_inclusion: "は %{width} x %{height} ピクセル以下の大きさにしてください"
10
+ dimension_width_inclusion: "の横幅は %{min} ピクセル以上 %{max} ピクセル以下にしてください"
11
+ dimension_height_inclusion: "の縦幅は %{min} ピクセル以上 %{max} ピクセル以下にしてください"
12
+ dimension_width_greater_than_or_equal_to: "の横幅は %{length} ピクセル以上にしてください"
13
+ dimension_height_greater_than_or_equal_to: "の縦幅は %{length} ピクセル以上にしてください"
14
+ dimension_width_less_than_or_equal_to: "の横幅は %{length} ピクセル以下にしてください"
15
+ dimension_height_less_than_or_equal_to: "の縦幅は %{length} ピクセル以下にしてください"
16
+ dimension_width_equal_to: "の横幅は %{length} ピクセルにしてください"
17
+ dimension_height_equal_to: "の縦幅は %{length} ピクセルにしてください"
18
+ aspect_ratio_not_square: "は正方形にしてください"
19
+ aspect_ratio_not_portrait: "は縦長にしてください"
20
+ aspect_ratio_not_landscape: "は横長にしてください"
21
+ aspect_ratio_is_not: "のアスペクト比は %{aspect_ratio} にしてください"
22
+ aspect_ratio_unknown: "のアスペクト比を取得できませんでした"
@@ -19,11 +19,12 @@ module ActiveStorageValidations
19
19
  private
20
20
 
21
21
  def read_image
22
- if file.is_a?(String)
23
- blob = ActiveStorage::Blob.find_signed(file)
22
+ is_string = file.is_a?(String)
23
+ if is_string || file.is_a?(ActiveStorage::Blob)
24
+ blob = is_string ? ActiveStorage::Blob.find_signed(file) : file
24
25
 
25
26
  tempfile = Tempfile.new(["ActiveStorage-#{blob.id}-", blob.filename.extension_with_delimiter])
26
- tempfile.binmode
27
+ tempfile.binmode
27
28
 
28
29
  blob.download do |chunk|
29
30
  tempfile.write(chunk)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveStorageValidations
4
- VERSION = '0.8.7'
4
+ VERSION = '0.8.8'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_storage_validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.7
4
+ version: 0.8.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Kasyanchuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-27 00:00:00.000000000 Z
11
+ date: 2020-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -107,6 +107,7 @@ files:
107
107
  - config/locales/de.yml
108
108
  - config/locales/en.yml
109
109
  - config/locales/fr.yml
110
+ - config/locales/ja.yml
110
111
  - config/locales/pt-BR.yml
111
112
  - config/locales/ru.yml
112
113
  - config/locales/uk.yml