Skip to content

Commit e1746e1

Browse files
jdelStrothermislav
andauthored
Fix running with RUBYOPT="--enable-frozen-string-literal" (#651)
* Fix running with RUBYOPT="--enable-frozen-string-literal" * remove use of inject --------- Co-authored-by: Mislav Marohnić <[email protected]>
1 parent f7e900f commit e1746e1

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

lib/will_paginate/view_helpers/link_renderer.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,12 @@ def link(text, target, attributes = {})
103103
end
104104

105105
def tag(name, value, attributes = {})
106-
string_attributes = attributes.inject('') do |attrs, pair|
106+
string_attributes = attributes.map do |pair|
107107
unless pair.last.nil?
108-
attrs << %( #{pair.first}="#{CGI::escapeHTML(pair.last.to_s)}")
108+
%( #{pair.first}="#{CGI::escapeHTML(pair.last.to_s)}")
109109
end
110-
attrs
111110
end
112-
"<#{name}#{string_attributes}>#{value}</#{name}>"
111+
"<#{name}#{string_attributes.compact.join("")}>#{value}</#{name}>"
113112
end
114113

115114
def rel_value(page)

spec/view_helpers/action_view_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,13 @@ def renderer.gap() '<span class="my-gap">~~</span>' end
126126

127127
it "should match expected markup" do
128128
paginate
129-
expected = <<-HTML
129+
expected = <<-HTML.strip.gsub(/\s{2,}/, ' ')
130130
<div class="pagination" role="navigation" aria-label="Pagination"><span class="previous_page disabled" aria-label="Previous page">&#8592; Previous</span>
131131
<em class="current" aria-label="Page 1" aria-current="page">1</em>
132132
<a href="/foo/bar?page=2" aria-label="Page 2" rel="next">2</a>
133133
<a href="/foo/bar?page=3" aria-label="Page 3">3</a>
134134
<a href="/foo/bar?page=2" class="next_page" rel="next" aria-label="Next page">Next &#8594;</a></div>
135135
HTML
136-
expected.strip!.gsub!(/\s{2,}/, ' ')
137136
expected_dom = parse_html_document(expected)
138137

139138
if expected_dom.respond_to?(:canonicalize)

0 commit comments

Comments
 (0)