Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update minimum required Ruby version #310

Merged
merged 6 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ 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.0', 3.1, 3.2]
ruby: [3.1, 3.2, 3.3]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.5
3.1.4
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
2 changes: 1 addition & 1 deletion govspeak.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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/**/*",
Expand Down
4 changes: 2 additions & 2 deletions lib/govspeak.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
"<li>#{Govspeak::Document.new(Regexp.last_match(2).strip, attachments: attachments).to_html}</li>\n"
"<li>#{Govspeak::Document.new(Regexp.last_match(2).strip, attachments:).to_html}</li>\n"
end
%(<ol class="steps">\n#{body}</ol>)
end
Expand Down
6 changes: 3 additions & 3 deletions lib/govspeak/html_sanitizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion lib/govspeak/html_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/govspeak/post_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/govspeak/presenters/attachment_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/govspeak/presenters/image_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def figcaption_html
lines = []
lines << "<figcaption>"
lines << %(<p>#{caption}</p>) if caption.present?
lines << %(<p>#{I18n.t('govspeak.image.figure.credit', credit: credit)}</p>) if credit.present?
lines << %(<p>#{I18n.t('govspeak.image.figure.credit', credit:)}</p>) if credit.present?
lines << "</figcaption>"
lines.join
end
Expand Down
2 changes: 1 addition & 1 deletion lib/govspeak/template_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/govspeak_attachment_link_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/govspeak_attachment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/govspeak_attachments_image_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/govspeak_attachments_inline_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/govspeak_test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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("%<number>#{digits}d: %<line>s", number: i + 1, line: line) }
.with_index { |line, i| sprintf("%<number>#{digits}d: %<line>s", number: i + 1, line:) }
.join("\n")
end
end
Expand Down
Loading