file_validators 2.3.0 → 3.0.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.
Files changed (37) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +32 -0
  3. data/.tool-versions +1 -0
  4. data/.travis.yml +36 -6
  5. data/Appraisals +8 -8
  6. data/CHANGELOG.md +20 -0
  7. data/Gemfile +2 -0
  8. data/README.md +21 -16
  9. data/Rakefile +3 -1
  10. data/file_validators.gemspec +12 -6
  11. data/gemfiles/activemodel_3.2.gemfile +0 -0
  12. data/gemfiles/activemodel_4.0.gemfile +0 -0
  13. data/gemfiles/activemodel_5.0.gemfile +0 -0
  14. data/gemfiles/{activemodel_4.1.gemfile → activemodel_6.0.gemfile} +1 -2
  15. data/gemfiles/{activemodel_4.2.gemfile → activemodel_6.1.gemfile} +1 -2
  16. data/lib/file_validators/error.rb +6 -0
  17. data/lib/file_validators/mime_type_analyzer.rb +106 -0
  18. data/lib/file_validators/validators/file_content_type_validator.rb +33 -42
  19. data/lib/file_validators/validators/file_size_validator.rb +43 -19
  20. data/lib/file_validators/version.rb +3 -1
  21. data/lib/file_validators.rb +6 -7
  22. data/spec/integration/combined_validators_integration_spec.rb +3 -1
  23. data/spec/integration/file_content_type_validation_integration_spec.rb +73 -17
  24. data/spec/integration/file_size_validator_integration_spec.rb +43 -16
  25. data/spec/lib/file_validators/mime_type_analyzer_spec.rb +139 -0
  26. data/spec/lib/file_validators/validators/file_content_type_validator_spec.rb +90 -32
  27. data/spec/lib/file_validators/validators/file_size_validator_spec.rb +78 -30
  28. data/spec/spec_helper.rb +4 -0
  29. data/spec/support/fakeio.rb +17 -0
  30. data/spec/support/helpers.rb +7 -0
  31. data/spec/support/matchers/allow_content_type.rb +2 -0
  32. data/spec/support/matchers/allow_file_size.rb +2 -0
  33. metadata +82 -23
  34. data/lib/file_validators/utils/content_type_detector.rb +0 -67
  35. data/lib/file_validators/utils/media_type_spoof_detector.rb +0 -46
  36. data/spec/lib/file_validators/utils/content_type_detector_spec.rb +0 -27
  37. data/spec/lib/file_validators/utils/media_type_spoof_detector_spec.rb +0 -31
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe ActiveModel::Validations::FileContentTypeValidator do
@@ -17,57 +19,85 @@ describe ActiveModel::Validations::FileContentTypeValidator do
17
19
  before { build_validator allow: 'image/jpg' }
18
20
  it { is_expected.to allow_file_content_type('image/jpg', @validator) }
19
21
  end
20
-
22
+
21
23
  context 'as an regexp' do
22
24
  before { build_validator allow: /^image\/.*/ }
23
25
  it { is_expected.to allow_file_content_type('image/png', @validator) }
24
26
  end
25
-
27
+
26
28
  context 'as a list' do
27
29
  before { build_validator allow: ['image/png', 'image/jpg', 'image/jpeg'] }
28
30
  it { is_expected.to allow_file_content_type('image/png', @validator) }
29
31
  end
30
32
 
31
33
  context 'as a proc' do
32
- before { build_validator allow: lambda { |record| ['image/png', 'image/jpg', 'image/jpeg'] } }
34
+ before { build_validator allow: ->(_record) { ['image/png', 'image/jpg', 'image/jpeg'] } }
33
35
  it { is_expected.to allow_file_content_type('image/png', @validator) }
34
36
  end
35
37
  end
36
-
38
+
37
39
  context 'with a disallowed type' do
38
40
  context 'as a string' do
39
41
  before { build_validator allow: 'image/png' }
40
42
  it { is_expected.not_to allow_file_content_type('image/jpeg', @validator) }
41
43
  end
