Skip to content

Commit cb40689

Browse files
committed
Support Ruby 3.4. Drop support for Rails 7.0, Ruby 3.1, 3.2
1 parent 87ce89c commit cb40689

8 files changed

Lines changed: 28 additions & 45 deletions

File tree

.github/workflows/test.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,19 @@ on: [push]
55
jobs:
66
test:
77
strategy:
8+
fail-fast: false
89
matrix:
910
ruby-version:
10-
- '3.0'
11-
- '3.1'
1211
- '3.2'
1312
- '3.3'
13+
- '3.4'
1414
gemfile:
15-
- gemfiles/Gemfile.rails70
1615
- gemfiles/Gemfile.rails71
1716
- gemfiles/Gemfile.rails72
1817
- gemfiles/Gemfile.rails80
1918
exclude:
20-
# rails 7.2 requires ruby >= 3.1
21-
# https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html
22-
- ruby-version: '3.0'
23-
gemfile: 'gemfiles/Gemfile.rails72'
2419
# rails 8.0 requires ruby >= 3.2
2520
# https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html
26-
- ruby-version: '3.0'
27-
gemfile: 'gemfiles/Gemfile.rails80'
2821
- ruby-version: '3.1'
2922
gemfile: 'gemfiles/Gemfile.rails80'
3023

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Exclude unneeded files from gem package
44
* Add 2027 bank holidays
55
* Replace Public Health England naming with NHS England
6+
* Support Ruby 3.4. Drop support for Rails 7.0, Ruby 3.0, 3.1
67

78
## 5.10.4 / 2024-11-13
89
### Added

gemfiles/Gemfile.rails70

Lines changed: 0 additions & 9 deletions
This file was deleted.

lib/ndr_support/string/clean_methodable.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ def clean_roman5
125125
end
126126

127127
def clean_tnmcategory
128-
sub!(/\A[tnm]/i, '')
129-
if self =~ /\Ax\z/i
130-
upcase
128+
without_prefix = sub(/\A[tnm]/i, '')
129+
if without_prefix =~ /\Ax\z/i
130+
without_prefix.upcase
131131
else
132-
downcase
132+
without_prefix.downcase
133133
end
134134
end
135135

ndr_support.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ Gem::Specification.new do |spec|
2020
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
2121
spec.require_paths = ['lib']
2222

23-
spec.add_dependency 'activerecord', '>= 7.0', '< 8.1'
24-
spec.add_dependency 'activesupport', '>= 7.0', '< 8.1'
23+
spec.add_dependency 'activerecord', '>= 7.1', '< 8.1'
24+
spec.add_dependency 'activesupport', '>= 7.1', '< 8.1'
2525

2626
spec.add_development_dependency 'bundler'
2727
spec.add_development_dependency 'rake', '>= 12.3.3'
2828

29-
spec.required_ruby_version = '>= 3.0'
29+
spec.required_ruby_version = '>= 3.2'
3030

3131
# Avoid std-lib minitest (which has different namespace)
3232
spec.add_development_dependency 'minitest', '>= 5.0.0'

test/utf8_encoding/control_characters_test.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ControlCharactersTest < Minitest::Test
2323
end
2424

2525
test 'escape_control_chars! with harmless string' do
26-
string = 'null \x00 characters suck'
26+
string = +'null \x00 characters suck'
2727
expected = 'null \x00 characters suck'
2828
actual = escape_control_chars!(string)
2929

@@ -41,7 +41,7 @@ class ControlCharactersTest < Minitest::Test
4141
end
4242

4343
test 'escape_control_chars! with unprintable control characters' do
44-
string = "null \x00 characters suck"
44+
string = +"null \x00 characters suck"
4545
expected = 'null 0x00 characters suck'
4646
actual = escape_control_chars!(string)
4747

@@ -50,24 +50,24 @@ class ControlCharactersTest < Minitest::Test
5050
end
5151

5252
test 'escape_control_chars! with printable control characters' do
53-
string = "null \x00 characters \r\n really \t suck \x07\x07\x07"
53+
string = +"null \x00 characters \r\n really \t suck \x07\x07\x07"
5454
expected = "null 0x00 characters \r\n really \t suck 0x070x070x07" # ring ring ring
5555

5656
assert_equal expected, escape_control_chars!(string)
5757
end
5858

5959
test 'escape_control_chars_in_object! with array' do
60-
array = %W( hello\tcruel \x00 world!\n \x07 )
61-
expected = %W( hello\tcruel 0x00 world!\n 0x07 )
60+
array = %W[hello\tcruel \x00 world!\n \x07].collect(&:dup)
61+
expected = %W[hello\tcruel 0x00 world!\n 0x07]
6262
actual = escape_control_chars_in_object!(array)
6363

6464
assert_equal expected, actual
6565
assert_equal array.object_id, actual.object_id
6666
end
6767

6868
test 'escape_control_chars_in_object! with hash' do
69-
hash = { :a => "hello\tcruel", :b => "\x00", :c => "world!\n", :d => "\x07" }
70-
expected = { :a => "hello\tcruel", :b => '0x00', :c => "world!\n", :d => '0x07' }
69+
hash = { a: +"hello\tcruel", b: +"\x00", c: +"world!\n", d: +"\x07" }
70+
expected = { a: "hello\tcruel", b: '0x00', c: "world!\n", d: '0x07' }
7171
actual = escape_control_chars_in_object!(hash)
7272

7373
assert_equal expected, actual

test/utf8_encoding_test.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
require 'test_helper'
42

53
class Utf8EncodingTest < Minitest::Test
@@ -14,7 +12,7 @@ class Utf8EncodingTest < Minitest::Test
1412
end
1513

