Skip to content

Commit

Permalink
Fix compatibility with --enable-frozen-string-literal (#2033)
Browse files Browse the repository at this point in the history
Ever since Ruby 2.3 it has been possible to enable frozen string
literals globally via `RUBYOPT`, and it is scheduled to be the default
in Ruby 4.

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
  • Loading branch information
casperisfine and byroot authored Jul 11, 2024
1 parent 319af3a commit 973c936
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ jobs:
rack_session: ${{ matrix.rack_session }}
puma: ${{ matrix.puma }}
tilt: ${{ matrix.tilt }}
RUBYOPT: "--enable-frozen-string-literal --debug-frozen-string-literal"

steps:
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ gem 'rdiscount', platforms: [:ruby]
gem 'rdoc'
gem 'redcarpet', platforms: [:ruby]
gem 'simplecov', require: false
gem 'slim', '~> 4'
gem 'slim', '~> 5'
gem 'yajl-ruby', platforms: [:ruby]
gem 'zeitwerk'

Expand Down
2 changes: 1 addition & 1 deletion sinatra-contrib/lib/sinatra/capture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def capture(*args, &block)
with_haml_buffer(buffer) { capture_haml(*args, &block) }
else
buf_was = @_out_buf
@_out_buf = ''
@_out_buf = +''
begin
raw = block[*args]
captured = block.binding.eval('@_out_buf')
Expand Down
2 changes: 2 additions & 0 deletions sinatra-contrib/lib/sinatra/link_header.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def link(*urls)
http_pattern = ['<%s>', *options].join ';'
link = (response['Link'] ||= '')

link = response['Link'] = +link

urls.map do |url|
link << "," unless link.empty?
link << (http_pattern % url)
Expand Down
2 changes: 1 addition & 1 deletion sinatra-contrib/lib/sinatra/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def get_response(url)
end

def log
@log ||= ''
@log ||= +''
loop { @log << pipe.read_nonblock(1) }
rescue Exception
@log
Expand Down
2 changes: 1 addition & 1 deletion test/integration_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def initialize(server, port, async)
def run
return unless installed?
kill
@log = ""
@log = +""
super
at_exit { kill }
end
Expand Down
2 changes: 1 addition & 1 deletion test/routing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def to_pattern(*)
end

def params(input)
{ "one" => "this", "two" => "is", "three" => "a", "four" => "test" }
{ "one" => +"this", "two" => +"is", "three" => +"a", "four" => +"test" }
end
end

Expand Down

0 comments on commit 973c936

Please sign in to comment.