Transform some if-statemens.

Signed-off-by: Thomas Hochstein <thh@inter.net>
This commit is contained in:
Thomas Hochstein 2017-05-25 23:01:49 +02:00
parent 484c0ebb56
commit 1e3c716f14

View file

@ -46,17 +46,13 @@ module Nanoc::Filters
CACHEDAYS = 7 CACHEDAYS = 7
def run(input, params={}) def run(input, params={})
if !(/§|&sect;|Art\.|\/[0-9][0-9](?![0-9\/])| [0-9][0-9]?[\/\.][0-9][0-9](?![0-9\.])|[0-9][0-9], / =~ input) # return input if there's nothing to replace
# nothing to replace return input if !(/§|&sect;|Art\.|\/[0-9][0-9](?![0-9\/])| [0-9][0-9]?[\/\.][0-9][0-9](?![0-9\.])|[0-9][0-9], / =~ input)
return input # return input if it contains '<!-- no-dejure -->'
end
# return if input contains '<!-- no-dejure -->'
return input if (/<!-- ?no-?dejure ?-->/ =~ input) return input if (/<!-- ?no-?dejure ?-->/ =~ input)
# set cache validity in days from params or set a default # set cache validity in days from params or set a default
cache_days = params.delete(:cache_days) cache_days = params.delete(:cache_days)
if cache_days.nil? cache_days = CACHEDAYS if cache_days.nil?
cache_days = CACHEDAYS
end
# return output if it's already cached # return output if it's already cached
if !(output = cache_read(input.strip,cache_days)) if !(output = cache_read(input.strip,cache_days))
# purge cache if a purge is due # purge cache if a purge is due