ndr_support 5.9.2 → 5.9.3

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: b92349bb86b84b6c5cc6c836613fadec463e824e87e6ccbe02fc07dd3f7049b5
4
- data.tar.gz: eb4312735ea0f25e517ec7b3d6676ab1b40c9ee64e36044b7b17f518cef0f592
3
+ metadata.gz: 4a2a7eee626500b24dda836864fbbe45061c73a01c1c0d8767084ef94feb4391
4
+ data.tar.gz: '084bd2b9c1d5d7dc13d45597ecd9d16c410d3653445af9790c1556da7e2d2f1d'
5
5
  SHA512:
6
- metadata.gz: 3d1edb198422ec9e566680943988f090762bd3fe2f254cb9237631a54ed0feb2e4dda45801574319e745487a11fee6f1540a5c7b5562c516d4b9e7a9004266cc
7
- data.tar.gz: d2dfa5bc36ece2a23b50d2406563604f6f5989a0706d7981382f9d6738e46cb89bfe3a4dfb7e1e0ab50b18971d8b07b2241d76e59bcf01f818da646898decf12
6
+ metadata.gz: 595af1c7799843cc6283cef5b5c77bf955f09c6d06bc316bf41e7f9fc0851639c9cb2f44f662c07b0b7e7b10a0b291ced307b9f1b109b5e1efe85fda2a018b40
7
+ data.tar.gz: 62651ee7d25752f68b9ff9ae197878b12003e0b0363b73b5bb2d48cb42624373f8ffa0d85fc61f5b0cc2f3c9026f22e0279b50fc94a829158a09a5ca03f1f34a
data/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  ## [Unreleased]
2
2
  * No unreleased changes
3
3
 
4
+ ## 5.9.3 / 2022-12-02
5
+ ## Fixed
6
+ * Support Rails 7.0
7
+
8
+ ## Changed
9
+ * Drop support for Rails 5.2
10
+
4
11
  ## 5.9.2 / 2022-11-17
5
12
  ## Fixed
6
13
  * Add extra 2023 Bank Holiday, and 2024 and 2025 Bank Holidays
data/code_safety.yml CHANGED
@@ -11,7 +11,7 @@ file safety:
11
11
  ".github/workflows/test.yml":
12
12
  comments:
13
13
  reviewed_by: brian.shand
14
- safe_revision: e91fab5ac8474b001ca3805c6cce8eefa6b49f2d
14
+ safe_revision: e977f8c0f8a5c6a1952bd1565b75e16850ef11e0
15
15
  ".gitignore":
16
16
  comments:
17
17
  reviewed_by: josh.pencheon
@@ -23,7 +23,7 @@ file safety:
23
23
  CHANGELOG.md:
24
24
  comments:
25
25
  reviewed_by: brian.shand
26
- safe_revision: bac214f4c93d8753268825408fc560171fac91c0
26
+ safe_revision: e977f8c0f8a5c6a1952bd1565b75e16850ef11e0
27
27
  CODE_OF_CONDUCT.md:
28
28
  comments:
29
29
  reviewed_by: timgentry
@@ -78,12 +78,12 @@ file safety:
78
78
  safe_revision: bac214f4c93d8753268825408fc560171fac91c0
79
79
  lib/ndr_support/date_and_time_extensions.rb:
80
80
  comments:
81
- reviewed_by: josh.pencheon
82
- safe_revision: c1158eccb843b637b4dd82815dc7c081f12b93e4
81
+ reviewed_by: brian.shand
82
+ safe_revision: e977f8c0f8a5c6a1952bd1565b75e16850ef11e0
83
83
  lib/ndr_support/daterange.rb:
84
84
  comments:
85
85
  reviewed_by: brian.shand
86
- safe_revision: 9d19593cc45a9f1724c4b34a1a05a5ff48003084
86
+ safe_revision: e977f8c0f8a5c6a1952bd1565b75e16850ef11e0
87
87
  lib/ndr_support/hash.rb:
88
88
  comments:
89
89
  reviewed_by: pauleves
