Skip to content

Commit

Permalink
Merge branch 'master' into vips
Browse files Browse the repository at this point in the history
  • Loading branch information
NARKOZ committed Mar 5, 2022
2 parents 30e468c + 9a2714b commit e779c8d
Show file tree
Hide file tree
Showing 16 changed files with 329 additions and 126 deletions.
22 changes: 18 additions & 4 deletions .github/workflows/minitest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,36 @@ jobs:
- 2.5
- 2.6
- 2.7
- 3.0
- '3.0'
- 3.1
gemfile:
- rails_5_2
- rails_6_0
- rails_6_1
- rails_7_0
- rails_next
image_processor:
- vips
- mini_magick
exclude:
# ruby 3.1 only supports rails 7.0+
- ruby: 3.1
gemfile: rails_5_2
- ruby: 3.1
gemfile: rails_6_0
- ruby: 3.1
gemfile: rails_6_1
# ruby 3 only supports rails 6.1+
- ruby: 3.0
- ruby: '3.0'
gemfile: rails_5_2
- ruby: 3.0
- ruby: '3.0'
gemfile: rails_6_0
# rails 7 only supports ruby 2.7+
# rails 7.0 only supports ruby 2.7+
- ruby: 2.5
gemfile: rails_7_0
- ruby: 2.6
gemfile: rails_7_0
# rails next only supports ruby 2.7+
- ruby: 2.5
gemfile: rails_next
- ruby: 2.6
Expand Down
9 changes: 9 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
- master

- 0.9.7 (unreleased)
- tests for Rails 7 and Ruby 3.1 https://github.com/igorkasyanchuk/active_storage_validations/pull/143
- Fix pt-BR translations https://github.com/igorkasyanchuk/active_storage_validations/pull/132
- Remove references to image/jpg content type https://github.com/igorkasyanchuk/active_storage_validations/pull/144
- missing relationship in dummy app https://github.com/igorkasyanchuk/active_storage_validations/pull/142
- References Marcel::TYPES only for Rails < 6.1 https://github.com/igorkasyanchuk/active_storage_validations/pull/138
- better clarify how to define between size https://github.com/igorkasyanchuk/active_storage_validations/pull/133
-

- 0.9.6
- Add min_size and max_size to :file_size_out_of_range error message https://github.com/igorkasyanchuk/active_storage_validations/pull/134
- Reference Marcel::EXTENSIONS https://github.com/igorkasyanchuk/active_storage_validations/pull/137
Expand Down
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ PLATFORMS
DEPENDENCIES
active_storage_validations!
combustion (~> 1.3)
marcel
mini_magick (>= 4.9.5)
pry
rubocop
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ For example you have a model like this and you want to add validation.
class User < ApplicationRecord
has_one_attached :avatar
has_many_attached :photos
has_one_attached :image

validates :name, presence: true

validates :avatar, attached: true, content_type: 'image/png',
dimension: { width: 200, height: 200 }
validates :photos, attached: true, content_type: ['image/png', 'image/jpg', 'image/jpeg'],
validates :photos, attached: true, content_type: ['image/png', 'image/jpeg'],
dimension: { width: { min: 800, max: 2400 },
height: { min: 600, max: 1800 }, message: 'is not given between dimension' }
validates :image, attached: true,
content_type: ['image/png', 'image/jpg'],
content_type: ['image/png', 'image/jpeg'],
aspect_ratio: :landscape
end
```
Expand All @@ -44,13 +45,15 @@ or

```ruby
class Project < ApplicationRecord
has_one_attached :logo
has_one_attached :preview
has_one_attached :attachment
has_many_attached :documents

validates :title, presence: true

validates :preview, attached: true, size: { less_than: 100.megabytes , message: 'is not given between size' }
validates :logo, attached: true, size: { less_than: 100.megabytes , message: 'is too large' }
validates :preview, attached: true, size: { between: 1.kilobyte..100.megabytes , message: 'is not given between size' }
validates :attachment, attached: true, content_type: { in: 'application/pdf', message: 'is not a PDF' }
validates :documents, limit: { min: 1, max: 3 }
end
Expand Down Expand Up @@ -364,6 +367,11 @@ You are welcome to contribute.
- https://github.com/vietqhoang
- https://github.com/kemenaran
- https://github.com/jrmhaig
- https://github.com/tagliala
- https://github.com/evedovelli
- https://github.com/JuanVqz
- https://github.com/luiseugenio
- https://github.com/equivalent

