Skip to content

Commit 1946c08

Browse files
committed
Support earlier than Ruby 2.4
Remove String#match? and heredoc with ">>~".
1 parent 6ff1766 commit 1946c08

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

lib/rdoc/parser/ripper_state_lex.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ def get_squashed_tk
479479

480480
private def retrieve_heredoc_info(tk)
481481
name = tk[:text].gsub(/\A<<[-~]?(['"`]?)(.+)\1\z/, '\2')
482-
indent = tk[:text].match?(/\A<<[-~]/)
482+
indent = tk[:text] =~ /\A<<[-~]/
483483
[name, indent]
484484
end
485485

lib/rdoc/parser/ruby.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,15 +1666,15 @@ def parse_statements(container, single = NORMAL, current_method = nil,
16661666
past_tokens = @read.size > 1 ? @read[0..-2] : []
16671667
nl_position = 0
16681668
past_tokens.reverse.each_with_index do |read_tk, i|
1669-
if read_tk.match?(/^\n$/) then
1669+
if read_tk =~ /^\n$/ then
16701670
nl_position = (past_tokens.size - 1) - i
16711671
break
1672-
elsif read_tk.match?(/^#.*\n$/) then
1672+
elsif read_tk =~ /^#.*\n$/ then
16731673
nl_position = ((past_tokens.size - 1) - i) + 1
16741674
break
16751675
end
16761676
end
1677-
comment_only_line = past_tokens[nl_position..-1].all?{ |c| c.match?(/^\s+$/) }
1677+
comment_only_line = past_tokens[nl_position..-1].all?{ |c| c =~ /^\s+$/ }
16781678
unless comment_only_line then
16791679
tk = get_tk
16801680
end

test/test_rdoc_parser_ruby.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2587,15 +2587,15 @@ def test_parse_statements_postfix_if_after_heredocbeg
25872587
util_parser <<RUBY
25882588
class Foo
25892589
def blah()
2590-
<<~EOM if true
2590+
<<-EOM if true
25912591
EOM
25922592
end
25932593
end
25942594
RUBY
25952595

25962596
expected = <<EXPTECTED
25972597
<span class="ruby-keyword">def</span> <span class="ruby-identifier">blah</span>()
2598-
<span class="ruby-identifier">&lt;&lt;~EOM</span> <span class="ruby-keyword">if</span> <span class="ruby-keyword">true</span>
2598+
<span class="ruby-identifier">&lt;&lt;-EOM</span> <span class="ruby-keyword">if</span> <span class="ruby-keyword">true</span>
25992599
<span class="ruby-value"></span><span class="ruby-identifier"> EOM</span>
26002600
<span class="ruby-keyword">end</span>
26012601
EXPTECTED
@@ -2608,7 +2608,7 @@ def blah()
26082608

26092609
blah = foo.method_list.first
26102610
markup_code = blah.markup_code.sub(/^.*\n/, '')
2611-
assert_equal markup_code, expected
2611+
assert_equal expected, markup_code
26122612
end
26132613

26142614
def test_parse_statements_method_oneliner_with_regexp

0 commit comments

Comments
 (0)