From 2dd2f2fb99099bd0bc6b7567a28acf37bf392ad4 Mon Sep 17 00:00:00 2001 From: Murilo Dal Ri Date: Tue, 13 Feb 2024 11:59:36 +0000 Subject: [PATCH 1/6] Update minimum required Ruby version We're adding support for Ruby 3.3 and dropping support for 3.0. The new minimum required version will be 3.1.4. For more info: https://docs.publishing.service.gov.uk/manual/publishing-a-ruby-gem.html#ruby-version-compatibility --- .ruby-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ruby-version b/.ruby-version index eca690e7..0aec50e6 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.0.5 +3.1.4 From 7a28a0c15ae096f6b440e804ab071bb0ceaa9efb Mon Sep 17 00:00:00 2001 From: Murilo Dal Ri Date: Tue, 13 Feb 2024 12:07:35 +0000 Subject: [PATCH 2/6] Update .gemspec file --- govspeak.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/govspeak.gemspec b/govspeak.gemspec index d29d03cb..380ff1ca 100644 --- a/govspeak.gemspec +++ b/govspeak.gemspec @@ -12,7 +12,7 @@ Gem::Specification.new do |s| s.summary = "Markup language for single domain" s.description = 'A set of extensions to markdown layered on top of the kramdown library for use in the UK Government Single Domain project' - s.required_ruby_version = ">= 3.0" + s.required_ruby_version = ">= 3.1.4" s.files = Dir[ "lib/**/*", From 88f63ff431820c2265873abd2fded4995134d356 Mon Sep 17 00:00:00 2001 From: Murilo Dal Ri Date: Tue, 13 Feb 2024 12:15:28 +0000 Subject: [PATCH 3/6] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f10fd899..00d0d300 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: fail-fast: false matrix: # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0' - ruby: ['3.0', 3.1, 3.2] + ruby: [3.1, 3.2, 3.3] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 83fee145e794b14af1ec901b6c63c4b76e180a37 Mon Sep 17 00:00:00 2001 From: Murilo Dal Ri Date: Tue, 13 Feb 2024 12:21:15 +0000 Subject: [PATCH 4/6] Remove comment about Ruby 3.0 --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 00d0d300..99c51f40 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,6 @@ jobs: strategy: fail-fast: false matrix: - # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0' ruby: [3.1, 3.2, 3.3] runs-on: ubuntu-latest steps: From 38ca0778fe136c745e0681bfd2528b9a52df440a Mon Sep 17 00:00:00 2001 From: Murilo Dal Ri Date: Tue, 13 Feb 2024 12:38:05 +0000 Subject: [PATCH 5/6] Update CHANGELOG.md Updates the CHANGELOG.md file to include the following changes: Drop support for Ruby 3.0. The minimum required Ruby version is now 3.1.4. Add support for Ruby 3.3 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e876ca86..23fc946c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## Unreleased + +* Drop support for Ruby 3.0. The minimum required Ruby version is now 3.1.4. +* Add support for Ruby 3.3. + ## 8.3.4 * Fix tables within call to action component ([#306](https://github.com/alphagov/govspeak/pull/306)) From 29ca33b10ca46603c1dbda92ba4464af69c71408 Mon Sep 17 00:00:00 2001 From: Callum Knights Date: Mon, 19 Feb 2024 15:42:06 +0000 Subject: [PATCH 6/6] Fix linting errors --- lib/govspeak.rb | 4 ++-- lib/govspeak/html_sanitizer.rb | 6 +++--- lib/govspeak/html_validator.rb | 2 +- lib/govspeak/post_processor.rb | 4 ++-- lib/govspeak/presenters/attachment_presenter.rb | 2 +- lib/govspeak/presenters/image_presenter.rb | 2 +- lib/govspeak/template_renderer.rb | 2 +- test/govspeak_attachment_link_test.rb | 2 +- test/govspeak_attachment_test.rb | 2 +- test/govspeak_attachments_image_test.rb | 2 +- test/govspeak_attachments_inline_test.rb | 2 +- test/govspeak_test_helper.rb | 2 +- 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/govspeak.rb b/lib/govspeak.rb index 0cd2882c..0f75512a 100644 --- a/lib/govspeak.rb +++ b/lib/govspeak.rb @@ -98,7 +98,7 @@ def structured_headers end def extracted_links(website_root: nil) - Govspeak::LinkExtractor.new(self, website_root: website_root).call + Govspeak::LinkExtractor.new(self, website_root:).call end def extract_contact_content_ids @@ -310,7 +310,7 @@ def render_image(image) extension("numbered list", /^[ \t]*((s\d+\.\s.*(?:\n|$))+)/) do |body| body.gsub!(/s(\d+)\.\s(.*)(?:\n|$)/) do - "
  • #{Govspeak::Document.new(Regexp.last_match(2).strip, attachments: attachments).to_html}
  • \n" + "
  • #{Govspeak::Document.new(Regexp.last_match(2).strip, attachments:).to_html}
  • \n" end %(
      \n#{body}
    ) end diff --git a/lib/govspeak/html_sanitizer.rb b/lib/govspeak/html_sanitizer.rb index 27c06aed..0c2626ba 100644 --- a/lib/govspeak/html_sanitizer.rb +++ b/lib/govspeak/html_sanitizer.rb @@ -34,8 +34,8 @@ def sanitize(allowed_elements: []) # currently does – i.e. to return Sanitize config without any transformers. # e.g. https://github.com/alphagov/hmrc-manuals-api/blob/4a83f78d0bb839520155623fd9b63b3b12a3b13a/app/validators/no_dangerous_html_in_text_fields_validator.rb#L44 config_with_transformers = Sanitize::Config.merge( - sanitize_config(allowed_elements: allowed_elements), - transformers: transformers, + sanitize_config(allowed_elements:), + transformers:, ) Sanitize.clean(@dirty_html, config_with_transformers) @@ -48,7 +48,7 @@ def sanitize_config(allowed_elements: []) Sanitize::Config.merge( Sanitize::Config::RELAXED, - elements: elements, + elements:, attributes: { # We purposefully disable style attributes which Sanitize::Config::RELAXED allows :all => Sanitize::Config::RELAXED[:attributes][:all] + %w[role aria-label] - %w[style], diff --git a/lib/govspeak/html_validator.rb b/lib/govspeak/html_validator.rb index 6b975183..bec2d368 100644 --- a/lib/govspeak/html_validator.rb +++ b/lib/govspeak/html_validator.rb @@ -26,7 +26,7 @@ def normalise_html(html) def govspeak_to_html(sanitize:) Govspeak::Document.new( govspeak_string, - sanitize: sanitize, + sanitize:, allowed_image_hosts: @allowed_image_hosts, ).to_html end diff --git a/lib/govspeak/post_processor.rb b/lib/govspeak/post_processor.rb index 1da22de5..76594ff0 100644 --- a/lib/govspeak/post_processor.rb +++ b/lib/govspeak/post_processor.rb @@ -67,7 +67,7 @@ def self.extension(title, &block) attachment_html = GovukPublishingComponents.render( "govuk_publishing_components/components/attachment", - attachment: attachment, + attachment:, margin_bottom: 6, locale: govspeak_document.locale, ) @@ -86,7 +86,7 @@ def self.extension(title, &block) attachment_html = GovukPublishingComponents.render( "govuk_publishing_components/components/attachment_link", - attachment: attachment, + attachment:, locale: govspeak_document.locale, ) el.swap(attachment_html) diff --git a/lib/govspeak/presenters/attachment_presenter.rb b/lib/govspeak/presenters/attachment_presenter.rb index e885bfa1..9606c153 100644 --- a/lib/govspeak/presenters/attachment_presenter.rb +++ b/lib/govspeak/presenters/attachment_presenter.rb @@ -51,7 +51,7 @@ def attachment_attributes MS_POWERPOINT_PRESENTATION_HUMANIZED_CONTENT_TYPE = "MS Powerpoint Presentation".freeze def file_abbr_tag(abbr, title) - content_tag(:abbr, abbr, title: title) + content_tag(:abbr, abbr, title:) end def humanized_content_type(file_extension) diff --git a/lib/govspeak/presenters/image_presenter.rb b/lib/govspeak/presenters/image_presenter.rb index b9433751..571bf3a1 100644 --- a/lib/govspeak/presenters/image_presenter.rb +++ b/lib/govspeak/presenters/image_presenter.rb @@ -34,7 +34,7 @@ def figcaption_html lines = [] lines << "
    " lines << %(

    #{caption}

    ) if caption.present? - lines << %(

    #{I18n.t('govspeak.image.figure.credit', credit: credit)}

    ) if credit.present? + lines << %(

    #{I18n.t('govspeak.image.figure.credit', credit:)}

    ) if credit.present? lines << "
    " lines.join end diff --git a/lib/govspeak/template_renderer.rb b/lib/govspeak/template_renderer.rb index 7d517b7d..6acfb58a 100644 --- a/lib/govspeak/template_renderer.rb +++ b/lib/govspeak/template_renderer.rb @@ -17,7 +17,7 @@ def render(locals) def t(*args) options = args.last.is_a?(Hash) ? args.last.dup : {} key = args.shift - I18n.t!(key, **options.merge(locale: locale)) + I18n.t!(key, **options.merge(locale:)) end def format_with_html_line_breaks(string) diff --git a/test/govspeak_attachment_link_test.rb b/test/govspeak_attachment_link_test.rb index 4205613c..1533b6f4 100644 --- a/test/govspeak_attachment_link_test.rb +++ b/test/govspeak_attachment_link_test.rb @@ -2,7 +2,7 @@ class GovspeakAttachmentLinkTest < Minitest::Test def render_govspeak(govspeak, attachments = []) - Govspeak::Document.new(govspeak, attachments: attachments).to_html + Govspeak::Document.new(govspeak, attachments:).to_html end test "renders an empty string for attachment link that is not found" do diff --git a/test/govspeak_attachment_test.rb b/test/govspeak_attachment_test.rb index ae11412d..12cc06cf 100644 --- a/test/govspeak_attachment_test.rb +++ b/test/govspeak_attachment_test.rb @@ -2,7 +2,7 @@ class GovspeakAttachmentTest < Minitest::Test def render_govspeak(govspeak, attachments = []) - Govspeak::Document.new(govspeak, attachments: attachments).to_html + Govspeak::Document.new(govspeak, attachments:).to_html end test "renders an empty string for attachment link that is not found" do diff --git a/test/govspeak_attachments_image_test.rb b/test/govspeak_attachments_image_test.rb index 699b7bef..b4b248d7 100644 --- a/test/govspeak_attachments_image_test.rb +++ b/test/govspeak_attachments_image_test.rb @@ -11,7 +11,7 @@ def build_attachment(args = {}) end def render_govspeak(govspeak, attachments = []) - Govspeak::Document.new(govspeak, attachments: attachments).to_html + Govspeak::Document.new(govspeak, attachments:).to_html end def compress_html(html) diff --git a/test/govspeak_attachments_inline_test.rb b/test/govspeak_attachments_inline_test.rb index 587ff468..a97483b2 100644 --- a/test/govspeak_attachments_inline_test.rb +++ b/test/govspeak_attachments_inline_test.rb @@ -11,7 +11,7 @@ def build_attachment(args = {}) end def render_govspeak(govspeak, attachments = []) - Govspeak::Document.new(govspeak, attachments: attachments).to_html + Govspeak::Document.new(govspeak, attachments:).to_html end test "renders an empty string for an inline attachment not found" do diff --git a/test/govspeak_test_helper.rb b/test/govspeak_test_helper.rb index 5dc3cdfe..9ae5e42b 100644 --- a/test/govspeak_test_helper.rb +++ b/test/govspeak_test_helper.rb @@ -55,7 +55,7 @@ def show_linenumbers(text) lines = text.split "\n" digits = Math.log10(lines.size + 2).ceil lines.map - .with_index { |line, i| sprintf("%#{digits}d: %s", number: i + 1, line: line) } + .with_index { |line, i| sprintf("%#{digits}d: %s", number: i + 1, line:) } .join("\n") end end