42
-
44
+
43
45
  context 'as a regexp' do
44
46
  before { build_validator allow: /^text\/.*/ }
45
47
  it { is_expected.not_to allow_file_content_type('image/png', @validator) }
46
48
  end
47
49
 
48
50
  context 'as a proc' do
49
- before { build_validator allow: lambda { |record| /^text\/.*/ } }
51
+ before { build_validator allow: ->(_record) { /^text\/.*/ } }
50
52
  it { is_expected.not_to allow_file_content_type('image/png', @validator) }
51
53
  end
52
-
54
+
53
55
  context 'with :message option' do
54
56
  context 'without interpolation' do
55
- before { build_validator allow: 'image/png', message: 'should be a PNG image' }
56
- it { is_expected.not_to allow_file_content_type('image/jpeg', @validator, message: 'Avatar should be a PNG image') }
57
+ before do
58
+ build_validator allow: 'image/png',
59
+ message: 'should be a PNG image'
60
+ end
61
+
62
+ it do
63
+ is_expected.not_to allow_file_content_type(
64
+ 'image/jpeg', @validator,
65
+ message: 'Avatar should be a PNG image'
66
+ )
67
+ end
57
68
  end
58
-
69
+
59
70
  context 'with interpolation' do
60
- before { build_validator allow: 'image/png', message: 'should have content type %{types}' }
61
- it { is_expected.not_to allow_file_content_type('image/jpeg', @validator,
62
- message: 'Avatar should have content type image/png') }
63
- it { is_expected.to allow_file_content_type('image/png', @validator,
64
- message: 'Avatar should have content type image/png') }
71
+ before do
72
+ build_validator allow: 'image/png',
73
+ message: 'should have content type %{types}'
74
+ end
75
+
76
+ it do
77
+ is_expected.not_to allow_file_content_type(
78
+ 'image/jpeg', @validator,
79
+ message: 'Avatar should have content type image/png'
80
+ )
81
+ end
82
+
83
+ it do
84
+ is_expected.to allow_file_content_type(
85
+ 'image/png', @validator,
86
+ message: 'Avatar should have content type image/png'
87
+ )
88
+ end
65
89
  end
66
90
  end
67
91
 
68
92
  context 'default message' do
69
93
  before { build_validator allow: 'image/png' }
70
- it { is_expected.not_to allow_file_content_type('image/jpeg', @validator, message: 'Avatar file should be one of image/png') }
94
+
95
+ it do
96
+ is_expected.not_to allow_file_content_type(
97
+ 'image/jpeg', @validator,
98
+ message: 'Avatar file should be one of image/png'
99
+ )
100
+ end
71
101
  end
72
102
  end
73
103
  end
@@ -78,23 +108,23 @@ describe ActiveModel::Validations::FileContentTypeValidator do
78
108
  before { build_validator exclude: 'image/gif' }
79
109
  it { is_expected.to allow_file_content_type('image/png', @validator) }
80
110
  end
81
-
111
+
82
112
  context 'as an regexp' do
83
113
  before { build_validator exclude: /^text\/.*/ }
84
114
  it { is_expected.to allow_file_content_type('image/png', @validator) }
85
115
  end
86
-
116
+
87
117
  context 'as a list' do
88
118
  before { build_validator exclude: ['image/png', 'image/jpg', 'image/jpeg'] }
89
119
  it { is_expected.to allow_file_content_type('image/gif', @validator) }
90
120
  end
91
121
 
92
122
  context 'as a proc' do
93
- before { build_validator exclude: lambda { |record| ['image/png', 'image/jpg', 'image/jpeg'] } }
123
+ before { build_validator exclude: ->(_record) { ['image/png', 'image/jpg', 'image/jpeg'] } }
94
124
  it { is_expected.to allow_file_content_type('image/gif', @validator) }
95
125
  end
96
126
  end
97
-
127
+
98
128
  context 'with a disallowed type' do
99
129
  context 'as a string' do
100
130
  before { build_validator exclude: 'image/gif' }
