validates_timeliness 5.0.0.alpha4 → 5.0.0.alpha5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0891cbd18ce77b4f8907bcb1267130e60350ffab7334f54fc11e4f8c412fef00'
4
- data.tar.gz: 329dcaba25102a694495be0d4f6de227d627fb96e4ba3beb97ae66f1c30f500f
3
+ metadata.gz: 4c8e4da95b2742cd11181d664cb5c5d7c2e6f69764641e72c0c9ad244196529f
4
+ data.tar.gz: 8b6e1cdcecb56aa889baaf0e0a874a53bedc940656757f52526f3f2eeac0e0fc
5
5
  SHA512:
6
- metadata.gz: c819a57b417a324a12f2c529b19a881640380c70aed98c51f7311e8826ff6bb378274f6c1aa8fff400bbf80d03bb59f86dd01cb0a365c0c096ee9f344beadc57
7
- data.tar.gz: aeb420b3b112c458546168f0d126c9b388895b5e511661a318827a5bdb39825f7d85d3fa747933263e146a2ef29f40c3dc266a48009b2d3ee07fdfa73105ec1b
6
+ metadata.gz: 5e4510dd3f118be6b9cda10aab0ce0bbc81a30886f269a7ac90f0328223d8a857b86ce24d79afb400df793482f0336f4704d68736ef49f640ef260c7f358b578
7
+ data.tar.gz: 59e81dfef384de7707585e2378d1b8f23cd557e9acab2f6a22f6c92d9c3032856620644daf0f42a163c9a9de7d58e944589e15fd37f6c81c7f7a410d6221fd74
data/CHANGELOG.rdoc CHANGED
@@ -3,12 +3,19 @@
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
+ * Add initializer to ensure Timeliness v0.4+ ambiguous date config is set
7
+ correctly when using `use_euro_formats` or `remove_use_formats'.
6
8
 
7
9
  Breaking Changes
8
10
  * Update Multiparameter extension to use ActiveRecord type classes with multiparameter handling
9
11
  which stores a hash of multiparamter values as the value before type cast, no longer a mushed datetime string
10
12
  * Removed all custom plugin attribute methods and method overrides in favour using ActiveModel type system
11
13
 
14
+ = 4.1.0 [2019-06-11]
15
+ * Relaxed Timeliness dependency version to >= 0.3.10 and < 1, which allows
16
+ version 0.4 with threadsafety fix for use_us_formats and use_euro_formats
17
+ hot switching in a request.
18
+
12
19
  = 4.0.2 [2016-01-07]
13
20
  * Fix undefine_generated_methods ivar guard setting to false
14
21
 
data/README.rdoc CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  == Description
7
7
 
8
- Complete validation of dates, times and datetimes for Rails 5.0.x and ActiveModel.
8
+ Complete validation of dates, times and datetimes for Rails 5.x and ActiveModel.
9
9
 
10
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].
11
11
 
@@ -8,11 +8,7 @@ gem "rspec-rails", "~> 3.7"
8
8
  gem "timecop"
9
9
  gem "byebug"
10
10
  gem "appraisal"
11
- gem "sqlite3"
11
+ gem "sqlite3", "~> 1.3.6"
12
12
  gem "nokogiri", "~> 1.8"
13
13
 
14
- group :active_record do
15
- gem "sqlite3-ruby", require: "sqlite3"
16
- end
17
-
18
14
  gemspec path: "../"
@@ -8,11 +8,7 @@ gem "rspec-rails", "~> 3.7"
8
8
  gem "timecop"
9
9
  gem "byebug"
10
10
  gem "appraisal"
11
- gem "sqlite3"
11
+ gem "sqlite3", "~> 1.3.6"
12
12
  gem "nokogiri", "~> 1.8"
13
13
 
14
- group :active_record do
15
- gem "sqlite3-ruby", require: "sqlite3"
16
- end
17
-
18
14
  gemspec path: "../"
@@ -8,11 +8,7 @@ gem "rspec-rails", "~> 3.7"
8
8
  gem "timecop"
9
9
  gem "byebug"
10
10
  gem "appraisal"
11
- gem "sqlite3"
11
+ gem "sqlite3", "~> 1.3.6"
12
12
  gem "nokogiri", "~> 1.8"
13
13
 
14
- group :active_record do
15
- gem "sqlite3-ruby", require: "sqlite3"
16
- end
17
-
18
14
  gemspec path: "../"
@@ -36,8 +36,8 @@ module ValidatesTimeliness
36
36
 
37
37
  # Shorthand time and date symbols for restrictions
38
38
  self.restriction_shorthand_symbols = {
39
- :now => lambda { Time.current },
40
- :today => lambda { Date.current }
39
+ now: proc { Time.current },
40
+ today: proc { Date.current }
41
41
  }
42
42
 
43
43
  # Use the plugin date/time parser which is stricter and extensible
@@ -11,7 +11,7 @@ module ValidatesTimeliness
11
11
  end
12
12
  end
13
13
 
14
- class ActiveRecord::Base
14
+ ActiveSupport.on_load(:active_record) do
15
15
  include ValidatesTimeliness::AttributeMethods
16
16
  include ValidatesTimeliness::ORM::ActiveRecord
17
17
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ValidatesTimeliness
2
- VERSION = '5.0.0.alpha4'
2
+ VERSION = '5.0.0.alpha5'
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -10,6 +10,8 @@ require 'timecop'
10
10
  require 'validates_timeliness'
11
11
  require 'validates_timeliness/orm/active_model'
12
12
 
13
+ require 'rails/railtie'
14
+
13
15
  require 'support/test_model'
14
16
  require 'support/model_helpers'
15
17
  require 'support/config_helper'
@@ -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
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: 5.0.0.alpha4
4
+ version: 5.0.0.alpha5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Meehan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-09 00:00:00.000000000 Z
11
+ date: 2019-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: timeliness
@@ -75,6 +75,7 @@ files:
75
75
  - spec/validates_timeliness/extensions/multiparameter_handler_spec.rb
76
76
  - spec/validates_timeliness/helper_methods_spec.rb
77
77
  - spec/validates_timeliness/orm/active_record_spec.rb
78
+ - spec/validates_timeliness/railtie_spec.rb
78
79
  - spec/validates_timeliness/validator/after_spec.rb
79
80
  - spec/validates_timeliness/validator/before_spec.rb
80
81
  - spec/validates_timeliness/validator/is_at_spec.rb
@@ -103,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
104
  version: 1.3.1
104
105
  requirements: []
105
106
  rubyforge_project:
106
- rubygems_version: 2.7.6
107
+ rubygems_version: 2.7.6.2
107
108
  signing_key:
108
109
  specification_version: 4
109
110
  summary: Date and time validation plugin for Rails which allows custom formats
@@ -119,6 +120,7 @@ test_files:
119
120
  - spec/validates_timeliness/extensions/multiparameter_handler_spec.rb
120
121
  - spec/validates_timeliness/helper_methods_spec.rb
121
122
  - spec/validates_timeliness/orm/active_record_spec.rb
123
+ - spec/validates_timeliness/railtie_spec.rb
122
124
  - spec/validates_timeliness/validator/after_spec.rb
123
125
  - spec/validates_timeliness/validator/before_spec.rb
124
126
  - spec/validates_timeliness/validator/is_at_spec.rb