activemodel 5.2.2.1 → 5.2.3.rc1
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/CHANGELOG.md +25 -0
- data/lib/active_model/gem_version.rb +2 -2
- data/lib/active_model/type/date.rb +2 -1
- data/lib/active_model/type/date_time.rb +1 -0
- data/lib/active_model/type/helpers.rb +1 -0
- data/lib/active_model/type/helpers/time_value.rb +0 -12
- data/lib/active_model/type/helpers/timezone.rb +19 -0
- data/lib/active_model/type/time.rb +5 -0
- data/lib/active_model/validations/numericality.rb +20 -11
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57fe827ff814dde112447074f27149b1b723e25ee1161210adcd46906b384222
|
4
|
+
data.tar.gz: 362da50ed52cdba8bfeb824673b37b0466cb92bb3ffafa70e6ede1daf27f8a47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed20115eaf44cc76db921bdd8339c96525751ab6285879a773d1aa0db7c9226e5b89c0b626d35bf50a41a51c23c2d9128270c2a908e845d521fae9634e612953
|
7
|
+
data.tar.gz: a4aa37d04da1aa165e945a587998dededb9197f96a57c7af5d289ebe45d873703a161d8595d91271bd997aa6433ef5ff05c9ba11f5b0feb2cac85a6751980db7
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,28 @@
|
|
1
|
+
## Rails 5.2.3.rc1 (March 21, 2019) ##
|
2
|
+
|
3
|
+
* Fix date value when casting a multiparameter date hash to not convert
|
4
|
+
from Gregorian date to Julian date.
|
5
|
+
|
6
|
+
Before:
|
7
|
+
|
8
|
+
Day.new({"day(1i)"=>"1", "day(2i)"=>"1", "day(3i)"=>"1"})
|
9
|
+
=> #<Day id: nil, day: "0001-01-03", created_at: nil, updated_at: nil>
|
10
|
+
|
11
|
+
After:
|
12
|
+
|
13
|
+
Day.new({"day(1i)"=>"1", "day(2i)"=>"1", "day(3i)"=>"1"})
|
14
|
+
=> #<Day id: nil, day: "0001-01-01", created_at: nil, updated_at: nil>
|
15
|
+
|
16
|
+
Fixes #28521.
|
17
|
+
|
18
|
+
*Sayan Chakraborty*
|
19
|
+
|
20
|
+
* Fix numericality equality validation of `BigDecimal` and `Float`
|
21
|
+
by casting to `BigDecimal` on both ends of the validation.
|
22
|
+
|
23
|
+
*Gannon McGibbon*
|
24
|
+
|
25
|
+
|
1
26
|
## Rails 5.2.2.1 (March 11, 2019) ##
|
2
27
|
|
3
28
|
* No changes.
|
@@ -3,6 +3,7 @@
|
|
3
3
|
module ActiveModel
|
4
4
|
module Type
|
5
5
|
class Date < Value # :nodoc:
|
6
|
+
include Helpers::Timezone
|
6
7
|
include Helpers::AcceptsMultiparameterTime.new
|
7
8
|
|
8
9
|
def type
|
@@ -49,7 +50,7 @@ module ActiveModel
|
|
49
50
|
|
50
51
|
def value_from_multiparameter_assignment(*)
|
51
52
|
time = super
|
52
|
-
time && time.
|
53
|
+
time && new_date(time.year, time.mon, time.mday)
|
53
54
|
end
|
54
55
|
end
|
55
56
|
end
|
@@ -21,18 +21,6 @@ module ActiveModel
|
|
21
21
|
value
|
22
22
|
end
|
23
23
|
|
24
|
-
def is_utc?
|
25
|
-
::Time.zone_default.nil? || ::Time.zone_default =~ "UTC"
|
26
|
-
end
|
27
|
-
|
28
|
-
def default_timezone
|
29
|
-
if is_utc?
|
30
|
-
:utc
|
31
|
-
else
|
32
|
-
:local
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
24
|
def apply_seconds_precision(value)
|
37
25
|
return value unless precision && value.respond_to?(:usec)
|
38
26
|
number_of_insignificant_digits = 6 - precision
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/core_ext/time/zones"
|
4
|
+
|
5
|
+
module ActiveModel
|
6
|
+
module Type
|
7
|
+
module Helpers # :nodoc: all
|
8
|
+
module Timezone
|
9
|
+
def is_utc?
|
10
|
+
::Time.zone_default.nil? || ::Time.zone_default =~ "UTC"
|
11
|
+
end
|
12
|
+
|
13
|
+
def default_timezone
|
14
|
+
is_utc? ? :utc : :local
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
module ActiveModel
|
4
4
|
module Type
|
5
5
|
class Time < Value # :nodoc:
|
6
|
+
include Helpers::Timezone
|
6
7
|
include Helpers::TimeValue
|
7
8
|
include Helpers::AcceptsMultiparameterTime.new(
|
8
9
|
defaults: { 1 => 1970, 2 => 1, 3 => 1, 4 => 0, 5 => 0 }
|
@@ -12,6 +13,10 @@ module ActiveModel
|
|
12
13
|
:time
|
13
14
|
end
|
14
15
|
|
16
|
+
def serialize(value)
|
17
|
+
super(cast(value))
|
18
|
+
end
|
19
|
+
|
15
20
|
def user_input_in_time_zone(value)
|
16
21
|
return unless value.present?
|
17
22
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "bigdecimal/util"
|
4
|
+
|
3
5
|
module ActiveModel
|
4
6
|
module Validations
|
5
7
|
class NumericalityValidator < EachValidator # :nodoc:
|
@@ -9,6 +11,8 @@ module ActiveModel
|
|
9
11
|
|
10
12
|
RESERVED_OPTIONS = CHECKS.keys + [:only_integer]
|
11
13
|
|
14
|
+
INTEGER_REGEX = /\A[+-]?\d+\z/
|
15
|
+
|
12
16
|
def check_validity!
|
13
17
|
keys = CHECKS.keys - [:odd, :even]
|
14
18
|
options.slice(*keys).each do |option, value|
|
@@ -49,11 +53,7 @@ module ActiveModel
|
|
49
53
|
return
|
50
54
|
end
|
51
55
|
|
52
|
-
|
53
|
-
value = raw_value
|
54
|
-
else
|
55
|
-
value = parse_raw_value_as_a_number(raw_value)
|
56
|
-
end
|
56
|
+
value = parse_as_number(raw_value)
|
57
57
|
|
58
58
|
options.slice(*CHECKS.keys).each do |option, option_value|
|
59
59
|
case option
|
@@ -69,6 +69,8 @@ module ActiveModel
|
|
69
69
|
option_value = record.send(option_value)
|
70
70
|
end
|
71
71
|
|
72
|
+
option_value = parse_as_number(option_value)
|
73
|
+
|
72
74
|
unless value.send(CHECKS[option], option_value)
|
73
75
|
record.errors.add(attr_name, option, filtered_options(value).merge!(count: option_value))
|
74
76
|
end
|
@@ -79,22 +81,29 @@ module ActiveModel
|
|
79
81
|
private
|
80
82
|
|
81
83
|
def is_number?(raw_value)
|
82
|
-
!
|
84
|
+
!parse_as_number(raw_value).nil?
|
83
85
|
rescue ArgumentError, TypeError
|
84
86
|
false
|
85
87
|
end
|
86
88
|
|
87
|
-
def
|
88
|
-
|
89
|
-
|
89
|
+
def parse_as_number(raw_value)
|
90
|
+
if raw_value.is_a?(Float)
|
91
|
+
raw_value.to_d
|
92
|
+
elsif raw_value.is_a?(Numeric)
|
93
|
+
raw_value
|
94
|
+
elsif is_integer?(raw_value)
|
95
|
+
raw_value.to_i
|
96
|
+
elsif !is_hexadecimal_literal?(raw_value)
|
97
|
+
Kernel.Float(raw_value).to_d
|
98
|
+
end
|
90
99
|
end
|
91
100
|
|
92
101
|
def is_integer?(raw_value)
|
93
|
-
|
102
|
+
INTEGER_REGEX === raw_value.to_s
|
94
103
|
end
|
95
104
|
|
96
105
|
def is_hexadecimal_literal?(raw_value)
|
97
|
-
/\A0[xX]/ === raw_value
|
106
|
+
/\A0[xX]/ === raw_value.to_s
|
98
107
|
end
|
99
108
|
|
100
109
|
def filtered_options(value)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemodel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.2.
|
4
|
+
version: 5.2.3.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 5.2.
|
19
|
+
version: 5.2.3.rc1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 5.2.
|
26
|
+
version: 5.2.3.rc1
|
27
27
|
description: A toolkit for building modeling frameworks like Active Record. Rich support
|
28
28
|
for attributes, callbacks, validations, serialization, internationalization, and
|
29
29
|
testing.
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- lib/active_model/type/helpers/mutable.rb
|
74
74
|
- lib/active_model/type/helpers/numeric.rb
|
75
75
|
- lib/active_model/type/helpers/time_value.rb
|
76
|
+
- lib/active_model/type/helpers/timezone.rb
|
76
77
|
- lib/active_model/type/immutable_string.rb
|
77
78
|
- lib/active_model/type/integer.rb
|
78
79
|
- lib/active_model/type/registry.rb
|
@@ -100,8 +101,8 @@ homepage: http://rubyonrails.org
|
|
100
101
|
licenses:
|
101
102
|
- MIT
|
102
103
|
metadata:
|
103
|
-
source_code_uri: https://github.com/rails/rails/tree/v5.2.
|
104
|
-
changelog_uri: https://github.com/rails/rails/blob/v5.2.
|
104
|
+
source_code_uri: https://github.com/rails/rails/tree/v5.2.3.rc1/activemodel
|
105
|
+
changelog_uri: https://github.com/rails/rails/blob/v5.2.3.rc1/activemodel/CHANGELOG.md
|
105
106
|
post_install_message:
|
106
107
|
rdoc_options: []
|
107
108
|
require_paths:
|
@@ -113,9 +114,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
114
|
version: 2.2.2
|
114
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
116
|
requirements:
|
116
|
-
- - "
|
117
|
+
- - ">"
|
117
118
|
- !ruby/object:Gem::Version
|
118
|
-
version:
|
119
|
+
version: 1.3.1
|
119
120
|
requirements: []
|
120
121
|
rubygems_version: 3.0.1
|
121
122
|
signing_key:
|