validates_timeliness 7.0.0.beta2 → 8.0.0.beta1
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 +4 -6
- data/CHANGELOG.md +9 -0
- data/README.md +3 -2
- data/gemfiles/rails_7_0.gemfile +3 -3
- data/gemfiles/rails_7_1.gemfile +13 -0
- data/gemfiles/rails_7_2.gemfile +13 -0
- data/gemfiles/rails_8_0.gemfile +13 -0
- data/lib/validates_timeliness/extensions/date_time_select.rb +1 -1
- data/lib/validates_timeliness/extensions.rb +3 -2
- data/lib/validates_timeliness/helper_methods.rb +4 -10
- data/lib/validates_timeliness/orm/active_model.rb +1 -84
- data/lib/validates_timeliness/validator.rb +2 -1
- data/lib/validates_timeliness/version.rb +1 -1
- data/validates_timeliness.gemspec +1 -1
- metadata +10 -8
- data/gemfiles/rails_edge.gemfile +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 446d638f58bf6867dcd02c8d3f89e7c339bde180c4eb56aa49be03860722a8d7
|
4
|
+
data.tar.gz: 33c94183ebfc40ee0d90ab1d05ea6e84a65d8e0912fbdc9a7a6338623f403d6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96aba97841df97ade11d86fcf1f28c91c323755f03fc49511fa821383030c3c1eab24d1b88df5e741ab3c2630fb80e86498437c06ded734030044593878c5f66
|
7
|
+
data.tar.gz: 020b4690d0b73f82ff21bc8c9c974fe925c6df216a4db0634678158705cc346808ffbc09d74c98fc03ded15867a0ace1e14d1b3da153819bf8667e95bada068d
|
data/.github/workflows/ci.yml
CHANGED
@@ -7,12 +7,10 @@ jobs:
|
|
7
7
|
fail-fast: false
|
8
8
|
matrix:
|
9
9
|
include:
|
10
|
-
- gemfile:
|
11
|
-
ruby: 2
|
12
|
-
- gemfile:
|
13
|
-
ruby: 3.
|
14
|
-
- gemfile: rails_7_0
|
15
|
-
ruby: 3.1
|
10
|
+
- gemfile: rails_8_0
|
11
|
+
ruby: 3.2
|
12
|
+
- gemfile: rails_8_0
|
13
|
+
ruby: 3.3
|
16
14
|
|
17
15
|
name: ${{ matrix.gemfile }}, ruby ${{ matrix.ruby }}
|
18
16
|
env:
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# 7.0.0 [2024-11-30]
|
2
|
+
* Removed all method overrides in ActiveModel now that the datetime type correctly stores before_type_cast values.
|
3
|
+
|
4
|
+
# 6.0.1 [2023-01-12]
|
5
|
+
* TODO need to complete this
|
6
|
+
|
7
|
+
# 6.0.0 [2022-10-20]
|
8
|
+
* TODO need to complete this
|
9
|
+
|
1
10
|
# 5.0.0 [2021-04-03]
|
2
11
|
* Fix DateTimeSelect extension support (AquisTech)
|
3
12
|
* Relaxed Timeliness dependency version which allows for >= 0.4.0 with
|
data/README.md
CHANGED
@@ -6,13 +6,14 @@
|
|
6
6
|
|
7
7
|
## Description
|
8
8
|
|
9
|
-
Complete validation of dates, times and datetimes for Rails
|
9
|
+
Complete validation of dates, times and datetimes for Rails 8.x and ActiveModel.
|
10
10
|
|
11
11
|
Older Rails versions:
|
12
12
|
|
13
13
|
- Rails 4.x: [https://github.com/adzap/validates_timeliness/tree/4-0-stable]
|
14
14
|
- Rails 5.x: [https://github.com/adzap/validates_timeliness/tree/5-0-stable]
|
15
15
|
- Rails 6.x: [https://github.com/adzap/validates_timeliness/tree/6-0-stable]
|
16
|
+
- Rails 7.x: [https://github.com/adzap/validates_timeliness/tree/7-0-stable]
|
16
17
|
|
17
18
|
|
18
19
|
## Features
|
@@ -30,7 +31,7 @@ Older Rails versions:
|
|
30
31
|
|
31
32
|
In Gemfile
|
32
33
|
```ruby
|
33
|
-
gem 'validates_timeliness', '~>
|
34
|
+
gem 'validates_timeliness', '~> 8.0.0.beta1'
|
34
35
|
```
|
35
36
|
|
36
37
|
Run bundler:
|
data/gemfiles/rails_7_0.gemfile
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# This file was generated by Appraisal
|
2
2
|
|
3
|
-
source "
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
5
|
gem "rails", "~> 7.0.0"
|
6
6
|
gem "rspec"
|
7
7
|
gem "rspec-rails", "~> 6.0"
|
8
|
-
gem "sqlite3"
|
8
|
+
gem "sqlite3", "~> 1.4"
|
9
9
|
gem "byebug"
|
10
10
|
gem "appraisal"
|
11
|
-
gem "nokogiri"
|
11
|
+
gem "nokogiri"
|
12
12
|
|
13
13
|
gemspec path: "../"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module ValidatesTimeliness
|
2
2
|
module Extensions
|
3
|
-
module
|
3
|
+
module DateTimeSelect
|
4
4
|
# Intercepts the date and time select helpers to reuse the values from
|
5
5
|
# the params rather than the parsed value. This allows invalid date/time
|
6
6
|
# values to be redisplayed instead of blanks to aid correction by the user.
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module ValidatesTimeliness
|
2
2
|
module Extensions
|
3
|
-
autoload :
|
3
|
+
autoload :DateTimeSelect, 'validates_timeliness/extensions/date_time_select'
|
4
4
|
end
|
5
5
|
|
6
6
|
def self.enable_date_time_select_extension!
|
7
|
-
|
7
|
+
require 'uri' # Do we need this? No, but the test suite fails without it.
|
8
|
+
::ActionView::Helpers::Tags::DateSelect.send(:prepend, ValidatesTimeliness::Extensions::DateTimeSelect)
|
8
9
|
end
|
9
10
|
|
10
11
|
def self.enable_multiparameter_extension!
|
@@ -3,25 +3,19 @@ module ActiveModel
|
|
3
3
|
|
4
4
|
module HelperMethods
|
5
5
|
def validates_date(*attr_names)
|
6
|
-
|
6
|
+
validates_with TimelinessValidator, _merge_attributes(attr_names).merge(type: :date)
|
7
7
|
end
|
8
8
|
|
9
9
|
def validates_time(*attr_names)
|
10
|
-
|
10
|
+
validates_with TimelinessValidator, _merge_attributes(attr_names).merge(type: :time)
|
11
11
|
end
|
12
12
|
|
13
13
|
def validates_datetime(*attr_names)
|
14
|
-
|
14
|
+
validates_with TimelinessValidator, _merge_attributes(attr_names).merge(type: :datetime)
|
15
15
|
end
|
16
16
|
|
17
17
|
def validates_timeliness_of(*attr_names)
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
def timeliness_validation_for(attr_names, type=nil)
|
22
|
-
options = _merge_attributes(attr_names)
|
23
|
-
options.update(:type => type) if type
|
24
|
-
validates_with TimelinessValidator, options
|
18
|
+
validates_with TimelinessValidator, _merge_attributes(attr_names)
|
25
19
|
end
|
26
20
|
end
|
27
21
|
|
@@ -3,91 +3,8 @@ module ValidatesTimeliness
|
|
3
3
|
module ActiveModel
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
-
module ClassMethods
|
7
|
-
public
|
8
|
-
|
9
|
-
# Hook into bulk method definitions for non-attribute based methods validated.
|
10
|
-
def define_attribute_methods(*attr_names)
|
11
|
-
super.tap {
|
12
|
-
define_timeliness_methods
|
13
|
-
}
|
14
|
-
end
|
15
|
-
|
16
|
-
# Called when `attribute` methods is called and the timeliness overrides are defined here
|
17
|
-
def define_attribute_method(attr_name)
|
18
|
-
super.tap {
|
19
|
-
define_attribute_timeliness_methods(attr_name)
|
20
|
-
}
|
21
|
-
end
|
22
|
-
|
23
|
-
def undefine_attribute_methods
|
24
|
-
super.tap {
|
25
|
-
undefine_timeliness_attribute_methods
|
26
|
-
}
|
27
|
-
end
|
28
|
-
|
29
|
-
def define_timeliness_methods(before_type_cast=false)
|
30
|
-
return if timeliness_validated_attributes.blank?
|
31
|
-
|
32
|
-
timeliness_validated_attributes.each do |attr_name|
|
33
|
-
unless timeliness_method_already_implemented?(attr_name)
|
34
|
-
define_attribute_timeliness_methods(attr_name, before_type_cast)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def define_timeliness_method(attr_name, before_type_cast=false)
|
40
|
-
define_attribute_timeliness_methods(attr_name, before_type_cast)
|
41
|
-
end
|
42
|
-
|
43
|
-
# Lazy instantiate module as container of timeliness methods included in the model
|
44
|
-
def generated_timeliness_methods
|
45
|
-
@generated_timeliness_methods ||= Module.new { |m|
|
46
|
-
extend Mutex_m
|
47
|
-
}.tap { |mod| include mod }
|
48
|
-
end
|
49
|
-
|
50
|
-
def timeliness_method_already_implemented?(method_name)
|
51
|
-
generated_timeliness_methods.method_defined?(method_name)
|
52
|
-
end
|
53
|
-
|
54
|
-
def undefine_timeliness_attribute_methods
|
55
|
-
generated_timeliness_methods.module_eval do
|
56
|
-
undef_method(*instance_methods)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def define_attribute_timeliness_methods(attr_name, before_type_cast=false)
|
61
|
-
define_timeliness_write_method(attr_name)
|
62
|
-
define_timeliness_before_type_cast_method(attr_name) if before_type_cast
|
63
|
-
end
|
64
|
-
|
65
|
-
def define_timeliness_write_method(attr_name)
|
66
|
-
generated_timeliness_methods.module_eval <<-STR, __FILE__, __LINE__ + 1
|
67
|
-
def #{attr_name}=(value)
|
68
|
-
@timeliness_cache ||= {}
|
69
|
-
@timeliness_cache['#{attr_name}'] = value
|
70
|
-
|
71
|
-
super
|
72
|
-
end
|
73
|
-
STR
|
74
|
-
end
|
75
|
-
|
76
|
-
def define_timeliness_before_type_cast_method(attr_name)
|
77
|
-
generated_timeliness_methods.module_eval <<-STR, __FILE__, __LINE__ + 1
|
78
|
-
def #{attr_name}_before_type_cast
|
79
|
-
read_timeliness_attribute_before_type_cast('#{attr_name}')
|
80
|
-
end
|
81
|
-
STR
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
6
|
def read_timeliness_attribute_before_type_cast(attr_name)
|
86
|
-
@
|
87
|
-
end
|
88
|
-
|
89
|
-
def _clear_timeliness_cache
|
90
|
-
@timeliness_cache = {}
|
7
|
+
@attributes[attr_name].value_before_type_cast
|
91
8
|
end
|
92
9
|
|
93
10
|
end
|
@@ -95,8 +95,9 @@ module ValidatesTimeliness
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def attribute_raw_value(record, attr_name)
|
98
|
-
record.respond_to?(:read_timeliness_attribute_before_type_cast)
|
98
|
+
if record.respond_to?(:read_timeliness_attribute_before_type_cast)
|
99
99
|
record.read_timeliness_attribute_before_type_cast(attr_name.to_s)
|
100
|
+
end
|
100
101
|
end
|
101
102
|
|
102
103
|
def time_zone_aware?(record, attr_name)
|
@@ -28,6 +28,6 @@ Gem::Specification.new do |s|
|
|
28
28
|
"wiki_uri" => "#{github_url}/wiki",
|
29
29
|
}
|
30
30
|
|
31
|
-
s.add_runtime_dependency("activemodel", [">=
|
31
|
+
s.add_runtime_dependency("activemodel", [">= 8.0.0", "< 9"])
|
32
32
|
s.add_runtime_dependency("timeliness", [">= 0.3.10", "< 1"])
|
33
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates_timeliness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 8.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Meehan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 8.0.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '9'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 8.0.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '9'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: timeliness
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,7 +67,9 @@ files:
|
|
67
67
|
- README.md
|
68
68
|
- Rakefile
|
69
69
|
- gemfiles/rails_7_0.gemfile
|
70
|
-
- gemfiles/
|
70
|
+
- gemfiles/rails_7_1.gemfile
|
71
|
+
- gemfiles/rails_7_2.gemfile
|
72
|
+
- gemfiles/rails_8_0.gemfile
|
71
73
|
- init.rb
|
72
74
|
- lib/generators/validates_timeliness/install_generator.rb
|
73
75
|
- lib/generators/validates_timeliness/templates/en.yml
|
@@ -130,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
132
|
- !ruby/object:Gem::Version
|
131
133
|
version: 1.3.1
|
132
134
|
requirements: []
|
133
|
-
rubygems_version: 3.
|
135
|
+
rubygems_version: 3.4.19
|
134
136
|
signing_key:
|
135
137
|
specification_version: 4
|
136
138
|
summary: Date and time validation plugin for Rails which allows custom formats
|
data/gemfiles/rails_edge.gemfile
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "http://rubygems.org"
|
4
|
-
|
5
|
-
gem "rails", git: "https://github.com/rails/rails.git", branch: "main"
|
6
|
-
gem "rspec"
|
7
|
-
gem "rspec-rails", "~> 3.7"
|
8
|
-
gem "sqlite3"
|
9
|
-
gem "byebug"
|
10
|
-
gem "appraisal"
|
11
|
-
gem "nokogiri", "~> 1.8"
|
12
|
-
|
13
|
-
gemspec path: "../"
|