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

Drop Ruby 2.7 and 3.0 support #45

Merged
merged 1 commit into from
May 6, 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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,7 +33,7 @@ jobs:
fail-fast: false
matrix:
ruby:
- 2.7
- 3.3
- head
steps:
- name: Checkout code
Expand All @@ -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' }}
2 changes: 1 addition & 1 deletion .standard.yml
Original file line number Diff line number Diff line change
@@ -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/**/*'
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
1 change: 0 additions & 1 deletion lib/rundoc/code_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions lib/rundoc/code_command/print/erb.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@

require "erb"

class EmptyBinding
def self.create
self.new.empty_binding
new.empty_binding
end

def empty_binding
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]
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/rundoc/code_command/website/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/rundoc/code_section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion lib/rundoc/peg_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 3 additions & 4 deletions test/integration/print_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")
Expand All @@ -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, "")
Expand Down Expand Up @@ -76,7 +76,6 @@ def test_erb_in_block
end
end


def test_erb_with_default_binding
contents = <<~RUBY
```
Expand Down
20 changes: 10 additions & 10 deletions test/rundoc/code_commands/print_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
1 change: 0 additions & 1 deletion test/rundoc/code_section_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require "test_helper"

class CodeSectionTest < Minitest::Test

def test_does_not_render_if_all_contents_hidden
contents = <<~RUBY
sup
Expand Down
1 change: 0 additions & 1 deletion test/rundoc/parser_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require "test_helper"

class ParserTest < Minitest::Test

def test_parse_bash
contents = <<~RUBY
sup
Expand Down
Loading