Skip to content

Commit

Permalink
Auto corrected by following Lint Ruby Performance/ConstantRegexp
Browse files Browse the repository at this point in the history
  • Loading branch information
Awesome Code committed Feb 21, 2021
1 parent 3b20ea4 commit e0b9f68
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/synvert/core/engine/erb.rb
Expand Up @@ -31,20 +31,20 @@ def decode(source)
private

def decode_ruby_stmt(source)
source.gsub(/#{ERUBY_STMT_SPLITTER}(.+?)#{ERUBY_STMT_SPLITTER}/m) { "<%#{Regexp.last_match(1)}%>" }
source.gsub(/#{ERUBY_STMT_SPLITTER}(.+?)#{ERUBY_STMT_SPLITTER}/mo) { "<%#{Regexp.last_match(1)}%>" }
end

def decode_ruby_output(source)
source.gsub(/@output_buffer.append=\((.+?)\);#{ERUBY_EXPR_SPLITTER}/m) { "<%=#{Regexp.last_match(1)}%>" }.gsub(
/@output_buffer.append= (.+?)\s+(do|\{)(\s*\|[^|]*\|)?\s*#{ERUBY_EXPR_SPLITTER}/m
source.gsub(/@output_buffer.append=\((.+?)\);#{ERUBY_EXPR_SPLITTER}/mo) { "<%=#{Regexp.last_match(1)}%>" }.gsub(
/@output_buffer.append= (.+?)\s+(do|\{)(\s*\|[^|]*\|)?\s*#{ERUBY_EXPR_SPLITTER}/mo
) { |m| "<%=#{m.sub('@output_buffer.append= ', '').sub(ERUBY_EXPR_SPLITTER, '')}%>" }
end

def decode_html_output(source)
source.gsub(/@output_buffer.safe_append='(.+?)'.freeze;/m) { reverse_escape_text(Regexp.last_match(1)) }.gsub(
/@output_buffer.safe_append=\((.+?)\);#{ERUBY_EXPR_SPLITTER}/m
/@output_buffer.safe_append=\((.+?)\);#{ERUBY_EXPR_SPLITTER}/mo
) { reverse_escape_text(Regexp.last_match(1)) }.gsub(
/@output_buffer.safe_append=(.+?)\s+(do|\{)(\s*\|[^|]*\|)?\s*#{ERUBY_EXPR_SPLITTER}/m
/@output_buffer.safe_append=(.+?)\s+(do|\{)(\s*\|[^|]*\|)?\s*#{ERUBY_EXPR_SPLITTER}/mo
) { reverse_escape_text(Regexp.last_match(1)) }
end

Expand Down

0 comments on commit e0b9f68

Please sign in to comment.