activestorage-validator 0.1.0 → 0.1.4
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 +54 -0
- data/.gitignore +3 -0
- data/CHANGELOG.md +20 -0
- data/Gemfile +7 -1
- data/README.md +8 -2
- data/activestorage-validator.gemspec +5 -4
- data/config.ru +9 -0
- data/config/locales/de.yml +7 -0
- data/config/locales/en.yml +7 -0
- data/config/locales/ja.yml +7 -0
- data/config/locales/pt-br.yml +7 -0
- data/gemfiles/rails52.gemfile +6 -0
- data/gemfiles/rails60.gemfile +6 -0
- data/lib/activestorage/validator.rb +6 -1
- data/lib/activestorage/validator/blob.rb +1 -1
- data/lib/activestorage/validator/version.rb +2 -2
- metadata +33 -13
- data/Gemfile.lock +0 -144
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 354d8f902cefe6a58a25fcc97f6bcae8c878b971be3e6b9f7689e4074ba3eb7d
|
4
|
+
data.tar.gz: 626b6ba362b037531daa1402387f788506ecf5cb7592cb1fd6c0e05c8a43d079
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30f39dbfc6c3a21a74590042072468bea28d910790cfbb67c5777cf403a405af5576cb5a1c4ccb775d39a0ce30c8d33d2f39c35633b0632d86f51316b0506fab
|
7
|
+
data.tar.gz: 809232803f18f3fd3769591376439aa171c9aa4710ad923f1212a61fbefa0524377dc0d58077f6ff6064eb739cbf508b9922007272df3b291aad7c76214ff8aa
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Build
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
|
15
|
+
jobs:
|
16
|
+
rspec:
|
17
|
+
|
18
|
+
runs-on: ubuntu-latest
|
19
|
+
env:
|
20
|
+
BUNDLE_JOBS: 4
|
21
|
+
BUNDLE_RETRY: 3
|
22
|
+
strategy:
|
23
|
+
fail-fast: false
|
24
|
+
matrix:
|
25
|
+
ruby: [2.6, 2.7]
|
26
|
+
gemfile: [
|
27
|
+
"gemfiles/rails52.gemfile",
|
28
|
+
"gemfiles/rails60.gemfile",
|
29
|
+
]
|
30
|
+
steps:
|
31
|
+
- name: Install packages
|
32
|
+
run: |
|
33
|
+
sudo apt update -y
|
34
|
+
sudo apt install -y libsqlite3-dev
|
35
|
+
- uses: actions/checkout@v2
|
36
|
+
- uses: actions/cache@v1
|
37
|
+
with:
|
38
|
+
path: /home/runner/bundle
|
39
|
+
key: bundle-${{ matrix.ruby }}-${{ matrix.gemfile }}-${{ hashFiles(matrix.gemfile) }}-${{ hashFiles('**/*.gemspec') }}
|
40
|
+
restore-keys: |
|
41
|
+
bundle-${{ matrix.ruby }}-${{ matrix.gemfile }}-
|
42
|
+
- name: Set up Ruby
|
43
|
+
uses: ruby/setup-ruby@v1
|
44
|
+
with:
|
45
|
+
ruby-version: ${{ matrix.ruby }}
|
46
|
+
- name: Install dependencies
|
47
|
+
run: |
|
48
|
+
bundle config path /home/runner/bundle
|
49
|
+
bundle config --global gemfile ${{ matrix.gemfile }}
|
50
|
+
bundle install
|
51
|
+
bundle update
|
52
|
+
bundle clean
|
53
|
+
- name: Run rspec
|
54
|
+
run: bundle exec rspec
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
## [Unreleased]
|
2
|
+
|
3
|
+
## 0.1.4
|
4
|
+
|
5
|
+
- Updated test environment to rails 6.0.0
|
6
|
+
- Add pt-br locale (#22)
|
7
|
+
|
8
|
+
## 0.1.3
|
9
|
+
|
10
|
+
- Update dependency
|
11
|
+
- Add German locale
|
12
|
+
|
13
|
+
## 0.1.2
|
14
|
+
|
15
|
+
- Fix typo
|
16
|
+
|
17
|
+
## 0.1.1
|
18
|
+
|
19
|
+
- Add default error messages
|
20
|
+
|
1
21
|
## 0.1.0
|
2
22
|
|
3
23
|
- First Release
|
data/Gemfile
CHANGED
@@ -5,4 +5,10 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
|
5
5
|
# Specify your gem's dependencies in activestorage-validator.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
|
8
|
+
local_gemfile = "Gemfile.local"
|
9
|
+
|
10
|
+
if File.exist?(local_gemfile)
|
11
|
+
eval_gemfile(local_gemfile) # rubocop:disable Security/Eval
|
12
|
+
else
|
13
|
+
gem 'sqlite3'
|
14
|
+
end
|
data/README.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
[](https://rubygems.org/gems/activestorage-validator)
|
2
|
+
[](https://github.com/aki77/activestorage-validator/actions)
|
3
|
+
|
1
4
|
# ActiveStorage Validator
|
2
5
|
|
3
6
|
ActiveStorage blob validator.
|
@@ -25,11 +28,14 @@ class User < ApplicationRecord
|
|
25
28
|
has_one_attached :avatar
|
26
29
|
has_many_attached :photos
|
27
30
|
|
28
|
-
validates :avatar,
|
29
|
-
validates :photos,
|
31
|
+
validates :avatar, presence: true, blob: { content_type: :image } # supported options: :image, :audio, :video, :text
|
32
|
+
validates :photos, presence: true, blob: { content_type: ['image/png', 'image/jpg', 'image/jpeg'], size_range: 1..5.megabytes }
|
33
|
+
# validates :photos, presence: true, blob: { content_type: %r{^image/}, size_range: 1..5.megabytes }
|
30
34
|
end
|
31
35
|
```
|
32
36
|
|
37
|
+
Note: For `has_many_attached`, size is validated on each file individually. In the code above, `:photos` validation allows any number of photos to be upload, each one being 5 MB or less in size.
|
38
|
+
|
33
39
|
## Contributing
|
34
40
|
|
35
41
|
Bug reports and pull requests are welcome on GitHub at https://github.com/aki77/activestorage-validator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
@@ -5,7 +5,7 @@ require "activestorage/validator/version"
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "activestorage-validator"
|
8
|
-
spec.version =
|
8
|
+
spec.version = ActiveStorage::Validator::VERSION
|
9
9
|
spec.authors = ["aki"]
|
10
10
|
spec.email = ["aki77@users.noreply.github.com"]
|
11
11
|
|
@@ -23,8 +23,9 @@ 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.add_dependency "rails", "
|
27
|
-
spec.add_development_dependency "bundler", "~>
|
28
|
-
spec.add_development_dependency "rake", "
|
26
|
+
spec.add_dependency "rails", ">= 5.2.0"
|
27
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
28
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
29
29
|
spec.add_development_dependency "rspec", "~> 3.0"
|
30
|
+
spec.add_development_dependency "combustion"
|
30
31
|
end
|
data/config.ru
ADDED
@@ -1,6 +1,9 @@
|
|
1
|
-
require 'activestorage/validator/blob'
|
2
1
|
require 'activestorage/validator/version'
|
3
2
|
|
3
|
+
ActiveSupport.on_load(:active_record) do
|
4
|
+
require 'activestorage/validator/blob'
|
5
|
+
end
|
6
|
+
|
4
7
|
module ActiveStorage
|
5
8
|
# https://github.com/rails/rails/commit/42259ce904eb2538761b32a793cbe390fb8272b7
|
6
9
|
if Rails::VERSION::MAJOR < 6
|
@@ -11,3 +14,5 @@ module ActiveStorage
|
|
11
14
|
end
|
12
15
|
end
|
13
16
|
end
|
17
|
+
|
18
|
+
I18n.load_path += Dir[File.expand_path(File.join(__dir__, '../../config/locales', '*.yml')).to_s]
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activestorage-validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 5.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 5.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -30,28 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '2.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 12.3.3
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 12.3.3
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: combustion
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: ActiveStorage blob validator.
|
70
84
|
email:
|
71
85
|
- aki77@users.noreply.github.com
|
@@ -73,19 +87,26 @@ executables: []
|
|
73
87
|
extensions: []
|
74
88
|
extra_rdoc_files: []
|
75
89
|
files:
|
90
|
+
- ".github/workflows/rspec.yml"
|
76
91
|
- ".gitignore"
|
77
92
|
- ".rspec"
|
78
93
|
- ".travis.yml"
|
79
94
|
- CHANGELOG.md
|
80
95
|
- CODE_OF_CONDUCT.md
|
81
96
|
- Gemfile
|
82
|
-
- Gemfile.lock
|
83
97
|
- LICENSE.txt
|
84
98
|
- README.md
|
85
99
|
- Rakefile
|
86
100
|
- activestorage-validator.gemspec
|
87
101
|
- bin/console
|
88
102
|
- bin/setup
|
103
|
+
- config.ru
|
104
|
+
- config/locales/de.yml
|
105
|
+
- config/locales/en.yml
|
106
|
+
- config/locales/ja.yml
|
107
|
+
- config/locales/pt-br.yml
|
108
|
+
- gemfiles/rails52.gemfile
|
109
|
+
- gemfiles/rails60.gemfile
|
89
110
|
- lib/activestorage/validator.rb
|
90
111
|
- lib/activestorage/validator/blob.rb
|
91
112
|
- lib/activestorage/validator/version.rb
|
@@ -108,8 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
129
|
- !ruby/object:Gem::Version
|
109
130
|
version: '0'
|
110
131
|
requirements: []
|
111
|
-
|
112
|
-
rubygems_version: 2.7.6
|
132
|
+
rubygems_version: 3.1.2
|
113
133
|
signing_key:
|
114
134
|
specification_version: 4
|
115
135
|
summary: ActiveStorage blob validator.
|
data/Gemfile.lock
DELETED
@@ -1,144 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
activestorage-validator (0.1.0)
|
5
|
-
rails (~> 5.2.0)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
actioncable (5.2.1)
|
11
|
-
actionpack (= 5.2.1)
|
12
|
-
nio4r (~> 2.0)
|
13
|
-
websocket-driver (>= 0.6.1)
|
14
|
-
actionmailer (5.2.1)
|
15
|
-
actionpack (= 5.2.1)
|
16
|
-
actionview (= 5.2.1)
|
17
|
-
activejob (= 5.2.1)
|
18
|
-
mail (~> 2.5, >= 2.5.4)
|
19
|
-
rails-dom-testing (~> 2.0)
|
20
|
-
actionpack (5.2.1)
|
21
|
-
actionview (= 5.2.1)
|
22
|
-
activesupport (= 5.2.1)
|
23
|
-
rack (~> 2.0)
|
24
|
-
rack-test (>= 0.6.3)
|
25
|
-
rails-dom-testing (~> 2.0)
|
26
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
27
|
-
actionview (5.2.1)
|
28
|
-
activesupport (= 5.2.1)
|
29
|
-
builder (~> 3.1)
|
30
|
-
erubi (~> 1.4)
|
31
|
-
rails-dom-testing (~> 2.0)
|
32
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
33
|
-
activejob (5.2.1)
|
34
|
-
activesupport (= 5.2.1)
|
35
|
-
globalid (>= 0.3.6)
|
36
|
-
activemodel (5.2.1)
|
37
|
-
activesupport (= 5.2.1)
|
38
|
-
activerecord (5.2.1)
|
39
|
-
activemodel (= 5.2.1)
|
40
|
-
activesupport (= 5.2.1)
|
41
|
-
arel (>= 9.0)
|
42
|
-
activestorage (5.2.1)
|
43
|
-
actionpack (= 5.2.1)
|
44
|
-
activerecord (= 5.2.1)
|
45
|
-
marcel (~> 0.3.1)
|
46
|
-
activesupport (5.2.1)
|
47
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
48
|
-
i18n (>= 0.7, < 2)
|
49
|
-
minitest (~> 5.1)
|
50
|
-
tzinfo (~> 1.1)
|
51
|
-
arel (9.0.0)
|
52
|
-
builder (3.2.3)
|
53
|
-
concurrent-ruby (1.0.5)
|
54
|
-
crass (1.0.4)
|
55
|
-
diff-lcs (1.3)
|
56
|
-
erubi (1.7.1)
|
57
|
-
globalid (0.4.1)
|
58
|
-
activesupport (>= 4.2.0)
|
59
|
-
i18n (1.1.0)
|
60
|
-
concurrent-ruby (~> 1.0)
|
61
|
-
loofah (2.2.2)
|
62
|
-
crass (~> 1.0.2)
|
63
|
-
nokogiri (>= 1.5.9)
|
64
|
-
mail (2.7.0)
|
65
|
-
mini_mime (>= 0.1.1)
|
66
|
-
marcel (0.3.3)
|
67
|
-
mimemagic (~> 0.3.2)
|
68
|
-
method_source (0.9.0)
|
69
|
-
mimemagic (0.3.2)
|
70
|
-
mini_mime (1.0.1)
|
71
|
-
mini_portile2 (2.3.0)
|
72
|
-
minitest (5.11.3)
|
73
|
-
nio4r (2.3.1)
|
74
|
-
nokogiri (1.8.4)
|
75
|
-
mini_portile2 (~> 2.3.0)
|
76
|
-
rack (2.0.5)
|
77
|
-
rack-test (1.1.0)
|
78
|
-
rack (>= 1.0, < 3)
|
79
|
-
rails (5.2.1)
|
80
|
-
actioncable (= 5.2.1)
|
81
|
-
actionmailer (= 5.2.1)
|
82
|
-
actionpack (= 5.2.1)
|
83
|
-
actionview (= 5.2.1)
|
84
|
-
activejob (= 5.2.1)
|
85
|
-
activemodel (= 5.2.1)
|
86
|
-
activerecord (= 5.2.1)
|
87
|
-
activestorage (= 5.2.1)
|
88
|
-
activesupport (= 5.2.1)
|
89
|
-
bundler (>= 1.3.0)
|
90
|
-
railties (= 5.2.1)
|
91
|
-
sprockets-rails (>= 2.0.0)
|
92
|
-
rails-dom-testing (2.0.3)
|
93
|
-
activesupport (>= 4.2.0)
|
94
|
-
nokogiri (>= 1.6)
|
95
|
-
rails-html-sanitizer (1.0.4)
|
96
|
-
loofah (~> 2.2, >= 2.2.2)
|
97
|
-
railties (5.2.1)
|
98
|
-
actionpack (= 5.2.1)
|
99
|
-
activesupport (= 5.2.1)
|
100
|
-
method_source
|
101
|
-
rake (>= 0.8.7)
|
102
|
-
thor (>= 0.19.0, < 2.0)
|
103
|
-
rake (10.5.0)
|
104
|
-
rspec (3.8.0)
|
105
|
-
rspec-core (~> 3.8.0)
|
106
|
-
rspec-expectations (~> 3.8.0)
|
107
|
-
rspec-mocks (~> 3.8.0)
|
108
|
-
rspec-core (3.8.0)
|
109
|
-
rspec-support (~> 3.8.0)
|
110
|
-
rspec-expectations (3.8.1)
|
111
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
112
|
-
rspec-support (~> 3.8.0)
|
113
|
-
rspec-mocks (3.8.0)
|
114
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
115
|
-
rspec-support (~> 3.8.0)
|
116
|
-
rspec-support (3.8.0)
|
117
|
-
sprockets (3.7.2)
|
118
|
-
concurrent-ruby (~> 1.0)
|
119
|
-
rack (> 1, < 3)
|
120
|
-
sprockets-rails (3.2.1)
|
121
|
-
actionpack (>= 4.0)
|
122
|
-
activesupport (>= 4.0)
|
123
|
-
sprockets (>= 3.0.0)
|
124
|
-
sqlite3 (1.3.13)
|
125
|
-
thor (0.20.0)
|
126
|
-
thread_safe (0.3.6)
|
127
|
-
tzinfo (1.2.5)
|
128
|
-
thread_safe (~> 0.1)
|
129
|
-
websocket-driver (0.7.0)
|
130
|
-
websocket-extensions (>= 0.1.0)
|
131
|
-
websocket-extensions (0.1.3)
|
132
|
-
|
133
|
-
PLATFORMS
|
134
|
-
ruby
|
135
|
-
|
136
|
-
DEPENDENCIES
|
137
|
-
activestorage-validator!
|
138
|
-
bundler (~> 1.16)
|
139
|
-
rake (~> 10.0)
|
140
|
-
rspec (~> 3.0)
|
141
|
-
sqlite3
|
142
|
-
|
143
|
-
BUNDLED WITH
|
144
|
-
1.16.2
|