range_component_attributes 1.0.1 → 1.1.0
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/.ruby-version +1 -1
- data/.travis.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +14 -14
- data/README.md +3 -3
- data/lib/range_component_attributes/range_wrapper.rb +4 -0
- data/lib/range_component_attributes/type_conversion.rb +13 -0
- data/lib/range_component_attributes/version.rb +1 -1
- data/lib/range_component_attributes.rb +4 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2683ab9c013c74b63b298c02362c114ad292a59117086d23d80e56dbc08afe54
|
4
|
+
data.tar.gz: ffa8b1a768045f885b9032bd79e60bf7c8d8ac968d8a2a6e3d60d3c6fbfad50d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aac7a5932571680473895f8b65fee9d97cdbae9121cbff24c4c2432974d38060242681b768a82e34bb181a3e3c7f98def800025bf125f8b3277beaa215934734
|
7
|
+
data.tar.gz: 16da1fb0bd51aa1662691898ebbb61a962f42fd95d4fdc3964a1339d05c00216a0f883db909893013ab408d212a1d0ae2a17668f0e261a6ad5456b4a19420e94
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.0
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -8,13 +8,13 @@ PATH
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activemodel (5.2.
|
12
|
-
activesupport (= 5.2.
|
13
|
-
activerecord (5.2.
|
14
|
-
activemodel (= 5.2.
|
15
|
-
activesupport (= 5.2.
|
11
|
+
activemodel (5.2.2)
|
12
|
+
activesupport (= 5.2.2)
|
13
|
+
activerecord (5.2.2)
|
14
|
+
activemodel (= 5.2.2)
|
15
|
+
activesupport (= 5.2.2)
|
16
16
|
arel (>= 9.0)
|
17
|
-
activesupport (5.2.
|
17
|
+
activesupport (5.2.2)
|
18
18
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
19
|
i18n (>= 0.7, < 2)
|
20
20
|
minitest (~> 5.1)
|
@@ -23,22 +23,22 @@ GEM
|
|
23
23
|
arel (9.0.0)
|
24
24
|
builder (3.2.3)
|
25
25
|
coderay (1.1.2)
|
26
|
-
concurrent-ruby (1.
|
27
|
-
i18n (1.
|
26
|
+
concurrent-ruby (1.1.4)
|
27
|
+
i18n (1.5.3)
|
28
28
|
concurrent-ruby (~> 1.0)
|
29
|
-
method_source (0.9.
|
29
|
+
method_source (0.9.2)
|
30
30
|
minitest (5.11.3)
|
31
|
-
minitest-reporters (1.
|
31
|
+
minitest-reporters (1.3.6)
|
32
32
|
ansi
|
33
33
|
builder
|
34
34
|
minitest (>= 5.0)
|
35
35
|
ruby-progressbar
|
36
|
-
pg (1.
|
37
|
-
pry (0.
|
36
|
+
pg (1.1.4)
|
37
|
+
pry (0.12.2)
|
38
38
|
coderay (~> 1.1.0)
|
39
39
|
method_source (~> 0.9.0)
|
40
40
|
rake (10.5.0)
|
41
|
-
ruby-progressbar (1.
|
41
|
+
ruby-progressbar (1.10.0)
|
42
42
|
thread_safe (0.3.6)
|
43
43
|
tzinfo (1.2.5)
|
44
44
|
thread_safe (~> 0.1)
|
@@ -56,4 +56,4 @@ DEPENDENCIES
|
|
56
56
|
range_component_attributes!
|
57
57
|
|
58
58
|
BUNDLED WITH
|
59
|
-
1.
|
59
|
+
1.17.2
|
data/README.md
CHANGED
@@ -65,9 +65,9 @@ Float::INFINITY.
|
|
65
65
|
|
66
66
|
`exclude_end` controls whether the end is exclusive or not. Ranges are
|
67
67
|
automatically normalized to this type. This is useful because PostgreSQL
|
68
|
-
automatically normalizes ranges of discrete values to exclusive
|
69
|
-
becomes `[1,11)`. RangeComponentAttributes will handle this so the exact
|
70
|
-
values persist even when PostgreSQL has changed them.
|
68
|
+
automatically normalizes ranges of discrete values to exclusive ends. e.g. `[1,
|
69
|
+
10]` becomes `[1,11)`. RangeComponentAttributes will handle this so the exact
|
70
|
+
bound values persist even when PostgreSQL has changed them.
|
71
71
|
|
72
72
|
Validations are automatically added that create an error if an assignment to
|
73
73
|
bounds attribute fails due to a type conversion error. In addition, a validation
|
@@ -61,4 +61,17 @@ module RangeComponentAttributes
|
|
61
61
|
raise TypeConversionError.new(e, "date")
|
62
62
|
end
|
63
63
|
end
|
64
|
+
|
65
|
+
class TimeConverter < BaseConverter
|
66
|
+
def call(value)
|
67
|
+
return @blank_value if value.blank?
|
68
|
+
return value if value == Float::INFINITY
|
69
|
+
return value if value.kind_of? Time
|
70
|
+
time = Time.zone.parse value.to_s
|
71
|
+
raise TypeConversionError.new(nil, "time") unless time
|
72
|
+
time
|
73
|
+
rescue StandardError => e
|
74
|
+
raise TypeConversionError.new(e, "time")
|
75
|
+
end
|
76
|
+
end
|
64
77
|
end
|
@@ -49,7 +49,9 @@ module RangeComponentAttributes
|
|
49
49
|
|
50
50
|
mod = Module.new do
|
51
51
|
define_method range_wrapper_name do
|
52
|
-
|
52
|
+
if instance_variable_defined?("@#{range_wrapper_name}")
|
53
|
+
instance_variable_get("@#{range_wrapper_name}")
|
54
|
+
else
|
53
55
|
instance_variable_set("@#{range_wrapper_name}",
|
54
56
|
RangeWrapper.new(
|
55
57
|
lower_type_converter: lower_type_converter,
|
@@ -59,6 +61,7 @@ module RangeComponentAttributes
|
|
59
61
|
crossed_bounds_message: crossed_bounds_message
|
60
62
|
)
|
61
63
|
)
|
64
|
+
end
|
62
65
|
end
|
63
66
|
|
64
67
|
define_method "#{lower_name}" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: range_component_attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Christensen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -164,8 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
164
|
- !ruby/object:Gem::Version
|
165
165
|
version: '0'
|
166
166
|
requirements: []
|
167
|
-
|
168
|
-
rubygems_version: 2.7.6
|
167
|
+
rubygems_version: 3.0.1
|
169
168
|
signing_key:
|
170
169
|
specification_version: 4
|
171
170
|
summary: Splits database ranges into lower and upper attributes in ActiveRecord
|