From 1e3c716f147360a815ca30d7e01ea077bb91a271 Mon Sep 17 00:00:00 2001 From: Thomas Hochstein Date: Thu, 25 May 2017 23:01:49 +0200 Subject: [PATCH] Transform some if-statemens. Signed-off-by: Thomas Hochstein --- lib/filters/dejure.rb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/filters/dejure.rb b/lib/filters/dejure.rb index c8dbc4d..dff98bf 100644 --- a/lib/filters/dejure.rb +++ b/lib/filters/dejure.rb @@ -46,17 +46,13 @@ module Nanoc::Filters CACHEDAYS = 7 def run(input, params={}) - if !(/§|§|Art\.|\/[0-9][0-9](?![0-9\/])| [0-9][0-9]?[\/\.][0-9][0-9](?![0-9\.])|[0-9][0-9], / =~ input) - # nothing to replace - return input - end - # return if input contains '' + # return input if there's nothing to replace + return input if !(/§|§|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 it contains '' return input if (// =~ input) # set cache validity in days from params or set a default cache_days = params.delete(:cache_days) - if cache_days.nil? - cache_days = CACHEDAYS - end + cache_days = CACHEDAYS if cache_days.nil? # return output if it's already cached if !(output = cache_read(input.strip,cache_days)) # purge cache if a purge is due