1614
test 'ensure_utf8! should return the same string' do
17-
string1 = 'hello'
15+
string1 = +'hello'
1816
string2 = ensure_utf8!(string1)
1917

2018
assert string1.object_id == string2.object_id
@@ -68,22 +66,22 @@ class Utf8EncodingTest < Minitest::Test
6866
end
6967

7068
test 'coerce_utf8! should return the same string' do
71-
string1 = 'hello'
69+
string1 = +'hello'
7270
string2 = coerce_utf8!(string1)
7371

7472
assert string1.object_id == string2.object_id
7573
end
7674

7775
test 'ensure_utf8 should convert low bytes to UTF-8 if possible' do
78-
string1 = 'hello'.force_encoding('Windows-1252')
76+
string1 = (+'hello').force_encoding('Windows-1252')
7977
string2 = ensure_utf8!(string1)
8078

8179
assert_equal string1, string2
8280
assert_equal 'UTF-8', string2.encoding.name
8381
end
8482

8583
test 'ensure_utf8 should convert high bytes to UTF-8 if possible' do
86-
string1 = "dash \x96 dash".force_encoding('Windows-1252')
84+
string1 = (+"dash \x96 dash").force_encoding('Windows-1252')
8785
assert_equal 11, string1.bytes.to_a.length
8886
assert_equal 11, string1.chars.to_a.length
8987

test/yaml/serialization_test.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class SerializationTest < Minitest::Test
1111
test 'should support aliases correctly' do
1212
x = { 'c' => 5 }
1313
hash = { 'a' => x, 'b' => x }
14-
hash_yaml = "---\na: &1\n c: 5\nb: *1\n"
14+
hash_yaml = +"---\na: &1\n c: 5\nb: *1\n"
1515
assert_equal hash, load_yaml(hash_yaml), 'Deserialising known YAML with an alias'
1616
assert_equal hash, load_yaml(dump_yaml(hash)), 'Deserialising a structure with repeated objects'
1717
end
@@ -22,24 +22,24 @@ class SerializationTest < Minitest::Test
2222

2323
test 'should handle binary yaml with control chars' do
2424
# irb> "\xC2\xA1null \x00 characters \r\n suck!".to_yaml
25-
yaml = "--- !binary |-\n wqFudWxsIAAgY2hhcmFjdGVycyANCiBzdWNrIQ==\n"
25+
yaml = +"--- !binary |-\n wqFudWxsIAAgY2hhcmFjdGVycyANCiBzdWNrIQ==\n"
2626
assert_equal "¡null 0x00 characters \r\n suck!", load_yaml(yaml)
2727

2828
# irb> {fulltext: "\xC2\xA1null \x00 characters \r\n suck!"}.to_yaml
29-
yamled_hash = "---\n:fulltext: !binary |-\n wqFudWxsIAAgY2hhcmFjdGVycyANCiBzdWNrIQ==\n"
29+
yamled_hash = +"---\n:fulltext: !binary |-\n wqFudWxsIAAgY2hhcmFjdGVycyANCiBzdWNrIQ==\n"
3030
assert_equal({ :fulltext => "¡null 0x00 characters \r\n suck!" }, load_yaml(yamled_hash))
3131
end
3232

3333
# Psych doesn't always base64-encode control characters:
3434
test 'should handle non-binary yaml with control chars' do
3535
#irb> Psych.dump("control \x01 char \n whoops!")
36-
chr_1_yaml = "--- ! \"control \\x01 char \\n whoops!\"\n"
36+
chr_1_yaml = +"--- ! \"control \\x01 char \\n whoops!\"\n"
3737
assert_equal "control 0x01 char \n whoops!", load_yaml(chr_1_yaml)
3838
end
3939

4040
test 'should handle non-binary yaml with escaped things that look like control chars' do
4141
# irb> Psych.dump(['\\x01 \\xAF \\\\xAF', "\x01 \\\x01 \x01\\\x01"])
42-
escaped_yaml = "---\n- \"\\\\x01 \\\\xAF \\\\\\\\xAF\"\n- \"\\x01 \\\\\\x01 \\x01\\\\\\x01\"\n"
42+
escaped_yaml = +"---\n- \"\\\\x01 \\\\xAF \\\\\\\\xAF\"\n- \"\\x01 \\\\\\x01 \\x01\\\\\\x01\"\n"
4343
assert_equal ['\\x01 \\xAF \\\\xAF', '0x01 \\0x01 0x01\\0x01'], load_yaml(escaped_yaml)
4444
end
4545

@@ -166,7 +166,7 @@ def assert_datetimes_with_zones
166166
end
167167

168168
def assert_syck_1_8_yaml_loads_correctly
169-
yaml = "--- \nname: Dr. Doctor\000\000\000 \ndiagnosis: \"CIN 1 \\xE2\\x80\\x93 CIN 2\"\n"
169+
yaml = +"--- \nname: Dr. Doctor\000\000\000 \ndiagnosis: \"CIN 1 \\xE2\\x80\\x93 CIN 2\"\n"
170170
hash = load_yaml(yaml)
171171

172172
# The null chars should be escaped:
@@ -187,7 +187,7 @@ def assert_syck_1_8_handles_encoding(hash)
187187

188188
def assert_yaml_coercion_behaviour
189189
# UTF-8, with an unmappable byte too:
190-
yaml = "---\nfulltextreport: \"Here is \\xE2\\x80\\x93 a weird \\x9D char\"\n"
190+
yaml = +"---\nfulltextreport: \"Here is \\xE2\\x80\\x93 a weird \\x9D char\"\n"
191191

192192
# By default, we'd expect the (serialised) \x9D
193193
assert_raises(UTF8Encoding::UTF8CoercionError) { load_yaml(yaml) }

0 commit comments

Comments
 (0)