Skip to content

Commit

Permalink
fixed warnings and a few backward incompatible statements
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Feb 19, 2019
1 parent a6a9371 commit 1f3c86f
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions lib/locales/plurals.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# A plural proc returns a plural type string based on the passed count
# Each plural proc may apply to one or more languages below
plurals = {
zero_one_other: -> (count) {zero_one[count] || 'other'},
zero_one_other: lambda {|count| zero_one[count] || 'other'},

zero_one_few_many_other: -> (count) do
zero_one_few_many_other: lambda do |count|
mod10, mod100 = count % 10, count % 100
if count == 0 ; 'zero'
elsif mod10 == 1 && mod100 != 11 ; 'one'
Expand All @@ -25,7 +25,7 @@
end
end,

pl: -> (count) do
pl: lambda do |count|
mod10, mod100 = count % 10, count % 100
if count == 0 ; 'zero'
elsif count == 1 ; 'one'
Expand Down
2 changes: 1 addition & 1 deletion lib/pagy/countless.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Countless < Pagy

# Merge and validate the options, do some simple arithmetic and set a few instance variables
def initialize(vars={})
@vars ||= VARS.merge(vars.delete_if{|_,v| v.nil? || v == '' }) # default vars + cleaned vars (can be overridden)
@vars = VARS.merge(vars.delete_if{|_,v| v.nil? || v == '' }) # default vars + cleaned vars (can be overridden)
{ items:1, outset:0, page:1 }.each do |k,min| # validate instance variables
(@vars[k] && instance_variable_set(:"@#{k}", @vars[k].to_i) >= min) \
or raise(ArgumentError, "expected :#{k} >= #{min}; got #{@vars[k].inspect}")
Expand Down
2 changes: 1 addition & 1 deletion lib/pagy/extras/items.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Backend ; private

def pagy_with_items(vars)
vars[:items] ||= (items = params[vars[:items_param] || VARS[:items_param]]) && # :items from :items_param
[items&.to_i, vars.key?(:max_items) ? vars[:max_items] : VARS[:max_items]].compact.min # :items capped to :max_items
[items.to_i, vars.key?(:max_items) ? vars[:max_items] : VARS[:max_items]].compact.min # :items capped to :max_items
end

alias_method :pagy_get_vars_without_items, :pagy_get_vars
Expand Down
2 changes: 1 addition & 1 deletion lib/pagy/extras/support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class Pagy

def to_h
{ count: @count,
{ count: defined?(@count) && @count,
page: @page,
items: @items,
pages: @pages,
Expand Down
2 changes: 1 addition & 1 deletion lib/pagy/extras/trim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def pagy_link_proc_with_trim(pagy, link_extra='')
page1_url = pagy_trim_url(marker_url, "#{p_vars[:page_param]}=#{MARKER}")
page1_link = %(<a href="#{page1_url}" #{p_vars[:link_extra]} #{link_extra})
a, b = %(<a href="#{marker_url}" #{p_vars[:link_extra]} #{link_extra}).split(MARKER, 2)
-> (n, text=n, extra='') { start = n.to_i == 1 ? page1_link : "#{a}#{n}#{b}"
lambda{|n, text=n, extra=''| start = n.to_i == 1 ? page1_link : "#{a}#{n}#{b}"
"#{start}#{ if n == p_prev ; ' rel="prev"'
elsif n == p_next ; ' rel="next"'
else '' end } #{extra}>#{text}</a>" }
Expand Down
6 changes: 3 additions & 3 deletions lib/pagy/frontend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def pagy_get_params(params) params end
def pagy_link_proc(pagy, link_extra='')
p_prev, p_next = pagy.prev, pagy.next
a, b = %(<a href="#{pagy_url_for(MARKER, pagy)}" #{pagy.vars[:link_extra]} #{link_extra}).split(MARKER, 2)
-> (n, text=n, extra='') { "#{a}#{n}#{b}#{ if n == p_prev ; ' rel="prev"'
elsif n == p_next ; ' rel="next"'
else '' end } #{extra}>#{text}</a>" }
lambda {|n, text=n, extra=''| "#{a}#{n}#{b}#{ if n == p_prev ; ' rel="prev"'
elsif n == p_next ; ' rel="next"'
else '' end } #{extra}>#{text}</a>" }
end

# Pagy::Frontend::I18N
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper/backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def count(*)
class TestGroupedCollection < TestCollection

def count(*)
@collection.map { |value| [value, value + 1] }.to_h
Hash[@collection.map { |value| [value, value + 1] }]
end

end

0 comments on commit 1f3c86f

Please sign in to comment.