From 695b5396fde83c84d38b134f0024b9b88bf9fb48 Mon Sep 17 00:00:00 2001 From: Anatoliy Yastreb Date: Fri, 17 Jun 2016 15:44:08 +0300 Subject: [PATCH 1/2] rubocop: fix code style --- .rubocop.yml | 1 - lib/jekyll/collection.rb | 34 ++++++++++++++++++++++------------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index f255cb76..426c61a8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,7 +4,6 @@ AllCops: Include: - lib/**/*.rb Exclude: - - lib/jekyll/collection.rb - lib/jekyll/convertible.rb - lib/jekyll/document.rb - lib/jekyll/renderer.rb diff --git a/lib/jekyll/collection.rb b/lib/jekyll/collection.rb index 6ec72703..88120d1f 100644 --- a/lib/jekyll/collection.rb +++ b/lib/jekyll/collection.rb @@ -57,18 +57,9 @@ module Jekyll full_path = collection_dir(file_path) next if File.directory?(full_path) if Utils.has_yaml_header? full_path - doc = Jekyll::Document.new(full_path, { :site => site, :collection => self }) - doc.read - if site.publisher.publish?(doc) || !write? - docs << doc - else - Jekyll.logger.debug "Skipped From Publishing:", doc.relative_path - end + read_docs(full_path) else - relative_dir = Jekyll.sanitized_path(relative_directory, - File.dirname(file_path)).chomp("/.") - files << StaticFile.new(site, site.source, relative_dir, - File.basename(full_path), self) + read_files(file_path, full_path) end end docs.sort! @@ -164,7 +155,7 @@ module Jekyll # # Returns a sanitized version of the label. def sanitize_label(label) - label.gsub(/[^a-z0-9_\-\.]/i, "") + label.gsub(%r![^a-z0-9_\-\.]!i, "") end # Produce a representation of this Collection for use in Liquid. @@ -204,5 +195,24 @@ module Jekyll {} end end + + private + def read_docs(full_path) + doc = Jekyll::Document.new(full_path, { :site => site, :collection => self }) + doc.read + if site.publisher.publish?(doc) || !write? + docs << doc + else + Jekyll.logger.debug "Skipped From Publishing:", doc.relative_path + end + end + + private + def read_files(file_path, full_path) + relative_dir = Jekyll.sanitized_path(relative_directory, + File.dirname(file_path)).chomp("/.") + files << StaticFile.new(site, site.source, relative_dir, + File.basename(full_path), self) + end end end From b9f232e5bfeb621f37e558ca0379d2f98344a95a Mon Sep 17 00:00:00 2001 From: Anatoliy Yastreb Date: Fri, 15 Jul 2016 10:56:29 +0300 Subject: [PATCH 2/2] rubocop: fix methods naming and indentation --- lib/jekyll/collection.rb | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/jekyll/collection.rb b/lib/jekyll/collection.rb index 88120d1f..ebe6891c 100644 --- a/lib/jekyll/collection.rb +++ b/lib/jekyll/collection.rb @@ -57,9 +57,9 @@ module Jekyll full_path = collection_dir(file_path) next if File.directory?(full_path) if Utils.has_yaml_header? full_path - read_docs(full_path) + read_document(full_path) else - read_files(file_path, full_path) + read_static_file(file_path, full_path) end end docs.sort! @@ -197,8 +197,8 @@ module Jekyll end private - def read_docs(full_path) - doc = Jekyll::Document.new(full_path, { :site => site, :collection => self }) + def read_document(full_path) + doc = Jekyll::Document.new(full_path, :site => site, :collection => self) doc.read if site.publisher.publish?(doc) || !write? docs << doc @@ -208,11 +208,14 @@ module Jekyll end private - def read_files(file_path, full_path) - relative_dir = Jekyll.sanitized_path(relative_directory, - File.dirname(file_path)).chomp("/.") + def read_static_file(file_path, full_path) + relative_dir = Jekyll.sanitized_path( + relative_directory, + File.dirname(file_path) + ).chomp("/.") + files << StaticFile.new(site, site.source, relative_dir, - File.basename(full_path), self) + File.basename(full_path), self) end end end