diff --git a/lib/ripper-tags/parser.rb b/lib/ripper-tags/parser.rb index 192c598..6c2d108 100644 --- a/lib/ripper-tags/parser.rb +++ b/lib/ripper-tags/parser.rb @@ -17,6 +17,7 @@ def on_#{event}(tok) end def on_stmts_add(first, *rest) + return if first == :~ (first || []) + rest.compact end diff --git a/test/test_ripper_tags.rb b/test/test_ripper_tags.rb index 9a93760..17979a5 100644 --- a/test/test_ripper_tags.rb +++ b/test/test_ripper_tags.rb @@ -434,4 +434,20 @@ class A assert_equal 1, tags.size assert_equal 'A', tags[0][:name] end + + def test_heredoc + tags = extract(<<-EOC) + def foo + puts "hello", <<~EOF + world + EOF + end + + def bar; end + EOC + + assert_equal 2, tags.size + assert_equal 'foo', tags[0][:name] + assert_equal 'bar', tags[1][:name] + end end