## License

Expand Down
1 change: 1 addition & 0 deletions active_storage_validations.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ Gem::Specification.new do |s|
s.add_development_dependency 'pry'
s.add_development_dependency 'rubocop'
s.add_development_dependency 'sqlite3'
s.add_development_dependency 'marcel'
end
28 changes: 14 additions & 14 deletions config/locales/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ pt-BR:
errors:
messages:
content_type_invalid: "tem um tipo de arquivo inválido"
file_size_out_of_range: "tamanho %{file_size} está fora da faixa de tamanho válida"
limit_out_of_range: "número total está fora do limite"
file_size_out_of_range: "tem tamanho %{file_size} e está fora da faixa de tamanho válida"
limit_out_of_range: "o número total está fora do limite"
image_metadata_missing: "não é uma imagem válida"
dimension_min_inclusion: "deve ser maior ou igual a %{width} x %{height} pixel"
dimension_max_inclusion: "deve ser menor ou igual a %{width} x %{height} pixel"
dimension_width_inclusion: "largura não está entre %{min} e %{max} pixel"
dimension_height_inclusion: "altura não está entre %{min} e %{max} pixel"
dimension_width_greater_than_or_equal_to: "largura deve ser maior ou igual a %{length} pixel"
dimension_height_greater_than_or_equal_to: "altura deve ser maior ou igual a %{length} pixel"
dimension_width_less_than_or_equal_to: "largura deve ser menor ou igual a %{length} pixel"
dimension_height_less_than_or_equal_to: "altura deve ser menor ou igual a %{length} pixel"
dimension_width_equal_to: "largura deve ser igual a %{length} pixel"
dimension_height_equal_to: "altura deve ser igual a %{length} pixel"
dimension_min_inclusion: "deve ser maior ou igual a %{width} x %{height} pixels"
dimension_max_inclusion: "deve ser menor ou igual a %{width} x %{height} pixels"
dimension_width_inclusion: "deve ter largura entre %{min} e %{max} pixels"
dimension_height_inclusion: "deve ter altura entre %{min} e %{max} pixels"
dimension_width_greater_than_or_equal_to: "deve ter largura maior ou igual a %{length} pixels"
dimension_height_greater_than_or_equal_to: "deve ter altura maior ou igual a %{length} pixels"
dimension_width_less_than_or_equal_to: "deve ter largura menor ou igual a %{length} pixels"
dimension_height_less_than_or_equal_to: "deve ter altura menor ou igual a %{length} pixels"
dimension_width_equal_to: "deve ter largura igual a %{length} pixels"
dimension_height_equal_to: "deve ter altura igual a %{length} pixels"
aspect_ratio_not_square: "não é uma imagem quadrada"
aspect_ratio_not_portrait: "não contém uma imagem no formato retrato"
aspect_ratio_not_landscape: "não contém uma imagem no formato paisagem"
aspect_ratio_not_portrait: "não está no formato retrato"
aspect_ratio_not_landscape: "não está no formato paisagem"
aspect_ratio_is_not: "não contém uma proporção de %{aspect_ratio}"
aspect_ratio_unknown: "não tem uma proporção definida"
3 changes: 2 additions & 1 deletion gemfiles/rails_5_2.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
active_storage_validations (0.9.6)
active_storage_validations (0.9.7)
activejob (>= 5.2.0)
activemodel (>= 5.2.0)
activestorage (>= 5.2.0)
Expand Down Expand Up @@ -134,6 +134,7 @@ DEPENDENCIES
activestorage (~> 5.2)
activesupport (~> 5.2)
combustion (~> 1.3)
marcel
mini_magick (>= 4.9.5)
pry
rubocop
Expand Down
3 changes: 2 additions & 1 deletion gemfiles/rails_6_0.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
active_storage_validations (0.9.6)
active_storage_validations (0.9.7)
activejob (>= 5.2.0)
activemodel (>= 5.2.0)
activestorage (>= 5.2.0)
Expand Down Expand Up @@ -135,6 +135,7 @@ DEPENDENCIES
activestorage (~> 6.0.0)
activesupport (~> 6.0.0)
combustion (~> 1.3)
marcel
mini_magick (>= 4.9.5)
pry
rubocop
Expand Down
3 changes: 2 additions & 1 deletion gemfiles/rails_6_1.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ..
specs:
active_storage_validations (0.9.6)
active_storage_validations (0.9.7)
activejob (>= 5.2.0)
activemodel (>= 5.2.0)
activestorage (>= 5.2.0)
Expand Down Expand Up @@ -136,6 +136,7 @@ DEPENDENCIES
activestorage (~> 6.1.0)
activesupport (~> 6.1.0)
combustion (~> 1.3)
marcel
mini_magick (>= 4.9.5)
pry
rubocop
Expand Down
5 changes: 5 additions & 0 deletions gemfiles/rails_7_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source 'https://rubygems.org'