@@ -107,28 +137,56 @@ describe ActiveModel::Validations::FileContentTypeValidator do
107
137
  end
108
138
 
109
139
  context 'as an proc' do
110
- before { build_validator exclude: lambda { |record| /^text\/.*/ } }
140
+ before { build_validator exclude: ->(_record) { /^text\/.*/ } }
111
141
  it { is_expected.not_to allow_file_content_type('text/plain', @validator) }
112
142
  end
113
-
143
+
114
144
  context 'with :message option' do
115
145
  context 'without interpolation' do
116
- before { build_validator exclude: 'image/png', message: 'should not be a PNG image' }
117
- it { is_expected.not_to allow_file_content_type('image/png', @validator, message: 'Avatar should not be a PNG image') }
146
+ before do
147
+ build_validator exclude: 'image/png',
148
+ message: 'should not be a PNG image'
149
+ end
150
+
151
+ it do
152
+ is_expected.not_to allow_file_content_type(
153
+ 'image/png', @validator,
154
+ message: 'Avatar should not be a PNG image'
155
+ )
156
+ end
118
157
  end
119
-
158
+
120
159
  context 'with interpolation' do
121
- before { build_validator exclude: 'image/png', message: 'should not have content type %{types}' }
122
- it { is_expected.not_to allow_file_content_type('image/png', @validator,
123
- message: 'Avatar should not have content type image/png') }
124
- it { is_expected.to allow_file_content_type('image/jpeg', @validator,
125
- message: 'Avatar should not have content type image/jpeg') }
160
+ before do
161
+ build_validator exclude: 'image/png',
162
+ message: 'should not have content type %{types}'
163
+ end
164
+
165
+ it do
166
+ is_expected.not_to allow_file_content_type(
167
+ 'image/png', @validator,
168
+ message: 'Avatar should not have content type image/png'
169
+ )
170
+ end
171
+
172
+ it do
173
+ is_expected.to allow_file_content_type(
174
+ 'image/jpeg', @validator,
175
+ message: 'Avatar should not have content type image/jpeg'
176
+ )
177
+ end
126
178
  end
127
179
  end
128
180
 
129
181
  context 'default message' do
130
182
  before { build_validator exclude: 'image/png' }
131
- it { is_expected.not_to allow_file_content_type('image/png', @validator, message: 'Avatar file cannot be image/png') }
183
+
184
+ it do
185
+ is_expected.not_to allow_file_content_type(
186
+ 'image/png', @validator,
187
+ message: 'Avatar file cannot be image/png'
188
+ )
189
+ end
132
190
  end
133
191
  end
134
192
  end
@@ -151,7 +209,7 @@ describe ActiveModel::Validations::FileContentTypeValidator do
151
209
  expect { build_validator argument => 'image/jpg' }.not_to raise_error
152
210
  expect { build_validator argument => ['image/jpg'] }.not_to raise_error
153
211
  expect { build_validator argument => /^image\/.*/ }.not_to raise_error
154
- expect { build_validator argument => lambda { |record| 'image/jpg' } }.not_to raise_error
212
+ expect { build_validator argument => ->(_record) { 'image/jpg' } }.not_to raise_error
155
213
  end
156
214
 
157
215
  it "raises argument error if :#{argument} is neither a string, array, regexp nor proc" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe ActiveModel::Validations::FileSizeValidator do
@@ -7,9 +9,9 @@ describe ActiveModel::Validations::FileSizeValidator do
7
9
 
8
10
  def storage_units
9
11
  if defined?(ActiveSupport::NumberHelper) # Rails 4.0+
10
- { 5120 => '5 KB', 10240 => '10 KB' }
12
+ { 5120 => '5 KB', 10_240 => '10 KB' }
11
13
  else
12
- { 5120 => '5120 Bytes', 10240 => '10240 Bytes' }
14
+ { 5120 => '5120 Bytes', 10_240 => '10240 Bytes' }
13
15
  end
14
16
  end
15
17
 
@@ -33,7 +35,7 @@ describe ActiveModel::Validations::FileSizeValidator do
33
35
  end
