range_component_attributes 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af663d1e0876517c2c25f2ccef86b0ece2a663f940414638f56e8fc5bba6216e
4
- data.tar.gz: 8af0f5aeaa1965352971b335468a7275a511d035d4a98ddc7a3fa89418040311
3
+ metadata.gz: 2683ab9c013c74b63b298c02362c114ad292a59117086d23d80e56dbc08afe54
4
+ data.tar.gz: ffa8b1a768045f885b9032bd79e60bf7c8d8ac968d8a2a6e3d60d3c6fbfad50d
5
5
  SHA512:
6
- metadata.gz: ed3c0344ac9114093e163a73fcecf310a50314a237b3556e9a805f8e7079659cf2abdca0e7ac329dc50736af3dce16c74ee89dfb4c9d001cfe8f2e5d2e7f9cab
7
- data.tar.gz: 238402739c0743ff773b2ebce7832aa970594444a3ca2cfc82901316641e77c7a9920311fde2ba1d081b525757fe04613e8cb8d66b0788520c911681aef28920
6
+ metadata.gz: aac7a5932571680473895f8b65fee9d97cdbae9121cbff24c4c2432974d38060242681b768a82e34bb181a3e3c7f98def800025bf125f8b3277beaa215934734
7
+ data.tar.gz: 16da1fb0bd51aa1662691898ebbb61a962f42fd95d4fdc3964a1339d05c00216a0f883db909893013ab408d212a1d0ae2a17668f0e261a6ad5456b4a19420e94
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.5.1
1
+ 2.6.0
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.5.1
4
+ - 2.6.0
5
5
 
6
6
  addons:
7
7
  postgresql: "9.6"
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 1.1.0 (January 28, 2019)
2
+
3
+ * Add TimeConverter
4
+
1
5
  # 1.0.1 (September 27, 2018)
2
6
 
3
7
  * Fix update of range boundaries where new lower is greater than old upper incorrectly triggering crossed bounds error.
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.1)
12
- activesupport (= 5.2.1)
13
- activerecord (5.2.1)
14
- activemodel (= 5.2.1)
15
- activesupport (= 5.2.1)
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.1)
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.0.5)
27
- i18n (1.1.0)
26
+ concurrent-ruby (1.1.4)
27
+ i18n (1.5.3)
28
28
  concurrent-ruby (~> 1.0)
29
- method_source (0.9.0)
29
+ method_source (0.9.2)
30
30
  minitest (5.11.3)
31
- minitest-reporters (1.2.0)
31
+ minitest-reporters (1.3.6)
32
32
  ansi
33
33
  builder
34
34
  minitest (>= 5.0)
35
35
  ruby-progressbar
36
- pg (1.0.0)
37
- pry (0.11.3)
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.9.0)
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.16.2
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 endsg. `[1, 10]`
69
- becomes `[1,11)`. RangeComponentAttributes will handle this so the exact bound
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
@@ -25,6 +25,10 @@ module RangeComponentAttributes
25
25
  @exclude_end = exclude_end
26
26
  @crossed_bounds_message = crossed_bounds_message
27
27
 
28
+ @range = nil
29
+ @lower = nil
30
+ @upper = nil
31
+
28
32
  if range
29
33
  self.range = range
30
34
  else
@@ -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
@@ -1,3 +1,3 @@
1
1
  module RangeComponentAttributes
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -49,7 +49,9 @@ module RangeComponentAttributes
49
49
 
50
50
  mod = Module.new do
51
51
  define_method range_wrapper_name do
52
- instance_variable_get("@#{range_wrapper_name}") ||
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.1
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: 2018-09-27 00:00:00.000000000 Z
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
- rubyforge_project:
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