@@ -111,15 +111,15 @@ file safety:
111
111
  lib/ndr_support/ourdate.rb:
112
112
  comments:
113
113
  reviewed_by: brian.shand
114
- safe_revision: 9d19593cc45a9f1724c4b34a1a05a5ff48003084
114
+ safe_revision: e977f8c0f8a5c6a1952bd1565b75e16850ef11e0
115
115
  lib/ndr_support/ourdate/build_datetime.rb:
116
116
  comments:
117
117
  reviewed_by: brian.shand
118
118
  safe_revision: 9d19593cc45a9f1724c4b34a1a05a5ff48003084
119
119
  lib/ndr_support/ourtime.rb:
120
120
  comments:
121
- reviewed_by: ollietulloch
122
- safe_revision: '09b3f97fb4c1afc88d0d070c39796b1f60c39d25'
121
+ reviewed_by: brian.shand
122
+ safe_revision: e977f8c0f8a5c6a1952bd1565b75e16850ef11e0
123
123
  lib/ndr_support/password.rb:
124
124
  comments: with input from brian.shand
125
125
  reviewed_by: josh.pencheon
@@ -175,7 +175,7 @@ file safety:
175
175
  lib/ndr_support/version.rb:
176
176
  comments:
177
177
  reviewed_by: brian.shand
178
- safe_revision: 8321c488b8a7342762ee8c322ce3ffd5b1a1a880
178
+ safe_revision: 3ccb4e78a657f33e80c10550ba8f25978cf548db
179
179
  lib/ndr_support/working_days.rb:
180
180
  comments:
181
181
  reviewed_by: josh.pencheon
@@ -187,7 +187,7 @@ file safety:
187
187
  ndr_support.gemspec:
188
188
  comments:
189
189
  reviewed_by: brian.shand
190
- safe_revision: e91fab5ac8474b001ca3805c6cce8eefa6b49f2d
190
+ safe_revision: e977f8c0f8a5c6a1952bd1565b75e16850ef11e0
191
191
  test/array_test.rb:
192
192
  comments:
193
193
  reviewed_by: timgentry
@@ -196,6 +196,10 @@ file safety:
196
196
  comments:
197
197
  reviewed_by: brian.shand
198
198
  safe_revision: bac214f4c93d8753268825408fc560171fac91c0
199
+ test/date_and_time_extensions_test.rb:
200
+ comments:
201
+ reviewed_by: brian.shand
202
+ safe_revision: e977f8c0f8a5c6a1952bd1565b75e16850ef11e0
199
203
  test/daterange_test.rb:
200
204
  comments:
201
205
  reviewed_by: ollietulloch
@@ -226,8 +230,8 @@ file safety:
226
230
  safe_revision: 50a4293953f9ae227823c390b069a3ed4825074c
227
231
  test/ourdate_test.rb:
228
232
  comments:
229
- reviewed_by: josh.pencheon
230
- safe_revision: 7c32f5a80c1fb7aaf6e850d4b0651a7b47640e15
233
+ reviewed_by: brian.shand
234
+ safe_revision: e977f8c0f8a5c6a1952bd1565b75e16850ef11e0
231
235
  test/ourtime_test.rb:
232
236
  comments:
233
237
  reviewed_by: brian.shand
@@ -15,6 +15,19 @@ class Date
15
15
  return in_time_zone.to_datetime if ActiveRecord::Base.default_timezone == :local
16
16
  orig_to_datetime
17
17
  end
18
+
19
+ alias orig_to_s to_s
20
+
21
+ # Rails 7 stops overriding to_s (without a format specification) (for performance on Ruby 3.1)
22
+ # cf. activesupport-7.0.4/lib/active_support/core_ext/date/deprecated_conversions.rb
23
+ # We keep overriding this for compatibility
24
+ def to_s(format = :default)
25
+ if format == :default
26
+ to_formatted_s(:default)
27
+ else
28
+ orig_to_s(format)
29
+ end
30
+ end
18
31
  end
19
32
 
20
33
  #-------------------------------------------------------------------------------
@@ -24,6 +37,55 @@ class Time
24
37
  def to_iso