34
36
 
35
37
  context 'as a proc' do
36
- before { build_validator in: lambda { |record| (5.kilobytes..10.kilobytes) } }
38
+ before { build_validator in: ->(_record) { (5.kilobytes..10.kilobytes) } }
37
39
 
38
40
  it { is_expected.to allow_file_size(7.kilobytes, @validator) }
39
41
  it { is_expected.not_to allow_file_size(4.kilobytes, @validator) }
@@ -51,7 +53,7 @@ describe ActiveModel::Validations::FileSizeValidator do
51
53
  end
52
54
 
53
55
  context 'as a proc' do
54
- before { build_validator greater_than_or_equal_to: lambda { |record| 10.kilobytes } }
56
+ before { build_validator greater_than_or_equal_to: ->(_record) { 10.kilobytes } }
55
57
 
56
58
  it { is_expected.to allow_file_size(11.kilobytes, @validator) }
57
59
  it { is_expected.to allow_file_size(10.kilobytes, @validator) }
@@ -69,7 +71,7 @@ describe ActiveModel::Validations::FileSizeValidator do
69
71
  end
70
72
 
71
73
  context 'as a proc' do
72
- before { build_validator less_than_or_equal_to: lambda { |record| 10.kilobytes } }
74
+ before { build_validator less_than_or_equal_to: ->(_record) { 10.kilobytes } }
73
75
 
74
76
  it { is_expected.to allow_file_size(9.kilobytes, @validator) }
75
77
  it { is_expected.to allow_file_size(10.kilobytes, @validator) }
@@ -86,7 +88,7 @@ describe ActiveModel::Validations::FileSizeValidator do
86
88
  end
87
89
 
88
90
  context 'as a proc' do
89
- before { build_validator greater_than: lambda { |record| 10.kilobytes } }
91
+ before { build_validator greater_than: ->(_record) { 10.kilobytes } }
90
92
 
91
93
  it { is_expected.to allow_file_size(11.kilobytes, @validator) }
92
94
  it { is_expected.not_to allow_file_size(10.kilobytes, @validator) }
@@ -102,7 +104,7 @@ describe ActiveModel::Validations::FileSizeValidator do
102
104
  end
103
105
 
104
106
  context 'as a proc' do
105
- before { build_validator less_than: lambda { |record| 10.kilobytes } }
107
+ before { build_validator less_than: ->(_record) { 10.kilobytes } }
106
108
 
107
109
  it { is_expected.to allow_file_size(9.kilobytes, @validator) }
108
110
  it { is_expected.not_to allow_file_size(10.kilobytes, @validator) }
@@ -119,8 +121,10 @@ describe ActiveModel::Validations::FileSizeValidator do
119
121
  end
120
122
 
121
123
  context 'as a proc' do
122
- before { build_validator greater_than: lambda { |record| 5.kilobytes },
123
- less_than: lambda { |record| 10.kilobytes } }
124
+ before do
125
+ build_validator greater_than: ->(_record) { 5.kilobytes },
126
+ less_than: ->(_record) { 10.kilobytes }
127
+ end
124
128
 
125
129
  it { is_expected.to allow_file_size(7.kilobytes, @validator) }
126
130
  it { is_expected.not_to allow_file_size(5.kilobytes, @validator) }
@@ -129,42 +133,86 @@ describe ActiveModel::Validations::FileSizeValidator do
129
133
  end
130
134
 
131
135
  context 'with :message option' do
132
- before { build_validator in: (5.kilobytes..10.kilobytes),
133
- message: 'is invalid. (Between %{min} and %{max} please.)' }
136
+ before do
137
+ build_validator in: (5.kilobytes..10.kilobytes),
138
+ message: 'is invalid. (Between %{min} and %{max} please.)'
139
+ end
134
140
 
135
- it { is_expected.not_to allow_file_size(11.kilobytes, @validator,
136
- message: "Avatar is invalid. (Between #{@storage_units[5120]} and #{@storage_units[10240]} please.)") }
141
+ it do
142
+ is_expected.not_to allow_file_size(
143
+ 11.kilobytes, @validator,
144
+ message: "Avatar is invalid. (Between #{@storage_units[5120]}" \
145
+ " and #{@storage_units[10_240]} please.)"
146
+ )
147
+ end
137
148
 
138
- it { is_expected.to allow_file_size(7.kilobytes, @validator,
139
- message: "Avatar is invalid. (Between #{@storage_units[5120]} and #{@storage_units[10240]} please.)") }
149
+ it do
150
+ is_expected.to allow_file_size(
151
+ 7.kilobytes, @validator,
152
+ message: "Avatar is invalid. (Between #{@storage_units[5120]}" \
153
+ " and #{@storage_units[10_240]} please.)"
154
+ )
155
+ end
140
156
  end
141
157
 
142
158
  context 'default error message' do
143
159
  context 'given :in options' do
144
160
  before { build_validator in: 5.kilobytes..10.kilobytes }
145
161
 
146
- it { is_expected.not_to allow_file_size(11.kilobytes, @validator,
147
- message: "Avatar file size must be between #{@storage_units[5120]} and #{@storage_units[10240]}") }
148
- it { is_expected.not_to allow_file_size(4.kilobytes, @validator,
149
- message: "Avatar file size must be between #{@storage_units[5120]} and #{@storage_units[10240]}") }
162
+ it do
163
+ is_expected.not_to allow_file_size(
164
+ 11.kilobytes, @validator,
165
+ message: "Avatar file size must be between #{@storage_units[5120]}" \
166
+ " and #{@storage_units[10_240]}"
167
+ )
168
+ end
169
+
170
+ it do
171
+ is_expected.not_to allow_file_size(
172
+ 4.kilobytes, @validator,
173
+ message: "Avatar file size must be between #{@storage_units[5120]}" \
174
+ " and #{@storage_units[10_240]}"
175
+ )
176
+ end
150
177
  end
151
178
 
152
179
  context 'given :greater_than and :less_than options' do
153
180
  before { build_validator greater_than: 5.kilobytes, less_than: 10.kilobytes }
154
181
 
155
- it { is_expected.not_to allow_file_size(11.kilobytes, @validator,
156
- message: "Avatar file size must be less than #{@storage_units[10240]}") }
157
- it { is_expected.not_to allow_file_size(4.kilobytes, @validator,
158
- message: "Avatar file size must be greater than #{@storage_units[5120]}") }
182
+ it do
183
+ is_expected.not_to allow_file_size(
184
+ 11.kilobytes, @validator,
185
+ message: "Avatar file size must be less than #{@storage_units[10_240]}"
186
+ )
187
+ end
188
+
189
+ it do
190
+ is_expected.not_to allow_file_size(
191
+ 4.kilobytes, @validator,
192
+ message: "Avatar file size must be greater than #{@storage_units[5120]}"
193
+ )
194
+ end
159
195
  end
160
196
 
161
197
  context 'given :greater_than_or_equal_to and :less_than_or_equal_to options' do
162
- before { build_validator greater_than_or_equal_to: 5.kilobytes, less_than_or_equal_to: 10.kilobytes }
198
+ before do
199
+ build_validator greater_than_or_equal_to: 5.kilobytes,
200
+ less_than_or_equal_to: 10.kilobytes
201
+ end
163
202
 
164
- it { is_expected.not_to allow_file_size(11.kilobytes, @validator,
165
- message: "Avatar file size must be less than or equal to #{@storage_units[10240]}") }
166
- it { is_expected.not_to allow_file_size(4.kilobytes, @validator,
167
- message: "Avatar file size must be greater than or equal to #{@storage_units[5120]}") }
203
+ it do
204
+ is_expected.not_to allow_file_size(
205
+ 11.kilobytes, @validator,
206
+ message: "Avatar file size must be less than or equal to #{@storage_units[10_240]}"
207
+ )
208
+ end
209
+
210
+ it do
211
+ is_expected.not_to allow_file_size(
212
+ 4.kilobytes, @validator,
213
+ message: "Avatar file size must be greater than or equal to #{@storage_units[5120]}"
214
+ )
215
+ end
168
216
  end
169
217
  end
170
218
 
@@ -191,7 +239,7 @@ describe ActiveModel::Validations::FileSizeValidator do
191
239
  (described_class::CHECKS.keys - [:in]).each do |argument|
192
240
  it "does not raise argument error if :#{argument} is numeric or a proc" do
193
241
  expect { build_validator argument => 5.kilobytes }.not_to raise_error
194
- expect { build_validator argument => lambda { |record| 5.kilobytes } }.not_to raise_error
242
+ expect { build_validator argument => ->(_record) { 5.kilobytes } }.not_to raise_error
195
243
  end
196
244
 
197
245
  it "raises error if :#{argument} is neither a number nor a proc" do
@@ -201,7 +249,7 @@ describe ActiveModel::Validations::FileSizeValidator do
201
249
 
202
250
  it 'does not raise argument error if :in is a range or a proc' do
203
251
  expect { build_validator in: 5.kilobytes..10.kilobytes }.not_to raise_error
204
- expect { build_validator in: lambda { |record| 5.kilobytes..10.kilobytes } }.not_to raise_error
252
+ expect { build_validator in: ->(_record) { 5.kilobytes..10.kilobytes } }.not_to raise_error
205
253
  end
206
254
 
207
255
  it 'raises error if :in is neither a range nor a proc' do
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ENV['RAILS_ENV'] ||= 'test'
2
4
 
3
5
  require 'active_support'
@@ -16,6 +18,8 @@ I18n.enforce_available_locales = false
16
18
  Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
17
19
 
18
20
  RSpec.configure do |config|
21
+ config.include Helpers
22
+
19
23
  # Suppress stdout in the console
20
24
  config.before { allow($stdout).to receive(:write) }
21
25
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'forwardable'
4
+ require 'stringio'
5
+
6
+ class FakeIO
7
+ attr_reader :original_filename, :content_type
8
+
9
+ def initialize(content, filename: nil, content_type: nil)
10
+ @io = StringIO.new(content)
11
+ @original_filename = filename
12
+ @content_type = content_type
13
+ end
14
+
15
+ extend Forwardable
16
+ delegate %i[read rewind eof? close size] => :@io
17
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Helpers
4
+ def fakeio(content = 'file', **options)
5
+ FakeIO.new(content, **options)
6
+ end
7
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec::Matchers.define :allow_file_content_type do |content_type, validator, message|
2
4
  match do |model|
3
5
  value = double('file', path: content_type, original_filename: content_type)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec::Matchers.define :allow_file_size do |size, validator, message|
2
4
  match do |model|
3
5
  value = double('file', size: size)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: file_validators
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ahmad Musaffa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-12 00:00:00.000000000 Z
11
+ date: 2020-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -39,21 +39,21 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: cocaine
42
+ name: coveralls
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 0.5.4
47
+ version: '0'
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: 0.5.4
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rake
56
+ name: fastimage
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,21 +67,49 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rspec
70
+ name: marcel
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 3.5.0
75
+ version: '0.3'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 3.5.0
82
+ version: '0.3'
83
83
  - !ruby/object:Gem::Dependency
84
- name: coveralls
84
+ name: mimemagic
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 0.3.2
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 0.3.2
97
+ - !ruby/object:Gem::Dependency
98
+ name: mini_mime
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rack-test
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
115
  - - ">="
@@ -95,7 +123,7 @@ dependencies:
95
123
  - !ruby/object:Gem::Version
96
124
  version: '0'
97
125
  - !ruby/object:Gem::Dependency
98
- name: rack-test
126
+ name: rake
99
127
  requirement: !ruby/object:Gem::Requirement
100
128
  requirements:
101
129
  - - ">="
@@ -108,6 +136,34 @@ dependencies:
108
136
  - - ">="
109
137
  - !ruby/object:Gem::Version
