validates_timeliness 5.0.0.beta1 → 6.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa25778ed03195da3bdd16dafc426d3345c2df57a21d225c73b97dd6785045e0
4
- data.tar.gz: bd5fd0cc630b48cdd9543be3e79ef11599ec7c92fa7cff7f9acdce4867707e74
3
+ metadata.gz: b584b13fcefa901798be0f9d6e1cf51eaf80a3f0d64c6c97c63289abb4b98352
4
+ data.tar.gz: 5f5fa790ca28e6a0f94ddc487987e27aa8a74a5607e549aa71beefd1f12e87e9
5
5
  SHA512:
6
- metadata.gz: fffd3ee1b2e79d67505b1866de6398eddb35bc52024a967b95d83b6e56b8f43a30c03efb89578e7bee7e8458a2ec38566c2048d6671ab3d55aa9e6365eb042a4
7
- data.tar.gz: fcdc2d3e74d7e8a6011bc684991c49090e40416a79148af5ac421cef2376c78d683d280ef4998edaa1edd14ac5e5ad61f50b7d38e7ef89df104045db2f16a362
6
+ metadata.gz: 54c496a3f7275eb0a8c037b5e1fb22cc17debfcbaf35c6821209b900dcf6e9efdda11f7eb5f8083372feaed9ae5936119cb483a139d3c1d78de67e52d1bd7afc
7
+ data.tar.gz: fc6279b210ef3e43b357b49540f4dc201778239cce5507589677c45fb72155f95430b13f07fb95950f112f9efa13750f4fb008a7f9689ffc9e4d929e351bafe6
data/.travis.yml CHANGED
@@ -1,14 +1,31 @@
1
+ dist: focal
2
+ os: linux
1
3
  language: ruby
2
4
  before_install: gem install bundler
3
5
  cache: bundler
4
6
 
5
7
  gemfile:
6
- - gemfiles/rails_5_0.gemfile
7
- - gemfiles/rails_5_1.gemfile
8
- - gemfiles/rails_5_2.gemfile
8
+ - gemfiles/rails_6_0.gemfile
9
+ - gemfiles/rails_6_1.gemfile
10
+ - gemfiles/rails_edge.gemfile
9
11
 
10
12
  rvm:
11
- - "2.5.3"
13
+ - "2.5.8"
14
+ - "2.6.6"
15
+ - "2.7.2"
16
+ - "3.0.0"
17
+ - ruby-head
18
+
19
+ jobs:
20
+ allow_failures:
21
+ - rvm: ruby-head
22
+ - gemfile: gemfiles/rails_edge.gemfile
23
+ exclude:
24
+ - rvm: 2.5.8
25
+ gemfile: gemfiles/rails_edge.gemfile
26
+ - rvm: 2.6.6
27
+ gemfile: gemfiles/rails_edge.gemfile
28
+ fast_finish: true
12
29
 
13
30
  script: 'bundle exec rspec'
14
31
 
data/CHANGELOG.rdoc CHANGED
@@ -1,10 +1,12 @@
1
- = [UNRELEASED]
1
+ = 5.0.0 [2021-04-03]
2
2
  * Fix DateTimeSelect extension support (AquisTech)
3
3
  * Relaxed Timeliness dependency version which allows for >= 0.4.0 with
4
4
  threadsafety fix for use_us_formats and use_euro_formats for hot switching
5
5
  in a request.
6
6
  * Add initializer to ensure Timeliness v0.4+ ambiguous date config is set