25
38
  strftime('%Y-%m-%dT%H:%M:%S')
26
39
  end
40
+
41
+ alias orig_to_s to_s
42
+
43
+ # Rails 7 stops overriding to_s (without a format specification) (for performance on Ruby 3.1)
44
+ # cf. activesupport-7.0.4/lib/active_support/core_ext/date/deprecated_conversions.rb
45
+ # We keep overriding this for compatibility
46
+ def to_s(format = :default)
47
+ if format == :default
48
+ to_formatted_s(:default)
49
+ else
50
+ orig_to_s(format)
51
+ end
52
+ end
53
+ end
54
+
55
+ #-------------------------------------------------------------------------------
56
+
57
+ class DateTime
58
+ alias orig_to_s to_s
59
+
60
+ # Rails 7 stops overriding to_s (without a format specification) (for performance on Ruby 3.1)
61
+ # cf. activesupport-7.0.4/lib/active_support/core_ext/date/deprecated_conversions.rb
62
+ # We keep overriding this for compatibility
63
+ def to_s(format = :default)
64
+ if format == :default
65
+ to_formatted_s(:default)
66
+ else
67
+ orig_to_s(format)
68
+ end
69
+ end
70
+ end
71
+
72
+ #-------------------------------------------------------------------------------
73
+
74
+ module ActiveSupport
75
+ class TimeWithZone
76
+ alias orig_to_s to_s
77
+
78
+ # Rails 7 stops overriding to_s (without a format specification) (for performance on Ruby 3.1)
79
+ # cf. activesupport-7.0.4/lib/active_support/core_ext/date/deprecated_conversions.rb
80
+ # We keep overriding this for compatibility
81
+ def to_s(format = :default)
82
+ if format == :default
83
+ to_formatted_s(:default)
84
+ else
85
+ orig_to_s(format)
86
+ end
87
+ end
88
+ end
27
89
  end
28
90
 
29
91
  #-------------------------------------------------------------------------------
@@ -52,8 +114,8 @@ module NdrSupport
52
114
  def apply_date_patch!
53
115
  # Ensure we emit "yaml-formatted" string, instead of the revised default format.
54
116
  Psych::Visitors::YAMLTree.class_eval do
55
- def visit_Date o
56
- @emitter.scalar o.to_s(:yaml), nil, nil, true, false, Psych::Nodes::Scalar::ANY
117
+ def visit_Date(o)
118
+ @emitter.scalar o.to_formatted_s(:yaml), nil, nil, true, false, Psych::Nodes::Scalar::ANY
57
119
  end
58
120
  end
59
121
  end
@@ -56,7 +56,7 @@ class Daterange
56
56
  end
57
57
 
58
58
  # If we have a valid date range, return a string representation of it
59
- # TODO: possibly add support for to_s(format) e.g. to_s(:short)
59
+ # TODO: possibly add support for to_formatted_s(format) e.g. to_formatted_s(:short)
60
60
  def to_s
61
61
  return '' unless @date1 && @date2
62
62
  if @date1 == @date2 # single date
@@ -139,9 +139,9 @@ class Daterange
139
139
  def tidy_string_if_midnight(datetime)
140
140
  if datetime.hour == 0 && datetime.min == 0 && datetime.sec == 0
141
141
  # it's midnight
142
- datetime.to_date.to_s(:ui)
142
+ datetime.to_date.to_formatted_s(:ui)
143
143
  else
144
- return datetime.to_time.to_s(:ui)
144
+ datetime.to_time.to_formatted_s(:ui)
145
145
  end
146
146
  end
147
147
 
@@ -39,7 +39,7 @@ class Ourdate
39
39
  end
40
40
 
41
41
  def to_s
42
- @thedate ? @thedate.to_date.to_s(:ui) : ''
42
+ @thedate ? @thedate.to_date.to_formatted_s(:ui) : ''
43
43
  end
44
44
 
45
45
  def empty?
@@ -24,7 +24,7 @@ class Ourtime
24
24
  end
25
25
 
26
26
  def to_s
