Skip to content

Update to be frozen string literal safe #545

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

Merged
merged 4 commits into from
Oct 10, 2024
Merged
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -30,6 +30,8 @@ jobs:
bundler-cache: true
- name: Run tests
run: bundle exec rake test:units
env:
RUBYOPT: ${{ startsWith(matrix.ruby, 'head') && '--enable=frozen-string-literal' || '' }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice enhancement!


test-legacy:
runs-on: ubuntu-20.04
4 changes: 2 additions & 2 deletions lib/sshkit/color.rb
Original file line number Diff line number Diff line change
@@ -44,8 +44,8 @@ def colorize(obj, color, mode=nil)
return string unless COLOR_CODES.key?(color)

result = mode == :bold ? "\e[1;" : "\e[0;"
result << COLOR_CODES.fetch(color).to_s
result << ";49m#{string}\e[0m"

"#{result}#{COLOR_CODES.fetch(color)};49m#{string}\e[0m"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

end

# Returns `true` if the underlying output is a tty, or if the SSHKIT_COLOR
7 changes: 6 additions & 1 deletion test/unit/backends/test_abstract.rb
Original file line number Diff line number Diff line change
@@ -112,7 +112,12 @@ def test_within_home
end

def test_background_logs_deprecation_warnings
deprecation_out = ''
deprecation_out =
if RUBY_VERSION < "2.3"
''
else
+''
end
SSHKit.config.deprecation_output = deprecation_out

ExampleBackend.new do
8 changes: 7 additions & 1 deletion test/unit/test_command.rb
Original file line number Diff line number Diff line change
@@ -211,7 +211,13 @@ def test_on_stderr
end

def test_deprecated_stdtream_accessors
deprecation_out = ''
deprecation_out =
if RUBY_VERSION < "2.3"
''
else
+''
end

SSHKit.config.deprecation_output = deprecation_out

c = Command.new(:whoami)
8 changes: 7 additions & 1 deletion test/unit/test_configuration.rb
Original file line number Diff line number Diff line change
@@ -11,7 +11,13 @@ def setup
end

def test_deprecation_output
output = ''
output =
if RUBY_VERSION < "2.3"
''
else
+''
end

SSHKit.config.deprecation_output = output
SSHKit.config.deprecation_logger.log('Test')
assert_equal "[Deprecated] Test\n", output.lines.first