From afe7f9c887e7219de03e51439698148cc74e3df6 Mon Sep 17 00:00:00 2001 From: Ross Phillips Date: Wed, 13 Nov 2019 14:02:40 +1300 Subject: [PATCH] Fix Rubocop warnings --- lib/cloudcannon-jekyll.rb | 4 ++-- lib/cloudcannon-jekyll/configuration.rb | 16 +++++----------- lib/cloudcannon-jekyll/generator.rb | 2 +- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/lib/cloudcannon-jekyll.rb b/lib/cloudcannon-jekyll.rb index 94515bd..fb47606 100644 --- a/lib/cloudcannon-jekyll.rb +++ b/lib/cloudcannon-jekyll.rb @@ -16,7 +16,7 @@ module CloudCannonJekyll if Jekyll::VERSION.start_with? "2" module Jekyll class Site - alias jekyll_reset reset + alias_method :jekyll_reset, :reset def reset jekyll_reset @@ -28,4 +28,4 @@ def reset Jekyll::Hooks.register :site, :after_reset do |site| CloudCannonJekyll::Configuration.set(site) end -end \ No newline at end of file +end diff --git a/lib/cloudcannon-jekyll/configuration.rb b/lib/cloudcannon-jekyll/configuration.rb index 60161a0..7e8f4ba 100644 --- a/lib/cloudcannon-jekyll/configuration.rb +++ b/lib/cloudcannon-jekyll/configuration.rb @@ -17,26 +17,20 @@ def overridden_config(user_config) config = config.fix_common_issues if config.respond_to? :fix_common_issues config = config.add_default_excludes if config.respond_to? :add_default_excludes - if Jekyll::VERSION.start_with? "2" - config["gems"] = Array(config["gems"]) - config["gems"].push("cloudcannon-jekyll") unless config["gems"].include? "cloudcannon-jekyll" - else - config["plugins"] = Array(config["plugins"]) - config["plugins"].push("cloudcannon-jekyll") unless config["plugins"].include? "cloudcannon-jekyll" - end + key = Jekyll::VERSION.start_with?("2") ? "gems" : "plugins" + config[key] = Array(config[key]) + config[key].push("cloudcannon-jekyll") unless config[key].include? "cloudcannon-jekyll" config end def set(site) return if processed? site - config = overridden_config(site.config) - if site.respond_to? :config= - site.config = config + site.config = overridden_config(site.config) else # Jekyll pre 3.5 - site.instance_variable_set :@config, config + site.instance_variable_set :@config, overridden_config(site.config) end process(site) diff --git a/lib/cloudcannon-jekyll/generator.rb b/lib/cloudcannon-jekyll/generator.rb index 8c471fc..825544e 100644 --- a/lib/cloudcannon-jekyll/generator.rb +++ b/lib/cloudcannon-jekyll/generator.rb @@ -18,7 +18,7 @@ def generate(site) def source_path path = "_cloudcannon/details.json" path = "_cloudcannon/details-2.x.json" if Jekyll::VERSION.start_with? "2." - path = "_cloudcannon/details-3.0.x.json" if Jekyll::VERSION.match /3\.[0-4]\./ + path = "_cloudcannon/details-3.0.x.json" if Jekyll::VERSION.match? %r!3\.[0-4]\.! File.expand_path(path, File.dirname(__FILE__)) end