27
- @thetime ? @thetime.to_time.to_s(:ui) : ''
27
+ @thetime ? @thetime.to_time.to_formatted_s(:ui) : ''
28
28
  end
29
29
 
30
30
  def empty?
@@ -3,5 +3,5 @@
3
3
  # This defines the NdrSupport version. If you change it, rebuild and commit the gem.
4
4
  # Use "rake build" to build the gem, see rake -T for all bundler rake tasks.
5
5
  module NdrSupport
6
- VERSION = '5.9.2'
6
+ VERSION = '5.9.3'
7
7
  end
data/ndr_support.gemspec CHANGED
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'activerecord', '>= 5.2.0', '< 7'
22
- spec.add_dependency 'activesupport', '>= 5.2.0', '< 7'
21
+ spec.add_dependency 'activerecord', '>= 6.0.0', '< 7.1'
22
+ spec.add_dependency 'activesupport', '>= 6.0.0', '< 7.1'
23
23
 
24
24
  spec.add_development_dependency 'bundler'
25
25
  spec.add_development_dependency 'rake', '>= 12.3.3'
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  # Avoid std-lib minitest (which has different namespace)
30
30
  spec.add_development_dependency 'minitest', '>= 5.0.0'
31
- spec.add_development_dependency 'mocha', '~> 1.1'
31
+ spec.add_development_dependency 'mocha', '~> 2.0'
32
32
 
33
33
  spec.add_development_dependency 'ndr_dev_support', '~> 6.0.2'
34
34
 
@@ -0,0 +1,56 @@
1
+ require 'test_helper'
2
+
3
+ # This tests our various date and time class extensions
4
+ # Note that these will probably all need to be changed in a major bump of ndr_support
5
+ # once we've moved everything to Rails 7.
6
+ class DateAndTimeExtensionsTest < Minitest::Test
7
+ def test_date_to_s
8
+ d = Date.new(2000, 2, 1)
9
+ assert_equal '2000-02-01', d.to_default_s, 'Rails 7 default to_s'
10
+ assert_equal '01.02.2000', d.to_formatted_s(:default), 'Rails 6 default to_s'
11
+ assert_equal d.to_formatted_s(:default), d.to_s,
12
+ 'We plan to change default to_s behaviour in a major version bump'
13
+ end
14
+
15
+ def test_datetime_to_s
16
+ bst_datetime = DateTime.new(2014, 4, 1, 0, 0, 0, '+1')
17
+ assert_equal '2014-04-01T00:00:00+01:00', bst_datetime.to_default_s, 'Rails 7 default to_s'
18
+ assert_equal '01.04.2014', bst_datetime.to_formatted_s(:default), 'Rails 6 default to_s'
19
+ assert_equal bst_datetime.to_formatted_s(:default), bst_datetime.to_s,
20
+ 'We plan to change default to_s behaviour in a major version bump'
21
+
22
+ gmt_datetime = DateTime.new(2014, 3, 1, 0, 0, 0, '+0')
23
+ assert_equal '2014-03-01T00:00:00+00:00', gmt_datetime.to_default_s, 'Rails 7 default to_s'
24
+ assert_equal '01.03.2014', gmt_datetime.to_formatted_s(:default), 'Rails 6 default to_s'
25
+ assert_equal gmt_datetime.to_formatted_s(:default), gmt_datetime.to_s,
26
+ 'We plan to change default to_s behaviour in a major version bump'
27
+
28
+ datetime_with_hhmmss = DateTime.new(2014, 4, 1, 12, 35, 11, '+0')
29
+ assert_equal '2014-04-01T12:35:11+00:00', datetime_with_hhmmss.to_default_s,
30
+ 'Rails 7 default to_s'
31
+ assert_equal '01.04.2014 12:35', datetime_with_hhmmss.to_formatted_s(:default),
32
+ 'Rails 6 default to_s'
33
+ assert_equal datetime_with_hhmmss.to_formatted_s(:default), datetime_with_hhmmss.to_s,
34
+ 'We plan to change default to_s behaviour in a major version bump'
35
+ end
36
+
37
+ def test_time_to_s
38
+ time = Time.new(2014, 4, 1, 12, 35, 11.5, '+01:00')
39
+ assert_equal '2014-04-01 12:35:11 +0100', time.to_default_s, 'Rails 7 default to_s'
40
+ assert_equal '01.04.2014 12:35', time.to_formatted_s(:default), 'Rails 6 default to_s'
41
+ assert_equal time.to_formatted_s(:default), time.to_s,
42
+ 'We plan to change default to_s behaviour in a major version bump'
43
+ end
44
+
45
+ def test_time_with_zone_to_s
46
+ time_with_zone = Time.find_zone('Europe/London').local(2014, 4, 1, 12, 35, 11.5)
47
+ assert_equal 'BST', time_with_zone.zone
48
+ # Without ndr_support extensions, we'd expect "2014-04-01 12:35:11 +0100"
49
+ # but we have to trick the database into assuming all times are UTC to retain local time
50
+ assert_equal '2014-04-01 12:35:11 UTC', time_with_zone.to_default_s,
51
+ 'Rails 7 default to_s with our date and time formatting'
52
+ assert_equal '01.04.2014 12:35', time_with_zone.to_formatted_s(:default), 'Rails 6 default to_s'
53
+ assert_equal time_with_zone.to_formatted_s(:default), time_with_zone.to_s,
54
+ 'We plan to change default to_s behaviour in a major version bump'
55
+ end
56
+ end
data/test/ourdate_test.rb CHANGED
@@ -5,13 +5,14 @@ class OurdateTest < Minitest::Test
5
5
  def test_date_and_time
