From b72556fd03d944e29276f58f9a6163352a81e142 Mon Sep 17 00:00:00 2001 From: Matt Rogers Date: Thu, 15 Oct 2015 20:34:44 -0500 Subject: [PATCH] Make a constant for the regex to find hidden files A raw regular expression isn't very expressive, IMHO. Rather than having people who read this code parse the regular expression to figure out what it's for, let's give a name. This way, it becomes more obvious what exactly it is we're doing here. --- lib/jekyll/cleaner.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/cleaner.rb b/lib/jekyll/cleaner.rb index 70bd2f79..30c0a432 100644 --- a/lib/jekyll/cleaner.rb +++ b/lib/jekyll/cleaner.rb @@ -3,6 +3,7 @@ require 'set' module Jekyll # Handles the cleanup of a site's destination before it is built. class Cleaner + HIDDEN_FILE_REGEX = /\/\.{1,2}$/ attr_reader :site def initialize(site) @@ -40,7 +41,7 @@ module Jekyll dirs = keep_dirs Dir.glob(site.in_dest_dir("**", "*"), File::FNM_DOTMATCH) do |file| - next if file =~ /\/\.{1,2}$/ || file =~ regex || dirs.include?(file) + next if file =~ HIDDEN_FILE_REGEX || file =~ regex || dirs.include?(file) files << file end