7
7
  correctly when using `use_euro_formats` or `remove_use_formats'.
8
+ * Add Ruby 3 compatibility
9
+ * Add Rails 6.1 compatibility
8
10
 
9
11
  Breaking Changes
10
12
  * Update Multiparameter extension to use ActiveRecord type classes with multiparameter handling
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
data/README.rdoc CHANGED
@@ -1,13 +1,17 @@
1
1
  = ValidatesTimeliness {<img src="https://travis-ci.org/adzap/validates_timeliness.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/adzap/validates_timeliness]
2
2
 
3
- * Source: http://github.com/adzap/validates_timeliness
4
- * Issues: http://github.com/adzap/validates_timeliness/issues
3
+ * Source: https://github.com/adzap/validates_timeliness
4
+ * Issues: https://github.com/adzap/validates_timeliness/issues
5
5
 
6
6
  == Description
7
7
 
8
- Complete validation of dates, times and datetimes for Rails 5.x and ActiveModel.
8
+ Complete validation of dates, times and datetimes for Rails 6.x and ActiveModel.
9
9
 
10
- If you a looking for the old version for Rails 4.x go here [https://github.com/adzap/validates_timeliness/tree/4-0-stable].
10
+ Old Rails versions:
11
+
12
+ * Rails 4.x: [https://github.com/adzap/validates_timeliness/tree/4-0-stable]
13
+
14
+ * Rails 5.x: [https://github.com/adzap/validates_timeliness/tree/5-0-stable]
11
15
 
12
16
 
13
17
  == Features
@@ -18,7 +22,7 @@ If you a looking for the old version for Rails 4.x go here [https://github.com/a
18
22
 
19
23
  * Only Rails date/time validation plugin offering complete validation (See ORM/ODM support)
20
24
 
21
- * Uses extensible date/time parser (Using {timeliness gem}[http://github.com/adzap/timeliness]. See Plugin Parser)
25
+ * Uses extensible date/time parser (Using {timeliness gem}[https://github.com/adzap/timeliness]. See Plugin Parser)
22
26
 
23
27
  * Adds extensions to fix Rails date/time select issues (See Extensions)
24
28
 
@@ -30,13 +34,13 @@ If you a looking for the old version for Rails 4.x go here [https://github.com/a
30
34
  == Installation
31
35
 
32
36
  # in Gemfile
33
- gem 'validates_timeliness', '~> 5.0.0.alpha3'
37
+ gem 'validates_timeliness', '~> 6.0.0.alpha1'
34
38
 
35
39
  # Run bundler
36
40
  $ bundle install
37
41
 
38
42
  Then run
39
-
43
+
40
44
  $ rails generate validates_timeliness:install
41
45
 
42
46
  This creates configuration initializer and locale files. In the initializer, there are a number of config
@@ -49,21 +53,21 @@ NOTE: You may wish to enable the plugin parser and the extensions to start. Plea
49
53
 
50
54
  validates_datetime :occurred_at
51
55
 
52
- validates_date :date_of_birth, :before => lambda { 18.years.ago },
53
- :before_message => "must be at least 18 years old"
56
+ validates_date :date_of_birth, before: lambda { 18.years.ago },
57
+ before_message: "must be at least 18 years old"
54
58
 
55
- validates_datetime :finish_time, :after => :start_time # Method symbol
59
+ validates_datetime :finish_time, after: :start_time # Method symbol
56
60
 
57
- validates_date :booked_at, :on => :create, :on_or_after => :today # See Restriction Shorthand.
61
+ validates_date :booked_at, on: :create, on_or_after: :today # See Restriction Shorthand.
58
62
 
59
- validates_time :booked_at, :between => ['9:00am', '5:00pm'] # On or after 9:00AM and on or before 5:00PM
60
- validates_time :booked_at, :between => '9:00am'..'5:00pm' # The same as previous example
61
- validates_time :booked_at, :between => '9:00am'...'5:00pm' # On or after 9:00AM and strictly before 5:00PM
63
+ validates_time :booked_at, between: ['9:00am', '5:00pm'] # On or after 9:00AM and on or before 5:00PM
64
+ validates_time :booked_at, between: '9:00am'..'5:00pm' # The same as previous example
65
+ validates_time :booked_at, between: '9:00am'...'5:00pm' # On or after 9:00AM and strictly before 5:00PM
62
66
 
63
- validates_time :breakfast_time, :on_or_after => '6:00am',
64
- :on_or_after_message => 'must be after opening time',
65
- :before => :lunchtime,
66
- :before_message => 'must be before lunch time'
67
+ validates_time :breakfast_time, on_or_after: '6:00am',
68
+ on_or_after_message: 'must be after opening time',
69
+ before: :lunchtime,
70
+ before_message: 'must be before lunch time'
67
71
 
68
72
 
69
73
  == Usage
@@ -72,14 +76,14 @@ To validate a model with a date, time or datetime attribute you just use the
72
76
  validation method
73
77
 
74
78
  class Person < ActiveRecord::Base
75
- validates_date :date_of_birth, :on_or_before => lambda { Date.current }
79
+ validates_date :date_of_birth, on_or_before: lambda { Date.current }
76
80
  # or
77
- validates :date_of_birth, :timeliness => {:on_or_before => lambda { Date.current }, :type => :date}
81
+ validates :date_of_birth, timeliness: {on_or_before: lambda { Date.current }, type: :date}
78
82
  end
79
83
 
80
84
  or even on a specific record, per ActiveModel API.
81
85
 
82
- @person.validates_date :date_of_birth, :on_or_before => lambda { Date.current }
86
+ @person.validates_date :date_of_birth, on_or_before: lambda { Date.current }
83
87
 
84
88
 
85
89
  The list of validation methods available are as follows:
@@ -97,7 +101,7 @@ Temporal options (or restrictions):
97
101
  :on_or_before - Attribute must be equal to or before this value to be valid
98
102
  :after - Attribute must be after this value to be valid
99
103
  :on_or_after - Attribute must be equal to or after this value to be valid
100
- :between - Attribute must be between the values to be valid. Range or Array of 2 values.
104
+ :between - Attribute must be between the values to be valid. Range or Array of 2 values.
101
105
 
102
106
  Regular validation options:
103
107
  :allow_nil - Allow a nil value to be valid
@@ -142,7 +146,7 @@ like so
142
146
 
143
147
  end
144
148
 
145
- By default the plugin extends ActiveRecord if loaded. If you wish to extend another ORM then look at the {wiki page}[http://github.com/adzap/validates_timeliness/wiki/ORM-Support] for more information.
149
+ By default the plugin extends ActiveRecord if loaded. If you wish to extend another ORM then look at the {wiki page}[https://github.com/adzap/validates_timeliness/wiki/ORM-Support] for more information.
146
150
 
147
151
  It is not required that you use a shim, but you will not catch errors when the attribute value is invalid and evaluated to nil.
148
152
 
@@ -184,7 +188,7 @@ It is highly recommended you use the I18n system for error messages.
184
188
 
185
189
  === Plugin Parser
186
190
 
187
- The plugin uses the {timeliness gem}[http://github.com/adzap/timeliness] as a fast, configurable and extensible date and time parser.
191
+ The plugin uses the {timeliness gem}[https://github.com/adzap/timeliness] as a fast, configurable and extensible date and time parser.
188
192
  You can add or remove valid formats for dates, times, and datetimes. It is also more strict than the
189
193
  Ruby parser, which means it won't accept day of the month if it's not a valid number for the month.
190
194
 
@@ -194,33 +198,33 @@ By default the parser is disabled. To enable it:
194
198
  config.use_plugin_parser = true
195
199
 
196
200
  Enabling the parser will mean that strings assigned to attributes validated with the plugin will be parsed
197
- using the gem. See the wiki[http://github.com/adzap/validates_timeliness/wiki/Plugin-Parser] for more details about the parser configuration.
201
+ using the gem. See the wiki[https://github.com/adzap/validates_timeliness/wiki/Plugin-Parser] for more details about the parser configuration.
198
202
 
199
203
 
200
204
  === Restriction Shorthand
201
205
 
202
- It is common to restrict an attribute to being on or before the current time or current day.
206
+ It is common to restrict an attribute to being on or before the current time or current day.
203
207
  To specify this you need to use a lambda as an option value e.g. <tt>lambda { Time.current }</tt>.
204
208
  This can be tedious noise amongst your validations for something so common. To combat this the
205
209
  plugin allows you to use shorthand symbols for often used relative times or dates.
206
210
 
207
211
  Just provide the symbol as the option value like so:
208
212
 
209
- validates_date :birth_date, :on_or_before => :today
213
+ validates_date :birth_date, on_or_before: :today
210
214
 
211
- The :today symbol is evaluated as <tt>lambda { Date.today }</tt>. The :now and :today
215
+ The :today symbol is evaluated as <tt>lambda { Date.current }</tt>. The :now and :today
212
216
  symbols are pre-configured. Configure your own like so:
213
217
 
214
218
  # in the setup block
215
219
  config.restriction_shorthand_symbols.update(
216
- :yesterday => lambda { 1.day.ago }
220
+ yesterday: lambda { 1.day.ago }
217
221
  )
218
222
 
219
223
 
220
224
  === Default Timezone
221
225
 
222
226
  The plugin needs to know the default timezone you are using when parsing or type casting values. If you are using
223
- ActiveRecord then the default is automatically set to the same default zone as ActiveRecord. If you are using
227
+ ActiveRecord then the default is automatically set to the same default zone as ActiveRecord. If you are using
224
228
  another ORM you may need to change this setting.
225
229
 
226
230
  # in the setup block
@@ -286,12 +290,12 @@ To activate it, uncomment this line in the initializer:
286
290
 
287
291
  == Contributors
288
292
 
289
- To see the generous people who have contributed code, take a look at the {contributors list}[http://github.com/adzap/validates_timeliness/contributors].
293
+ To see the generous people who have contributed code, take a look at the {contributors list}[https://github.com/adzap/validates_timeliness/contributors].
290
294
 
291
295
 
292
296
  == Maintainers
293
297
 
294
- * {Adam Meehan}[http://github.com/adzap]
298
+ * {Adam Meehan}[https://github.com/adzap]
295
299
 
296
300
 
297
301
  == License
data/Rakefile CHANGED
@@ -19,10 +19,11 @@ end
19
19
 
20
20
  desc 'Generate documentation for plugin.'
21
21
  Rake::RDocTask.new(:rdoc) do |rdoc|
22
+ rdoc.main = 'README.rdoc'
22
23
  rdoc.rdoc_dir = 'rdoc'
23
24
  rdoc.title = 'ValidatesTimeliness'
24
- rdoc.options << '--line-numbers' << '--inline-source'
25
- rdoc.rdoc_files.include('README')
25
+ rdoc.options << '--line-numbers'
26
+ rdoc.rdoc_files.include('README.rdoc')
26
27
  rdoc.rdoc_files.include('lib/**/*.rb')
27
28
  end
28
29
 
@@ -2,13 +2,13 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "rails", "~> 5.0.0"
5
+ gem "rails", "~> 6.0.0"
6
6
  gem "rspec"
7
7
  gem "rspec-rails", "~> 3.7"
8
+ gem "sqlite3"
8
9
  gem "timecop"
9
10
  gem "byebug"
10
11
  gem "appraisal"
11
- gem "sqlite3", "~> 1.3.6"
12
12
  gem "nokogiri", "~> 1.8"
13
13
 
14
14
  gemspec path: "../"
@@ -2,13 +2,13 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "rails", "~> 5.1.0"
5
+ gem "rails", "~> 6.1.0"
6
6
  gem "rspec"
7
7
  gem "rspec-rails", "~> 3.7"
8
+ gem "sqlite3"
8
9
  gem "timecop"
9
10
  gem "byebug"
10
11
  gem "appraisal"
11
- gem "sqlite3", "~> 1.3.6"
12
12
  gem "nokogiri", "~> 1.8"
13
13
 
14
14
  gemspec path: "../"
@@ -2,13 +2,13 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "rails", "~> 5.2.0"
5
+ gem "rails", git: "https://github.com/rails/rails.git", branch: "main"
6
6
  gem "rspec"
7
7
  gem "rspec-rails", "~> 3.7"
8
+ gem "sqlite3"
8
9
  gem "timecop"
9
10
  gem "byebug"
10
11
  gem "appraisal"
11
- gem "sqlite3", "~> 1.3.6"
12
12
  gem "nokogiri", "~> 1.8"
13
13
 
14
14
  gemspec path: "../"
@@ -43,7 +43,7 @@ module ValidatesTimeliness
43
43
  values[POSITION.key(position.to_i)] = value.to_i
44
44
  end
45
45
 
46
- DateTimeValue.new(values)
46
+ DateTimeValue.new(**values)
47
47
  end
48
48
  end
49
49
  end
@@ -12,7 +12,7 @@ module ValidatesTimeliness
12
12
  ValidatesTimeliness.ignore_restriction_errors = !Rails.env.test?
13
13
  end
14
14
 
15
- initializer "validates_timeliness.initialize_timeliness_ambiguous_date_format", :after => 'load_config_initializers' do
15
+ initializer "validates_timeliness.initialize_timeliness_ambiguous_date_format", :after => :load_config_initializers do
16
16
  if Timeliness.respond_to?(:ambiguous_date_format) # i.e. v0.4+
17
17
  # Set default for each new thread if you have changed the default using
18
18
  # the format switching methods.
@@ -85,12 +85,12 @@ module ValidatesTimeliness
85
85
 
86
86
  def add_error(record, attr_name, message, value=nil)
87
87
  value = format_error_value(value) if value
88
- message_options = { :message => options.fetch(:"#{message}_message", options[:message]), :restriction => value }
88
+ message_options = { message: options.fetch(:"#{message}_message", options[:message]), restriction: value }
89
89
  record.errors.add(attr_name, message, message_options)
90
90
  end
91
91
 
92
92
  def format_error_value(value)
93
- format = I18n.t(@type, :default => DEFAULT_ERROR_VALUE_FORMATS[@type], :scope => 'validates_timeliness.error_value_formats')
93
+ format = I18n.t(@type, default: DEFAULT_ERROR_VALUE_FORMATS[@type], scope: 'validates_timeliness.error_value_formats')
94
94
  value.strftime(format)
95
95
  end
96
96
 
@@ -1,3 +1,3 @@
1
1
  module ValidatesTimeliness
2
- VERSION = '5.0.0.beta1'
2
+ VERSION = '6.0.0.beta1'
3
3
  end
@@ -15,11 +15,11 @@ module TestModel
15
15
  self.model_attributes[name] = type
16
16
  end
17
17
 
18
- def define_method_attribute=(attr_name)
18
+ def define_method_attribute=(attr_name, owner: nil)
19
19
  generated_attribute_methods.module_eval("def #{attr_name}=(new_value); @attributes['#{attr_name}']=self.class.type_cast('#{attr_name}', new_value); end", __FILE__, __LINE__)
20
20
  end
21
21
 
22
- def define_method_attribute(attr_name)
22
+ def define_method_attribute(attr_name, owner: nil)
23
23
  generated_attribute_methods.module_eval("def #{attr_name}; @attributes['#{attr_name}']; end", __FILE__, __LINE__)
24
24
  end
25
25
 
@@ -17,5 +17,6 @@ Gem::Specification.new do |s|
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
  s.extra_rdoc_files = ["README.rdoc", "CHANGELOG.rdoc", "LICENSE"]
19
19
 
20
- s.add_runtime_dependency(%q<timeliness>, [">= 0.3.10", "< 1"])
20
+ s.add_runtime_dependency("activemodel", [">= 6.0.0", "< 7"])
21
+ s.add_runtime_dependency("timeliness", [">= 0.3.10", "< 1"])
21
22
  end
metadata CHANGED
@@ -1,15 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates_timeliness
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.beta1
4
+ version: 6.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Meehan
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-06 00:00:00.000000000 Z
11
+ date: 2021-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activemodel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 6.0.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 6.0.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7'
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: timeliness
15
35
  requirement: !ruby/object:Gem::Requirement
@@ -45,9 +65,9 @@ files:
45
65
  - LICENSE
46
66
  - README.rdoc
47
67
  - Rakefile
48
- - gemfiles/rails_5_0.gemfile
49
- - gemfiles/rails_5_1.gemfile
50
- - gemfiles/rails_5_2.gemfile
68
+ - gemfiles/rails_6_0.gemfile
69
+ - gemfiles/rails_6_1.gemfile
70
+ - gemfiles/rails_edge.gemfile
51
71
  - init.rb
52
72
  - lib/generators/validates_timeliness/install_generator.rb
53
73
  - lib/generators/validates_timeliness/templates/en.yml
@@ -88,7 +108,7 @@ homepage: http://github.com/adzap/validates_timeliness
88
108
  licenses:
89
109
  - MIT
90
110
  metadata: {}
91
- post_install_message:
111
+ post_install_message:
92
112
  rdoc_options: []
93
113
  require_paths:
94
114
  - lib
@@ -103,8 +123,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
123
  - !ruby/object:Gem::Version
104
124
  version: 1.3.1
105
125
  requirements: []
106
- rubygems_version: 3.0.3
107
- signing_key:
126
+ rubygems_version: 3.0.3.1
127
+ signing_key:
108
128
  specification_version: 4
109
129
  summary: Date and time validation plugin for Rails which allows custom formats
110
130
  test_files: