Skip to content

Instantly share code, notes, and snippets.

@parkr
Created April 26, 2013 18:35
Show Gist options
  • Select an option

  • Save parkr/5469410 to your computer and use it in GitHub Desktop.

Select an option

Save parkr/5469410 to your computer and use it in GitHub Desktop.
Jekyll::Site#initialize refactor
module Jekyll
class Site
attr_accessor :config, :layouts, :posts, :pages, :static_files,
:categories, :exclude, :include, :source, :dest, :lsi, :pygments,
:permalink_style, :tags, :time, :future, :safe, :plugins, :limit_posts,
:show_drafts, :keep_files, :baseurl
attr_accessor :converters, :generators
# Public: Initialize a new Site.
#
# config - A Hash containing site configuration details.
def initialize(config)
self.config = config.clone
config['source'] = File.expand_path(config['source'])
config['destination'] = File.expand_path(config['destination'])
config['permalink'] = config['permalink'].to_sym
%w[safe source dest lsi pygments baseurl permalink_style exclude
include future show_drafts limit_posts keep_files].each do |meth|
send("#{meth}=", config[meth])
end
self.reset
self.setup
end
end
end
@qrush
Copy link
Copy Markdown

qrush commented Apr 26, 2013

There's a ton of different concerns here:

  • Content of your site (pages, posts, categories)
  • Configuration of how it's generated, etc (drafts, source/dest, ex/include, etc)
  • External stuff (lsi, pygments, plugins)

There's probably more concerns than just that. Splitting them out into more classes sounds reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment