validates_timeliness 3.0.15 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +5 -5
  2. data/.github/dependabot.yml +7 -0
  3. data/.github/workflows/ci.yml +36 -0
  4. data/CHANGELOG.md +337 -0
  5. data/LICENSE +1 -1
  6. data/README.md +319 -0
  7. data/Rakefile +0 -10
  8. data/gemfiles/rails_6_0.gemfile +13 -0
  9. data/gemfiles/rails_6_1.gemfile +14 -0
  10. data/gemfiles/rails_edge.gemfile +13 -0
  11. data/lib/generators/validates_timeliness/templates/validates_timeliness.rb +2 -2
  12. data/lib/validates_timeliness/attribute_methods.rb +35 -78
  13. data/lib/validates_timeliness/{conversion.rb → converter.rb} +28 -14
  14. data/lib/validates_timeliness/extensions/date_time_select.rb +23 -34
  15. data/lib/validates_timeliness/extensions/multiparameter_handler.rb +38 -63
  16. data/lib/validates_timeliness/extensions.rb +3 -4
  17. data/lib/validates_timeliness/helper_methods.rb +8 -2
  18. data/lib/validates_timeliness/orm/active_model.rb +71 -0
  19. data/lib/validates_timeliness/orm/active_record.rb +3 -39
  20. data/lib/validates_timeliness/railtie.rb +8 -0
  21. data/lib/validates_timeliness/validator.rb +28 -17
  22. data/lib/validates_timeliness/version.rb +1 -1
  23. data/lib/validates_timeliness.rb +4 -4
  24. data/spec/spec_helper.rb +13 -11
  25. data/spec/support/model_helpers.rb +5 -6
  26. data/spec/support/tag_matcher.rb +35 -0
  27. data/spec/support/test_model.rb +6 -5
  28. data/spec/validates_timeliness/attribute_methods_spec.rb +8 -25
  29. data/spec/validates_timeliness/converter_spec.rb +247 -0
  30. data/spec/validates_timeliness/extensions/date_time_select_spec.rb +37 -34
  31. data/spec/validates_timeliness/extensions/multiparameter_handler_spec.rb +12 -13
  32. data/spec/validates_timeliness/helper_methods_spec.rb +9 -11
  33. data/spec/validates_timeliness/orm/active_record_spec.rb +85 -139
  34. data/spec/validates_timeliness/railtie_spec.rb +22 -0
  35. data/spec/validates_timeliness/validator/after_spec.rb +4 -6
  36. data/spec/validates_timeliness/validator/before_spec.rb +4 -6
  37. data/spec/validates_timeliness/validator/is_at_spec.rb +9 -7
  38. data/spec/validates_timeliness/validator/on_or_after_spec.rb +4 -6
  39. data/spec/validates_timeliness/validator/on_or_before_spec.rb +4 -6
  40. data/spec/validates_timeliness/validator_spec.rb +45 -29
  41. data/spec/validates_timeliness_spec.rb +9 -11
  42. data/validates_timeliness.gemspec +16 -4
  43. metadata +61 -31
  44. data/CHANGELOG.rdoc +0 -188
  45. data/README.rdoc +0 -299
  46. data/gemfiles/mongoid_2_1.gemfile +0 -16
  47. data/gemfiles/mongoid_2_2.gemfile +0 -16
  48. data/gemfiles/mongoid_2_3.gemfile +0 -16
  49. data/gemfiles/mongoid_2_4.gemfile +0 -16
  50. data/gemfiles/rails_3_0.gemfile +0 -15
  51. data/gemfiles/rails_3_1.gemfile +0 -15
  52. data/gemfiles/rails_3_2.gemfile +0 -15
  53. data/lib/validates_timeliness/orm/mongoid.rb +0 -49
  54. data/spec/validates_timeliness/conversion_spec.rb +0 -234
  55. data/spec/validates_timeliness/orm/mongoid_spec.rb +0 -223
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a60055680e49760bf31b2a820e30d35c125701e5
4
- data.tar.gz: 846e163f120d01337b2e55356cc1a01fca513ea7
2
+ SHA256:
3
+ metadata.gz: a1b8043b997be8d2c2c20462ad6ff2569c36f361e831648e62afcdccfb34a9a9
4
+ data.tar.gz: 4fd9cdea497d79b06469b973669f961aca84fb876c0fdbc00b66d5eb0006f62d
5
5
  SHA512:
