From c88105425fff39db74691668d82e7026eeea0936 Mon Sep 17 00:00:00 2001 From: Schneems Date: Mon, 6 May 2024 10:13:18 -0500 Subject: [PATCH] Drop Ruby 2.7 and 3.0 support --- .github/workflows/ci.yml | 8 ++++---- .standard.yml | 2 +- CHANGELOG.md | 1 + lib/rundoc/code_command.rb | 1 - lib/rundoc/code_command/print/erb.rb | 8 +++----- lib/rundoc/code_command/website/driver.rb | 2 +- lib/rundoc/code_section.rb | 6 +++--- lib/rundoc/peg_parser.rb | 2 +- test/integration/print_test.rb | 7 +++---- test/rundoc/code_commands/print_test.rb | 20 ++++++++++---------- test/rundoc/code_section_test.rb | 1 - test/rundoc/parser_test.rb | 1 - 12 files changed, 27 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37126ed..3bc19fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,9 +11,9 @@ jobs: fail-fast: false matrix: ruby: - - 2.7 - - '3.0' - 3.1 + - 3.2 + - 3.3 - head steps: - name: Checkout code @@ -33,7 +33,7 @@ jobs: fail-fast: false matrix: ruby: - - 2.7 + - 3.3 - head steps: - name: Checkout code @@ -44,5 +44,5 @@ jobs: ruby-version: ${{ matrix.ruby }} bundler-cache: true - name: lint - run: bundle exec standardrb + run: bundle exec standardrb --no-fix continue-on-error: ${{ matrix.ruby == 'head' }} diff --git a/.standard.yml b/.standard.yml index 7f0c40d..dbe8881 100644 --- a/.standard.yml +++ b/.standard.yml @@ -1,6 +1,6 @@ fix: true # default: false parallel: true # default: false format: progress # default: Standard::Formatter -ruby_version: 2.7 # default: RUBY_VERSION +ruby_version: 3.1 # default: RUBY_VERSION ignore: # default: [] - 'test/fixtures/**/*' diff --git a/CHANGELOG.md b/CHANGELOG.md index 206a091..60c0462 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## HEAD +- Change: Ruby 2.7 and 3.0 are no longer supported - Add: `print.text` and `print.erb` see README for usage details - Add: Output documents include more frequent warnings that the document was autogenerated and should not be modified - Breaking: Remove repl_runner support. diff --git a/lib/rundoc/code_command.rb b/lib/rundoc/code_command.rb index 1dab385..e485d90 100644 --- a/lib/rundoc/code_command.rb +++ b/lib/rundoc/code_command.rb @@ -2,7 +2,6 @@ module Rundoc # Generic CodeCommand class to be inherited # class CodeCommand - # Newlines are stripped and re-added, this tells the project that # we're intentionally wanting an extra newline NEWLINE = Object.new diff --git a/lib/rundoc/code_command/print/erb.rb b/lib/rundoc/code_command/print/erb.rb index 6fbc446..e16a079 100644 --- a/lib/rundoc/code_command/print/erb.rb +++ b/lib/rundoc/code_command/print/erb.rb @@ -1,9 +1,8 @@ - require "erb" class EmptyBinding def self.create - self.new.empty_binding + new.empty_binding end def empty_binding @@ -11,11 +10,10 @@ def empty_binding end end -RUNDOC_ERB_BINDINGS = Hash.new {|h, k| h[k] = EmptyBinding.create } +RUNDOC_ERB_BINDINGS = Hash.new { |h, k| h[k] = EmptyBinding.create } class Rundoc::CodeCommand class PrintERB < Rundoc::CodeCommand - def initialize(line = nil, binding: "default") @line = line @binding = RUNDOC_ERB_BINDINGS[binding] @@ -33,7 +31,7 @@ def render @render ||= ERB.new([@line, contents].compact.join("\n")).result(@binding) end - def call(erb={}) + def call(erb = {}) if render_before? "" else diff --git a/lib/rundoc/code_command/website/driver.rb b/lib/rundoc/code_command/website/driver.rb index 429889b..6adae64 100644 --- a/lib/rundoc/code_command/website/driver.rb +++ b/lib/rundoc/code_command/website/driver.rb @@ -16,7 +16,7 @@ def initialize(name:, url:, width: 1024, height: 720, visible: false) @height = height @driver = Capybara::Selenium::Driver.new(nil, browser: :chrome, options: browser_options) - driver_name = "rundoc_driver_#{name}".to_sym + driver_name = :"rundoc_driver_#{name}" Capybara.register_driver(driver_name) do |app| @driver end diff --git a/lib/rundoc/code_section.rb b/lib/rundoc/code_section.rb index 29cb3c7..51449d5 100644 --- a/lib/rundoc/code_section.rb +++ b/lib/rundoc/code_section.rb @@ -20,7 +20,7 @@ def initialize(options = {}) msg << "registered commands: #{Rundoc.known_commands.inspect}\n\n" msg << block msg << "\n" - super msg + super(msg) end end @@ -77,7 +77,7 @@ def render result.flatten! result.compact! - result.map! {|s| s.respond_to?(:rstrip) ? s.rstrip : s } + result.map! { |s| s.respond_to?(:rstrip) ? s.rstrip : s } result.reject!(&:empty?) result.map!(&:to_s) @@ -90,7 +90,7 @@ def render array.flatten! array.compact! - array.map! {|s| s.respond_to?(:rstrip) ? s.rstrip : s } + array.map! { |s| s.respond_to?(:rstrip) ? s.rstrip : s } array.reject!(&:empty?) array.map!(&:to_s) diff --git a/lib/rundoc/peg_parser.rb b/lib/rundoc/peg_parser.rb index 957cea7..77ad7ef 100644 --- a/lib/rundoc/peg_parser.rb +++ b/lib/rundoc/peg_parser.rb @@ -224,7 +224,7 @@ class TransformError < ::StandardError attr_reader :line_and_column def initialize(message:, line_and_column:) @line_and_column = line_and_column || [1, 1] - super message + super(message) end end diff --git a/test/integration/print_test.rb b/test/integration/print_test.rb index 86235ff..abd4dea 100644 --- a/test/integration/print_test.rb +++ b/test/integration/print_test.rb @@ -17,8 +17,8 @@ def test_erb_shared_binding_persists_values env = {} env[:before] = [] expected = <<~EOF - one - #{key} + one + #{key} EOF parsed = Rundoc::Parser.new(contents) actual = parsed.to_md.gsub(Rundoc::CodeSection::AUTOGEN_WARNING, "") @@ -41,7 +41,7 @@ def test_erb_shared_binding_persists_values env = {} env[:before] = [] expected = <<~EOF - one + one EOF parsed = Rundoc::Parser.new(contents) actual = parsed.to_md.gsub(Rundoc::CodeSection::AUTOGEN_WARNING, "") @@ -76,7 +76,6 @@ def test_erb_in_block end end - def test_erb_with_default_binding contents = <<~RUBY ``` diff --git a/test/rundoc/code_commands/print_test.rb b/test/rundoc/code_commands/print_test.rb index a04938d..462274a 100644 --- a/test/rundoc/code_commands/print_test.rb +++ b/test/rundoc/code_commands/print_test.rb @@ -5,7 +5,7 @@ def test_plain_text_before_block env = {} env[:before] = [] - input = %Q{$ rails new myapp # Not a command since it's missing the ":::>>"} + input = %($ rails new myapp # Not a command since it's missing the ":::>>") cmd = Rundoc::CodeCommand::PrintText.new(input) cmd.render_command = false cmd.render_result = true @@ -19,7 +19,7 @@ def test_plain_text_in_block env = {} env[:before] = [] - input = %Q{$ rails new myapp # Not a command since it's missing the ":::>>"} + input = %($ rails new myapp # Not a command since it's missing the ":::>>") cmd = Rundoc::CodeCommand::PrintText.new(input) cmd.render_command = true cmd.render_result = true @@ -34,7 +34,7 @@ def test_erb_before_block env = {} env[:before] = [] - input = %Q{$ rails new <%= 'myapp' %> # Not a command since it's missing the ":::>>"} + input = %($ rails new <%= 'myapp' %> # Not a command since it's missing the ":::>>") cmd = Rundoc::CodeCommand::PrintERB.new(input) cmd.render_command = false cmd.render_result = true @@ -49,8 +49,8 @@ def test_erb_in_block env = {} env[:before] = [] - cmd = Rundoc::CodeCommand::PrintERB.new() - cmd.contents = %Q{<%= "foo" %>} + cmd = Rundoc::CodeCommand::PrintERB.new + cmd.contents = %(<%= "foo" %>) cmd.render_command = true cmd.render_result = true @@ -62,8 +62,8 @@ def test_erb_in_block def test_binding_is_preserved env = {} env[:before] = [] - cmd = Rundoc::CodeCommand::PrintERB.new() - cmd.contents = %Q{<%= @foo = SecureRandom.hex(16) %>} + cmd = Rundoc::CodeCommand::PrintERB.new + cmd.contents = %{<%= @foo = SecureRandom.hex(16) %>} cmd.render_command = true cmd.render_result = true @@ -73,8 +73,8 @@ def test_binding_is_preserved assert !expected.empty? - cmd = Rundoc::CodeCommand::PrintERB.new() - cmd.contents = %Q{<%= @foo %>} + cmd = Rundoc::CodeCommand::PrintERB.new + cmd.contents = %(<%= @foo %>) cmd.render_command = true cmd.render_result = true @@ -83,7 +83,7 @@ def test_binding_is_preserved assert_equal [], env[:before] cmd = Rundoc::CodeCommand::PrintERB.new(binding: "different") - cmd.contents = %Q{<%= @foo %>} + cmd.contents = %(<%= @foo %>) cmd.render_command = true cmd.render_result = true diff --git a/test/rundoc/code_section_test.rb b/test/rundoc/code_section_test.rb index 38b4751..f97ff1d 100644 --- a/test/rundoc/code_section_test.rb +++ b/test/rundoc/code_section_test.rb @@ -1,7 +1,6 @@ require "test_helper" class CodeSectionTest < Minitest::Test - def test_does_not_render_if_all_contents_hidden contents = <<~RUBY sup diff --git a/test/rundoc/parser_test.rb b/test/rundoc/parser_test.rb index a784d3f..eb91338 100644 --- a/test/rundoc/parser_test.rb +++ b/test/rundoc/parser_test.rb @@ -1,7 +1,6 @@ require "test_helper" class ParserTest < Minitest::Test - def test_parse_bash contents = <<~RUBY sup