Skip to content

Commit

Permalink
Fix Rubocop warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rphillips-nz committed Nov 13, 2019
1 parent 5c6e5a2 commit afe7f9c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/cloudcannon-jekyll.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,4 +28,4 @@ def reset
Jekyll::Hooks.register :site, :after_reset do |site|
CloudCannonJekyll::Configuration.set(site)
end
end
end
16 changes: 5 additions & 11 deletions lib/cloudcannon-jekyll/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/cloudcannon-jekyll/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit afe7f9c

Please sign in to comment.