6
- metadata.gz: 46b5e4bfba055d99c8e6ba8dc3e122bc8e3dc872efb35ee957802f7b3f827b92ec5efd19d64f2054f2597656b91409432a7dcc731b48090cd91603e6323e5fb4
7
- data.tar.gz: 93ed8ea91b878022a29aee4c5ad0b0586e4c1cff6cc531168c7bfe2aab4e8a232b26c4dfe683bdc99c7d3897dc97b4d91f2c4af0d5e4dffdf90f6362aea3f581
6
+ metadata.gz: 103153fbfef87bbf3dabb2ec3bf1fe8c9178ad45dfda1d90948ca21802c40a7a70c41089e85bb717ed5f9861c163ce67058d9016c6e68e0aaa1bac4684e96971
7
+ data.tar.gz: de9ba7e8bb62fe6ccffb5e9e2507ec11fcbf8b30403ebf1c1d0e91ac25d1aa5377f2147d5b508ef0a2ce23ad71ce3ce440ce3282c011abeb7f1a47b3f63b9b17
@@ -0,0 +1,7 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: weekly
7
+ open-pull-requests-limit: 10
@@ -0,0 +1,36 @@
1
+ name: CI
2
+ on: [push, pull_request]
3
+ jobs:
4
+ tests:
5
+ runs-on: ubuntu-latest
6
+ strategy:
7
+ fail-fast: false
8
+ matrix:
9
+ include:
10
+ - gemfile: rails_6_0
11
+ ruby: 2.6
12
+ - gemfile: rails_6_0
13
+ ruby: 2.7
14
+ - gemfile: rails_6_0
15
+ ruby: 3.0
16
+ - gemfile: rails_6_1
17
+ ruby: 2.6
18
+ - gemfile: rails_6_1
19
+ ruby: 2.7
20
+ - gemfile: rails_6_1
21
+ ruby: 3.0
22
+
23
+ name: ${{ matrix.gemfile }}, ruby ${{ matrix.ruby }}
24
+ env:
25
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
26
+ steps:
27
+ - uses: actions/checkout@v2
28
+
29
+ - name: Set up Ruby
30
+ uses: ruby/setup-ruby@v1
31
+ with:
32
+ ruby-version: ${{ matrix.ruby }}
33
+ bundler-cache: true
34
+
35
+ - name: Run specs
36
+ run: bundle exec rspec
data/CHANGELOG.md ADDED
@@ -0,0 +1,337 @@
1
+ # 5.0.0 [2021-04-03]
2
+ * Fix DateTimeSelect extension support (AquisTech)
3
+ * Relaxed Timeliness dependency version which allows for >= 0.4.0 with
4
+ threadsafety fix for use_us_formats and use_euro_formats for hot switching
5
+
6
+ in a request.
7
+ * Add initializer to ensure Timeliness v0.4+ ambiguous date config is set
8
+ correctly when using `use_euro_formats` or `remove_use_formats'.
9
+ * Add Ruby 3 compatibility
10
+ * Add Rails 6.1 compatibility
11
+
12
+
13
+ Breaking Changes
14
+ * Update Multiparameter extension to use ActiveRecord type classes with
15
+ multiparameter handling which stores a hash of multiparamter values as the
16
+ value before type cast, no longer a mushed datetime string
17
+ * Removed all custom plugin attribute methods and method overrides in favour
18
+ using ActiveModel type system
19
+
20
+
21
+ # 4.1.0 [2019-06-11]
22
+ * Relaxed Timeliness dependency version to >= 0.3.10 and < 1, which allows
23
+ version 0.4 with threadsafety fix for use_us_formats and use_euro_formats
24
+ hot switching in a request.
25
+
26
+
27
+ # 4.0.2 [2016-01-07]
28
+ * Fix undefine_generated_methods ivar guard setting to false
29
+
30
+
31
+ # 4.0.1 [2016-01-06]
32
+ * Fix undefine_generated_methods thread locking bug
33
+ * Created an ActiveModel ORM, for manual require if using without any full
34
+ blown ORM
35
+
36
+
37
+ # 4.0.0 [2015-12-29]
38
+ * Extracted mongoid support into
39
+ https://github.com/adzap/validates_timeliness-mongoid which is broken (not
40
+ supported anymore).
41
+ * Fixed Rails 4.0, 4.1 and 4.2 compatability issues
42
+ * Upgrade specs to RSpec 3
43
+ * Added travis config
44
+ * Huge thanks to @johncarney for keeping it alive with his fork
45
+ (https://github.com/johncarney/validates_timeliness)
46
+
47
+
48
+ # 3.0.15 [2015-12-29]
49
+ * Fixes mongoid 3 support and removes mongoid 2 support(johnnyshields)
50
+ * Some documentation/comments tidying
51
+ * Some general tidying up
52
+
53
+
54
+ # 3.0.14 [2012-08-23]
55
+ * Fix for using validates :timeliness => {} form to correctly add attributes
56
+ to timeliness validated attributes.
57
+
58
+
59
+ # 3.0.13 [2012-08-21]
60
+ * Fix ActiveRecord issues with using plugin parser by using old way of
61
+ caching values.
62
+ * Allow any ActiveRecord non-column attribute to be validated
63
+
64
+
65
+ # 3.0.12 [2012-06-23]
66
+ * Fix load order issue when relying on Railtie to load ActiveRecord
67
+ extension
68
+
69
+
70
+ # 3.0.11 [2012-04-01]
71
+ * Change dependency on Timeliness version due to a broken release
72
+
73
+
74
+ # 3.0.10 [2012-03-26]
75
+ * Fix for ActiveRecord shim and validation with :allow_blank => true in AR
76
+ 3.1+. Fixes issue#52.
77
+
78
+
79
+ # 3.0.9 [2012-03-26]
80
+ * ActiveRecord 3.1+ suport
81
+ * Fixes for multiparameter extension with empty date values (thanks @mogox,
82
+ @Sharagoz)
83
+
84
+
85
+ # 3.0.8 [2011-12-24]
86
+ * Remove deprecated InstanceMethods module when using AS::Concern
87
+ (carlosantoniodasilva)
88
+ * Update Mongoid shim for v2.3 compatability.
89
+
90
+
91
+ # 3.0.7 [2011-09-21]
92
+ * Fix ActiveRecord before_type_cast extension for non-dirty attributes.
93
+ * Don't override AR before_type_cast for >= 3.1.0 which now has it's own
94
+ implementation for date/time attributes.
95
+ * Fix DateTimeSelect extension to convert params to integers (#45)
96
+ * Add #change method to DateTimeSelect extension (@trusche, #45)
97
+ * Cleanup Mongoid shim.
98
+
99
+
100
+ # 3.0.6 [2011-05-09]
101
+ * Fix for AR type conversion for date columns when using plugin parser.
102
+ * Add timeliness_type_cast_code for ORM specific type casting after parsing.
103
+
104
+
105
+ # 3.0.5 [2011-01-29]
106
+ * Fix for Conversion#parse when given nil value (closes issue #34)
107
+
108
+
109
+ # 3.0.4 [2011-01-22]
110
+ * Fix :between option which was being ignored (ebeigarts)
111
+ * Use class_attribute to remove deprecated class_inheritable_accessor
112
+ * Namespace copied validator class to ActiveModel::Validations::Timeliness
113
+ for :timeliness option
114
+
115
+
116
+ # 3.0.3 [2010-12-11]
117
+ * Fix validation of values which don't respond to to_date or to_time
118
+ (renatoelias)
119
+
120
+
121
+ # 3.0.2 [2010-12-04]
122
+ * Fix AR multiparameter extension for Date columns
123
+ * Update to Timeliness 0.3.2 for zone abbreviation and offset support
124
+
125
+
126
+ # 3.0.1 [2010-11-02]
127
+ * Generate timeliness write methods in an included module to allow
128
+ overriding in model class (josevalim)
129
+
130
+
131
+ # 3.0.0 [2010-10-18]
132
+ * Rails 3 and ActiveModel compatibility
133
+ * Uses ActiveModel::EachValidator as validator base class.
134
+ * Configuration settings stored in ValidatesTimeliness module only.
135
+ ValidatesTimeliness.setup block to configure.
136
+ * Parser extracted to the Timeliness gem http://github.com/adzap/timeliness
137
+ * Parser is disabled by default. See initializer for enabling it.
138
+ * Removed RSpec matcher. Encouraged poor specs by copy-pasting from spec to
139
+ model, or worse, the other way round.
140
+ * Method override for parsing and before type cast values is on validated
141
+ attributes only. Old version handled all date/datetime columns, validates
142
+ or not. Too intrusive.
143
+ * Add validation helpers to classes using extend_orms config setting. e.g.
144
+ conf.extend_orms = [ :active_record ]
145
+ * Changed :between option so it is split into :on_or_after and :on_or_before
146
+ option values. The error message for either failing check will be used
147
+ instead of a between error message.
148
+ * Provides :timeliness option key for validates class method. Be sure to
149
+ pass :type option as well e.g. :type => :date.
150
+ * Allows validation methods to be called on record instances as per
151
+ ActiveModel API.
152
+ * Performs parsing (optional) and raw value caching (before_type_cast) on
153
+ validated attributes only. It used to be all date, time and datetime
154
+ attributes.
155
+
156
+
157
+ # 2.3.1 [2010-03-19]
158
+ * Fixed bug where custom attribute writer method for date/times were being
159
+ overriden
160
+
161
+
162
+ # 2.3.0 [2010-02-04]
163
+ * Backwards incompatible change to :equal_to option. Fixed error message
164
+ clash with :equal_to option which exists in Rails already. Option is now
165
+ :is_at.
166
+ * Fixed I18n support so it returns missing translation message instead of
167
+ error
168
+ * Fixed attribute method bug. Write method was bypassed when method was
169
+ first generated and used Rails default parser.
170
+ * Fixed date/time selects when using enable_datetime_select_extension! when
171
+ some values empty
172
+ * Fixed ISO8601 datetime format which is now split into two formats
173
+ * Changed I18n error value format to fallback to global default if missing
174
+ in locale
175
+ * Refactored date/time select invalid value extension to use param values.
176
+ Functionality will be extracted from plugin for v3.
177
+
178
+
179
+ # 2.2.2 [2009-09-19]
180
+ * Fixed dummy_time using make_time to respect timezone. Fixes 1.9.1 bug.
181
+
182
+
183
+ # 2.2.1 [2009-09-12]
184
+ * Fixed dummy date part for time types in Validator.type_cast_value
185
+ * No more core extensions! Removed dummy_time methods.
186
+
187
+
188
+ # 2.2.0 [2009-09-12]
189
+ * Ruby 1.9 support!
190
+ * Customise dummy date values for time types. See DUMMY DATE FOR TIME TYPES.
191
+ * Fixed matcher conflict with Shoulda. Load plugin matcher manually now see
192
+ matcher section in README
193
+ * Fixed :ignore_usec when used with :with_time or :with_date
194
+ * Some clean up and refactoring
195
+
196
+
197
+ # 2.1.0 [2009-06-20]
198
+ * Added ambiguous year threshold setting in Formats class to customize the
199
+ threshold for 2 digit years (See README)
200
+ * Fixed interpolation values in custom error message for Rails 2.2+
201
+ * Fixed custom I18n local override of en locale
202
+ * Dramatically simplified ActiveRecord monkey patching and hackery
203
+
204
+
205
+ # 2.0.0 [2009-04-12]
206
+ * Error value formats are now specified in the i18n locale file instead of
207
+ updating plugin hash. See OTHER CUSTOMISATION section in README.
208
+ * Date/time select helper extension is disabled by default. To enable see
209
+ DISPLAY INVALID VALUES IN DATE HELPERS section in README to enable.
210
+ * Added :format option to limit validation to a single format if desired
211
+ * Matcher now supports :equal_to option
212
+ * Formats.parse can take :include_offset option to include offset value from
213
+ string in seconds, if string contains an offset. Offset not used in rest
214
+ of plugin yet.
215
+ * Refactored to remove as much plugin code from ActiveRecord as possible.
216
+
217
+
218
+ # 1.1.7 [2009-03-26]
219
+ * Minor change to multiparameter attributes which I had not properly
220
+ implemented for chaining
221
+
222
+
223
+ # 1.1.6 [2009-03-19]
224
+ * Rail 2.3 support
225
+ * Added :with_date and :with_time options. They allow an attribute to be
226
+ combined with another attribute or value to make a datetime value for
227
+ validation against the temporal restrictions
228
+ * Added :equal_to option
229
+ * Option key validation
230
+ * Better behaviour with other plugins using alias_method_chain on
231
+ read_attribute and define_attribute_methods
232
+ * Added option to enable datetime_select extension for future use to
233
+ optionally enable. Enabled by default until version 2.
234
+ * Added :ignore_usec option for datetime restrictions to be compared without
235
+ microsecond
236
+ * some refactoring
237
+
238
+
239
+ # 1.1.5 [2009-01-21]
240
+ * Fixed regex for 'yy' format token which wasn't greedy enough for date
241
+ formats ending with year when a datetime string parsed as date with a 4
242
+ digit year
243
+
244
+
245
+ # 1.1.4 [2009-01-13]
246
+ * Make months names respect i18n in Formats
247
+
248
+
249
+ # 1.1.3 [2009-01-13]
250
+ * Fixed bug where time and date attributes still being parsed on read using
251
+ Rails default parser [reported by Brad (pvjq)]
252
+
253
+
254
+ # 1.1.2 [2009-01-12]
255
+ * Fixed bugs
256
+ * matcher failing for custom error message without interpolation keys
257
+ using I18n
258
+ * validator custom error messages not being extracted
259
+
260
+
261
+
262
+ # 1.1.1 [2009-01-03]
263
+ * Fixed bug in matcher for options local variable
264
+
265
+
266
+ # 1.1.0 [2009-01-01]
267
+ * Added between option
268
+
269
+
270
+ # 1.0.0 [2008-12-06]
271
+ * Gemified!
272
+ * Refactor of plugin into a Data Mapper style validator class which makes
273
+ for a cleaner implementation and possible future MerbData Mapper support
274
+ * Added Rails 2.2 i18n support. Plugin error messages can specified in
275
+ locale files. See README.
276
+ * ignore_datetime_restriction_errors setting has been moved from AR to
277
+ ValidatesTimeliness::Validator.ignore_restriction_errors
278
+ * date_time_error_value_formats setting has been moved from AR to
279
+ ValidatesTimeliness::Validator.error_value_formats
280
+ * Namespaced modules and specs
281
+ * Clean up of specs
282
+ * fixed a few bugs
283
+ * accessor methods not generating properly due method name stored as
284
+ symbol in generated_attributes which fails on lookup
285
+ * force value assigned to time/datetime attributes to time objects
286
+
287
+
288
+
289
+ # 0.1.0 [2008-12-06]
290
+ * Tagged plugin as version 0.1.0
291
+
292
+
293
+ # 2008-11-13
294
+ * allow uppercase meridian to be valid [reported by Alex
295
+ (http://alex.digns.com/)]
296
+
297
+
298
+ # 2008-10-28
299
+ * fixed bug when dirty attributes not reflecting change when attribute
300
+ changed from time value to nil [reported by Brad (pvjq)]
301
+ * fixes for Rails 2.2 compatibility. Will refactor in to Rails version
302
+ specific branches in the future.
303
+
304
+
305
+ # 2008-09-24
306
+ * refactored attribute write method definitions
307
+
308
+
309
+ # 2008-08-25
310
+ * fixed bug for non-timezone write method not updating changed attributes
311
+ hash [reported by Sylvestre Mergulhão]
312
+
313
+
314
+ # 2008-08-22
315
+ * fixed bug with attribute cache not clearing on write for date and time
316
+ columns [reported by Sylvestre Mergulhão]
317
+ * parse method returns Date object for date column assigned string as per
318
+ normal Rails behaviour
319
+ * parse method returns same object type when assigned Date or Time object as
320
+ per normal Rails behaviour
321
+
322
+
323
+ # 2008-08-07
324
+ * modified matcher option value parsing to allow same value types as
325
+ validation method
326
+ * fixed matcher message
327
+
328
+
329
+ # 2008-08-02
330
+ * refactored validation
331
+ * refactored matcher
332
+
333
+
334
+ # 2008-07-30
335
+ * removed setting values to nil when validation fails to preserve
336
+ before_type_cast value
337
+
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008-2010 Adam Meehan
1
+ Copyright (c) 2008-2021 Adam Meehan
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the