validates_timeliness 4.0.2 → 4.1.1
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 +5 -5
- data/.travis.yml +13 -9
- data/CHANGELOG.rdoc +19 -0
- data/README.rdoc +4 -3
- data/gemfiles/rails_4_2.gemfile +6 -11
- data/lib/validates_timeliness/railtie.rb +8 -0
- data/lib/validates_timeliness/validator.rb +2 -2
- data/lib/validates_timeliness/version.rb +1 -1
- data/spec/spec_helper.rb +4 -2
- data/spec/validates_timeliness/orm/active_record_spec.rb +8 -2
- data/spec/validates_timeliness/railtie_spec.rb +22 -0
- data/spec/validates_timeliness/validator_spec.rb +14 -0
- data/validates_timeliness.gemspec +2 -1
- metadata +17 -10
- data/gemfiles/rails_4_0.gemfile +0 -19
- data/gemfiles/rails_4_1.gemfile +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 942eb4506928d381dae7a7356206a045a57d8085cc9ef8ea6e96801186274bea
|
4
|
+
data.tar.gz: 6991d619ce2c4872c16e1c757f6de78c8f1761c6b5194f10b0312158431aba15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abf74b01270b55f495fd10ca1e5abcdfe899742499dcb8c7af17b11f68aa04143b843d3b65c9cbafbd6eae1f56a4a9d4959b9bd8af6ec42a1c7bcc65055689d1
|
7
|
+
data.tar.gz: afb9c7e4657292e244749548a8669222da167410d7a28831c665f6a86fa88e0415e3daecbd4580f8c2eec24e754c59cfe7ba2a232256c7a769b0ff2805aea6a5
|
data/.travis.yml
CHANGED
@@ -1,16 +1,20 @@
|
|
1
1
|
language: ruby
|
2
|
+
before_install:
|
3
|
+
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
4
|
+
- gem install bundler -v '< 2'
|
5
|
+
before_script:
|
6
|
+
- bundle install
|
2
7
|
cache: bundler
|
8
|
+
bundler_args: --verbose
|
3
9
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
10
|
+
matrix:
|
11
|
+
include:
|
12
|
+
- rvm: "2.4.6"
|
13
|
+
gemfile: gemfiles/rails_4_2.gemfile
|
14
|
+
- rvm: "2.5.5"
|
15
|
+
gemfile: gemfiles/rails_4_2.gemfile
|
8
16
|
|
9
|
-
|
10
|
-
- "2.2.3"
|
11
|
-
- "2.3.0"
|
12
|
-
|
13
|
-
script: 'bundle exec rake'
|
17
|
+
script: 'bundle exec rspec'
|
14
18
|
|
15
19
|
notifications:
|
16
20
|
email:
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
= 4.1.1 [2019-08-06]
|
2
|
+
* Add initializer to ensure Timeliness default ambigiuous date handling config
|
3
|
+
in Timeliness v0.4.1+ is set correctly when using `use_us_formats` or
|
4
|
+
`use_euro_formats` switcher to set default.
|
5
|
+
* Removed build support for Ruby 2.3 and Rails 4.0 and 4.1 to EOL official
|
6
|
+
support for those.
|
7
|
+
|
8
|
+
= 4.1.0 [2019-06-11]
|
9
|
+
* Relaxed Timeliness dependency version to >= 0.3.10 and < 1, which allows
|
10
|
+
version 0.4 with threadsafety fix for use_us_formats and use_euro_formats
|
11
|
+
hot switching in a request.
|
12
|
+
|
13
|
+
= 4.0.2 [2016-01-07]
|
14
|
+
* Fix undefine_generated_methods ivar guard setting to false
|
15
|
+
|
16
|
+
= 4.0.1 [2016-01-06]
|
17
|
+
* Fix undefine_generated_methods thread locking bug
|
18
|
+
* Created an ActiveModel ORM, for manual require if using without any full blown ORM
|
19
|
+
|
1
20
|
= 4.0.0 [2015-12-29]
|
2
21
|
* Extracted mongoid support into https://github.com/adzap/validates_timeliness-mongoid which is broken (not supported anymore).
|
3
22
|
* Fixed Rails 4.0, 4.1 and 4.2 compatability issues
|
data/README.rdoc
CHANGED
@@ -5,7 +5,8 @@
|
|
5
5
|
|
6
6
|
== Description
|
7
7
|
|
8
|
-
Complete validation of dates, times and datetimes for Rails 4.x and ActiveModel.
|
8
|
+
Complete validation of dates, times and datetimes for Rails 4.2.x and ActiveModel. Rails 4.0.x and 4.1.x may
|
9
|
+
still work but official support has ended.
|
9
10
|
|
10
11
|
If you a looking for the old version for Rails 3.x go here[http://github.com/adzap/validates_timeliness/tree/v3.x].
|
11
12
|
|
@@ -22,7 +23,7 @@ If you a looking for the old version for Rails 3.x go here[http://github.com/adz
|
|
22
23
|
|
23
24
|
* Adds extensions to fix Rails date/time select issues (See Extensions)
|
24
25
|
|
25
|
-
* Supports I18n for the error messages
|
26
|
+
* Supports I18n for the error messages. For multi-language support try {timeliness-i18n gem}[https://github.com/pedrofurtado/timeliness-i18n].
|
26
27
|
|
27
28
|
* Supports all the Rubies (that any sane person would be using in production).
|
28
29
|
|
@@ -30,7 +31,7 @@ If you a looking for the old version for Rails 3.x go here[http://github.com/adz
|
|
30
31
|
== Installation
|
31
32
|
|
32
33
|
# in Gemfile
|
33
|
-
gem 'validates_timeliness', '~> 4.
|
34
|
+
gem 'validates_timeliness', '~> 4.1'
|
34
35
|
|
35
36
|
# Run bundler
|
36
37
|
$ bundle install
|
data/gemfiles/rails_4_2.gemfile
CHANGED
@@ -1,19 +1,14 @@
|
|
1
1
|
# This file was generated by Appraisal
|
2
2
|
|
3
|
-
source "
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "rails", "~> 4.2.
|
6
|
-
gem "rspec", "~> 3.
|
7
|
-
gem "rspec-rails", "~> 3.
|
5
|
+
gem "rails", "~> 4.2.8"
|
6
|
+
gem "rspec", "~> 3.6.0"
|
7
|
+
gem "rspec-rails", "~> 3.6.0"
|
8
8
|
gem "timecop"
|
9
|
-
gem "rspec_tag_matchers"
|
10
9
|
gem "byebug"
|
11
10
|
gem "appraisal"
|
12
|
-
gem "sqlite3"
|
11
|
+
gem "sqlite3", "~> 1.3.0"
|
13
12
|
gem "nokogiri", "1.6.7"
|
14
13
|
|
15
|
-
|
16
|
-
gem "sqlite3-ruby", :require => "sqlite3"
|
17
|
-
end
|
18
|
-
|
19
|
-
gemspec :path => "../"
|
14
|
+
gemspec path: "../"
|
@@ -11,5 +11,13 @@ module ValidatesTimeliness
|
|
11
11
|
initializer "validates_timeliness.initialize_restriction_errors" do
|
12
12
|
ValidatesTimeliness.ignore_restriction_errors = !Rails.env.test?
|
13
13
|
end
|
14
|
+
|
15
|
+
initializer "validates_timeliness.initialize_timeliness_ambiguous_date_format", :after => 'load_config_initializers' do
|
16
|
+
if Timeliness.respond_to?(:ambiguous_date_format) # i.e. v0.4+
|
17
|
+
# Set default for each new thread if you have changed the default using
|
18
|
+
# the format switching methods.
|
19
|
+
Timeliness.configuration.ambiguous_date_format = Timeliness::Definitions.current_date_format
|
20
|
+
end
|
21
|
+
end
|
14
22
|
end
|
15
23
|
end
|
@@ -56,7 +56,7 @@ module ValidatesTimeliness
|
|
56
56
|
end
|
57
57
|
|
58
58
|
# Rails 4.0 compatibility for old #setup method with class as arg
|
59
|
-
if ActiveModel
|
59
|
+
if Gem::Version.new(ActiveModel::VERSION::STRING) <= Gem::Version.new('4.1')
|
60
60
|
alias_method(:setup, :setup_timeliness_validated_attributes)
|
61
61
|
end
|
62
62
|
|
@@ -91,7 +91,7 @@ module ValidatesTimeliness
|
|
91
91
|
|
92
92
|
def add_error(record, attr_name, message, value=nil)
|
93
93
|
value = format_error_value(value) if value
|
94
|
-
message_options = { :message => options
|
94
|
+
message_options = { :message => options.fetch(:"#{message}_message", options[:message]), :restriction => value }
|
95
95
|
record.errors.add(attr_name, message, message_options)
|
96
96
|
end
|
97
97
|
|
data/spec/spec_helper.rb
CHANGED
@@ -9,6 +9,8 @@ require 'timecop'
|
|
9
9
|
require 'validates_timeliness'
|
10
10
|
require 'validates_timeliness/orm/active_model'
|
11
11
|
|
12
|
+
require 'rails/railtie'
|
13
|
+
|
12
14
|
require 'support/test_model'
|
13
15
|
require 'support/model_helpers'
|
14
16
|
require 'support/config_helper'
|
@@ -71,8 +73,8 @@ end
|
|
71
73
|
class Employee < ActiveRecord::Base
|
72
74
|
attr_accessor :redefined_birth_date_called
|
73
75
|
validates_date :birth_date, :allow_nil => true
|
74
|
-
|
75
|
-
|
76
|
+
validates_time :birth_time, :allow_nil => true
|
77
|
+
validates_datetime :birth_datetime, :allow_nil => true
|
76
78
|
|
77
79
|
def birth_date=(value)
|
78
80
|
self.redefined_birth_date_called = true
|
@@ -241,8 +241,14 @@ RSpec.describe ValidatesTimeliness, 'ActiveRecord' do
|
|
241
241
|
end
|
242
242
|
|
243
243
|
context "undefine_attribute_methods" do
|
244
|
-
it "returns
|
245
|
-
|
244
|
+
it "returns remove attribute methods that have already been generated" do
|
245
|
+
Employee.define_attribute_methods
|
246
|
+
|
247
|
+
expect(Employee.instance_methods).to include(:birth_datetime)
|
248
|
+
|
249
|
+
Employee.undefine_attribute_methods
|
250
|
+
|
251
|
+
expect(Employee.instance_methods).to_not include(:birth_datetime)
|
246
252
|
end
|
247
253
|
end
|
248
254
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'validates_timeliness/railtie'
|
2
|
+
|
3
|
+
RSpec.describe ValidatesTimeliness::Railtie do
|
4
|
+
context "intializers" do
|
5
|
+
context "validates_timeliness.initialize_timeliness_ambiguous_date_format" do
|
6
|
+
it 'should set the timeliness default ambiguous date format from the current format' do
|
7
|
+
expect(Timeliness.configuration.ambiguous_date_format).to eq :us
|
8
|
+
ValidatesTimeliness.parser.use_euro_formats
|
9
|
+
|
10
|
+
initializer("validates_timeliness.initialize_timeliness_ambiguous_date_format").run
|
11
|
+
|
12
|
+
expect(Timeliness.configuration.ambiguous_date_format).to eq :euro
|
13
|
+
end
|
14
|
+
end if Timeliness.respond_to?(:ambiguous_date_format)
|
15
|
+
|
16
|
+
def initializer(name)
|
17
|
+
ValidatesTimeliness::Railtie.initializers.find { |i|
|
18
|
+
i.name == name
|
19
|
+
} || raise("Initializer #{name} not found")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -87,6 +87,20 @@ RSpec.describe ValidatesTimeliness::Validator do
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
+
describe ':message options' do
|
91
|
+
it 'should allow message option too' do
|
92
|
+
Person.validates_date :birth_date, on_or_after: :today, message: 'cannot be in past'
|
93
|
+
invalid!(:birth_date, Date.today - 5.days, 'cannot be in past')
|
94
|
+
valid!(:birth_date, Date.today)
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'should first allow the defined message' do
|
98
|
+
Person.validates_date :birth_date, on_or_after: :today, on_or_after_message: 'cannot be in past', message: 'dummy message'
|
99
|
+
invalid!(:birth_date, Date.today - 5.days, 'cannot be in past')
|
100
|
+
valid!(:birth_date, Date.today)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
90
104
|
describe ":between option" do
|
91
105
|
describe "array value" do
|
92
106
|
it 'should be split option into :on_or_after and :on_or_before values' do
|
@@ -10,11 +10,12 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.description = %q{Adds validation methods to ActiveModel for validating dates and times. Works with multiple ORMS.}
|
11
11
|
s.email = %q{adam.meehan@gmail.com}
|
12
12
|
s.homepage = %q{http://github.com/adzap/validates_timeliness}
|
13
|
+
s.license = "MIT"
|
13
14
|
|
14
15
|
s.require_paths = ["lib"]
|
15
16
|
s.files = `git ls-files`.split("\n") - %w{ .gitignore .rspec Gemfile Gemfile.lock autotest/discover.rb Appraisals Travis.yml } - Dir['gemsfiles/*']
|
16
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
18
|
s.extra_rdoc_files = ["README.rdoc", "CHANGELOG.rdoc", "LICENSE"]
|
18
19
|
|
19
|
-
s.add_runtime_dependency(%q<timeliness>, ["
|
20
|
+
s.add_runtime_dependency(%q<timeliness>, [">= 0.3.10", "< 1"])
|
20
21
|
end
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates_timeliness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.1.1
|
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: 2019-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: timeliness
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.3.
|
19
|
+
version: 0.3.10
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '1'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.3.10
|
30
|
+
- - "<"
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
32
|
+
version: '1'
|
27
33
|
description: Adds validation methods to ActiveModel for validating dates and times.
|
28
34
|
Works with multiple ORMS.
|
29
35
|
email: adam.meehan@gmail.com
|
@@ -39,8 +45,6 @@ files:
|
|
39
45
|
- LICENSE
|
40
46
|
- README.rdoc
|
41
47
|
- Rakefile
|
42
|
-
- gemfiles/rails_4_0.gemfile
|
43
|
-
- gemfiles/rails_4_1.gemfile
|
44
48
|
- gemfiles/rails_4_2.gemfile
|
45
49
|
- init.rb
|
46
50
|
- lib/generators/validates_timeliness/install_generator.rb
|
@@ -69,6 +73,7 @@ files:
|
|
69
73
|
- spec/validates_timeliness/extensions/multiparameter_handler_spec.rb
|
70
74
|
- spec/validates_timeliness/helper_methods_spec.rb
|
71
75
|
- spec/validates_timeliness/orm/active_record_spec.rb
|
76
|
+
- spec/validates_timeliness/railtie_spec.rb
|
72
77
|
- spec/validates_timeliness/validator/after_spec.rb
|
73
78
|
- spec/validates_timeliness/validator/before_spec.rb
|
74
79
|
- spec/validates_timeliness/validator/is_at_spec.rb
|
@@ -78,7 +83,8 @@ files:
|
|
78
83
|
- spec/validates_timeliness_spec.rb
|
79
84
|
- validates_timeliness.gemspec
|
80
85
|
homepage: http://github.com/adzap/validates_timeliness
|
81
|
-
licenses:
|
86
|
+
licenses:
|
87
|
+
- MIT
|
82
88
|
metadata: {}
|
83
89
|
post_install_message:
|
84
90
|
rdoc_options: []
|
@@ -96,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
102
|
version: '0'
|
97
103
|
requirements: []
|
98
104
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.
|
105
|
+
rubygems_version: 2.7.6.2
|
100
106
|
signing_key:
|
101
107
|
specification_version: 4
|
102
108
|
summary: Date and time validation plugin for Rails which allows custom formats
|
@@ -112,6 +118,7 @@ test_files:
|
|
112
118
|
- spec/validates_timeliness/extensions/multiparameter_handler_spec.rb
|
113
119
|
- spec/validates_timeliness/helper_methods_spec.rb
|
114
120
|
- spec/validates_timeliness/orm/active_record_spec.rb
|
121
|
+
- spec/validates_timeliness/railtie_spec.rb
|
115
122
|
- spec/validates_timeliness/validator/after_spec.rb
|
116
123
|
- spec/validates_timeliness/validator/before_spec.rb
|
117
124
|
- spec/validates_timeliness/validator/is_at_spec.rb
|
data/gemfiles/rails_4_0.gemfile
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "http://rubygems.org"
|
4
|
-
|
5
|
-
gem "rails", "~> 4.0.0"
|
6
|
-
gem "rspec", "~> 3.0.0"
|
7
|
-
gem "rspec-rails", "~> 3.0.0"
|
8
|
-
gem "timecop"
|
9
|
-
gem "rspec_tag_matchers"
|
10
|
-
gem "byebug"
|
11
|
-
gem "appraisal"
|
12
|
-
gem "sqlite3"
|
13
|
-
gem "nokogiri", "1.6.7"
|
14
|
-
|
15
|
-
group :active_record do
|
16
|
-
gem "sqlite3-ruby", :require => "sqlite3"
|
17
|
-
end
|
18
|
-
|
19
|
-
gemspec :path => "../"
|
data/gemfiles/rails_4_1.gemfile
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "http://rubygems.org"
|
4
|
-
|
5
|
-
gem "rails", "~> 4.1.0"
|
6
|
-
gem "rspec", "~> 3.0.0"
|
7
|
-
gem "rspec-rails", "~> 3.0.0"
|
8
|
-
gem "timecop"
|
9
|
-
gem "rspec_tag_matchers"
|
10
|
-
gem "byebug"
|
11
|
-
gem "appraisal"
|
12
|
-
gem "sqlite3"
|
13
|
-
gem "nokogiri", "1.6.7"
|
14
|
-
|
15
|
-
group :active_record do
|
16
|
-
gem "sqlite3-ruby", :require => "sqlite3"
|
17
|
-
end
|
18
|
-
|
19
|
-
gemspec :path => "../"
|