validates_timeliness 6.0.1 → 7.0.0.beta1
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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +4 -10
- data/README.md +4 -4
- data/gemfiles/{rails_6_0.gemfile → rails_7_0.gemfile} +2 -2
- data/gemfiles/{rails_6_1.gemfile → rails_edge.gemfile} +1 -2
- data/lib/validates_timeliness/converter.rb +2 -3
- data/lib/validates_timeliness/helper_methods.rb +1 -1
- data/lib/validates_timeliness/railtie.rb +1 -1
- data/lib/validates_timeliness/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/validates_timeliness/converter_spec.rb +17 -48
- data/spec/validates_timeliness/orm/active_model_spec.rb +0 -0
- data/validates_timeliness.gemspec +1 -1
- metadata +12 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 284d18473a0007c273fc4608579b619afac6a3809dfdcd12864d6aeea30c6f17
|
4
|
+
data.tar.gz: 12d2db9663bb6c80a643d7c7365fc4d44218a64a9b69feacb6d060dc737ddd93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77eb167f597fe224c293b6a9e9143c0b5eb8b443ed54539dc89e34c28e5cb7c9517e826c25660641281d6b477451cb2ff4b1187f0332e33fd0d94d7618223204
|
7
|
+
data.tar.gz: de5c7cb989b1148acf4a7af524171c7eead44663b43088da99f79bb5af7c7b1c120f28ace62cb62bcfe533979fbe9975763e59aa463acccf7ed1a951496e1f39
|
data/.github/workflows/ci.yml
CHANGED
@@ -7,18 +7,12 @@ jobs:
|
|
7
7
|
fail-fast: false
|
8
8
|
matrix:
|
9
9
|
include:
|
10
|
-
- gemfile:
|
11
|
-
ruby: 2.6
|
12
|
-
- gemfile: rails_6_0
|
10
|
+
- gemfile: rails_7_0
|
13
11
|
ruby: 2.7
|
14
|
-
- gemfile:
|
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
|
12
|
+
- gemfile: rails_7_0
|
21
13
|
ruby: 3.0
|
14
|
+
- gemfile: rails_7_0
|
15
|
+
ruby: 3.1
|
22
16
|
|
23
17
|
name: ${{ matrix.gemfile }}, ruby ${{ matrix.ruby }}
|
24
18
|
env:
|
data/README.md
CHANGED
@@ -6,13 +6,13 @@
|
|
6
6
|
|
7
7
|
## Description
|
8
8
|
|
9
|
-
Complete validation of dates, times and datetimes for Rails
|
10
|
-
ActiveModel.
|
9
|
+
Complete validation of dates, times and datetimes for Rails 7.x and ActiveModel.
|
11
10
|
|
12
|
-
|
11
|
+
Older Rails versions:
|
13
12
|
|
14
13
|
- Rails 4.x: [https://github.com/adzap/validates_timeliness/tree/4-0-stable]
|
15
14
|
- Rails 5.x: [https://github.com/adzap/validates_timeliness/tree/5-0-stable]
|
15
|
+
- Rails 6.x: [https://github.com/adzap/validates_timeliness/tree/6-0-stable]
|
16
16
|
|
17
17
|
|
18
18
|
## Features
|
@@ -30,7 +30,7 @@ Old Rails versions:
|
|
30
30
|
|
31
31
|
In Gemfile
|
32
32
|
```ruby
|
33
|
-
gem 'validates_timeliness', '~>
|
33
|
+
gem 'validates_timeliness', '~> 7.0.0.beta1'
|
34
34
|
```
|
35
35
|
|
36
36
|
Run bundler:
|
@@ -2,11 +2,10 @@
|
|
2
2
|
|
3
3
|
source "http://rubygems.org"
|
4
4
|
|
5
|
-
gem "rails", "
|
5
|
+
gem "rails", git: "https://github.com/rails/rails.git", branch: "main"
|
6
6
|
gem "rspec"
|
7
7
|
gem "rspec-rails", "~> 3.7"
|
8
8
|
gem "sqlite3"
|
9
|
-
gem "timecop"
|
10
9
|
gem "byebug"
|
11
10
|
gem "appraisal"
|
12
11
|
gem "nokogiri", "~> 1.8"
|
@@ -19,13 +19,12 @@ module ValidatesTimeliness
|
|
19
19
|
when :date
|
20
20
|
value.to_date
|
21
21
|
when :datetime
|
22
|
-
value.is_a?(Time) ? value :
|
22
|
+
value.is_a?(Time) ? value : value.to_time
|
23
23
|
else
|
24
24
|
value
|
25
25
|
end
|
26
|
-
|
27
26
|
if ignore_usec && value.is_a?(Time)
|
28
|
-
value.
|
27
|
+
Timeliness::Parser.make_time(Array(value).reverse[4..9], (:current if time_zone_aware?))
|
29
28
|
else
|
30
29
|
value
|
31
30
|
end
|
@@ -2,7 +2,7 @@ module ValidatesTimeliness
|
|
2
2
|
class Railtie < Rails::Railtie
|
3
3
|
initializer "validates_timeliness.initialize_active_record", :after => 'active_record.initialize_timezone' do
|
4
4
|
ActiveSupport.on_load(:active_record) do
|
5
|
-
ValidatesTimeliness.default_timezone = ActiveRecord
|
5
|
+
ValidatesTimeliness.default_timezone = ActiveRecord.default_timezone
|
6
6
|
ValidatesTimeliness.extend_orms << :active_record
|
7
7
|
ValidatesTimeliness.load_orms
|
8
8
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -57,7 +57,7 @@ class PersonWithShim < Person
|
|
57
57
|
include TestModelShim
|
58
58
|
end
|
59
59
|
|
60
|
-
ActiveRecord
|
60
|
+
ActiveRecord.default_timezone = :utc
|
61
61
|
ActiveRecord::Base.time_zone_aware_attributes = true
|
62
62
|
ActiveRecord::Base.establish_connection({:adapter => 'sqlite3', :database => ':memory:'})
|
63
63
|
ActiveRecord::Base.time_zone_aware_types = [:datetime, :time]
|
@@ -63,61 +63,30 @@ RSpec.describe ValidatesTimeliness::Converter do
|
|
63
63
|
|
64
64
|
describe "for datetime type" do
|
65
65
|
let(:type) { :datetime }
|
66
|
+
let(:time_zone_aware) { true }
|
66
67
|
|
67
|
-
it
|
68
|
-
expect(type_cast_value(
|
68
|
+
it "should return Date as Time value" do
|
69
|
+
expect(type_cast_value(Date.new(2010, 1, 1))).to eq(Time.local(2010, 1, 1, 0, 0, 0))
|
69
70
|
end
|
70
71
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
around { |example|
|
75
|
-
Time.use_zone("Perth", &example)
|
76
|
-
}
|
77
|
-
|
78
|
-
it "should return Date as Time value" do
|
79
|
-
Time.use_zone('London') do
|
80
|
-
result = type_cast_value(Date.new(2010, 1, 1))
|
81
|
-
expected = Time.zone.local(2010, 1, 1, 0, 0, 0)
|
82
|
-
|
83
|
-
expect(result).to eq(expected)
|
84
|
-
expect(result.zone).to eq(expected.zone)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should return same Time value" do
|
89
|
-
value = Time.utc(2010, 1, 1, 12, 34, 56)
|
90
|
-
expect(type_cast_value(value)).to eq(value)
|
91
|
-
end
|
92
|
-
|
93
|
-
it "should return as Time with same component values" do
|
94
|
-
expect(type_cast_value(DateTime.civil_from_format(:utc, 2010, 1, 1, 12, 34, 56))).to eq(Time.utc(2010, 1, 1, 12, 34, 56))
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should return same Time in correct zone if timezone aware" do
|
98
|
-
value = Time.utc(2010, 1, 1, 12, 34, 56)
|
99
|
-
result = type_cast_value(value)
|
100
|
-
|
101
|
-
expect(result).to eq(Time.zone.local(2010, 1, 1, 20, 34, 56))
|
102
|
-
expect(result.zone).to eq('AWST')
|
103
|
-
end
|
72
|
+
it "should return same Time value" do
|
73
|
+
value = Time.utc(2010, 1, 1, 12, 34, 56)
|
74
|
+
expect(type_cast_value(Time.utc(2010, 1, 1, 12, 34, 56))).to eq(value)
|
104
75
|
end
|
105
76
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
it "should return Date as Time value" do
|
110
|
-
expect(type_cast_value(Date.new(2010, 1, 1))).to eq(Time.local(2010, 1, 1, 0, 0, 0))
|
111
|
-
end
|
77
|
+
it "should return as Time with same component values" do
|
78
|
+
expect(type_cast_value(DateTime.civil_from_format(:utc, 2010, 1, 1, 12, 34, 56))).to eq(Time.utc(2010, 1, 1, 12, 34, 56))
|
79
|
+
end
|
112
80
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
81
|
+
it "should return same Time in correct zone if timezone aware" do
|
82
|
+
value = Time.utc(2010, 1, 1, 12, 34, 56)
|
83
|
+
result = type_cast_value(value)
|
84
|
+
expect(result).to eq(Time.zone.local(2010, 1, 1, 23, 34, 56))
|
85
|
+
expect(result.zone).to eq('AEDT')
|
86
|
+
end
|
117
87
|
|
118
|
-
|
119
|
-
|
120
|
-
end
|
88
|
+
it 'should return nil for invalid value types' do
|
89
|
+
expect(type_cast_value(12)).to eq(nil)
|
121
90
|
end
|
122
91
|
end
|
123
92
|
|
File without changes
|
@@ -27,6 +27,6 @@ Gem::Specification.new do |s|
|
|
27
27
|
"wiki_uri" => "#{github_url}/wiki",
|
28
28
|
}
|
29
29
|
|
30
|
-
s.add_runtime_dependency("activemodel", [">=
|
30
|
+
s.add_runtime_dependency("activemodel", [">= 7.0.0", "< 8"])
|
31
31
|
s.add_runtime_dependency("timeliness", [">= 0.3.10", "< 1"])
|
32
32
|
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: 7.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: 2022-11-21 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: 7.0.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '8'
|
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: 7.0.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '8'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: timeliness
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,8 +66,8 @@ files:
|
|
66
66
|
- LICENSE
|
67
67
|
- README.md
|
68
68
|
- Rakefile
|
69
|
-
- gemfiles/
|
70
|
-
- gemfiles/
|
69
|
+
- gemfiles/rails_7_0.gemfile
|
70
|
+
- gemfiles/rails_edge.gemfile
|
71
71
|
- init.rb
|
72
72
|
- lib/generators/validates_timeliness/install_generator.rb
|
73
73
|
- lib/generators/validates_timeliness/templates/en.yml
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- spec/validates_timeliness/extensions/date_time_select_spec.rb
|
95
95
|
- spec/validates_timeliness/extensions/multiparameter_handler_spec.rb
|
96
96
|
- spec/validates_timeliness/helper_methods_spec.rb
|
97
|
+
- spec/validates_timeliness/orm/active_model_spec.rb
|
97
98
|
- spec/validates_timeliness/orm/active_record_spec.rb
|
98
99
|
- spec/validates_timeliness/railtie_spec.rb
|
99
100
|
- spec/validates_timeliness/validator/after_spec.rb
|
@@ -123,9 +124,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
124
|
version: '0'
|
124
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
126
|
requirements:
|
126
|
-
- - "
|
127
|
+
- - ">"
|
127
128
|
- !ruby/object:Gem::Version
|
128
|
-
version:
|
129
|
+
version: 1.3.1
|
129
130
|
requirements: []
|
130
131
|
rubygems_version: 3.1.6
|
131
132
|
signing_key:
|
@@ -142,6 +143,7 @@ test_files:
|
|
142
143
|
- spec/validates_timeliness/extensions/date_time_select_spec.rb
|
143
144
|
- spec/validates_timeliness/extensions/multiparameter_handler_spec.rb
|
144
145
|
- spec/validates_timeliness/helper_methods_spec.rb
|
146
|
+
- spec/validates_timeliness/orm/active_model_spec.rb
|
145
147
|
- spec/validates_timeliness/orm/active_record_spec.rb
|
146
148
|
- spec/validates_timeliness/railtie_spec.rb
|
147
149
|
- spec/validates_timeliness/validator/after_spec.rb
|