Skip to content

Commit b5e121f

Browse files
committed
Embed racc/info.rb too
1 parent 96ded6b commit b5e121f

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

Rakefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,17 @@ end
3939
file 'lib/racc/parser-text.rb' => ['lib/racc/parser.rb'] do |t|
4040
source = 'lib/racc/parser.rb'
4141

42+
text = File.read(source)
43+
text.gsub!(/^require '(.*)'$/) do
44+
%[unless $".find {|p| p.end_with?('/#$1.rb')}\n$".push '#$1.rb'\n#{File.read("lib/#{$1}.rb")}\nend\n]
45+
rescue
46+
$&
47+
end
4248
open(t.name, 'wb') { |io|
4349
io.write(<<-eorb)
4450
module Racc
4551
PARSER_TEXT = <<'__end_of_file__'
46-
#{File.read(source)}
52+
#{text}
4753
__end_of_file__
4854
end
4955
eorb

test/test_parser_text.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require File.expand_path(File.join(__dir__, 'case'))
2+
3+
module Racc
4+
class TestRaccParserText < TestCase
5+
def test_parser_text_require
6+
assert_not_match(/^require/, Racc::PARSER_TEXT)
7+
ruby "-I#{LIB_DIR}", "-rracc/parser-text", %[-e$:.clear], %[-eeval(Racc::PARSER_TEXT)]
8+
end
9+
end
10+
end

0 commit comments

Comments
 (0)