Skip to content

Commit

Permalink
Remove frozen_string_literal pragmas from embedded runtime files
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Aug 9, 2023
1 parent 08c12b3 commit f7bf342
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ file 'lib/racc/parser-text.rb' => ['lib/racc/parser.rb', __FILE__] do |t|
source = 'lib/racc/parser.rb'

text = File.read(source)
text.sub!(/\A# *frozen[-_]string[-_]literal:.*\n/, '')
text.gsub!(/^require '(.*)'$/) do
%[unless $".find {|p| p.end_with?('/#$1.rb')}\n$".push "\#{__dir__}/#$1.rb"\n#{File.read("lib/#{$1}.rb")}\nend\n]
lib = $1
code = File.read("lib/#{lib}.rb")
code.sub!(/\A(?:#.*\n)+/, '')
%[unless $".find {|p| p.end_with?('/#{lib}.rb')}\n$".push "\#{__dir__}/#{lib}.rb"\n#{code}\nend\n]
rescue
$&
end
open(t.name, 'wb') { |io|
File.open(t.name, 'wb') { |io|
io.write(<<-eorb)
module Racc
PARSER_TEXT = <<'__end_of_file__'
Expand Down
1 change: 1 addition & 0 deletions lib/racc/info.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#--
#
#
Expand Down
2 changes: 1 addition & 1 deletion lib/racc/parser.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: false
# frozen_string_literal: true
#--
# Copyright (c) 1999-2006 Minero Aoki
#
Expand Down

0 comments on commit f7bf342

Please sign in to comment.