Skip to content

Commit

Permalink
Update to be frozen string literal safe (#545)
Browse files Browse the repository at this point in the history
  • Loading branch information
npezza93 authored Oct 10, 2024
1 parent c3815c2 commit 88d712a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' || '' }}

test-legacy:
runs-on: ubuntu-20.04
Expand Down
4 changes: 2 additions & 2 deletions lib/sshkit/color.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
end

# Returns `true` if the underlying output is a tty, or if the SSHKIT_COLOR
Expand Down
7 changes: 6 additions & 1 deletion test/unit/backends/test_abstract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion test/unit/test_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion test/unit/test_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 88d712a

Please sign in to comment.