6
6
  d = Ourdate.build_datetime(2003, 11, 30)
7
7
  assert_equal '2003-11-30', d.to_iso
8
+ assert_equal '30.11.2003', d.to_formatted_s
8
9
  assert_equal '30.11.2003', d.to_s
9
10
  end
10
11
 
11
12
  def test_ourdate
12
13
  # Creating an Ourdate from a String
13
14
  od = Ourdate.new('01.02.2000')
14
- assert_equal Date.new(2000, 2, 1).to_s(:ui), od.to_s
15
+ assert_equal Date.new(2000, 2, 1).to_formatted_s(:ui), od.to_s
15
16
  assert_kind_of Date, od.thedate
16
17
  assert_equal '01.02.2000', od.thedate.to_s
17
18
  # Creating an Ourdate from a Date
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ndr_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.9.2
4
+ version: 5.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - NCRS Development Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-17 00:00:00.000000000 Z
11
+ date: 2022-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,40 +16,40 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 5.2.0
19
+ version: 6.0.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '7'
22
+ version: '7.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 5.2.0
29
+ version: 6.0.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '7'
32
+ version: '7.1'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: activesupport
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 5.2.0
39
+ version: 6.0.0
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '7'
42
+ version: '7.1'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 5.2.0
49
+ version: 6.0.0
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '7'
52
+ version: '7.1'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: bundler
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -98,14 +98,14 @@ dependencies:
98
98
  requirements:
99
99
  - - "~>"
100
100
  - !ruby/object:Gem::Version
101
- version: '1.1'
101
+ version: '2.0'
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - "~>"
107
107
  - !ruby/object:Gem::Version
108
- version: '1.1'
108
+ version: '2.0'
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: ndr_dev_support
111
111
  requirement: !ruby/object:Gem::Requirement
@@ -257,6 +257,7 @@ files:
257
257
  - ndr_support.gemspec
258
258
  - test/array_test.rb
259
259
  - test/concerns/working_days_test.rb
260
+ - test/date_and_time_extensions_test.rb
260
261
  - test/daterange_test.rb
261
262
  - test/hash_test.rb
262
263
  - test/integer/calculations_test.rb
@@ -305,6 +306,7 @@ summary: NDR Support library
305
306
  test_files:
306
307
  - test/array_test.rb
307
308
  - test/concerns/working_days_test.rb
309
+ - test/date_and_time_extensions_test.rb
308
310
  - test/daterange_test.rb
309
311
  - test/hash_test.rb
310
312
  - test/integer/calculations_test.rb