class Jekyll::RemoteTheme::Munger

Attributes

site[R]

Public Class Methods

new(site) click to toggle source
# File lib/jekyll-remote-theme/munger.rb, line 10
def initialize(site)
  @site = site
end

Public Instance Methods

munge!() click to toggle source
# File lib/jekyll-remote-theme/munger.rb, line 14
def munge!
  return unless raw_theme

  unless theme.valid?
    Jekyll.logger.error LOG_KEY, "#{raw_theme.inspect} is not a valid remote theme"
    return
  end

  Jekyll.logger.info LOG_KEY, "Using theme #{theme.name_with_owner}"
  unless munged?
    downloader.run
    configure_theme
  end
  enqueue_theme_cleanup

  theme
end

Private Instance Methods

configure_theme() click to toggle source
# File lib/jekyll-remote-theme/munger.rb, line 50
def configure_theme
  return unless theme

  site.config["theme"] = theme.name
  site.theme = theme
  site.theme.configure_sass if site.theme.respond_to?(:configure_sass)
  site.send(:configure_include_paths)
  site.plugin_manager.require_theme_deps
end
downloader() click to toggle source
# File lib/jekyll-remote-theme/munger.rb, line 46
def downloader
  @downloader ||= Downloader.new(theme)
end
enqueue_theme_cleanup() click to toggle source
# File lib/jekyll-remote-theme/munger.rb, line 60
def enqueue_theme_cleanup
  at_exit do
    Jekyll.logger.debug LOG_KEY, "Cleaning up #{theme.root}"
    FileUtils.rm_rf theme.root
  end
end
munged?() click to toggle source
# File lib/jekyll-remote-theme/munger.rb, line 34
def munged?
  site.theme&.is_a?(Jekyll::RemoteTheme::Theme)
end
raw_theme() click to toggle source
# File lib/jekyll-remote-theme/munger.rb, line 42
def raw_theme
  config[CONFIG_KEY]
end
theme() click to toggle source
# File lib/jekyll-remote-theme/munger.rb, line 38
def theme
  @theme ||= Theme.new(raw_theme)
end