%w[activejob activemodel activestorage activesupport].each { |rails_subcomponent| gem rails_subcomponent, '~> 7.0.0' }

gemspec :path => '../'
133 changes: 133 additions & 0 deletions gemfiles/rails_7_0.gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
PATH
remote: ..
specs:
active_storage_validations (0.9.6)
activejob (>= 5.2.0)
activemodel (>= 5.2.0)
activestorage (>= 5.2.0)
activesupport (>= 5.2.0)

GEM
remote: https://rubygems.org/
specs:
actionpack (7.0.2.2)
actionview (= 7.0.2.2)
activesupport (= 7.0.2.2)
rack (~> 2.0, >= 2.2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actionview (7.0.2.2)
activesupport (= 7.0.2.2)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (7.0.2.2)
activesupport (= 7.0.2.2)
globalid (>= 0.3.6)
activemodel (7.0.2.2)
activesupport (= 7.0.2.2)
activerecord (7.0.2.2)
activemodel (= 7.0.2.2)
activesupport (= 7.0.2.2)
activestorage (7.0.2.2)
actionpack (= 7.0.2.2)
activejob (= 7.0.2.2)
activerecord (= 7.0.2.2)
activesupport (= 7.0.2.2)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (7.0.2.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
ast (2.4.2)
builder (3.2.4)
coderay (1.1.3)
combustion (1.3.5)
activesupport (>= 3.0.0)
railties (>= 3.0.0)
thor (>= 0.14.6)
concurrent-ruby (1.1.9)
crass (1.0.6)
erubi (1.10.0)
globalid (1.0.0)
activesupport (>= 5.0)
i18n (1.10.0)
concurrent-ruby (~> 1.0)
loofah (2.14.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
marcel (1.0.2)
method_source (1.0.0)
mini_magick (4.11.0)
mini_mime (1.1.2)
mini_portile2 (2.8.0)
minitest (5.15.0)
nokogiri (1.13.3)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
parallel (1.21.0)
parser (3.1.1.0)
ast (~> 2.4.1)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
racc (1.6.0)
rack (2.2.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.2)
loofah (~> 2.3)
railties (7.0.2.2)
actionpack (= 7.0.2.2)
activesupport (= 7.0.2.2)
method_source
rake (>= 12.2)
thor (~> 1.0)
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.2.1)
rexml (3.2.5)
rubocop (1.25.1)
parallel (~> 1.10)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.15.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.16.0)
parser (>= 3.1.1.0)
ruby-progressbar (1.11.0)
sqlite3 (1.4.2)
thor (1.2.1)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unicode-display_width (2.1.0)
zeitwerk (2.5.4)

PLATFORMS
ruby

DEPENDENCIES
active_storage_validations!
activejob (~> 7.0.0)
activemodel (~> 7.0.0)
activestorage (~> 7.0.0)
activesupport (~> 7.0.0)
combustion (~> 1.3)
mini_magick (>= 4.9.5)
pry
rubocop
sqlite3

BUNDLED WITH
2.3.6
Loading

0 comments on commit e779c8d

Please sign in to comment.