110
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 3.5.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 3.5.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.58.2
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 0.58.2
111
167
  description: Adds file validators to ActiveModel
112
168
  email:
113
169
  - musaffa_csemm@yahoo.com
@@ -117,6 +173,8 @@ extra_rdoc_files: []
117
173
  files:
118
174
  - ".gitignore"
119
175
  - ".rspec"
176
+ - ".rubocop.yml"
177
+ - ".tool-versions"
120
178
  - ".travis.yml"
121
179
  - Appraisals
122
180
  - CHANGELOG.md
@@ -128,13 +186,13 @@ files:
128
186
  - file_validators.gemspec
129
187
  - gemfiles/activemodel_3.2.gemfile
130
188
  - gemfiles/activemodel_4.0.gemfile
131
- - gemfiles/activemodel_4.1.gemfile
132
- - gemfiles/activemodel_4.2.gemfile
133
189
  - gemfiles/activemodel_5.0.gemfile
190
+ - gemfiles/activemodel_6.0.gemfile
191
+ - gemfiles/activemodel_6.1.gemfile
134
192
  - lib/file_validators.rb
193
+ - lib/file_validators/error.rb
135
194
  - lib/file_validators/locale/en.yml
136
- - lib/file_validators/utils/content_type_detector.rb
137
- - lib/file_validators/utils/media_type_spoof_detector.rb
195
+ - lib/file_validators/mime_type_analyzer.rb
138
196
  - lib/file_validators/validators/file_content_type_validator.rb
139
197
  - lib/file_validators/validators/file_size_validator.rb
140
198
  - lib/file_validators/version.rb
@@ -146,12 +204,13 @@ files:
146
204
  - spec/integration/combined_validators_integration_spec.rb
147
205
  - spec/integration/file_content_type_validation_integration_spec.rb
148
206
  - spec/integration/file_size_validator_integration_spec.rb
149
- - spec/lib/file_validators/utils/content_type_detector_spec.rb
150
- - spec/lib/file_validators/utils/media_type_spoof_detector_spec.rb
207
+ - spec/lib/file_validators/mime_type_analyzer_spec.rb
151
208
  - spec/lib/file_validators/validators/file_content_type_validator_spec.rb
152
209
  - spec/lib/file_validators/validators/file_size_validator_spec.rb
153
210
  - spec/locale/en.yml
154
211
  - spec/spec_helper.rb
212
+ - spec/support/fakeio.rb
213
+ - spec/support/helpers.rb
155
214
  - spec/support/matchers/allow_content_type.rb
156
215
  - spec/support/matchers/allow_file_size.rb
157
216
  homepage: https://github.com/musaffa/file_validators
@@ -173,8 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
232
  - !ruby/object:Gem::Version
174
233
  version: '0'
175
234
  requirements: []
176
- rubyforge_project:
177
- rubygems_version: 2.5.1
235
+ rubygems_version: 3.1.2
178
236
  signing_key:
179
237
  specification_version: 4
180
238
  summary: ActiveModel file validators
@@ -187,11 +245,12 @@ test_files:
187
245
  - spec/integration/combined_validators_integration_spec.rb
188
246
  - spec/integration/file_content_type_validation_integration_spec.rb
189
247
  - spec/integration/file_size_validator_integration_spec.rb
190
- - spec/lib/file_validators/utils/content_type_detector_spec.rb
191
- - spec/lib/file_validators/utils/media_type_spoof_detector_spec.rb
248
+ - spec/lib/file_validators/mime_type_analyzer_spec.rb
192
249
  - spec/lib/file_validators/validators/file_content_type_validator_spec.rb
193
250
  - spec/lib/file_validators/validators/file_size_validator_spec.rb
194
251
  - spec/locale/en.yml
195
252
  - spec/spec_helper.rb
253
+ - spec/support/fakeio.rb
254
+ - spec/support/helpers.rb
196
255
  - spec/support/matchers/allow_content_type.rb
197
256
  - spec/support/matchers/allow_file_size.rb