activestorage-validator 0.3.0 → 0.5.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 +4 -4
- data/.github/workflows/rspec.yml +17 -3
- data/.gitignore +1 -0
- data/CHANGELOG.md +8 -0
- data/README.md +1 -1
- data/activestorage-validator.gemspec +2 -0
- data/gemfiles/rails61.gemfile +2 -1
- data/gemfiles/rails70.gemfile +2 -1
- data/gemfiles/rails71.gemfile +6 -0
- data/gemfiles/rails72.gemfile +6 -0
- data/gemfiles/rails80.gemfile +6 -0
- data/lib/activestorage/validator/blob.rb +5 -3
- data/lib/activestorage/validator/version.rb +1 -1
- data/lib/activestorage/validator.rb +0 -11
- metadata +7 -8
- data/.travis.yml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb2851d4b64cc39176ceaba155c80ac8989930899110e55f471c67df9d78a1bc
|
4
|
+
data.tar.gz: ea620cd996d2b50cf53e058fb43acc89652c5edaaa754de8f333855bab4f177e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9288e28946a1e1fb38691329eae86807c4d781116b2f64b389a6bc4e8b3c8e87c0cff3342c1bf716693126d84d64d553a0abddd2ae7a99e4fd28855f9940f0db
|
7
|
+
data.tar.gz: 6098588122be931263ae237cd6e486c1a975e446578502179f6b2064ed54ef1397431e3a23ce9aa1c086ecddc3fc49e42a2d402ed725472b57587ca8cc42d975
|
data/.github/workflows/rspec.yml
CHANGED
@@ -22,15 +22,29 @@ jobs:
|
|
22
22
|
strategy:
|
23
23
|
fail-fast: false
|
24
24
|
matrix:
|
25
|
-
|
26
|
-
|
25
|
+
include:
|
26
|
+
- { ruby: "3.0", gemfile: "rails61" }
|
27
|
+
- { ruby: "3.1", gemfile: "rails61" }
|
28
|
+
- { ruby: "3.2", gemfile: "rails61" }
|
29
|
+
- { ruby: "3.0", gemfile: "rails70" }
|
30
|
+
- { ruby: "3.1", gemfile: "rails70" }
|
31
|
+
- { ruby: "3.2", gemfile: "rails70" }
|
32
|
+
- { ruby: "3.0", gemfile: "rails71" }
|
33
|
+
- { ruby: "3.1", gemfile: "rails71" }
|
34
|
+
- { ruby: "3.2", gemfile: "rails71" }
|
35
|
+
- { ruby: "3.2", gemfile: "rails72" }
|
36
|
+
- { ruby: "3.3", gemfile: "rails72" }
|
37
|
+
- { ruby: "3.4", gemfile: "rails72" }
|
38
|
+
- { ruby: "3.2", gemfile: "rails80" }
|
39
|
+
- { ruby: "3.3", gemfile: "rails80" }
|
40
|
+
- { ruby: "3.4", gemfile: "rails80" }
|
27
41
|
steps:
|
28
42
|
- name: Install packages
|
29
43
|
run: |
|
30
44
|
sudo apt update -y
|
31
45
|
sudo apt install -y libsqlite3-dev
|
32
46
|
|
33
|
-
- uses: actions/checkout@
|
47
|
+
- uses: actions/checkout@v4
|
34
48
|
|
35
49
|
- name: Set up Ruby
|
36
50
|
uses: ruby/setup-ruby@v1
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
For changelogs from version 0.5.0 onwards, please see the [GitHub Releases page](https://github.com/aki77/activestorage-validator/releases).
|
4
|
+
|
1
5
|
## [Unreleased]
|
2
6
|
|
7
|
+
## 0.4.0
|
8
|
+
|
9
|
+
- Add `content_type: :web_image` options
|
10
|
+
|
3
11
|
## 0.3.0
|
4
12
|
|
5
13
|
- Drop support for rails 6.0
|
data/README.md
CHANGED
@@ -28,7 +28,7 @@ class User < ApplicationRecord
|
|
28
28
|
has_one_attached :avatar
|
29
29
|
has_many_attached :photos
|
30
30
|
|
31
|
-
validates :avatar, presence: true, blob: { content_type: :
|
31
|
+
validates :avatar, presence: true, blob: { content_type: :web_image } # supported options: :web_image, :image, :audio, :video, :text
|
32
32
|
validates :photos, presence: true, blob: { content_type: ['image/png', 'image/jpg', 'image/jpeg'], size_range: 1..(5.megabytes) }
|
33
33
|
# validates :photos, presence: true, blob: { content_type: %r{^image/}, size_range: 1..(5.megabytes) }
|
34
34
|
end
|
@@ -23,6 +23,8 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
|
26
|
+
spec.required_ruby_version = '>= 3.0.0'
|
27
|
+
|
26
28
|
spec.add_dependency "rails", ">= 6.1.0"
|
27
29
|
spec.add_development_dependency "bundler", "~> 2.0"
|
28
30
|
spec.add_development_dependency "rake", ">= 12.3.3"
|
data/gemfiles/rails61.gemfile
CHANGED
data/gemfiles/rails70.gemfile
CHANGED
@@ -7,14 +7,14 @@ module ActiveRecord
|
|
7
7
|
Array(values).each do |value|
|
8
8
|
if options[:size_range].present?
|
9
9
|
if options[:size_range].min > value.blob.byte_size
|
10
|
-
record.errors.add(attribute, :min_size_error, min_size: ActiveSupport::NumberHelper.number_to_human_size(options[:size_range].min))
|
10
|
+
record.errors.add(attribute, :min_size_error, min_size: ActiveSupport::NumberHelper.number_to_human_size(options[:size_range].min), filename: value.blob.filename.to_s)
|
11
11
|
elsif options[:size_range].max < value.blob.byte_size
|
12
|
-
record.errors.add(attribute, :max_size_error, max_size: ActiveSupport::NumberHelper.number_to_human_size(options[:size_range].max))
|
12
|
+
record.errors.add(attribute, :max_size_error, max_size: ActiveSupport::NumberHelper.number_to_human_size(options[:size_range].max), filename: value.blob.filename.to_s)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
unless valid_content_type?(value.blob)
|
17
|
-
record.errors.add(attribute, :content_type)
|
17
|
+
record.errors.add(attribute, :content_type, filename: value.blob.filename.to_s)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -29,6 +29,8 @@ module ActiveRecord
|
|
29
29
|
options[:content_type].match?(blob.content_type)
|
30
30
|
when Array
|
31
31
|
options[:content_type].include?(blob.content_type)
|
32
|
+
when :web_image
|
33
|
+
ActiveStorage.web_image_content_types.include?(blob.content_type)
|
32
34
|
when Symbol
|
33
35
|
blob.public_send("#{options[:content_type]}?")
|
34
36
|
else
|
@@ -4,15 +4,4 @@ ActiveSupport.on_load(:active_record) do
|
|
4
4
|
require 'activestorage/validator/blob'
|
5
5
|
end
|
6
6
|
|
7
|
-
module ActiveStorage
|
8
|
-
# https://github.com/rails/rails/commit/42259ce904eb2538761b32a793cbe390fb8272b7
|
9
|
-
if Rails::VERSION::MAJOR < 6
|
10
|
-
class Attached::One < Attached
|
11
|
-
def blank?
|
12
|
-
attachment.blank?
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
7
|
I18n.load_path += Dir[File.expand_path(File.join(__dir__, '../../config/locales', '*.yml')).to_s]
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activestorage-validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aki
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-06-15 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rails
|
@@ -91,7 +90,6 @@ files:
|
|
91
90
|
- ".github/workflows/rspec.yml"
|
92
91
|
- ".gitignore"
|
93
92
|
- ".rspec"
|
94
|
-
- ".travis.yml"
|
95
93
|
- CHANGELOG.md
|
96
94
|
- CODE_OF_CONDUCT.md
|
97
95
|
- Gemfile
|
@@ -111,6 +109,9 @@ files:
|
|
111
109
|
- config/locales/pt-br.yml
|
112
110
|
- gemfiles/rails61.gemfile
|
113
111
|
- gemfiles/rails70.gemfile
|
112
|
+
- gemfiles/rails71.gemfile
|
113
|
+
- gemfiles/rails72.gemfile
|
114
|
+
- gemfiles/rails80.gemfile
|
114
115
|
- lib/activestorage/validator.rb
|
115
116
|
- lib/activestorage/validator/blob.rb
|
116
117
|
- lib/activestorage/validator/version.rb
|
@@ -118,7 +119,6 @@ homepage: https://github.com/aki77/activestorage-validator
|
|
118
119
|
licenses:
|
119
120
|
- MIT
|
120
121
|
metadata: {}
|
121
|
-
post_install_message:
|
122
122
|
rdoc_options: []
|
123
123
|
require_paths:
|
124
124
|
- lib
|
@@ -126,15 +126,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
126
|
requirements:
|
127
127
|
- - ">="
|
128
128
|
- !ruby/object:Gem::Version
|
129
|
-
version:
|
129
|
+
version: 3.0.0
|
130
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
131
|
requirements:
|
132
132
|
- - ">="
|
133
133
|
- !ruby/object:Gem::Version
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
|
-
rubygems_version: 3.
|
137
|
-
signing_key:
|
136
|
+
rubygems_version: 3.6.2
|
138
137
|
specification_version: 4
|
139
138
|
summary: ActiveStorage blob validator.
|
140
139
|
test_files: []
|