activemodel-csv_validator 0.1.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +22 -0
- data/CHANGELOG.md +11 -0
- data/README.md +1 -1
- data/activemodel-csv_validator.gemspec +3 -2
- data/config/locales/en.yml +1 -0
- data/config/locales/ja.yml +1 -0
- data/lib/activemodel/csv_validator/version.rb +1 -1
- data/lib/activemodel/validations/csv_validator.rb +7 -2
- metadata +9 -9
- data/.travis.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fd12e527341af3f693fe8e8212c684751c8e45fcb4de9d3069ee3a482df0445
|
4
|
+
data.tar.gz: 8533c6126319e1a956c9f5f4d9e84e00ad6e991e884ceca6b2d6a65c5d1f845a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f10ad1fb87c9378e8dcadbd46e85207073345871fed953793e53a4ed20ef1d0d0a8e687a86c23fcad8ddb25fd4a68d11e9f8ef2bce87d2aea90e374dfbbf1b52
|
7
|
+
data.tar.gz: ccd3dafafbdff4fed38a0fa6ff09fb9d3c68d8d8c1fa197a1636f12dba017f72d351b58b8d18ae0955681f9c503fcb038e22514791ed6c3200a103834e09ffd9
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
|
9
|
+
strategy:
|
10
|
+
fail-fast: false
|
11
|
+
matrix:
|
12
|
+
ruby: ["2.7", "3.0", "3.1", ruby-head, jruby-head]
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v3
|
16
|
+
- name: Set up Ruby
|
17
|
+
uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
bundler-cache: true # 'bundle install' and cache gems
|
20
|
+
ruby-version: ${{ matrix.ruby }}
|
21
|
+
- name: Run tests
|
22
|
+
run: bundle exec rake
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -22,8 +22,9 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
|
-
spec.
|
26
|
-
spec.add_dependency "
|
25
|
+
spec.required_ruby_version = '>= 2.7.0'
|
26
|
+
spec.add_dependency "activemodel", ">= 6.1.0"
|
27
|
+
spec.add_dependency "activesupport", ">= 6.1.0"
|
27
28
|
spec.add_development_dependency "bundler", "~> 2.0"
|
28
29
|
spec.add_development_dependency "rake", "~> 13.0"
|
29
30
|
spec.add_development_dependency "rspec", "~> 3.0"
|
data/config/locales/en.yml
CHANGED
data/config/locales/ja.yml
CHANGED
@@ -12,11 +12,16 @@ module ActiveModel
|
|
12
12
|
rows = CSV.parse(content, headers: :first_row, converters: :integer)
|
13
13
|
|
14
14
|
if options[:max].present? && rows.size > options[:max]
|
15
|
-
record.errors.add(attribute, :max_rows, options.slice(:max).merge(rows: rows.size))
|
15
|
+
record.errors.add(attribute, :max_rows, **options.slice(:max).merge(rows: rows.size))
|
16
|
+
end
|
17
|
+
|
18
|
+
if options[:min].present? && rows.size < options[:min]
|
19
|
+
record.errors.add(attribute, :min_rows, **options.slice(:min).merge(rows: rows.size))
|
16
20
|
end
|
17
21
|
|
18
22
|
if options[:headers].present?
|
19
|
-
|
23
|
+
headers = options[:headers].respond_to?(:call) ? options[:headers].call(record) : options[:headers]
|
24
|
+
missing_headers = headers - rows.headers
|
20
25
|
if missing_headers.present?
|
21
26
|
record.errors.add(attribute, :missing_headers, missing_headers: missing_headers.to_sentence)
|
22
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemodel-csv_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aki77
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 6.1.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
|
-
version:
|
26
|
+
version: 6.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 6.1.0
|
34
34
|
type: :runtime
|
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: 6.1.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,9 +87,9 @@ executables: []
|
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
|
+
- ".github/workflows/ci.yml"
|
90
91
|
- ".gitignore"
|
91
92
|
- ".rspec"
|
92
|
-
- ".travis.yml"
|
93
93
|
- CHANGELOG.md
|
94
94
|
- CODE_OF_CONDUCT.md
|
95
95
|
- Gemfile
|
@@ -116,14 +116,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
116
116
|
requirements:
|
117
117
|
- - ">="
|
118
118
|
- !ruby/object:Gem::Version
|
119
|
-
version:
|
119
|
+
version: 2.7.0
|
120
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
|
-
rubygems_version: 3.
|
126
|
+
rubygems_version: 3.1.2
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: CSV Validator for Active Model
|